I think the readability to an inexperienced coder greatly improves just by moving the "robot.number++" outside the conditional and perhaps even changing it to "robot.number = robot.number + 1"
Though that is slightly different (since ++ will execute after the conditional is evaluated when following the lval but the change will make it run before)
Edit: on 2 seconds though... put that code AFTER the if statement and it would behave exactly as the example.
If I remember correctly, Google's Blockly Games used to allow JavaScript on more than just the last "level". It definitely starts at a much earlier point in the learning process.
The best part of the previous discussions is links to similar technologies; I look forward to seeing what else is mentioned today.
It's an interesting game, but I was immediately put off by level two, which sinks you into the limitations of the robot API by making you introduce a counter that needs checking. That would be totally counter-intuitive for beginners.
Stops working for me after level 1. Repro:
1. https://lab.reaal.me/jsrobot and click "start"
2. Complete the level and click "next level"
3. This takes me to https://lab.reaal.me/jsrobot/#level=2 but the screen is blank
4. Dev tools shows this: "ReferenceError: URLcode is not defined[Learn More] ui.js:32:5"
I contributed to a similar project[0] for the 2016 7DRL[1].
It was a lot of fun to build but ultimately I just wanted to play the game manually. Someone who tried it back when we released actually wrote a script to control the game turn-by-turn via alert boxes, hah.
Reminds me of a course I had to take freshman year in college called Karel the Robot[1]. It had a Basic like programming language. It mostly existed to try to quickly bring up to speed the students that has no experience coding prior to college. This is interesting because Javascript is a much more complete language and probably also a it harder to learn if you are just getting started.
:/ Fun idea, but I wrote a chunk of code for the third level, bumped the electro thing, died, clicked the restart button and it wiped my script. I should know better than to trust browser based text editors, but it made iteration and exploration difficult.
It's a nice idea and really well executed but the second test just demonstrates to me how JS is not an ideal language for a beginner to learn as you're thrown straight into async execution and having to work around the fact that functions execute immediately with arcane workarounds.
I still think Python is the most straightforward to learn, even though the whitespace constantly catches beginners out too.
Or the action could be the return value. IMHO, trying to guess the physical model by experimentation is painful. Why not propose a debug button to display the state of variables during the execution of script.
I bet jump() has something like `if (robot.touchingFloor) { action = 'jump'; }` which makes your code work because it doesn't overwrite the robot action if it can't actually jump.
Switch the order of actions and you'll see the robot never jumps because its action gets overwritten (as stated in the instructions tab).
Incrementing inside a check is awkward, as is just calling the variable 'number'. Perhaps something like