JavaScript Interview Questions- Machine Coding - Most Asked Question

Поделиться
HTML-код
  • Опубликовано: 24 авг 2024
  • Javascript Interview Question on objects and Array will be discussed in this video .
    Watch the complete video till the end to understand it completely
    Checkout my Instagram account to find the latest notes on React, Angular and Javascript.
    Instagram handler Name: @nishasingla05
    Watch complete video to understand in depth.
    Support my channel by liking and sharing my videos so that I can reach to wider audience. Please share it in your network 🙏
    ►Checkout JavaScript Interview Playlist
    • Frontend Interview Que...
    ►Checkout ES6 Playlist
    / playlistlist=plc8okhrv...
    ►Click here to Subscribe the channel:
    studio.youtube....
    ►Angular Complete Course:
    ruclips.net/user/pl....
    ►All important shorts videos:
    ruclips.net/user/pl....
    Connect with Me On Social Media
    Facebook: / angularjs4be. .
    LinkedIn: / nisha-sin. .
    Instagram : / nishasingla05
    Twitter: / nishasingla05
    #nishasingla #javascript #interview

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

  • @PriyaHm-o4j
    @PriyaHm-o4j 4 дня назад

    Nice explanation. Thank you ❤

  • @VinitNeogi
    @VinitNeogi Год назад +3

    Should we use data.forEach instead of data.map as we are not concerned with return value of map function?

  • @pranavpawar7792
    @pranavpawar7792 Год назад

    Wow such a nice explanation... I really liked your approach and logic... Thanks Nisha

  • @websilt
    @websilt Год назад +5

    Another way to do this:
    const items = ["a", "b", "c", "a", "b", "b", "c", "d"];
    const count = {};
    for (const item of items) {
    if (count[item]) {
    count[item] += 1;
    } else {
    count[item] = 1;
    }
    }
    console.log(count);

  • @sivatirumani531
    @sivatirumani531 Год назад

    Nice Explanation

  • @Aravind-mh5wh
    @Aravind-mh5wh 2 месяца назад

    we can write using ternary operator like below
    let ar = ['a','s','s','b','c','a','c','d','a','s'];
    function arrOccurances(items){
    let output = {};
    items.forEach(item=>{
    output[item] = output[item] ? output[item]+1 : 1
    })
    return output;
    }
    console.log(arrOccurances(ar));
    (OR)
    let ar = ['a','s','s','b','c','a','c','d','a','s'];
    let output = {};
    for(let item of ar){
    output[item] = output[item] ? output[item]+1 : 1
    }
    console.log(output) ;
    not only these ways, as Nisha said we have many ways to do it.
    Thanks Nisha :-)

  • @amitbm3608
    @amitbm3608 Год назад

    Thank u for the awesome video. Please continue react tutorial and complete the series.

  • @DanielSparza
    @DanielSparza Год назад

    Thanks for do this kind of videos

  • @akiratoriyama1320
    @akiratoriyama1320 Год назад

    Thank you!!

  • @kavinkumar
    @kavinkumar 6 месяцев назад

    well if you cant use map ,
    let arr=['a','b','z','a','b','a','c']
    let obj={};
    for (let key in arr) {
    console.log(obj[arr[key]],arr[key]); //undefined , a initially
    obj[arr[key]]?obj[arr[key]]=obj[arr[key]]+1:obj[arr[key]]=1;
    }

    console.log(obj)
    {
    a: 3,
    b: 2,
    c: 1,
    z: 1
    }

    • @Aravind-mh5wh
      @Aravind-mh5wh 2 месяца назад

      last line of code is repeated , so simply we can write like below
      obj[arr[key]] = obj[arr[key]] ? obj[arr[key]]+1 : 1;