본문 바로가기
알고리즘/Codewars

[Codewars] How many lightsabers do you own? (8 kyu) / JavaScript

by fluss 2023. 5. 7.

https://www.codewars.com/kata/51f9d93b4095e0a7200001b8

 

Codewars - Achieve mastery through coding practice and developer mentorship

A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!

www.codewars.com

 

DESCRIPTION:

Inspired by the development team at Vooza, write the function that

  • accepts the name of a programmer, and
  • returns the number of lightsabers owned by that person.

The only person who owns lightsabers is Zach, by the way. He owns 18, which is an awesome number of lightsabers. Anyone else owns 0.

Note: your function should have a default parameter.

For example(Input --> Output):

"anyone else" --> 0
"Zach" --> 18

 

코드

function howManyLightsabersDoYouOwn(name) {
  return name === "Zach" ? 18 : 0;
}

댓글