Assessment wanted for Functions 1 skill test. (Tasks 1-4)

Assessment wanted for Functions 1 skill test. (Tasks 1-4)

Link to task:

Links to my code:

Thanks :wink:

Nice work, @EiN!

I have just two tiny remarks:

  • Task 2: The assignment to canvas.textContent is not needed. You can just call the function.
  • Task 3: You can replace name.length - name.length with 0 since this value is mathematically always zero.

If you like I have an additional question for task 3:
We want our random() function to have an excluding upper bound. For example random(3, 6) should return 3, 4 or 5.

  • What needs to be changed in random() to achieve this?
  • What needs to be changed in chooseName() so that the example still works?

Have a nice weekend,

1 Like

Additional questions are always cool, thank you for them. They help you understand the topic better.

Link to the completed additional task:

I will be glad if in the future you will give me additional tasks. :slightly_smiling_face:

I’m glad you enjoyed it. Sometimes, when a learner presents well solved tasks I’m afraid they are getting bored and I try to come up with something. :grin:

You’re new solution is correct. As you see, by redefining the meaning of the upper bound the code became simpler (function and its call). So the point to take away is: “Always think about the (coding) rules you impose on yourself. Can they be changed to make things easier?”
Most of the time it’s more like you’re making a function more complex, but its calls at different places in the code will become easier. It’s kind of a balancing thing.

I’ll try my best :slightly_smiling_face:

1 Like