我是編程新手。我知道我可以使用函數(shù)和循環(huán)來避免重復(fù)此代碼,但我需要幫助。任何人?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);
使用 JavaScript Mad Libs Challenge 進行 DRY 編程
偶然的你
2021-10-29 15:57:30