+ 1
Hello please i want to know to put a space btw a string and a variable
e.g var a=love JavaScript I would like to see ( I + a) =I love JavaScript, and not (ilove JavaScript)
4 Answers
+ 8
var x = " love JavaScript.";
document.write("I" + x);
//Note the space before "love".
+ 7
As you can see, why not put a space in the string itself? If you are adding 2 string variables, why not do a ( StringA + " " + StringB ) inside there?
+ 3
var a = "love JavaScript";
document.write("I "+a);
+ 1
Make sure to put a space in string. Like this:
var a= " love JavaScript". See there is a space before love. That will solve your problem. Here:
var a = " love javascript"
window.alert('I' + a)
You can put that space in "I " like this. Doesn't really matter