Learn Javascript with Exercism
It’s really funny ^^
00. Hello World!
- Write a function that returns the string “Hello, World!”.
- Run the test suite and make sure that it succeeds.
- Submit your solution and check it at the website.
// hello-world.js export const hello = () => ('Hello, World!');
01. Two Fer
- If the given name is “Alice”, the result should be “One for Alice, one for me.” If no name is given, the result should be “One for you, one for me.”
// two-fer.js export const twoFer = (name) => { if (name === '') { return ('One for you, one for me.'); } return (`One for ${name}, one for me.`); };
02. Leap year: The tricky thing here is that a leap year in the Gregorian calendar occurs:
- On every year that is evenly divisible by 4
- Except for every year that is evenly divisible by 100
- Unless the year is also evenly divisible by 400
// leap.js export const isLeap = (year) => { if (year % 4 !== 0) { return false; } if (year % 100 !== 0) { return true; } if (year % 400 === 0) { return true; } return false; };