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
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) { |
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
function remove(s){ | |
//coding and coding.... | |
return s.split('!').join('') + '!'; | |
} |
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
function duckDuckGoose(players, goose) { | |
return players[(goose-1) % players.length].name; | |
} |
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
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 | |
} |
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
function getAge(inputString){ | |
return parseInt(inputString.charAt(0)); | |
} |
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
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.'; |
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
class Button extends React.Component { | |
handleClick = () => { | |
this.props.onClickFunction(this.props.incrementValue); | |
}; | |
render() { | |
return ( | |
<button onClick={this.handleClick}> | |
+{this.props.incrementValue} | |
</button> |
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
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> | |
); |
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
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> | |
); |
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
// 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++ ) { |