+ 3
How to make this code work ?
This isn't working How to change "+" into just + Here, https://code.sololearn.com/W17lrO6J9bOU/?ref=app
6 Réponses
+ 8
console.log(eval('1+ 1'));
alert(eval('1 + 1'));
+ 6
If you want only to print string then you can use this
console.log(eval(new String('2 + 2')));
+ 3
I wanted to do that differently
+ 3
I know that.
I want to do that separately.
How to change "+" into just +
+ 3
Do you mean that you want to output the + sign directly?
Like showing 1+1 in the alert box?
0
let sum = 2;
alert("1 + 1 = " + sum);
you can also use a string template without having to enclose the string in quotes and adding the + to concatenate.
the syntax uses the back tick (shift+~) which is not available on my iPhone keyboard so I will use a single quote here.
just enclose the entire expression in back ticks. Enclose your variables in ${} and it will be concatenated.
alert(‘1 + 1 = ${sum}’)