9
JS Assignment 4: Control Flow Continued
BrianTran2 (9)

Is anyone doing LambdaSchool JavaScript pretest because I have worked for 40 minutes and I can get question 3 from assignment 4 correct.

You are viewing a single comment. View All
5
Cwill14 (10)

This worked for me:

function exerciseThree(typeOfPizza){
  let lovesPizza;
  
  // In this exercise, you will be given a variable, it will be called: typeOfPizza
  // You are also given another variable called: lovesPizza;
  // Using an if/else statement assign lovesPizza to true if typeOfPizza is 'pepperoni', assign it to false if it is 'olives'
  if(typeOfPizza === 'pepperoni'){
    return true;
  } if (typeOfPizza === 'olives'){
    return false;
  }
  // Please write your answer in the line above.
  return lovesPizza;
}

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
  if(age >= 16){
    return 'Full License';
  } else if (age === 15) {
    return 'Permit';
  } else {
    return 'None';
  }
  
  // Please write your answer in the line above.
  return typeOfLicense;
1
sweaze97 (0)

@Cwill14 Thanks a lot for this, it really helped me.

1
BrianTran2 (9)

@Cwill14 thank you. Sorry for the late reply on my part.

1
JwalyaOza (3)

@BrianTran2 . Mr brian. actually i've been stuck at the js assignment 9 from last 3 days and i'm not able to get the suitable answers. sir can you please guide me in order to finish the assignment 9 as quick as possible? i really need some help to complete that assignment so that i can move ahead. i hope you can help me sir

2
Shif (1)

@Cwill14 this may "pass" - but I dont think it fulfills the request in the assignment:

// Using an if/else if/else statement *assign typeOfLicense to*

Here is a solution to consider that assigns typeOfLicense to Full/Permit/None:

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
    if (age >=16) {
      typeOfLicense = 'Full License';
  } else if (age === 15) {
      typeOfLicense = 'Permit';
  } else {
      typeOfLicense = 'None';
  }

  // Please write your answer in the line above.
  return typeOfLicense;
}
1
Cwill14 (10)

@Shif you are correct, I must have misread it but it still passed lol