ARTICLEViews: 18Share  Posted by - Anonymous

interview question - write a program to remember the sum of previous value


function getSumFn(){

 var prevSum = 0;

 return function sum(value){

  prevSum = prevSum + value;

  return prevSum;

 }

}


const sum = getSumFn();


console.log(sum(1));

console.log(sum(5));

console.log(sum(9));

console.log(sum(10));


Sum of Node - the question is asked in many companies like Adobe, Google, Facebook, Microsoft, Amazon, Apple, Goldman ...

Interview Question: Sum

Conquer the JavaScript Interview: Cumulative Sum [Beginner Skill Level]

Interview Question: Three Sum

Big Finance Coding Interview Question - Minimum Value to Get Positive Step by Step Sum



Views -