我是编程新手。我知道我可以使用函数和循环来避免重复此代码,但我需要帮助。任何人?var questions = 3; var questionsCount = ' [' + questions + ' questions left]'; var adjective = prompt('Please type an adjective' + questionsCount); questions -= 1; questionsCount = ' [' + questions + ' questions left]';var verb = prompt('Please type a verb' + questionsCount);questions -= 1;questionsCount = ' [' + questions + ' questions left]';var noun = prompt('Please type a noun' + questionsCount);alert('All done. Ready for the message?');var sentence = "There once was a " + adjective;sentence += ' programmer who wanted to use JavaScript to ' + verb;sentence += ' the ' + noun + '.';document.write(sentence);
添加回答
举报
0/150
提交
取消