Assessment wanted for solution on Functions 3 skill test

Hello!
I would like assessment for Test your skills: Functions - Functions 3 task.

Source code

I tried to improve the assessment functions and somewhat document them.
Any constructive criticism on code and documentation would be very appreciate.

Thanks you in advance.

Hi @franriol and welcome to the community :wave:

Congratulations! :medal_sports: Your code works correctly and the documentation makes it easy to follow. Cool idea to improve the chooseName() function with boundaries and value checks.

Few remarks:

  • You could write your lets as consts (always use const when possible)
  • With the help of the Destructuring Assignment you could write the swapping in one line: [a, b] = [b, a];
  • The ternary operator could be simplified to: a = a > arr.length ? arr.length - 1 : a; Or, since we do nothing in the else part, a simple if statement would also be possible (matter of taste):
if (a > arr.length) {
  a = arr.length - 1;
}

I hope that helps! Feel free to ask questions.

Happy coding!
Michael

Hi @mikoMK,

Thanks your for your review, for sure it helps me a lot of. I take note of your remarks for the future.

Regards the code documentantion I made some research on how to document the code in JS but I don’t know if is the preferred form.

Nice day!!
Fran

I personally don’t use the JSDoc comment style for functions (/** ... */). I’m neither a fan of “comment everything” nor “the code itself is comment enough”. As a guideline for myself I ask: “Could I immediately understand this code when revisiting some months later?”. If not, I add a comment.
When commenting I always use /* ... */ so they look the same regardless if they are single-line or multi-line.

Michael