D
D
Denis Bukreev2016-12-22 12:35:51
JavaScript
Denis Bukreev, 2016-12-22 12:35:51

In different case (switch case) it is impossible to use the same variables?

Kodu has been around for a long time and just now stumbled upon a problem: when processing switch cases in different cases, I get the same answer variables, but with a different value. The compiler swears that I duplicate the name of the variable, although it is in two different cases.
It is hard to believe that it is impossible to name variables in different cases the same way. This is some nonsense.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nicholas, 2016-12-22
@denisbookreev

He probably swears that you write var several times.
All vars are taken out (and executed at the beginning of the function), no matter where they are in the code.
Declare a variable 1 time at the beginning of the function, and then use it at least in all branches.

M
Michael, 2016-12-22
@FFxSquall

What other compiler in js? What do you write code in? Perhaps you are using jslint, which is configured in such a way that it writes a warning when it sees the same variables. And I would like to see a sample code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question