DEV Community

Lakshya Tyagi
Lakshya Tyagi

Posted on • Edited on

15 5

JavaScript Code Daily Challenge #1

About

This is a series of JavaScript Code Daily Challenge. Each day I show a few solutions written in JavaScript. The questions are from coding practice/contest sites such as HackerRank, LeetCode, Codeforces, Atcoder and etc.

Day 1: Hello, World
https://www.hackerrank.com/challenges/js10-hello-world/problem

'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++];
}
Enter fullscreen mode Exit fullscreen mode

Function need to be change

function greeting(parameterVariable) {
    console.log('Hello, World!');
    console.log(parameterVariable)
}
Enter fullscreen mode Exit fullscreen mode
function main() {
    const parameterVariable = readLine();

    greeting(parameterVariable);
}
Enter fullscreen mode Exit fullscreen mode

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (1)

Collapse
 
abhishekgowda28 profile image
Abhishek Gowda

How to run this and what is expected the output ?

I am running as node challenge-1.js, as I type in the stings don't see any output in the console expect for the text typed in.

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay