+ 2
Noop here How can i integrate a variable in a text ?
4 Answers
+ 1
mohamad ali,
To call a variable back into a string you need to work with
``
instead of
"" or ''
Here is an example:
window.onload = function() {
var text = ("SoloLearn!");
console.log(`String output: \n${text}`);
}
${text} inside `` will return the variable inside the string.
Therefore the output of this code is:
//String output:
//SoloLearn!
Additional post:
https://www.sololearn.com/discuss/1477768/?ref=app
+ 1
What programming language?
+ 1
oh sorry
js
+ 1
Example:
var hello = 5
document.write(hello)
//its gonna output 5