JavaScript For-Loop问题:为什么我会收到语法错误? [关闭]

问题描述 投票:-1回答:1

我正在使用Javascript for Kids,对于初学者来说这是一本非常有趣的小书,但我在测试文本中的For循环示例时遇到了问题:

var sheepCounted = 0;
for (var sheepCounted = 0; sheepCounted < 10; sheepCounted++) {
  console.log(“I have counted” + sheepCounted + “sheep!”);
}
console.log(sheepCounted);

当我使用Javascript测试器测试此示例时,我收到语法错误,但我不确定为什么?谁能帮我吗?谢谢。

javascript for-loop
1个回答
3
投票

更改使用“ ”的这一行:

console.log(“I have counted” + sheepCounted + “sheep!”);

" "对此:

console.log("I have counted" + sheepCounted + "sheep!");
© www.soinside.com 2019 - 2024. All rights reserved.