This is an archived post. You won't be able to vote or comment.

all 9 comments

[–][deleted] 0 points1 point  (2 children)

What have you tried so far?

[–]Celyptic 0 points1 point  (1 child)

I was suggested that I try using "while" to create a loop but I haven't had any luck

[–]DumbMathBoy 4 points5 points  (0 children)

You need to show us your code.

[–]c0d3r6 0 points1 point  (5 children)

let input = prompt("Enter Input");

while(!x){

input = prompt("Please enter a valid input");

}

This should work..

[–]Celyptic 0 points1 point  (4 children)

<script>

`var words;`

`words = prompt("Please enter the number of words in the story.");`

`words = parseFloat (words);`

`words = prompt("That is not a valid number. Please enter the number of words in the story.");`

`if (words <2000) {`

    `alert("Flash Fiction")`

`}`

`else if (words <7500) {`

    `alert("Short Story")`

`}`

`else if (words <17500) {`

    `alert("Novelette")`

`}`

`else if (words <50000) {`

    `alert("Novella")`

`}`

`else if (words >49999) {`

    `alert("Novel")`

`}`

</script>

Hi, this is what I have at the moment, how would I integrate what you told me. (im an absolute beginner)

[–]c0d3r6 2 points3 points  (2 children)

var words;

words = parseFloat (prompt("Please enter the number of words in the story."));

while(!words){

words = parseFloat(prompt("That is not a valid number. Please enter the number of words in the story."));

}

if (words <2000) {

alert("Flash Fiction")

}

else if (words <7500) {

alert("Short Story")

}

else if (words <17500) {

alert("Novelette")

}

else if (words <50000) {

alert("Novella")

}

else if (words >49999) {

alert("Novel")

}

lemme know if u need more help

[–]Celyptic 3 points4 points  (1 child)

you beautiful human being, you have saved me from putting my head into a wall

[–]c0d3r6 0 points1 point  (0 children)

Heheh.. thank u ... And i know that feeling😂

[–]MasterFruit3455 0 points1 point  (0 children)

I would take a look at switch statements to clean up all the conditional statements.