Comparing parameters to values

Hello, I’m new to javascript and this is my first post here. Sorry if I sould like a noob but here is my code.

this is working fine, but what I want to ask… is there a better way to compare the parameters to 0 and 100? … it is fine as it is now, but what if I have way more parameters… this would be a pain to write.

furthermore, if you know what 2 or 4 grades, you would have to modify a lot of your code

have you already learned about arrays?

No… not yet. These are the final assignments for functions lessons. Code Challenges: JavaScript Fundamentals

If as you say, data structures have not yet been introduced, when was the ternary expression introduced? Did you find that code somewhere else and use it, anyway?

I don’t really understand your question… and what does it have to do whit my question to be honest… trenary is introduced in with the conditionals lessons.… but again I don’t know what does that have to do with my question!?

1 Like

not much, except surprise from our (well, my side at least) that you learn ternary operator before array

i would just continue the course for now, so you hopefully learn about arrays, and can apply them to this problem

I think I’m missing something… now I’m really confused… did I somehow miss the array lesson? I’m on stage 3 of the web development path ( Getting Started with JavaScript )… on lesson 3… u learn how to do ternary (if else)… now I’m on leson 5… " Code Challenges: Javascript Fundamentals"…

i don’t think you did, the array could be in a later lesson.

Sorry to push this forward… it it’s not too much trouble, can I have an answer to my original question?
I’m interested in this part of code… how could I write this better? (even if it’s something I haven’t learn yet, I like to try to understand code) :stuck_out_tongue:

You can learn about arrays:

arrays will help you to write this code better.

Rather than focusing on what is better, how about finish the course first, then go back and review. You will discover better ways once you can identify all the options.

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.