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