+ 1

JavaScript challenge mistake.

I have a screenshot of my old challenge attempt, I did answered right but it recognised my answer as incorrect. My answer was 6 which is correct. I don't remember answer provided by the question, because screenshot wasn't full page. https://code.sololearn.com/Wr3kG0YM532K/?ref=app Question author is Aaron Sarkissian

23rd Mar 2020, 7:54 PM
Vladyslav Semeniuk 🐸
Vladyslav Semeniuk 🐸 - avatar
7 Answers
0
EmmanueLZ. Btw, You are wrong. IIFE increments global variable with local variable and as a result we got 6 when adding a+b in global scope :)
23rd Mar 2020, 11:01 PM
Vladyslav Semeniuk 🐸
Vladyslav Semeniuk 🐸 - avatar
+ 1
Excuse me but question asks about output, and in the question was alert instead of console.log which doesn't change things at all.
23rd Mar 2020, 10:59 PM
Vladyslav Semeniuk 🐸
Vladyslav Semeniuk 🐸 - avatar
+ 1
No, version of JS doesn't influent on it. I didn't report that question, because I doing screenshots of my incorrect answers to find out what was wrong and then i forgetting them for a long time. For example, this question i did in October 2019 and since then I've checked it today :)
23rd Mar 2020, 11:31 PM
Vladyslav Semeniuk 🐸
Vladyslav Semeniuk 🐸 - avatar
0
Vladyslav Semeniuk 🐸 Hi, I give it a try... I would have say that the function which auto call give a=4 b=3. Then the console.log ask for a+b without asking for the function . So , are that variables inside the function still exists once executed.Maybe for the b one which is declare and initialize inside but for the a one ? With b =3 and a=1 it would be 4 otherwise 3. So I wonder what's the correct way to handle things here.Why are you sure 6 is the correct answer? There is something about the scope I guess.
23rd Mar 2020, 8:42 PM
EmmanueLZ.
EmmanueLZ. - avatar
0
Ah,ok thanks for correcting me, indeed, trying to answer made me feel as I was missing something, that's why I ended wondering also for the correct answer. So, why your answer was wrong? It might be a mistake from them,as at the end of the quizz you are invited to report any mistakes or so if you want (in the upper right corner of the question when you check answers), also by the time question was posted, it could have been another version of JavaScript which was by that time giving/allowing another solution .Just an hypothesis.
23rd Mar 2020, 11:11 PM
EmmanueLZ.
EmmanueLZ. - avatar
0
There are mistakes in challenges. I find the code you run on app and website different. I think sololearn should consider selecting challenges questions seriously.
5th Apr 2020, 12:33 AM
\•/
\•/ - avatar
0
Vladyslav Semeniuk 🐸 i also do screenshot 😀
5th Apr 2020, 12:37 AM
\•/
\•/ - avatar