• + 0 comments

    Javascript solution for those whoo need help

    { // Predefined variables

    var i = 4;  // Integer
    var d = 4.0;  // Double
    var s = "HackerRank ";  // String
    
    // Read input values
    
    let num = parseInt(readLine());  // Read integer from input
    let myDouble = parseFloat(readLine());  // Read double from input
    let myString = readLine();  // Read string from input
    
    // Print the sum of both integer variables
    let sum = num + i;
    console.log(sum);
    
    // Print the sum of both double variables, rounded to 1 decimal place
    
    let sum1 = myDouble + d;
    console.log(sum1.toFixed(1));  // Print with one decimal place
    
    // Concatenate and print the String variables
    
    let newString = s + myString;
    console.log(newString);
    

    }