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
"use strict"; | |
const tree = { | |
left: null, | |
right: null, | |
parent: null, | |
value: '0', | |
}; | |
const node1 = { |
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 isMultipleOf(input, number) { | |
if (input % number === 0) { | |
return Promise.resolve(input); | |
} | |
return Promise.reject(new Error(`not a multiple ${input}`)); | |
} | |
isMultipleOf(20, 10).then(console.log, console.error) |
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
{ | |
React.cloneElement(props.children, { props1: propsValue }); | |
} |
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 { compose, createStore, applyMiddleware } from 'redux'; | |
import { Provider } from 'react-redux'; | |
import thunkMiddleware from 'redux-thunk'; | |
const middlewares = [ | |
thunkMiddleware, | |
]; | |
if (process.env.NODE_ENV !== 'production') { | |
const createLogger = require('redux-logger'); |
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 solution(A) { | |
let longest = []; | |
let uniqueList = []; | |
let lengthList = []; | |
if (!Array.isArray(A) || A.length === 0) { | |
return 0; | |
} | |
for (let i = 0; i < A.length; i++) { |
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 integerLists = [1,2,3]; | |
Array.prototype.multiply = function (callback) { | |
let list = []; | |
for(let i= 0; i < this.length; i++) { | |
list.push(callback(this[i], i)); | |
} | |
return list; | |
}; |
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 init() { | |
var a = []; | |
function airPlane(val) { | |
a.push(val); | |
return a; | |
} | |
return airPlane; | |
} | |
var airPlane = init(); |
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 titleCase(str) { | |
return str.toLowerCase().split(' ').map((word) => `${word[0].toUpperCase() + word.slice(1)}` ).join(' '); | |
} | |
titleCase("hEllo wORld"); // "Hello World" |
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 divideByMinus (a, b) { | |
var i = 0; | |
while(a >= b) { | |
i++; | |
a = a - b; | |
} | |
return i; | |
} |
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 a = [1,2,3,1,1]; | |
var b = [4,5,6,1]; | |
var c = [1,1,1]; | |
function sumArray(a,b,c) { | |
const max = Math.max(a.length, b.length, c.length); | |
const sumList = []; | |
for(let i = 0; i < max; i++) { | |
sumList.push((a[i] || 0) + (b[i] || 0) + (c[i] || 0)); |