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 res = [ [ 8, 5, 11 ], [ 6, 3, 9 ] ] | |
res = [].concat(...res); | |
return res; | |
// output -> [ 8, 5, 11, 6, 3, 9 ] |
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
sum: function(arr) { | |
return arr.reduce( (total, num) => total + num, 0); | |
} |
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 number_with_commas(x) { | |
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') | |
} |
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 a = Object.create(null); // => {} | |
let a = {}; // => {} |
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 arr = [3, 5, 7]; | |
arr.foo = 'hello'; | |
for (var i in arr) { | |
console.log(i); // logs "0", "1", "2", "foo" | |
} | |
for (var i of arr) { | |
console.log(i); // logs 3, 5, 7 | |
} |
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 = ['label one', 1, 'label two', 2, 'label 3', 3]; | |
arr.chunk(2) | |
.map(([label, value]) => ({ label, value })); |
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
Object.defineProperty(Array.prototype, 'chunk', { | |
value: function(n) { | |
// ACTUAL CODE FOR CHUNKING ARRAY: | |
return Array.range(Math.ceil(this.length/n)).map((x,i) => this.slice(i*n,i*n+n)); | |
} | |
}); |
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
_.reduce(code, function(memo, current) { return _.assign(memo, current) }, {}) |
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
for (var i=0;i<100;i++) { | |
let generated = window.randomstring.generate(4); | |
code.push({ | |
[`R${generated}`] : { | |
used: false, | |
[`R${generated}A`] : { | |
used: false, | |
}, | |
[`R${generated}B`] : { | |
used: 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
<template> | |
<div> | |
<v-container align-content-center> | |
<v-layout class="px-4 pt-4 pt-2"> | |
<v-flex> | |
<v-form v-model="valid"> | |
<div class="py-1"> | |
<v-text-field | |
v-model="name" | |
:rules="nameRules" |