Assessment wanted Functions 3 Skill Test

Chris!

Cha cha check it! I believe that I have the correct answer for #3 on functions quiz. I even made up a different array and entered it as a parameter; everything worked well. Just looking for input… am I heading in the right direction? Is there something that I’m missing. I did change range of random() to 8.

link:
https://jsfiddle.net/cazzimoto/gtrf8zms/5/

Thank you for your continued support!

V/R,
cazzimoto

1 Like

Hello again @cazzimoto!

I’ve looked at this, and it isn’t looking too bad at all — it works, and does what you expect it to.

However, have a look at our solution: https://github.com/mdn/learning-area/blob/master/javascript/building-blocks/tasks/functions/marking.md#task-3

There’s a couple of bits that could be improved:

  1. random() should take min and max parameters, allowing you to return a random number between any two values, not just 0 and 8.
  2. You can then call array[random(0, array.length)] and it will work any array, regardless of the length.
  3. You should have returned the chosen array index value out of the chooseName() function. The instructions say “Update the chooseName() function so that it makes use of the random number function, takes the array to choose from as a parameter (making it more flexible), and returns the result.”
  4. You can then call it like so — para.textContent = chooseItem(names);

@chrisdavidmills,

As always, thank you for the feedback and guidance! I am brand new to coding and am making a career change; even if it kills me. So your feedback is invaluable.
Question: Do you have any recommendations on books/textbooks for learning Javascript? To go along with, I’m assuming, your in-depth course on MDN! I love the course! I’m just trying to grab as much knowledge as I can.

Finally, if you were brand new to coding, knowing what you know now, would you learn Javascript or Python or other? Or does it even matter as I’ve been hearing it’s important to just learn one language well and the other languages will be similar?

Thank you again,
cazzimoto

For JavaScript, I would recommend continuing through our course, which teaches you all the basics. I’d definitely recommend also learning HTML and CSS basics, as the three are all closely linked.

In terms of books, I’d recommend https://eloquentjavascript.net/, which is really good and free.

In terms of the Python or JavaScript question, I would learn both. They are both really useful and versatile.

Learn client-side JavaScript (the stuff my course covers) along with HTML/CSS to make website front ends.

Learn server-side JavaScript (e.g. Node.js) and/or Python to make the server-side part of web sites; the bit that talks to databases, serves dynamic content, etc. Both are currently very popular, and useful in different ways. Python is probably more versatile, and Node is integral to a lot of mdern web tooling.

Once you’ve got the basics of JS under your belt, you should also look into learning a client-side framework or two, e.g. React, or Ember. You don’t need these to create web sites, but they are powerful and make a lot of tasks easier, plus they are very popular these days - many jobs will require knowledge of frameworks.

1 Like