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
| // Method 1: | |
| class Parent extends Component { | |
| state = { foo: '', bar: '', buzz: '' } | |
| render() { | |
| return ( | |
| <Child | |
| setParentState={this.setState} | |
| > | |
| ) |
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
| let rootCommentsCard = [] | |
| let repliesCard = [] | |
| function arrangeComments(comments){ | |
| for (var commentId in comments) { | |
| let parent = comments[commentId].parent | |
| if (parent[0] == 'root') { | |
| comments[commentId].commentId = commentId | |
| comments[commentId].replies = [] | |
| rootCommentsCard.push(comments[commentId]) |
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
| let array = [{ | |
| name: "John", | |
| ranking: 5 | |
| }, { | |
| name: "Sam", | |
| ranking: 4 | |
| }, { | |
| name: "Timi", | |
| ranking: 1 | |
| }, { |
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 test(){ | |
| var h = 'Hello'; | |
| var w = 'World'; | |
| return w, | |
| console.log(f), | |
| h; | |
| } | |
| console.log(this.test()); //World |
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 test(){ | |
| var h = 'Hello'; | |
| var w = 'World'; | |
| return (h,w); | |
| } | |
| console.log(this.test()); //World |
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
| let evens = [] | |
| simpleArray = [0, 12, 16, 12, 10, 7, 9]; | |
| simpleArray.forEach(function(e) { | |
| if (e % 2 === 0) { | |
| this.fives.push(e) | |
| } | |
| }.bind(this)) | |
| console.log(fives) //[ 0, 12, 16, 12, 10 ] | |
| /* Using the arrow function*/ |
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
| let evens = [] | |
| simpleArray = [0, 12, 16, 12, 10, 7, 9]; | |
| simpleArray.forEach(function(e) { | |
| if (e % 2 === 0) { | |
| this.fives.push(e) | |
| } | |
| }.bind(this)) | |
| console.log(fives) //[ 0, 12, 16, 12, 10 ] | |
| /* Using the arrow function*/ |
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
| let user = [Jane, Bane, Deadpool, Thanos] | |
| let state = 0; | |
| let uninvitedUsers = users.filter(user => { | |
| if (user.invite == "notInvited") { | |
| let rangeArray = range(from, to) | |
| for (let i = 0; i < rangeArray.length; i++) { | |
| if (user.rank == rangeArray[i]) { | |
| state += 1 | |
| return user, state | |
| } |
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
| #add 'node_modules' to .gitignore file | |
| git rm -r --cached node_modules | |
| git commit -m 'Remove the now ignored directory node_modules' | |
| git push origin master |
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
| { | |
| "name": "Cron-test", | |
| "version": "0.0.1", | |
| "private": true, | |
| "engines": { | |
| "node": ">= 7.6.0" | |
| }, | |
| "now": { | |
| "dotenv": "variables.env.now" | |
| }, |