10 Days of Javascript HackerRank

10 Days of JavaScript by HackerRank

 

 

1.

 



    function readLine() {
        return inputString[currentLine++];
    }

    /**
    *   A line of code that prints "Hello, World!" on a new line is provided in the editor.
    *   Write a second line of code that prints the contents of 'parameterVariable' on a new line.
    *
    *   Parameter:
    *   parameterVariable - A string of text.
    **/
    function greeting(parameterVariable) {
        // This line prints 'Hello, World!' to the console:
        console.log('Hello, World!');

   
   
    console.log(parameterVariable);

        // Write a line of code that prints parameterVariable to stdout using console.log:
       
    }


 

 

 

 2.


    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.
        console.log(firstInteger + Number(secondInteger));

       
        // Write code that uses console.log to print the sum of 'firstDecimal' and 'secondDecimal' (converted to a Number            type) on a new line.

        console.log(firstDecimal + Number(secondDecimal));
   
       
       
        // 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.
       
        console.log(firstString + secondString);
    }


 

 

 

3.

 

  • Objective

    In this challenge, we practice looping over the characters of string. Check out the attached tutorial for more details.

    Task

    1. First, print each vowel in
    on a new line. The English vowels are a, e, i, o, and u, and each vowel must be printed in the same order as it appeared in
  • .
  • Second, print each consonant (i.e., non-vowel) in
  • on a new line in the same order as it appeared in
    1. .

    Function Description

    Complete the vowelsAndConsonants function in the editor below.

    vowelsAndConsonants has the following parameters:

    • string s: the string to process

    Prints

    • Print each vowel of
    • in order on a new line, then print each consonant in order on a new line. Return nothing.

    Input Format

    There is one line of input with the string

    .

    Output Format

    First, print each vowel in

    on a new line (in the same order as they appeared in ). Second, print each consonant (i.e., non-vowel) in on a new line (in the same order as they appeared in

    ).

    Sample Input 0

    javascriptloops
    

    Sample Output 0

    a
    a
    i
    o
    o
    j
    v
    s
    c
    r
    p
    t
    l
    p
    s
    

    Explanation 0

    Observe the following:

    • Each letter is printed on a new line.
    • Then the vowels are printed in the same order as they appeared in
  • .
  • Then the consonants are printed in the same order as they appeared in  s
  • .

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Post a Comment (0)
Previous Post Next Post