10 Days Of JavaScript

Day 0: Hello World! Solution

Hello Friends in this article i am gone to share Hackerrank 10 days of javascript solutions with you. | Day 0: Hello World! Solution


Also visit this link:ย  Day 9: Binary Calculator Solution


 

Day 0: Hello World! Solution

Objective

In this challenge, we review some basic concepts that will get you started with this series. Check out the tutorial to learn more about JavaScriptโ€™s lexical structure.

Task

Aย greetingย function is provided for you in the editor below. It has one parameter,ย parameterVariable. Perform the following tasks to complete this challenge:

  1. Useย console.log()ย to printย Hello, World!ย on a new line in the console, which is also known asย stdoutย orย standard output. The code for this portion of the task is already provided in the editor.
  2. Useย console.log()ย to print the contents ofย parameterVariableย (i.e., the argument passed toย main).

Youโ€™ve got this!ย 

Input Format

Data Type Parameter Description
string parameterVariable A single line of text containing one or more space-separated words.

Output Format

Print the following two lines of output:

  1. On the first line, printย Hello, World!ย (this is provided for you in the editor).
  2. On the second line, print the contents ofย parameterVariable.

Sample Inputย 0

Welcome to 10 Days of JavaScript!

Sample Output 0

Hello, World!
Welcome to 10 Days of JavaScript!

Explanation 0

We printed two lines of output:

  1. We printed the literal stringย Hello, World!ย using the code provided in the editor.
  2. The value ofย parameterVariableย passed to ourย mainย function in thisย Sample Caseย wasย Welcome to 10 Days of JavaScript!. We then passed our variable toย console.log, which printed the contents ofย parameterVariable.

 

Solution โ€“ Day 0: Hello, World!


/**
*   A line of code that prints "Hello, World!" on a new line is provided in the editor. 
*   Write a second line of code that prints the contents of 'parameterVariable' on a new line.
*
*   Parameter:
*   parameterVariable - A string of text.
**/
function greeting(parameterVariable) {
    // This line prints 'Hello, World!' to the console:
    console.log('Hello, World!');
    console.log(parameterVariable);

    // Write a line of code that prints parameterVariable to stdout using console.log:
    
}