I just got through with the lesson on loops. One of the exercises wants me to write a script that will accept a string of numbers, one at a time, from the user then calculate the sum, average, smallest number, and largest number.
So I'm not sure how to go about this but I'm just going to try and work through it. Any clues here would be great.
The trouble I'm having is with my first attempt. I'm going to try a do-while loop, with nested loops probably. so far I've got this
do
{
number = parseFloat(prompt("Enter a number from the series to be averaged.", ""));
s = prompt("Are there more numbers to enter? Enter Y or N.", "");
seq_length++;
}
while (s = "Y" || s = "y");
I've declared all the variables above this. Itwouldn't run initially so I started commenting out lines. I found that continue isn't a valid variable. I changed that but I still can't get the do-while block to run. If I comment out all lines except 3, 4, and 5 it works fine.
When I take out the comments the bock doesn't run.

New Topic/Question
Reply



MultiQuote





|