JavaScript Mock Interview | Online Interview | Questions and Answers

Поділитися
Вставка
  • Опубліковано 27 вер 2024
  • Online Front End Phone Interview recorded live with questions on JavaScript , Algorithms and Problem Solving with suggestions. interview practice. Practice javaScript
    #Mock #JavaScript #Interview
    If you like to be mock interviewed, email me at
    * techlover2000@gmail.com
    *My Udemy Courses
    www.udemy.com/...
    www.udemy.com/...
    Follow me for technology updates
    * / techsith
    * / techsith
    * / techsith1
    * / 13677140
    * / patelhemil
    Help me translate this video.
    * www.youtube.co...
    Note: use translate.goog... to translate this video to your language. Let me know once you do that so i can give you credit. Thank you in advance.

КОМЕНТАРІ • 65

  • @vikrantgupta7896
    @vikrantgupta7896 3 роки тому +1

    2 yr exp solved all of them within 5mins, no google

  • @sundargp9463
    @sundargp9463 5 років тому +3

    My answer for the first question
    const addMemberAge = ({ age, kids = [] }) =>
    [age]
    .concat(...kids.map(addMemberAge))
    .reduce((accumulator, currentValue) => accumulator + currentValue);

    • @Techsithtube
      @Techsithtube  5 років тому +1

      Sundar, I like how creative you are . short and sweet solution .

    • @sundargp9463
      @sundargp9463 5 років тому

      thank you @techsith

    • @michaelrooze278
      @michaelrooze278 3 роки тому +1

      @@sundargp9463 Nice solution....I dont think you need the spread operator on kids since you gave it the default value of an empty array.

    • @michaelrooze278
      @michaelrooze278 3 роки тому

      Im trying to understand why this does not work when you change the nested "kids" to something else

  • @sandeepreddy1866
    @sandeepreddy1866 5 років тому +1

    Good questions. Thank you for uploading.

  • @maheshsingh6787
    @maheshsingh6787 5 років тому +6

    No offense to the interviewee, but I really wouldn't really start an answer to TechSith's questions with "it's a very simple question" :)
    Anyways, a potential recursive answer to the first question: (should be able to handle ages as keys or within nested arrays, objects etc )
    function getSum(obj, sum = 0) {
    if(Array.isArray(obj)) {
    for(let ele of obj) {
    sum = getSum(ele, sum)
    }
    } else if(typeof obj === 'object') {
    for(let key in obj) {
    if(typeof obj[key] !== 'object') {
    if(key === 'age') {
    sum = sum + obj[key]
    }
    } else {
    sum = getSum(obj[key], sum)
    }
    }
    }
    return sum
    }

  • @srinumajji501
    @srinumajji501 5 років тому +1

    Thanks for the video

  • @nanasarathi
    @nanasarathi 5 років тому +1

    Awesome as usual...

  • @Chessmasteroo
    @Chessmasteroo 4 роки тому +6

    The first problem can be solved with one line. Easy
    JSON.stringify(profile).match(/\d+/gi).reduce((a, c) => {return a + parseInt(c)}, 0)

  • @vikasraju2380
    @vikasraju2380 5 років тому +2

    function totalAge({age,kids=[]}){
    return kids.reduce((sum,kid)=> sum + totalAge(kid),age )
    }
    console.log(totalAge(profile));
    //Use reduce

    • @Techsithtube
      @Techsithtube  5 років тому +2

      Vikas, this is simple and clean . bravo.

    • @vikasraju2380
      @vikasraju2380 5 років тому

      @@Techsithtube Thank You Sir

  • @ozzyfromspace
    @ozzyfromspace 2 роки тому +1

    A "neater" recursive solution to question 1:
    function addKidAge(kids) {
    let kidTotalAge = 0;
    for(const kid of kids) {
    kidTotalAge += kid.age;
    if(kid?.kids?.length > 0) {
    kidTotalAge += addKidAge(kid.kids);
    }
    }
    return kidTotalAge;
    }
    To run it, just do addKidAge([profile])
    Notice that the profile object is inside an array :)

  • @ickimadrasi8965
    @ickimadrasi8965 5 років тому +1

    Can you recommend a good GIT and GIThub course

  • @vadivelraja2344
    @vadivelraja2344 5 років тому

    Hi, I have asked to write code for write in ballots using JavaScript in my interview

  • @assamaafzal3516
    @assamaafzal3516 4 роки тому

    last problem solution :
    const generateRandomNumber = (max, min = 1) => {
    return Math.floor(Math.random() * (max - min) + min);
    };
    const generateProblems = (max, n) => {
    for (let i = 0; i < n; i++) {
    const firstRandomNumber = generateRandomNumber(max);
    console.log(
    `${firstRandomNumber} + ${generateRandomNumber(
    max - firstRandomNumber
    )} = `
    );
    }
    };

  • @hari9321
    @hari9321 5 років тому +2

    Can you make a video on career path in IT field...
    Thankyou for all your react and javascript videos ,
    with best and simple way of explaining things.

    • @Techsithtube
      @Techsithtube  5 років тому

      hkv , Are you trying to follow a specific path in IT field?

  • @MohdAfeef
    @MohdAfeef 5 років тому +1

    hi techsit interviewer asked prime no program n no asked me optmize for loop for n=3000 for(i=0;i

    • @aravindanil930
      @aravindanil930 5 років тому

      If you are finding whether 3000 is prime number, I think you have to compute only factors up to sqrt(3000) to check this. If I am getting the question wrong, please feel free to correct me

  • @bawaparampreet24
    @bawaparampreet24 4 роки тому

    function sum(root) {
    return root.age + (root.kids || []).reduce((s, k) => s + sum(k), 0);
    }

  • @ChaoticBlackout
    @ChaoticBlackout 3 роки тому

    This SHOULD be a bulletproof solution to the first problem! Accounts for when some ages don't exist
    const addAllAges = (profile) => {
    if (!Object.keys(profile).length) return 0;
    let totalAge = profile.age || 0;
    for (let kid of profile.kids) {
    if (kid.age === undefined) continue;
    if (kid.kids !== undefined) {
    totalAge += addAllAges(kid);
    } else {
    totalAge += kid.age;
    }
    }
    return totalAge;
    }

  • @orz5516
    @orz5516 5 років тому

    my simple solution for the second problem. can i use a function that accepts 2 arguments?
    function game(num, num2){
    for(var i =0; i

    • @Techsithtube
      @Techsithtube  5 років тому

      Thanks for sharing your solution . Thanks

  • @MohdAfeef
    @MohdAfeef 5 років тому

    asked me api has currency , value store value ony db by api request should not repeat for currency he told me solution 1/1 , 2/2 diagonal matrix solution for this problem

  • @MohdAfeef
    @MohdAfeef 5 років тому

    what is is viewencapsulation

    • @Techsithtube
      @Techsithtube  5 років тому +1

      where you able to pass the interview?

    • @MohdAfeef
      @MohdAfeef 5 років тому

      @@Techsithtube yup, thanks techsit most of question belongs to your videos ,i clear basic

    • @MohdAfeef
      @MohdAfeef 5 років тому

      @@Techsithtube I do front end and back end coding, please make Angular 8 Interview Question
      Thank you

  • @Script_Sage
    @Script_Sage 5 років тому

    Sir, please use a good mic, your sound creates echo effects soo much.

    • @Techsithtube
      @Techsithtube  5 років тому

      Satyam, this was recorded as a meeting which is very difficult to handle audio wise as the network issue and the audio equipment of the other party. Thanks for pointing it out.

  • @Thankful_n_Grateful
    @Thankful_n_Grateful 5 років тому +1

    I'm just starting out in coding with Javascript...
    But regardless of coding language being used, I think it might be more efficient to write stubs & pseudo code first, explaining what your doing and why verbally as you stub it out...
    Once psuedo code makes sense, then write corresponding code for each stub...
    If one just jumps in and starts coding, even if one gets it correct first time, there's very lil interaction with interviewer....
    Just a thought...
    I've always been of mindset that if one cannot explain it, then they don't really understand it...
    Plus during an interview psuedo coding & stubbing it as you explain gives interviewer an idea of your thought process and opportunity to explain as you're writing pseudo code why ( your rationale ) for implementing something a particular way...
    I'm not a professional programmer. I'm working on becoming one...
    Thanks for sharing video

    • @Techsithtube
      @Techsithtube  5 років тому

      I think that is the right way to approach . Think , plan, discuss and code. good luck!

  • @satish8299
    @satish8299 5 років тому +3

    This Indian guy was baad, does he work for a University ?

  • @patrickren7395
    @patrickren7395 5 років тому +1

    The first problem is just flat a tree. Using recursion is the first thing that pops into my head. However you can run away from the problem by using JSON.stringify, then all there left to do is analyse the json string, kind of like cheating

    • @Techsithtube
      @Techsithtube  5 років тому

      Patrick, I think that is a valid answer. :)

    • @michaelrooze278
      @michaelrooze278 3 роки тому

      can you post your solution please?

  • @ManojSingh-of5ep
    @ManojSingh-of5ep 4 роки тому

    my answer for 2nd problem:
    function que(){
    let first = Math.floor(Math.random() * Math.floor(10));
    let sec = Math.floor(Math.random() * Math.floor(10-first));
    console.log(`${first}+${sec}`);
    }
    for(let i=0;i

  • @mayow6767
    @mayow6767 5 років тому +1

    Can you direct me to video tutorial you're explaining these concepts deeply ? Thank you

    • @Techsithtube
      @Techsithtube  5 років тому +3

      Abhirahamn, these are basic javaScript and problem solving questions , I have some playlist to learn JavaScript . feel free to check it out. here is the link ua-cam.com/play/PL7pEw9n3GkoVYU-ZKBrDnxIiiUn0YP-uO.html

  • @maelstrom57
    @maelstrom57 3 роки тому +1

    It only took me 367 tries but I finally solved the first problem. (Feel free to suggest improvements.)
    function addUpAges(profile) {
    let total = 0;
    function addUp(profile) {
    total += profile.age || 0;
    if (!profile.kids)
    return;
    return profile.kids.forEach(addUp);
    }
    addUp(profile);
    return total;
    }

  • @mdshoaibAlamgcetts
    @mdshoaibAlamgcetts 5 років тому

    Hi sir , an interviewer asked me to find largest number can be form by concatinating the numbers . Eg
    Let arr =[ 90,95,9]; so after concat largest number would be like "99590"
    .
    Could you please suggest me solve this in easiest way .

    • @Techsithtube
      @Techsithtube  5 років тому +1

      here is the best solution www.geeksforgeeks.org/arrange-given-numbers-form-biggest-number-set-2/

    • @tausifkovadiya1810
      @tausifkovadiya1810 2 роки тому

      const findLargest = arr.sort((a, b) => ('" + b + a) - ("" + a + b)).join("");
      concatinating string with 2 numbers and sort by descending, later join all numbers of arr.

  • @vinayakshahdeo7578
    @vinayakshahdeo7578 5 років тому +3

    Hello sir I am a new coder in Javascript my level is beginner can I get a mock interview as I want to move to Javascript frameworks.

  • @pppluronwrj
    @pppluronwrj 5 років тому +4

    too slow

  • @GodsDevil5thF
    @GodsDevil5thF 5 років тому +1

    I think he is over complicating the problems. In a interview you wanna start with the simplest solution and then work up from it.
    My solutions :
    problem 1:
    const ageTotal =
    profile.age +
    profile.kids[0].age +
    profile.kids[0].kids[0].age +
    profile.kids[0].kids[1].age;
    console.log(ageTotal);
    Problem 2:
    function simpleMathProblem() {
    let number1 = Math.floor(Math.random() * 10);
    let number2 = Math.floor(Math.random() * 10);
    if (number1 + number2

    • @Techsithtube
      @Techsithtube  5 років тому

      That is exactly right, you want to show your interviewer that you can think in steps. first simple solution and then expand on it.

  • @ansreenath
    @ansreenath 5 років тому

    Hi Techsith, It would be great if you can please show us how to read an email in outlook using Microsoft Graph API. Thanks in advance.

    • @Techsithtube
      @Techsithtube  5 років тому

      Thanks for sharing, I will add to the list of video that i need to create.

  • @ansreenath
    @ansreenath 5 років тому

    Hi Techsith, Thank you for Javscript and NodeJS videos. It would be great if you can please make a video on 'How to Monitor Log files Monitoring log files using some metrics exporter + Prometheus + Grafana'? Thanks a lot.