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.
Data Types - #2
https://www.hackerrank.com/challenges/js10-data-types/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++];
}
Complete the function in comment
function performOperation(secondInteger, secondDecimal, secondString) {
// Declare a variable named 'firstInteger' and initialize with integer value 4.
const firstInteger = 4;
// Declare a variable named 'firstDecimal' and initialize with floating-point value 4.0.
const firstDecimal = 4.0;
// Declare a variable named 'firstString' and initialize with the string "HackerRank".
const firstString = 'HackerRank ';
// Write code that uses console.log to print the sum of the 'firstInteger' and 'secondInteger' (converted to a Number type) on a new line.
// Write code that uses console.log to print the sum of 'firstDecimal' and 'secondDecimal' (converted to a Number type) on a new line.
// Write code that uses console.log to print the concatenation of 'firstString' and 'secondString' on a new line. The variable 'firstString' must be printed first.
}
function main() {
const secondInteger = readLine();
const secondDecimal = readLine();
const secondString = readLine();
performOperation(secondInteger, secondDecimal, secondString);
}
Top comments (3)
Nice read! If you want to improve the readability you can use
js
to the first 3 backticks to add syntax highlighting! It would look like this:Thanks Joachim Today i get to know something knew and it's really interesting