Question

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.

Was it helpful?

Solution

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)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top