美文网首页
leetcode 1. 写一个返回hello world的函数

leetcode 1. 写一个返回hello world的函数

作者: 米诺zuo | 来源:发表于2024-07-08 11:19 被阅读0次

    写一个返回hello world的函数

    Example 1:
    
    Input: args = []
    Output: "Hello World"
    Explanation:
    const f = createHelloWorld();
    f(); // "Hello World"
    
    The function returned by createHelloWorld should always return "Hello World".
    Example 2:
    
    Input: args = [{},null,42]
    Output: "Hello World"
    Explanation:
    const f = createHelloWorld();
    f({}, null, 42); // "Hello World"
    
    Any arguments could be passed to the function but it should still always return "Hello World".
     
    
    Constraints:
    
    0 <= args.length <= 10
    

    solution:

    /**
     * @return {Function}
     */
    var createHelloWorld = function() {
        return function(...args) {
            return "Hello World"
        }
    };
    
    /**
     * const f = createHelloWorld();
     * f(); // "Hello World"
     */
    

    相关文章

      网友评论

          本文标题:leetcode 1. 写一个返回hello world的函数

          本文链接:https://www.haomeiwen.com/subject/djoocjtx.html