Total Pageviews

Friday 30 August 2019

JavaScript Interview Question | Closure

In many interview question nowdays there is a popular interview question based on JavaScript closure and that is:


Input:    messageWord(‘2’)(‘3’)(‘4’)

Output: ‘234’

Solution:

function messageWord (x){
  return function(y){
      return function(z){
        return x + y + z;
      };
  };
}

No comments:

Post a Comment

Microsoft Logo using flexbox and Reactjs

 <!DOCTYPE html> <html> <head>     <script src="https://unpkg.com/react@18/umd/react.development.js" crossori...