Skip to content

Instantly share code, notes, and snippets.

Avatar

Ethan Stenis ethanstenis

View GitHub Profile
@ethanstenis
ethanstenis / KATA: Welcome!
Created Jul 13, 2017
This is the solution for the Codewars Kata: Welcome!
View KATA: Welcome!
function greet(language) {
var database = {
english: "Welcome",
czech: "Vitejte",
danish: "Velkomst",
dutch: "Welkom",
estonian: "Tere tulemast",
finnish: "Tervetuloa",
flemish: "Welgekomen",
french: "Bienvenue",
@ethanstenis
ethanstenis / KATA: I love you, a little, a lot, passionately... not at all
Created Jul 13, 2017
This is the solution to Codewars' I love you, a little, a lot, passionately, madly... not at all KATA
View KATA: I love you, a little, a lot, passionately... not at all
function howMuchILoveYou(nbPetals) {
if(nbPetals % 6 === 1) {
return 'I love you';
} else if (nbPetals % 6 === 2) {
return 'a little'
} else if (nbPetals % 6 === 3) {
return 'a lot';
} else if (nbPetals % 6 === 4) {
return 'passionately';
} else if (nbPetals % 6 === 5) {
@ethanstenis
ethanstenis / KATA: Remove Extra Exclamation Marks
Created Jul 13, 2017
This is the solution for Codewars' Exclamation marks series #4 KATA: Remove all exclamation marks from sentence but ensure a exclamation mark at the end of string
View KATA: Remove Extra Exclamation Marks
function remove(s){
//coding and coding....
return s.split('!').join('') + '!';
}
@ethanstenis
ethanstenis / KATA: Duck, Duck, Goose
Created Jul 13, 2017
This is the solution to Codewars' Duck, Duck, Goose KATA (JS)
View KATA: Duck, Duck, Goose
function duckDuckGoose(players, goose) {
return players[(goose-1) % players.length].name;
}
@ethanstenis
ethanstenis / KATA: First Non-Consecutive Numbers
Created Jul 13, 2017
This is the solution for Codewars' KATA: Find the First Non-Consecutive Numbers
View KATA: First Non-Consecutive Numbers
function firstNonConsecutive (arr) {
for(let i = 0; i < arr.length-1; i++) {
if(arr[i] + 1 !== arr[i + 1]) {
return arr[i + 1];
}
}
return null
}
@ethanstenis
ethanstenis / KATA: Parse Int from Char Problem
Created Jul 13, 2017
This is the solution to Codewars' KATA: Parse int from char problem.
View KATA: Parse Int from Char Problem
function getAge(inputString){
return parseInt(inputString.charAt(0));
}
@ethanstenis
ethanstenis / KATA: How Old Will I Be In 2099?
Created Jul 14, 2017
This is the solution to the Codewars Kata: How Old Will I be in 2099
View KATA: How Old Will I Be In 2099?
function calculateAge(birthDate, otherDate) {
var age = otherDate - birthDate;
if(age === 1) {
return 'You are ' + age + ' year old.';
} else if(age > 1) {
return 'You are ' + age + ' years old.';
} else if (age < -1) {
return 'You will be born in ' + Math.abs(age) + ' years.';
@ethanstenis
ethanstenis / KATA: My Head is at the Wrong End!
Created Jul 17, 2017
This is the solution to Codewars' Kata: My head is at the wrong end.
View KATA: My Head is at the Wrong End!
function fixTheMeerkat(arr) {
var end = arr.shift();
var begin = arr.pop();
arr.push(end);
arr.unshift(begin);
return arr;
}
@ethanstenis
ethanstenis / KATA: Basic Mathematical Operations
Created Jul 17, 2017
This is the solution to Codewars' KATA: Basical Mathematical Operations
View KATA: Basic Mathematical Operations
function basicOp(operation, value1, value2)
{
if (operation === '+') {
return value1 + value2;
} else if(operation === '-') {
return value1 - value2;
} else if(operation === '*') {
return value1 * value2;
} else if(operation === '/'){
return value1/value2;
@ethanstenis
ethanstenis / KATA: Do I get a bonus?
Created Jul 17, 2017
This is the solution to Codewars' KATA: Do I get a bonus?
View KATA: Do I get a bonus?
function bonusTime(salary, bonus) {
if(bonus === true){
return '£' + salary * 10;
} else {
return '£' + salary;
}
}
You can’t perform that action at this time.