1
我是jessi,我是一名網絡開發學生。我正在嘗試編寫一個程序與數組,我卡住了。我有一組短語,當用戶輸入一個介於1到10之間的數字時,它應該顯示屏幕上有很多短語,但我被卡住了。我不知道如何在屏幕上顯示多個結果。我非常感謝任何幫助。謝謝。javascript數組和循環
<!DOCTYPE html>
<html>
<head>
<title>Get A Response</title>
</head>
<body>
<form>
<h1>Select how many phrases you want displayed.</h1>
<input type="number" class="userInput"></input>
<button type="submit" value="submit" onclick="showme()"></button>
</form>
<div class="myphrases">
</div>
<script src="js/main.js"></script>
</body>
</html>
////////////////// Javascript
function showme() {
var number = document.querySelector('.userInput').value;
var display = "";
var phrases = [
"Hello there",
"What's up Doc",
"Because I said so",
"Say it again",
"It's a celebration",
"Enjoy yourselves",
"Welcome",
"Where did you go", "Why you crying", "Stop playing"];
var random = Math.floor(Math.random() * phrases.length);
for(var i = 0; i < phrases.length; i++) {
}
}