Day 1 of 30 Days JavaScript Challenge

Vasant MestryVasant Mestry
2 min read

Hellooo guys, welcome back to new series of JavaScript, where we‘ll be solving 30 days of JavaScript Questions from Leetcode.

Here is link of all the problems

In this series, we'll tackle each question one by one. I'll guide you by providing solutions and discussing the approach we should take to solve each problem, so let's dive in.

Prerequisite

For this challenge, you only need a basic understanding of JavaScript, nothing more!

Question

In this challenge, we need to write a “ createHelloWorld “ function that always returns the string “ Hello World “.

Approach

To solve this problem, we will utilize a function and a string.

Solution

To solve this problem LeetCode provide basic snippet, which is as below

/**
 * @return {Function}
 */
var createHelloWorld = function() {
    return function(...args) {

    }
};

To solve this, we'll use the return keyword along with the "Hello World" string. The final code snippet will look like this.

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

That’s it, it was this simple

Since this is our first problem, it was quite easy. As we move forward, the complexity of the problems will increase.

Conclusion

I hope you find this article helpful and that it adds some value to your coding career.

Be sure to check out my other articles to gain more knowledge.

In you have any suggestions, ideas or doubts please reach out to me on my social handles.

Untill next time, Have a nice coding! 🤙 🤘

1
Subscribe to my newsletter

Read articles from Vasant Mestry directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vasant Mestry
Vasant Mestry