Skip to content

Instantly share code, notes, and snippets.

View ethanstenis's full-sized avatar

Ethan Stenis ethanstenis

View GitHub Profile
@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: 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: 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: 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: 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: 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.';
class Button extends React.Component {
handleClick = () => {
this.props.onClickFunction(this.props.incrementValue);
};
render() {
return (
<button onClick={this.handleClick}>
+{this.props.incrementValue}
</button>
const Card = (props) => {
return (
<div style={{margin: '1em'}}>
<img width="75" src={props.avatar_url} />
<div style={{display: 'inline-block', marginLeft: 10}}>
<div style={{fontSize: '1.25em', fontWeight: 'bold'}}>{props.name}</div>
<div>{props.company}</div>
</div>
</div>
);
const Stars = (props) => {
// const numberofStars = 1 + Math.floor(Math.random()*9);
return (
<div className="col-5">
{_.range(props.numberofStars).map(i =>
<i key={i} className="fa fa-star"></i>
)}
</div>
);
@ethanstenis
ethanstenis / ReactJS: Play Nine Numbers Game
Last active August 8, 2017 15:38
This is the code for the REACT.JS Play Nine numbers game
// bit.ly/s-pcs
var possibleCombinationSum = function(arr, n) {
if (arr.indexOf(n) >= 0) { return true; }
if (arr[0] > n) { return false; }
if (arr[arr.length - 1] > n) {
arr.pop();
return possibleCombinationSum(arr, n);
}
var listSize = arr.length, combinationsCount = (1 << listSize);
for (var i = 1; i < combinationsCount ; i++ ) {