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 getProductImagesByIds = productImagesIds => | |
Promise.all(productImagesIds.map(PROMISE_TO_SOLVE_WITH_ID_FROM_ARRAY)) | |
.then(results => Array.isArray(results) ? | |
results.reduce((acc, row) => [...acc, row.url], []) : | |
[results] | |
) | |
.catch(e => { | |
throw new Error(e) | |
}) |
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 addTwo = prop => { | |
console.log(`In addTwo, prop: ${prop}`) | |
return prop + 2 | |
} | |
const addTen = prop => { | |
console.log(`In addTen, prop: ${prop}`) | |
return prop + 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
// Write a function that receives two sequences: | |
// A and B of integers and returns one sequence C. | |
// Sequence C should contain all elements from sequence A (maintaining the order) | |
// except those, that are present in sequence B p times, where p is a prime number. | |
// Example: | |
// A=[2,3,9,2,5,1,3,7,10] | |
// B=[2,1,3,4,3,10,6,6,1,7,10,10,10] | |
// C=[2,9,2,5,7,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 isObject = (subj: any) => typeof subj === 'object' && !Array.isArray(subj) && subj !== null; | |
export const applyToAllProps = (obj: Record<any, any>, fun: (props: any) => any) => { | |
const appliedEntries: any = Object | |
.entries(obj) | |
.map(([key, value]) => ([key, applyToProp(value, fun)])); | |
return Object.fromEntries(appliedEntries); | |
}; |
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 a = [2,3,7,5,1,3,9] | |
const startI = 4 | |
const moves = 6 | |
const mushroomPicker = (A, k, m) => { | |
let maxSum = 0 | |
let sumFromMovesL = 0 // stores prefix sum for each step moving left | |
for ( | |
let movesL = 0; |