(help with HW problem) spent like 2 days researching and finding how i cant solve this

<script>
function exerciseFour(age){
  let typeOfLicense;
  // In this exercise, you will be given a variable, it will be called: age
  // You are also given another variable called: typeOfLicense;
  // Using an if/else if/else statement assign typeOfLicense to:
    // 'Full License' if age is greater than or equal to 16,
    // 'Permit' if age is equal to 15,
    // 'None' if age is less than 15
  
let typeOfLicense
  if (age >= 16){console.log('Full License')}
  else if (age = 15){console.log('Permit')
  else (age < 15){console.log('None')
  
  return typeOfLicense;
}
<script>

You have declared variable with let typeOfLicense, but later you are not assigning to it anywhere.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

your code doesn’t work first because of syntax errors:
your else if and else statements are missing the closing curly brackets. Fix this as first thing or the other corrections will be useless

after that it will not work as the function returns undefined
as per line return typeOfLicense as the variable never is assigned a value

also here , it should be a closing
parison but you are changing the value of age

that’s true but I didn’t know how to apply it anywhere

Thanks for the advice but is there any way I can get any examples that can help me with this solution?

It looks like you have the right logic in your if statements but there are some issues with syntax such as missing closing curly braces ( } ) on lines 12 and 13 and using assignment operator ( = ) on line 13 instead of equality operator (==). Also in the exercise it says to “assign typeOfLicense to…” so you don’t have to console.log it. Please see below for an example solution:

  if (age >= 16) {
    typeOfLicense = 'Full License'
  } else if (age == 15) {
    typeOfLicense = 'Permit'
  } else if (age < 15) {
    typeOfLicense = 'None'
  }

Hope this helps and let us know if you have any questions!

1 Like

thanks for the advice, but I still haven’t figured out how to apply typeOfLicense to anything right now

What do you mean by apply typeOfLicense? typeOfLicense is just a variable that you are setting to a particular value based on the age argument that is passed in to the function exerciseFour(age). So if this is done correctly you should be able to execute the function in the following way and it will return the value given below:

exerciseFour(22) --> 'Full License'
exerciseFour(15) --> 'Permit'
exerciseFour(12) --> 'None'

so is that how its suppose to be implamented in the work?

Yes that is my understanding based on the instructions given. Is there any way you can test it or how will this be graded?

aparntly in the assignment I have to finish, it is the last question of the assignment, and the assignment tells me if im right or wrong. So far I have done so much research and youtube videos and re looked at my notes, but at the end I feel like the question isn’t really specific on how it wants it.

The assignment im taking is the pre course from Lambda school, in which I have to finish before entering so I can qualify.

If the question is exactly what you have pasted at the top then the example solution I gave earlier should be able to pass the test. Can you give it a try and see?

By the way, I am currently a student in Lambda School’s Full Stack Web Development program and would be happy to answer any questions you have about the program. I am about half-way through right now and highly recommend it!

thanks man!! I’m very interested in the class, but ima be taking the part time curriculum, since at the same time I have to help out my family financially, and maybe one day move to san Francisco, but yeah thanks a lot

do you by any chance remebre working on the pre course work?

Sure, no problem! I am a part-time student as well and it really is an amazing program. Definitely challenging and you’ll have to work hard but nothing worth doing is easy, right? :slight_smile:

yeah nothing in life is easy. so far I have been able to go this far without asking for some much advice, but this particular question kinda got me off guard, ive spent 2-3 days asking about it

Yes I completed the pre-course work before applying. But that was almost 1 year ago so I’m not sure if it has changed since then. Do you have any questions or is anything unclear?

HOLD UP I got it :rofl: :rofl: :rofl: