Reputation: 11
Code:
var prompt = require("prompt-sync")()
function start() {
var whatbox = prompt('What box would you like to open?(ALL LOWER CASE)')
if (whatbox == "School") {
box("School")
} else if (whatbox == "Park") {
box("Park")
} else if (whatbox == "Tech"
} {
box("Tech")
} else {
console.log("That is NOT a box! Try again and check your spelling!")
}
}
start()
Error: The prompt keeps on repeating every time I press a key.
Upvotes: 1
Views: 1477
Reputation: 37
var prompt = require("prompt-sync")()
function start() {
console.log("What box would you like to open?(ALL LOWER CASE)")
var whatbox = prompt("Your input >> ")
if (whatbox == "School") {
box("School")
} else if (whatbox == "Park") {
box("Park")
} else if (whatbox == "Tech"
} {
box("Tech")
} else {
console.log("That is NOT a box! Try again and check your spelling!")
}
}
start()
The prompt-sync has this problem where if your prompt text/qustion is too long it fails when refreshing it. To solve this problem, you can simply console.log question and then ask for input.
Upvotes: 3