我正在学习 Udacity 的 JS 入门类(class),我对这个关于分号的教程感到困惑!
问题是:
Directions: Define two variables called thingOne and thingTwo and assign them values. Print the values of both variables in one console.log statement using concatenation. For example,
red blue
where "red" is the value of thingOne and "blue" is the value of thingTwo. Don't forget to use semicolons!
我几乎尝试了所有的变体,但我总是得到错误的答案。我收到此消息:
What Went Well
Your code should have a variable thingOne
Your code should have a variable thingTwo
Your code should only have one console.log statement
Your code should print out the values of thingOne and thingTwo using concatenation
What Went Wrong
- Your code is missing semicolons at the end of each line
这是我的回答:
var thingOne = "red";
var thingTwo = " blue";
console.log(thingOne + thingTwo);
我也尝试过:
var thingOne = "red"; var thingTwo = " blue";
console.log(thingOne + thingTwo);
我还尝试了这两种组合,其中 console.log 语句末尾没有分号...只是为了看看这是否是问题所在。
这些都没有通过测试。
这是他们的错误还是我遗漏了什么? 很抱歉问了这个极其简单的问题。我只是想确保我正确地学习 JS。谢谢
最佳答案
您的解决方案是这样的:
var thingOne = "red";
var thingTwo = "blue";
console.log (thingOne + " " + thingTwo);
关于javascript - 我怎么没有正确使用分号(javascript)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55764593/