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 lastlink = location.pathname.split('/').filter(el => el) | |
| lastlink = lastlink[lastlink.length - 1] | |
| $('.category_sidebar a').each((index, element) => { | |
| //.category_sidebar a is just selector for your menu links | |
| let href = $(element).attr('href').split('/').filter(el => el) | |
| href = href[href.length - 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
| const reverser = (text) =>{ | |
| let string = text, | |
| reverse = '' | |
| for(i=string.length-1;i>=0;i--){ | |
| reverse+= string[i] | |
| } | |
| return reverse | |
| } |
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
| //Logging | |
| const log = val => console.log(val), | |
| error = message => console.error(message), | |
| type = val => log(typeof val) | |
| //Math | |
| let random = (min, max) => Math.random() * (max - min + 1) + min, | |
| floor = val => Math.floor(val), | |
| abs = val => Math.abs(val) |
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
| const xlsx = require('xlsx') | |
| /* original data */ | |
| let data = [ | |
| {"name":"John", "city": "Seattle"}, | |
| {"name":"Mike", "city": "Los Angeles"}, | |
| {"name":"Zach", "city": "New York"} | |
| ] | |
| /* make the worksheet */ | |
| let ws = XLSX.utils.json_to_sheet(data) |
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
| const multiplier = factor => x => x * factor | |
| let doubler = multiplier(2) | |
| //doubler(4) = 8 | |
| /* | |
| function multiplier(factor) { | |
| return function (x) { | |
| return x * factor | |
| } |
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 vals = [1, 3, 65, 7, 3, 2, 6, 75, 3, 42, 12, 312, 23] | |
| let sum = vals.reduce((storage, val) => storage + val) | |
| console.log(sum); | |
| let biggest = vals.reduce((storage, val) => val > storage ? val : storage), | |
| lowest = vals.reduce((storage, val) => val > storage ? storage : val) |
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 vals = [1, 3, 65, 7, 3, 2, 6, 75, 3, 42, 12, 312, 23] | |
| vals = vals.map(x => x * 2) | |
| console.log(vals); |
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 vals = [1, 3, 65, 7, 3, 2, 6, 75, 3, 42, 12, 312, 23] | |
| vals = vals.filter(num =>!(num % 2)) | |
| /*vals = vals.filter(num =>num % 2 == 0)*/ | |
| //same thing | |
| console.log(vals); |