DEV Community

LogicWiz Admin
LogicWiz Admin

Posted on

An AI explained JavaScript in four lines. One of them is wrong.

We asked Aria, our AI, for four quick JavaScript facts. She was completely sure about all of them:

1. const stops you from reassigning the variable.
2. typeof null returns "object".
3. 0.1 + 0.2 === 0.3 is true.
4. Arrow functions don't get their own this.
Enter fullscreen mode Exit fullscreen mode

One line is wrong. Pick yours before you scroll.

.

.

.

.

.

It's line 3. Numbers in JavaScript are floating point, so 0.1 + 0.2 is 0.30000000000000004 and the check is false. Line 2 looks wrong but is true, and it's been that way since the first version of the language.

We turned this kind of thing into a free game. Aria answers a coding question in 5 or 6 lines and you tap the one that's wrong, then pick why. Pick from tracks like frontend, Python, SQL or AI. Five rounds take about five minutes on a phone.

Our October event closes Monday 19 Oct at 11:59 pm IST, and the top 10 get LogicWiz goodies delivered home.

Play it here: https://arena.logicwiz.ai/club/BJSRBK?utm_source=devto-js

Did line 2 trick you?

Top comments (0)