Don't rush, be quiet...solved!


#1

I FOUND IT!
This is my code for ‘Don’t Rush, be Quiet’:

function mod30(n) {
if (n >= 30) {
return n - 30;
} else {
return n;
}
}

// This function should return a value from 0 to 40:
function mod40(n) {
// Use an if-statement to return the correct value.
if (n >= 40) {
** return n - 40;**
** } else {**
** return n;**
** }**
}
// You don’t need to change the following code:
while (true) {
var time = hero.time;
var x = mod30(time) + 25;
var y = mod40(time) + 10;
hero.moveXY(x, y);
}

Bolded: the bolded coding is something that I changed because I felt like it and I got it right!


the following code is what i did originally.

HOPE THIS HELPED!!! :grin:


#2

and for some reason, the ‘you don’t need to change the following code’ part was wrong!! :fearful:


#3

Hi, congratulation for solving the level!

Your code seems to be just right! (some formattiong issues with the bold thoug, but it’s clear what you wrote!)

In contrast to that there was an error in the picture you posted:
In the function mod40(n), the else branch ist missing, so that there is no value returned whenever n < 40. The function would thus return NaN (not an number) when finnished. This would result in the error message that you have shown.

NB. I’m not sure about the rules here, but I think that complete solution should not be posted in order not to spoil it for others…

Not sure what you meant with “you don’t need to change the following code’ part was wrong!”. You did not change the code after the line with that text :wink:

Regards!


#4

oh okay, thanks! :blush:
Yes, the bolding did not work (sadly :cry:)
but, what I meant is that on line 21 it says "//You don’t need to change the following code:"
there is an error which I was (of course) meant to fix, although… it says NOT to change anything!! :rofl:

I probably shouldn’t have can ANYONE the answer but this is for people who got really confused…

LIKE ME!! :laughing:


#5

no python?
i can’t solve


#6

@Tailin.Chen
Use the search feature. There was recently a thread discussing this level in Python.