This is a practice challenge to show you how things are set up and how to test, etc.
Write a function called helloWorld
that returns a string of 'Hello World!'.
/**
* Returns a string containing 'Hello World!'.
* @returns {string} - The string 'Hello World!'.
*/
function helloWorld(): string;
helloWorld() // 'Hello World!'
I will put any constraints here. They will vary depending on the challenge.
- The function must return a string
- I will put a couple hints here. You can choose to use them or not.
Click For Solution
function printHelloWorld() {
return 'Hello World!';
}
I will put the explanation to the solution here. The length and depth of the explanation will vary depending on the challenge.
The Jest tests will go here. They are already included in the course files. You just need to run npm test
. Sometimes I will also put manual tests here.
test("Returning 'Hello, World!' as a string", () => {
const result = helloWorld();
expect(result).toBe('Hello World!');
});