-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday1.js
More file actions
31 lines (29 loc) · 1.36 KB
/
Copy pathday1.js
File metadata and controls
31 lines (29 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function main() {
var i = 4
var d = 4.0
var s = "HackerRank "
// Declare second integer, double, and String variables.
var ii,dd,ss;
// Read and save an integer, double, and String to your variables.
ii=parseInt(readLine());
//function parseInt(s: string, radix?: number): number
//Converts a string to an integer.
//@param - s A string to convert into a number.
//@param radix A value between 2 and 36 that specifies the base of the number in numString. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal.
dd=parseFloat(readLine());
//function parseFloat(string: string): number
//Converts a string to a floating-point number.
//@param - string A string that contains a floating-point number.
ss=readLine();
//function readLine(): string
// Print the sum of both integer variables on a new line.
console.log(i+ii);
// Print the sum of the double variables on a new line.
console.log((d+dd).toFixed(1));
//(method) Number.toFixed(fractionDigits?: number): string
// Returns a string representing a number in fixed-point notation.
// @param - fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.
// Concatenate and print the String variables on a new line
// The 's' variable above should be printed first.
console.log(s+ss);
}