【发布时间】:2020-01-17 22:17:50
【问题描述】:
我将特定单词插入到一个带有连接的句子中,但单词 a 一起运行,它们之间没有空格。
var adjective1 = + 'amazing';
var adjective2 = + 'fun';
var adjective3 = + 'entertaining';
var madLib = 'The Intro to JavaScript course is' + adjective1 + 'james and Julia are so' +
adjective2 + 'I cannot wait to work through the rest of this' + adjective3 + 'content!';
console.log(madLib);
【问题讨论】:
-
只需在字符串中加一个空格即可:
The Intro to JavaScript course is -
你的
adjective变量都是NaN。 -
在字符串中包含空格
-
或在形容词字符串中添加空格。
-
考虑template literal:
`The Intro to JavaScript course is ${adjective1} james and Julia are so...`。
标签: javascript