Created
February 10, 2025 01:24
-
-
Save AlvisonHunterArnuero/1944b2fb337655f83b94f64c2f597d6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Training JS #1 Create your first function | |
// https://www.codewars.com/kata/571ec274b1c8d4a61c0000c8 | |
const helloWorld = () => { | |
const str = 'Hello World!'; | |
console.log(str); | |
} | |
// Training #6 basic data-types and conditional statements | |
// https://www.codewars.com/kata/571f832f07363d295d001ba8/javascript | |
const trueOrFalse = val => Boolean(val).toString(); | |
// Even or Odd | |
// https://www.codewars.com/kata/53da3dbb4a5168369a0000fe | |
const evenOrOdd = number => number % 2 === 0 ? 'Even' : 'Odd'; | |
// Simple Calculator | |
// https://www.codewars.com/kata/57158fb92ad763bb180004e7/javascript | |
const MINIMUM_WATER_REQUIREMENT_MM = 40; | |
const RESPONSES = { | |
NEED_MORE_WATER: (deficit) => `You need to give your plant ${deficit}mm of water`, | |
ENOUGH_WATER: "Your plant has had more than enough water for today!", | |
}; | |
const rainAmount = (rainfallAmount) => { | |
if (rainfallAmount < MINIMUM_WATER_REQUIREMENT_MM) { | |
const waterDeficit = MINIMUM_WATER_REQUIREMENT_MM - rainfallAmount; | |
return RESPONSES.NEED_MORE_WATER(waterDeficit); | |
} | |
return RESPONSES.ENOUGH_WATER; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment