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

[Codewars] L1: Set Alarm (8 kyu) / JavaScript

by fluss 2023. 3. 3.

https://www.codewars.com/kata/568dcc3c7f12767a62000038

 

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:

Write a function named setAlarm which receives two parameters. The first parameter, employed, is true whenever you are employed and the second parameter, vacation is true whenever you are on vacation.

The function should return true if you are employed and not on vacation (because these are the circumstances under which you need to set an alarm). It should return false otherwise. Examples:

setAlarm(true, true) -> false
setAlarm(false, true) -> false
setAlarm(false, false) -> false
setAlarm(true, false) -> true
 
 

코드

function setAlarm(employed, vacation){
 return employed && !vacation;
}

댓글