Skip to content

Instantly share code, notes, and snippets.

View ethanstenis's full-sized avatar

Ethan Stenis ethanstenis

View GitHub Profile
@ethanstenis
ethanstenis / KATA: How Old Will I Be In 2099?
Created July 14, 2017 16:03
This is the solution to the Codewars 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: Parse Int from Char Problem
Created July 13, 2017 21:59
This is the solution to Codewars' KATA: Parse int from char problem.
function getAge(inputString){
return parseInt(inputString.charAt(0));
}
@ethanstenis
ethanstenis / KATA: First Non-Consecutive Numbers
Created July 13, 2017 21:46
This is the solution for Codewars' KATA: Find the 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: Duck, Duck, Goose
Created July 13, 2017 21:29
This is the solution to Codewars' Duck, Duck, Goose KATA (JS)
function duckDuckGoose(players, goose) {
return players[(goose-1) % players.length].name;
}
@ethanstenis
ethanstenis / KATA: Remove Extra Exclamation Marks
Created July 13, 2017 18:32
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
function remove(s){
//coding and coding....
return s.split('!').join('') + '!';
}
@ethanstenis
ethanstenis / KATA: I love you, a little, a lot, passionately... not at all
Created July 13, 2017 18:21
This is the solution to Codewars' I love you, a little, a lot, passionately, madly... not at all KATA
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: Welcome!
Created July 13, 2017 18:09
This is the solution for the Codewars 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 / Verizon Samsung Galaxy S8 Interactive Video Embed Code
Created July 13, 2017 18:06
Verizon Samsung Galaxy S8 Interactive Video Embed Code
<iframeallowfullscreen="1" webkitAllowFullScreen id="interactiveExperience" width=720 height=405 class="embed-responsive-item" frameborder="0" src="https://ixd.invodo.com/verizon_embed/galaxy-test-index.html"></iframe>
@ethanstenis
ethanstenis / KATA: Odd, Even, or Prime Number
Created July 13, 2017 18:03
This is the solution for the Odds/Even/Prime Number Kata
function oddEven() {
for(let i = 1; i <= 100; i++) {
if(i % 2 === 0) {
console.log('Even');
} else if (i % 2 !== 0 && i % 3 === 0 || i % 9 === 0 || i % 5 === 0){
console.log('Odd');
} else {
console.log(i);
}
}
@ethanstenis
ethanstenis / KATA: FizzBuzz
Created July 13, 2017 18:02
This is the solution to the FizzBuzz Kata
function fizzbuzz() {
for(let i=0; i <= 100; i++) {
if(i % 15 === 0) {
console.log('FizzBuzz');
} else if (i % 5 === 0) {
console.log('Fizz');
} else if (i % 3 === 0) {
console.log('Buzz');
} else {
console.log(i);