Sunday, June 13, 2021

Hackerrank Day 1: Data Types

process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
process.stdin.on('end', function () {
input_stdin_array = input_stdin.split("\n");
main();
});
// Reads complete line from STDIN
function readLine() {
return input_stdin_array[input_currentline++];
}
function main() {
var i = 4
var d = 4.0
var s = "HackerRank "
// Declare second integer, double, and String variables.
var i2 = +(readLine());
// Read and save an integer, double, and String to your variables.
var d2 = +(readLine());
// Print the sum of both integer variables on a new line.
console.log(i + i2)
// Print the sum of the double variables on a new line.
console.log((d + d2).toFixed(1));
// Concatenate and print the String variables on a new line
// The 's' variable above should be printed first.
var s2 = readLine();
console.log(s + s2);
}

No comments:

How to build an Express and Node.js app with Typescript

  In this tutorial, you will learn how to set up a Node.js and Express project with Typescript and live auto-reloading. Note that this metho...