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
/* | |
* Concatenation of arrays and remove duplicates from all of them | |
* @arguments Arrays | |
*/ | |
concatArrays = (...arrays) => { | |
var children = [].concat(...arrays); | |
var returnArray = [...new Set(children)]; | |
return returnArray; | |
} |
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
/* | |
* Concatenation of arrays | |
* @arguments Arrays | |
*/ | |
concatArrays = (...arrays) => { | |
var children = [].concat(...arrays); | |
return children; | |
} |
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
import React, { useState, useEffect } from "react"; | |
import ReactDOM from "react-dom"; | |
function hexToRgb(hex) { | |
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); | |
return result | |
? { | |
r: parseInt(result[1], 16), | |
g: parseInt(result[2], 16), | |
b: parseInt(result[3], 16) |
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
var personObject = { | |
name: "John Doe", | |
ridingBike: function(){ | |
console.log(`I'm riding a bike, weeeeeeee!!!`); | |
}, | |
walk: function(howMuch){ | |
console.log(`${this.name} was walking ${howMuch}`); | |
} | |
}; |
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
var basketballModule = (function(){ | |
var points = 0; | |
return { | |
twoPointsMade: function(){ | |
return points = points + 2; | |
}, | |
threePointsMade: function(){ | |
return points = points + 3; |
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
// Spread operator | |
function fruits(apples, bananas, pears){ | |
console.log(apples); | |
console.log(bananas); | |
console.log(pears); | |
} | |
fruitsNo = [7, 9, 14]; | |
fruits(...fruitsNo); | |
/* |
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
let firstString = `He says: "Ok, let's do that".`; // He says: "Ok, let's do that". | |
// Variable interpolation | |
let name = "Joe"; | |
let secondString = `Hi, my name is ${name}.`; // Hi, my name is Joe. | |
// Expression interpolation | |
let isMarry = true; | |
let thirdString = `Please say hello to ${isMarry ? "Marry" : "Mike"}!`; // Please say hello to Marry! |
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
let baskets = [12, 5, 8, 130, 44]; | |
function moreThanTenApples(element) { | |
return (element >= 10); | |
} | |
let passed = baskets.filter(moreThanTenApples); | |
console.log("Those baskets have more than 10 apples: " + passed ); // "Those baskets have more than 10 apples: 12, 130, 44" |
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
let fruit = ['banana','pear','ananas', 'apple', 'peach']; | |
let stuffs = ['desk', 'pen', 'wardrobe']; | |
function findApple(newFruit){ | |
return newFruit==='apple'; | |
} | |
console.log(fruit.find(findApple)); // "apple" | |
console.log(stuffs.find(findApple)); // undefined |
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
let arr = [1, 2, 3, 4, 5]; | |
let doubled = arr.map(num => { | |
return num * 2; | |
}); | |
console.log(doubled); // [2, 4, 6, 8, 10] |
NewerOlder