JavaScript Hello World - First Exercise

Why is this incorrect for the first exercise?

function helloWorld() {
return “Hello, World!”;
}
helloWorld();

Did you forget the export part?
Also the function expected from test is named “hello”

import { hello } from './hello-world';

Exercism uses unit tests to check if your solution is correct.
These tests call your function and compare the actual with the expected result.
Therefore you cannot rename the function (from hello to helloWorld) and you cannot remove the keyword export, otherwise the tests will not be able to call your function.

This first practice exercise is mostly for onboarding, so you can get familiar with how Exercism works, how to use the online editor (or the CLI if you choose that), how to run the tests, how to submit a correct solution.

This is the initial file:

//
// This is only a SKELETON file for the 'Hello World' exercise. It's been provided as a
// convenience to get you started writing code faster.
//

export function hello() {
  return 'Goodbye, Mars!';
}

In this first exercise almost the entire solution is already given, you just have to return the correct string, the traditional greeting in a new programming language here on our planet Earth.

2 Likes

Thanks for the detailed explanation