LeetCode in Kotlin

2667. Create Hello World Function

Easy

Write a function createHelloWorld. It should return a new function that always returns "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:

Solution

const createHelloWorld = () => () => "Hello World";

/*
 * const f = createHelloWorld();
 * f(); // "Hello World"
 */

export { createHelloWorld }
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy