Skip to content

Instantly share code, notes, and snippets.

View NAZIMUDHEEN267's full-sized avatar
🎯
Focusing

NAZIMUDHEEN TI NAZIMUDHEEN267

🎯
Focusing
View GitHub Profile
@NAZIMUDHEEN267
NAZIMUDHEEN267 / runningSum1dArray.js
Created March 29, 2023 05:35
Get all the numbers sum that passed on the "runningSum" function
function runningSum(nums: number[]): number[] {
let sum = [nums[0]];
for(let i=1; i<nums.length; i++) {
sum[i] = sum[i-1] + nums[i];
}
return sum;
}
runningSum([1,2,3,4,5,6,7,8,9,10) // return [1, 3, 6, 10, 15, 21, 28, 36, 45, 55];
@NAZIMUDHEEN267
NAZIMUDHEEN267 / simple.js
Last active May 13, 2023 16:08
shortcuts && simple methods
1.
// !! double exclamation it returns boolean value true/false
const array = [0, 1, 2, 3, 0];
array.filter(num => num > 0); // bad
array.filter(num => !!num); // good
2.
// It checks first condition is true or not then only move on to the second condition, if both condition is fullfilling then
// the object spread operator to the parent object