我是编码的新手,完全是白板。
我正在遵循以下描述的路径:http: //javascriptissexy.com/how-to-learn-javascript-properly/在构建 node.js 时学习 javascript。
它建议我使用 jsfiddle 或 Firefox 的浏览器控制台使用 Javascript the Definitive Guide 中的代码片段。我首先尝试了控制台,但最终发现了 Scratchpad,它至少可以运行确认和提示功能的代码。
与此同时,我正在与 Codeacademy 合作,他们的控制台也返回答案和文本。我无法使用 jsfiddle 或暂存器返回非确认/提示函数答案,也无法让 firefox 浏览器控制台执行任何操作(我什至在哪里编写代码?!?)。
为了再次测试它并确保它不仅仅是 Firefox 的东西,我将 Firefox 代码剪切并粘贴到http://www.codeavengers.com/javascript/1#1.1中,它就像 Codeacademy 的控制台一样工作。我错过了什么?
请详细说明,因为我现在不知道。感谢您的帮助,如果您还记得刚开始的时候,我相信您知道这样的小事有多大的意义!这是我在 codeavengers、code academy、jsfiddle 和暂存器中使用的代码示例:
confirm("Are you ready to play");
var age = prompt("What's your age");
if (age < 13) {console.log("You\'re allowed to play but we take no responsibility");} else {console.log("Let\'s get started");}
console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");
console.log("Suddenly, Beiber stops and says, 'Who wants to race me?'");
var userAnswer = prompt("Do you want to race Bieber on stage?");
if (userAnswer === "yes") {console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!");} else {console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");}
var feedback = prompt("How do you rate this game on a scale of 1 to 10?");
if (feedback > 8) {console.log("Thank you! We should race at the next concert!");} else {console.log("I'll keep practicing coding and racing.");}