Algorithm/leetcode
[leetcode][JS] 2667. Create Hello World Function
chelim
2024. 1. 29. 21:03
문제
Write a function createHelloWorld. It should return a new function that always returns "Hello World".
https://leetcode.com/problems/create-hello-world-function/
예시
코드
/**
* @return {Function}
*/
var createHelloWorld = function() {
return function(...args) {
return "Hello World";
}
};
/**
* const f = createHelloWorld();
* f(); // "Hello World"
*/
createHelloworld는 함수를 반환해야 하고, 반환된 함수를 호출했을 때 "Hello World"라는 문자열이 리턴되면 된다.
728x90