js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Solve 'Leonardo Dicaprio and Oscars' #64

Closed odv closed 5 years ago

odv commented 5 years ago

https://www.codewars.com/kata/leonardo-dicaprio-and-oscars/train/javascript

@RazvanBugoi Read the text of the problem very carefully.

RazvanBugoi commented 5 years ago
function leo(oscar) {
 if (typeof oscar === "number" && oscar == 88) {
 return "Leo finally won the oscar! Leo is happy";
} else if (oscar === 86) {
 return "Not even for Wolf of wallstreet?!";
 } else if (oscar != 88 && oscar < 88) {
  return "When will you give Leo an Oscar?";
  } else if (oscar != 86 && oscar < 88) { 
  return "When will you give Leo an Oscar?";
  } else {
  return "Leo got one already!";
}
}
odv commented 5 years ago

@RazvanBugoi Why do you use typeof in the first if statement?

RazvanBugoi commented 5 years ago

I forgot to delete it. It is there from my first attempt.

function leo(oscar) {
 if (oscar === 88) {
 return "Leo finally won the oscar! Leo is happy";
} else if (oscar === 86) {
 return "Not even for Wolf of wallstreet?!";
 } else if (oscar != 88 && oscar < 88) {
  return "When will you give Leo an Oscar?";
  } else if (oscar != 86 && oscar < 88) { 
  return "When will you give Leo an Oscar?";
  } else {
  return "Leo got one already!";
}
}