DEV Community

Cover image for 30 Days of JavaScript - Day 1
Leonardo Cunha
Leonardo Cunha

Posted on

30 Days of JavaScript - Day 1

Hey, join me in answering the 30 Days of Javascript from Leetcode.

Here is the description of Day 1.

Answer:

This is an easy challenge. To return "Hello World", we could do the following:

var createHelloWorld = function() {
  return function(...args) {
    return "Hello World"
  }
}
Enter fullscreen mode Exit fullscreen mode

The time complexity is O(1) because it's always returning "Hello World". No matter if we increase the input size.

The space complexity is also O(1) because nothing more will be stored in memory if we increase the input size.

That's it. Simple, right? Let's go to Day 2.

Top comments (0)