문제

I was just making a PDFGenerator for my cross platform Phonegap app.

In the report there are fields like Patient name, Patient number, etc. So I thought it'll be a good idea to store these Patient name, Patient number, etc. in variables and change them for every different person and individual.

I don't know how to print variables in between text. Below is my statement for writing a line of text in between which a variable's text value has to be printed out:

loremipsum ='Ambulatory Blood Pressure Report\nPatient name: <heregoesthevalueofpatientname>'

Please let me know.

도움이 되었습니까?

해결책

To combine literal strings with variables, you can concatenate them with the + operator.

loremipsum = 'Ambulatory Blood Pressure Report\nPatient name:' + patientname;

And just to be sure that I address the question in the title,

  • there's no built-in facility that provides the same formatting functionality as printf
  • there's no one "standard out" in JavaScript, so displaying text is different depending on how you want it to show up

(this is assuming the JavaScript is for a browser)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top