R
R
rostick31232020-10-19 01:29:04
Programming
rostick3123, 2020-10-19 01:29:04

Why doesn't break work?

Why doesn't the loop end when I write to the stop prompt, and yes, I'm a beginner:(

let arrA = [];

arrA = fillArr('A');

function fillArr(arrName) {
for (i = 0; ; i++) {
arrA[i] = parseInt(prompt('Elements of arrA'));
if (arrA[i] == 'stop') break;
}
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrew, 2016-03-19
@igoodmood

I'm not an expert in pros, but according to the text of the error, you need to initialize the u2 variable before using it. Just add for example
u2=0;

P
Pavel Kornilov, 2020-10-19
@rostick3123

You need to use something like this:

A
Alexey Yarkov, 2020-10-19
@yarkov

And why the hell will there be a stop after the parseInt operation?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question