This file contains hidden or 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
| ?ps_debug=true | |
| // Add to URL and reload page - shows all analytics events being captured by the Data Layer in the console. | |
| &ps_debug=true | |
| // same query string except that it is not be used first. | |
| analytics.debug(); | |
| analytics.debug(false); |
This file contains hidden or 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++ ) { |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 squareSum(numbers){ | |
| var total = 0; | |
| for(var i = 0; i < numbers.length; i++) { | |
| total += numbers[i] * numbers[i]; | |
| } | |
| return total; |
This file contains hidden or 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 bonusTime(salary, bonus) { | |
| if(bonus === true){ | |
| return '£' + salary * 10; | |
| } else { | |
| return '£' + salary; | |
| } | |
| } |
This file contains hidden or 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 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; |
This file contains hidden or 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 fixTheMeerkat(arr) { | |
| var end = arr.shift(); | |
| var begin = arr.pop(); | |
| arr.push(end); | |
| arr.unshift(begin); | |
| return arr; | |
| } |
This file contains hidden or 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.'; |
NewerOlder