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.
2 yr exp solved all of them within 5mins, no google
Vikrant. that is great.
My answer for the first question
const addMemberAge = ({ age, kids = [] }) =>
[age]
.concat(...kids.map(addMemberAge))
.reduce((accumulator, currentValue) => accumulator + currentValue);
Sundar, I like how creative you are . short and sweet solution .
thank you @techsith
@@sundargp9463 Nice solution....I dont think you need the spread operator on kids since you gave it the default value of an empty array.
Im trying to understand why this does not work when you change the nested "kids" to something else
Good questions. Thank you for uploading.
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
}
Thanks for the video
Awesome as usual...
The first problem can be solved with one line. Easy
JSON.stringify(profile).match(/\d+/gi).reduce((a, c) => {return a + parseInt(c)}, 0)
json stringify is so slow, i dont think this is a good solution
This is really brittle. Dont use this.
function totalAge({age,kids=[]}){
return kids.reduce((sum,kid)=> sum + totalAge(kid),age )
}
console.log(totalAge(profile));
//Use reduce
Vikas, this is simple and clean . bravo.
@@Techsithtube Thank You Sir
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 :)
Thanks for sharing!
Can you recommend a good GIT and GIThub course
Hi, I have asked to write code for write in ballots using JavaScript in my interview
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
)} = `
);
}
};
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.
hkv , Are you trying to follow a specific path in IT field?
hi techsit interviewer asked prime no program n no asked me optmize for loop for n=3000 for(i=0;i
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
function sum(root) {
return root.age + (root.kids || []).reduce((s, k) => s + sum(k), 0);
}
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;
}
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
Thanks for sharing your solution . Thanks
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
what is is viewencapsulation
where you able to pass the interview?
@@Techsithtube yup, thanks techsit most of question belongs to your videos ,i clear basic
@@Techsithtube I do front end and back end coding, please make Angular 8 Interview Question
Thank you
Sir, please use a good mic, your sound creates echo effects soo much.
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.
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
I think that is the right way to approach . Think , plan, discuss and code. good luck!
This Indian guy was baad, does he work for a University ?
10/10
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
Patrick, I think that is a valid answer. :)
can you post your solution please?
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
Can you direct me to video tutorial you're explaining these concepts deeply ? Thank you
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
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;
}
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 .
here is the best solution www.geeksforgeeks.org/arrange-given-numbers-form-biggest-number-set-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.
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.
email him at techlover2000@gmail.com
@@Geomaverick124 thanks
too slow
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
That is exactly right, you want to show your interviewer that you can think in steps. first simple solution and then expand on it.
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.
Thanks for sharing, I will add to the list of video that i need to create.
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.