Header Ad

HackeRank Day 0: Hello, World! 10 days of javascript solution

In this HackerRank Day 0: Hello, World! 10 days of javascript A greeting function is provided for you in the editor below. It has one parameter, parameterVariable. you need to use console.log() to print Hello, World! on a new line in the console, which is also known as stdout or standard output. second Use console.log() to print the contents of parameterVariable.

HackeRank Day 0: Hello, World! 10 days of javascript


Day 0: Hello, World! problem solution in JavaScript programming.

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    
    main();    
});

function readLine() {
    return inputString[currentLine++];
}

/**
*   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:
    
}


function main() {
    const parameterVariable = readLine();
    
    greeting(parameterVariable);
}


Post a Comment

1 Comments

  1. After printing it on the console, when I submit, it record failed to another question I don't see. Why's that?

    ReplyDelete