Why isnt ES6 code working on the codeplayground? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why isnt ES6 code working on the codeplayground?

Its giving me "unexpected identifier", even for code, given by the lessons itself.

31st Mar 2019, 9:10 AM
K4run0
13 Answers
31st Mar 2019, 12:01 PM
K4run0
+ 4
Codeplayground does support ES6. Kindly share the link of the lesson where you're getting that error.
31st Mar 2019, 9:43 AM
Шащи Ранжан
Шащи Ранжан - avatar
+ 3
K4run0 if you'd have gone thoroughly through the topic called var&let in here https://www.sololearn.com/learn/JavaScript/2969/ then you'd have seen that it's clearly mentioned there that "let allows you to declare variables that are limited in scope to the block, statement, or expression in which they are used. In this case, the name variable is accessible only in the scope of the if statement because it was declared as let."
31st Mar 2019, 10:21 AM
Шащи Ранжан
Шащи Ранжан - avatar
+ 2
Is the sololearn app using androids built in browser enginge? Than maybe my phone is too old?or can i update it in some way?
31st Mar 2019, 9:11 AM
K4run0
+ 2
TheWhiteCat💡 Yes, your code should alert 'jack', but if i'm running it, i still get the "unexpected identifier" error on line 4 (let) Btw: running the newest version of the app on an android 4.4.2.
31st Mar 2019, 11:19 AM
K4run0
+ 2
It's strange, because when I run the code it alerts the expected. I don't find any errors in the code.
31st Mar 2019, 11:20 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 2
Ok, hope you can find a solution for this problem 😉
31st Mar 2019, 11:30 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
K4run0 , it's normal, because name variable declared with "let" exists only in the if conditional check. You can see the code. https://code.sololearn.com/W7yWus25NzYx/?ref=app
31st Mar 2019, 10:23 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
K4run0, the code I proposed doesn't give errors, it just alerts the value of name variable => 'Jack'.
31st Mar 2019, 10:42 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
It happens here for example https://code.sololearn.com/WtK6Ek8Bcsge/?ref=app Getting an error on "let" like evertime its used (or other ES6 stuff)
31st Mar 2019, 9:55 AM
K4run0
0
Thanks, i understand what you r telling me, but i still get the error. The Code given by thewhitecat gives me the error in line 4 ( again the "let")...
31st Mar 2019, 10:39 AM
K4run0
0
TheWhiteCat💡 i know, the code is fine. It's just auf Problem for me to run ES6 code on the playground. I suspect that the app uses the android-built-in browser enginge and it's too old for ES6, so m question is, if it's like that and if so, can i do something about it? (Except from customROM stuff or buying a new phone😉)
31st Mar 2019, 11:28 AM
K4run0
0
Thx
31st Mar 2019, 11:48 AM
K4run0