InternDoor

Rubrik interview prep

4 practice questions on the topics candidates reported from Rubrik interviews, with answers. The questions are ours; each one links to the interview report that names its topic.

Practise them as a timed round4 roles open at Rubrik

Web development 4

  1. Web developmentEasy

    What does this print?

    const row = [1, "two", true, null, undefined];
    console.log(JSON.stringify(row));
    1. [1,"two",true,null,undefined]
    2. [1,"two",true,null]
    3. [1,two,true,null]
    4. [1,"two",true,null,null]
    Show the answer

    D. [1,"two",true,null,null]

    JSON has no undefined, so inside an array JSON.stringify writes it as null to keep the positions. Strings are quoted, numbers, booleans and null are written as they are. In an object, a property holding undefined is left out instead.

    This topic is named in a candidate’s interview report: Frontend engineer interview, 2022, on Code360.

  2. Web developmentHard

    What does this print?

    const curry = (fn) => function c(...args) {
      return args.length >= fn.length ? fn(...args) : (...more) => c(...args, ...more);
    };
    
    const add3 = curry((a, b, c) => a + b + c);
    console.log(add3(1)(2)(3), add3(1, 2)(3), add3(1)(2, 3));
    1. 6 6 6
    2. 6 3 3
    3. NaN NaN NaN
    4. It throws a TypeError
    Show the answer

    A. 6 6 6

    fn.length is 3, the number of declared parameters. Until three arguments have been collected, c returns a function that remembers the ones so far; any grouping of the three arguments ends in the same call fn(1, 2, 3).

    This topic is named in a candidate’s interview report: Frontend engineer interview, 2022, on Code360.

  3. Web developmentMedium

    What does this print?

    let calls = 0;
    const memoize = (fn) => {
      const cache = new Map();
      return (x) => {
        if (!cache.has(x)) cache.set(x, fn(x));
        return cache.get(x);
      };
    };
    
    const square = memoize((x) => { calls++; return x * x; });
    square(4); square(4); square(5);
    console.log(calls);
    1. 3
    2. 2
    3. 1
    4. 0
    Show the answer

    B. 2

    The second square(4) is served from the cache, so the wrapped function runs for 4 and 5 only. Memoizing is safe only for pure functions; a Map keeps 4 and "4" apart, which a plain object would not.

    This topic is named in a candidate’s interview report: Frontend engineer interview, 2022, on Code360.

  4. Web developmentHard

    What does this print?

    console.log(JSON.stringify({
      a: undefined,
      b: 1,
      c: () => 2,
      d: [undefined, 3],
      e: NaN,
    }));
    1. {"a":null,"b":1,"c":null,"d":[null,3],"e":null}
    2. {"b":1,"d":[null,3],"e":null}
    3. {"b":1,"d":[3],"e":"NaN"}
    4. {"b":1,"d":[undefined,3],"e":NaN}
    Show the answer

    B. {"b":1,"d":[null,3],"e":null}

    JSON has no undefined or functions, so object properties holding them are left out. In an array a slot cannot be left out without moving the rest, so it becomes null. NaN and Infinity are not valid JSON numbers and also become null.

    This topic is named in a candidate’s interview report: Frontend engineer interview, 2022, on Code360.

Prep for other employers

All employers
See who is hiring after Rubrik

Engineering internships and entry-level jobs in India, newest first.