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
const array = [1, 2, 3, 4, 5]; | |
for (let i=0; i < array.length; i++) { | |
array[i] = array[i] * 2; | |
} | |
console.log(array); // [ 2, 4, 6, 8, 10 ] |
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
const array = [1, 2, 3, 4, 5]; | |
const array2 = array.map((value) => value * 2); | |
console.log(array2); // [ 2, 4, 6, 8, 10 ] |
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 sumDigPow(a, b) { | |
const arr = []; | |
for (let i = a; i <= b; i++) { | |
let sum = 0; | |
for (let j = 0; j <= String(i).length; j++) { | |
sum += Math.pow(parseInt(String(i)[j]), j+1); | |
if (sum == i) arr.push(i); | |
} | |
} | |
return arr; |
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 sumDigPow(start, stop) { | |
// create array from start to stop | |
const arr = Array.apply(null, Array(stop-start)).map((_,i) => i+start); | |
function calc(num) { | |
const n_arr = String(num).split('').map(Number).map((n,i) => Math.pow(n,i+1)); | |
return n_arr.reduce((acc,n) => acc+n); | |
} | |
// create new array with numbers that match criteria |
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
<RevertApply onApplyClick={this.handleApplyClick} onRevertClick={this.handleRevertClick} > | |
<Label title="Parameter 1"> | |
<Textbox value={param1} onChange={e => this.handleChange('param1', e)} /> | |
</Label> | |
<Label title="Parameter 2"> | |
<Textbox value={param2} onChange={e => this.handleChange('param2', e)} /> | |
</Label> | |
</RevertApply> |
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
createHandleChange(callback) { | |
// This has to be a ES5 function, because we need to access its `arguments` | |
return (function() { | |
// don't run for children that has no onChange prop | |
if (!callback) { | |
return | |
} | |
// set touched to true so we can re-render active Apply/Revert buttons | |
if (!this.state.touched) { |
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
renderWrappedChildren(children) { | |
// Traverse through all children with pretty functional way :-) | |
return React.Children.map(children, (child) => { | |
// This is support for non-node elements (eg. pure text), they have no props | |
if (!child.props) { | |
return child | |
} | |
// If current component has additional children, traverse through them as well! |
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
handleApplyClick() { | |
const { onApplyClick } = this.props | |
const result = onApplyClick() | |
// Don't update state if callback is signaling failing behaviour | |
if (result !== false) { | |
this.setState({ touched: false }) | |
} | |
} |
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 from 'react' | |
import classnames from 'classnames' | |
import './revert-apply.scss' | |
const getClassNames = (props) => classnames( | |
'revert-apply', | |
{ | |
bordered: props.bordered, | |
}, |
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
const aes256 = require('aes256'); | |
// const pbkdf2 = require('pbkdf2'); | |
const { ec: EC } = require('elliptic'); | |
const { expect } = require('chai'); | |
const key = 'my passphrase'; | |
const plaintext = 'my plaintext message'; | |
// const MASTER_PASSWORD = 'cornflake12'; | |
// const SALT = '2019-01-29T21:54:56.015Z'; |
OlderNewer