0
My main problem is with adding space in a JavaScript code.
how can I add space to the output of this code? function bestFiends(name1,name2,name3) { alert("The following, "+ name1 + name2 + name3+" are your bestfriends"); } name1=prompt("1rst name"); name2=prompt("2nd name"); name3=prompt("3rd name"); bestFiends(name1,name2,name3);
4 Respostas
+ 2
Consider that when you want to add a text or space you write on "" and when you want to add a variable to a text you need to separate it with +
this is called concatenation
Example :
var a = awesome;
alert("Learning at Sololearn is "+ a + " and this make me happy");
Output : Learning at Sololearn is awesome and this make me happy
0
Thank you so much, I appreciate your answers.
0
@Mirielle
how exactly are you supposed to apply, because it is displaying an error?
alert("The following, "+ ${name1},+ ${name2},+ ${name3} + "are your bestfriends");