Skip to content

Instantly share code, notes, and snippets.

@saloni-jain484
Created May 14, 2020 10:20
Show Gist options
  • Save saloni-jain484/1f68443007101b3a74c71c31534d4d8b to your computer and use it in GitHub Desktop.
Save saloni-jain484/1f68443007101b3a74c71c31534d4d8b to your computer and use it in GitHub Desktop.
Hacker Rank - 10 Days of Javascript
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, . Perform the following tasks to complete this challenge:
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.
Use console.log() to print the contents of (i.e., the argument passed to main).
You've got this!
Input Format
Data Type Parameter Description
string A single line of text containing one or more space-separated words.
Output Format
Print the following two lines of output:
On the first line, print Hello, World! (this is provided for you in the editor).
On the second line, print the contents of .
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:
We printed the literal string Hello, World! using the code provided in the editor.
The value of 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 parameter variable .
Solution
function greeting(parameterVariable) {
console.log('Hello, World!');
console.log(parameterVariable);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment