Solving LinkedIn Frontend Interview Question | Tuple | Arrays of Array | JavaScript

Поделиться
HTML-код
  • Опубликовано: 21 сен 2024
  • НаукаНаука

Комментарии • 15

  • @DhruvDhar-r3l
    @DhruvDhar-r3l Месяц назад

    i was under the impression that `multiply()` had to be added on the prototype of `tuple()`'s result only.....
    function multiply(position) {
    let res = this[0][position-1]
    for(let i=1; i

  • @JigyasaUpadhyay-l9s
    @JigyasaUpadhyay-l9s 4 месяца назад

    great explanation, keep up the consistency !

  • @sourabhrajwade1061
    @sourabhrajwade1061 3 месяца назад

    Nice explanation. I did it by using transversing the tuple array. I have one question though. Why you added multiple in Array prototype ? Shouldn't it be tuple's property?

    • @DevtoolsTech
      @DevtoolsTech  3 месяца назад

      Depends upon the interviewer what they want to test. Both works. I added on tuple because of convenience as we dont need to take care of a lot of edge cases in thatcase.

  • @sujalgupta6100
    @sujalgupta6100 4 месяца назад +1

    Hi Yomesh,
    is there any video of yours for guiding for prep for interview like from JS Topics to cover + What concepts/kind of questions one must prepare as there are so many of them.
    Some folks keep posting huge list of JS concepts + Output based questions + Polyfill based questions + Any component implementation like Chip or OTP form etc.
    What to prepare form all of them ? Or maybe how much, it feels way too much.

    • @DevtoolsTech
      @DevtoolsTech  4 месяца назад

      Hey, I don't have curated list. This is too big so any list will become big eventually. I will try to create something already it ajd share soon!

  • @AnkitGupta-lr1qq
    @AnkitGupta-lr1qq 4 месяца назад

    Great explanation.
    Wondering if it'd be better to throw OR return something like NaN instead of 0 inside the multiple method when the array length is 0.
    0 might be a valid return value as well and doesn't distinguish enough from an edge case (like the empty array)

    • @DevtoolsTech
      @DevtoolsTech  4 месяца назад

      Valid point. This is also a discussion point with interview about what is the expected behaviour. I agree that 0 is a valid output. However, we need to make a decision that should we break the application by throwing an error or return 0 that shows like a default output as for user if the application breaks then that is a really bad experience.

  • @virendrapratap2417
    @virendrapratap2417 2 месяца назад

    Correct me if i am wrong.
    line no 22:
    can be replaced with current.hasOwnProperty(position) instead of borrowing has own property using call?

    • @DevtoolsTech
      @DevtoolsTech  2 месяца назад

      Yes, it can be used. However, it id advised not to. Check the following please
      eslint.org/docs/latest/rules/no-prototype-builtins

  • @DhruvDhar-r3l
    @DhruvDhar-r3l Месяц назад

    i was under the impression that multiply had to be added to the prototype of the returned array only and not on the entire Array.prototype
    function tuple(input) {
    const outputArr = []
    let stack = []
    for(const ch of input) {
    if(ch === '(' || ch === ',' || ch === ' ') continue
    else if(ch === ')') {
    outputArr.push(stack)
    stack = []
    } else {
    stack.push(+ch)
    }
    }
    //ADD multiply to the prototype of the returned array
    outputArr.multiply = multiply
    return outputArr
    }

    • @DevtoolsTech
      @DevtoolsTech  Месяц назад

      It works both ways. You can add it to tuple too. There are edge cases that you need to take if you add it to tuple.

  • @jithendra16
    @jithendra16 4 месяца назад

    Can you please make a video on how to write regex expressions
    Also any explanation on why did you use prototype to find whether that index is present?
    It will be helpful

    • @DevtoolsTech
      @DevtoolsTech  4 месяца назад

      Thanks for the suggestions! I will include it in future videos!