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 BookWithReviews { | |
constructor(id, title) { | |
this.id = id; | |
this.title = title; | |
this.reviews = []; | |
} | |
addReview(author, content) { | |
this.reviews.push({ author, content }); | |
}; |
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
<!DOCTYPE html> | |
<html ng-app="plunker"> | |
<head> | |
<meta charset="utf-8"/> | |
<title>AngularJS Plunker</title> | |
<script>document.write('<base href="'+ document.location +'"/>');</script> | |
<linkrel="stylesheet"href="style.css"/> | |
<script data-require="[email protected]"src="https://code.angularjs.org/1.5.8/angular.js"data-semver="1.5.8"></script><scriptsrc="app.js"></script> | |
</head> | |
<body ng-controller="MainCtrl"> |
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 MyComponent extends React.Component { | |
constructor(props) { | |
// set the default internal state | |
this.state = { | |
clicks: 0 | |
}; | |
} | |
componentDidMount() { | |
this.refs.myComponentDiv.addEventListener('click', this.clickHandler); |
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
/** | |
* Flattens any levels of nested arrays into single level | |
* @author Kader Fasid([email protected]) | |
* @params {Array} - Nested Array to Flatten | |
* @returns {Array} - Flattened array. | |
*/ | |
const flatten = (input) => { | |
var arr = []; | |
const recursiveArr = (input) => { | |
if(Array.isArray(input)) { |
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 email(email) { | |
if(typeof email !== "undefined"){ | |
let lastAtPos = email.lastIndexOf('@'); | |
let lastDotPos = email.lastIndexOf('.'); | |
if (!(lastAtPos < lastDotPos && lastAtPos > 0 && email.indexOf('@@') == -1 && lastDotPos > 2 && (email.length - lastDotPos) > 2)) { | |
formIsValid = false; | |
return console.log("Email is not valid"); | |
} | |
return console.log('valid') |