Skip to content

Instantly share code, notes, and snippets.

View elushnikova's full-sized avatar

Lena Lushnikova elushnikova

View GitHub Profile

Cheat sheet: JavaScript Array methods

Deriving a new Array from an existing Array:

['■','●','▲'].slice(1, 3)           ['●','▲']
['■','●','■'].filter(x => x==='■')  ['■','■']
    ['▲','●'].map(x => x+x)         ['▲▲','●●']
    ['▲','●'].flatMap(x => [x,x])   ['▲','▲','●','●']
@elushnikova
elushnikova / questionsReducer.js
Created October 22, 2021 12:46
questionsReducer
function questionsReducer(questions, line, lineIndex, sourceLines) {
const isEven = lineIndex % 2 === 0;
if (isEven) {
return [
...questions,
{ question: line, answer: sourceLines[lineIndex + 1] },
];
}
@elushnikova
elushnikova / git-aliases.md
Last active May 13, 2021 12:26
List of git aliases that I use frequently. Subject to changes as I learn more.