为了账号安全,请及时绑定邮箱和手机立即绑定

使用 JavaScript Mad Libs Challenge 进行 DRY 编程

使用 JavaScript Mad Libs Challenge 进行 DRY 编程

偶然的你 2021-10-29 15:57:30
我是编程新手。我知道我可以使用函数和循环来避免重复此代码,但我需要帮助。任何人?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);
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 137 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信