Hello all,
I’m working on:
https://www.codecademy.com/paths/web-development/tracks/getting-started-with-javascript/modules/code-challenge-javascript-fundamentals/lessons/javascript-fundamentals-code-challenge/exercises/calculate-weight
I’m stuck when it comes to the instructions to:
- expect
earthWeight
to be a number
- expect
planet
to be a string.
I’ve reviewed the lesson and searched for the answer but have absolutely no idea how to force the parameters to expect a number or expect a string. I’m familiar with setting a default parameter, but not sure how I’m supposed to set a default type of parameter.
Thanks in advance
Hey!
I don’t think you need to set a default/required type for the parameter and as far as I know that’s not something you can do in plain JS (at least not directly in the function declaration itself, you could of course use something like an if
statement and typeof
)
I believe it’s just there as a note to you as the developer so that you are aware of what data type would be passed in and you can plan/write the function accordingly.
Happy coding! 
1 Like