An interview question about valueOf's JavaScript

implement a sum method to make it behave as follows

sum(2,3).valueOf()    //5
    
sum(2,3,4).valueOf()        //9
    
sum(2,3)(4).valueOf()        //9
    
sum(2,3,4)(2)(3,4).valueOf()         //18

the previous parts sum () , sum () () are easy to say. But how do you rewrite valueOf to print the sum of the data returned by the previous execution method?

Jul.15,2021

The results of

sum () can continue to use the () operator, indicating that sum () returns a function (function / function expression / arrow function collectively); in addition, the return value also has a valueOf () method, so you can put a box

first.
 
< hr >
< hr >
< hr >
! [quote text] [1]
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c2e6c3-33bd2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c2e6c3-33bd2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?