Тёмный

JavaScript Mock Interview | Online Interview Questions and Answers (Part 3) 

techsith
Подписаться 147 тыс.
Просмотров 26 тыс.
50% 1

Опубликовано:

 

26 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 178   
@JohnDoe-rj2kf
@JohnDoe-rj2kf 3 года назад
this should be like a tv series like episodes and seasons. So many emotions, struggle, real emotions, techsits patience. Amazing. I would watch it.
@Techsithtube
@Techsithtube 3 года назад
Interviews are full of emotions and anxiety. Thanks for watching!
@VinothKumar5403
@VinothKumar5403 6 лет назад
Thanks a lot sir.i have been selected an interview and got good offer with help of your videos.once again trillions of thanks techsith.
@Techsithtube
@Techsithtube 6 лет назад
Congratulations and good luck with your new job. Keep learning! :)
@2adelmani
@2adelmani 4 года назад
This a shot code helping to find out the length of digits without converting into String : const nbr = 3214; console.log('===> length of a number: ', Math.floor( Math.log10( nbr) ) + 1 );
@mkSkeptics
@mkSkeptics 5 лет назад
Amazing! this is how I would do. no need to search function count(N){ let count = 1; let result = N; let i = 10; while(result>10){ result = N/i; i = i*10; count++; } return count; } console.log(count(232));
@fadimoussa8382
@fadimoussa8382 4 года назад
The very first line of the function should be: if (number < 10) return 1; 😊
@sumitghewade2002
@sumitghewade2002 4 года назад
I did this and it works function lengthInteger(num){ let count = 0; while(num!==0){ let temp = parseInt(num/10); num = temp; count +=1; } return count }
@SanderBuruma
@SanderBuruma 6 лет назад
For the 2nd problem can't you just do this? function integerLength(nr){ return Math.floor(Math.log10(nr))+1 } For me this works for any integer between 1 and 9e15
@brewzonekeeone5724
@brewzonekeeone5724 6 лет назад
very cool - i knew there was a logarithmic way lol
@Techsithtube
@Techsithtube 6 лет назад
Wow. this didnt cross my mind. Good solution.
@iQwert789
@iQwert789 6 лет назад
Works except 0 :)
@SanderBuruma
@SanderBuruma 6 лет назад
yes, that's why I said numbers between 1 and 9e15
@iQwert789
@iQwert789 6 лет назад
Sorry, missed that because text was collapsed, very cool answer bro :)
@aezius2644
@aezius2644 5 лет назад
const x = [1, 2, 3, 4]; const biggest = x.reduce((a,b) => a + b) - Math.max(...x); const smallest = x.reduce((a, b) => a + b) - Math.min(...x);
@facundocorradini
@facundocorradini 6 лет назад
This series is awesome. Really, really useful.
@naveenreddydepa8324
@naveenreddydepa8324 6 лет назад
For Second problem this is my solution function getLength(x){ let num = x; let counter =0; while(num>0){ num = num/10; if(num >=1)counter++; else{counter++;return counter;} } }
@sunilKumar-uu2cx
@sunilKumar-uu2cx 5 лет назад
let num = 12345; let leng = Math.ceil(Math.log10(num + 1)); console.log(leng); result length is 5
@ankush3707
@ankush3707 3 года назад
Length of a number :- let num=1234; num=Math.abs(num); let count=0; let i=10 while(i
@ajitjadhav7540
@ajitjadhav7540 4 года назад
We could also use parseInt() to round the number, while(number !=0){ number = parseInt(number / 10) counter += 1 } return counter
@jiahaoyu855
@jiahaoyu855 6 лет назад
Hi @techsith, thanks for you videos, finally I got an offer!
@Techsithtube
@Techsithtube 6 лет назад
Congratulations Jiahao. Make sure you negotiate properly. and good luck with your new job. :)
@cugal1613
@cugal1613 Год назад
Hah thought an easier way for the number length problem. Times the number by 0.1 and floor it. If it’s not zero then repeat. Great vids keep up the good work!
@NikhilMahirrao
@NikhilMahirrao 5 лет назад
let someNum = 1234; console.log(Math.ceil(Math.log10(someNum + 1))); OR You can use while(Math.floor(num) > 0) by your approach
@aaronbrowne7862
@aaronbrowne7862 3 года назад
My solution to maximum number, inspired by a solution on a C++ forum: let x = 1234; function numDigits(num) { let digits = num === 0 ? 1 : Math.log10(Math.abs(num)) + 1 return Math.floor(digits); } console.log("Result=", numDigits(x) )
@anuranjansrivastav9864
@anuranjansrivastav9864 6 лет назад
First one to like before watching it -:)
@Techsithtube
@Techsithtube 6 лет назад
Thanks you Anurajan, for liking before watching :)
@shellykapoor7331
@shellykapoor7331 6 лет назад
Could you please explain me how to find length of number without using tostring method
@Kailu_YT
@Kailu_YT 4 года назад
@@shellykapoor7331 let a = 1237; console.log((a+"").length);
@EktaMishraekta
@EktaMishraekta 2 года назад
This is how i did the count number question without changing it to string function intLength(int){ let counter=0; while(int>=1){ int=parseInt(int/10); counter++; } return counter; } console.log(intLength(12347687658));
@SurajAgarwaladad
@SurajAgarwaladad 6 лет назад
Sir please make a full mock interview video which includes questions from HTML, CSS, Js, Angular for front end developer role.
@Techsithtube
@Techsithtube 6 лет назад
Yes i have intervied few people with css and angular. I will release it soon.
@n_fan329
@n_fan329 4 года назад
my approach for the first question : let tab = [1, 2, 3, 4] let result = [] tab.forEach(el => { result.push(tab.filter(val => val !== el).reduce((a, b) => a + b)) }) console.log(result.sort((a, b) => b - a)[0], result.sort((a, b) => b - a)[result.sort((a, b) => b - a).length - 1])
@Techsithtube
@Techsithtube 4 года назад
Awesome, thanks for sharing.
@n_fan329
@n_fan329 4 года назад
techsith how would u rate my solution boss ?
@ManOnHorizon
@ManOnHorizon 6 лет назад
You help me to dive into the working process. Thanks!
@abhilashpoojary3812
@abhilashpoojary3812 4 года назад
loved your work, really appriciated.
@Techsithtube
@Techsithtube 4 года назад
Thanks for watching!
@easy-stuffs
@easy-stuffs 5 лет назад
for length of the given Integer. i did something like this rather than using while loop and it works though! var tn=-1; function countInt(x){ tn++; return (parseInt(x)/10===0)?tn : countInt(parseInt(x)/10) } countInt(1234567);
@n_fan329
@n_fan329 4 года назад
first question : let tab = [1,2,3,4] let result= [] tab.forEach(val => { result.push(tab.filter(val2 => val2 !== val).reduce((a,b)=>a+b,0)) }) result.sort((a,b)=>a-b) console.log({ 'min':result[0], 'max': result.slice(-1)[0] }); //{ min: 6, max: 9 }
@25011990rockstar
@25011990rockstar 5 лет назад
function findNumDigits(x) { let ln = 0; while(x !== 0) { ln++; x = Math.floor(x/10); } return ln; } Isn't this simpler if we know that the number is an integer?
@deepakzaro
@deepakzaro 3 года назад
a=1233 i=0 while(a>0){ a = parseInt(a /10,10) i++ } console.log(i)
@ozzyfromspace
@ozzyfromspace 2 года назад
Around ~22 a quick 'binary-esque' implementation would be to use the Math.log() function to compute the power of a number, then round up to get a numerical expression for the number of digits in the number. If the test value is a perfect power of the base, just add one. Also, logs break for x
@ralexand56
@ralexand56 5 лет назад
Love this because it taught me I can do Math.max(...arr). Thanks again for your awesome channel!
@TechGeniusHub
@TechGeniusHub 4 года назад
But in terms of speed it slow
@meilyn22
@meilyn22 3 года назад
I would've done that too.
@vijayu707
@vijayu707 6 лет назад
Question #2 function findNumDigits(x) { if (x < 0) return 0; if (x < 10) return 1; return 1 + findNumDigits(x/10); } worked for me..Is there any corner cases which I missed?
@Techsithtube
@Techsithtube 6 лет назад
nice work . Thanks:)
@celidee
@celidee 6 лет назад
Can someone explain how this works please? I don't get it yet, the if statements are obvious the recursion not so much =(
@phow4rd
@phow4rd 6 лет назад
Here's a version that I find slightly easier to read (uses es6 'fat arrow' function syntax, though): // ------------------------------- const countDigitsRecursively = num => { if (num / 10 < 1) { return 1; } return countDigitsRecursively(num / 10) + 1; }; console.log(countDigitsRecursively(1234)); // ------------------------------- Basically it takes the input, divides it by 10, and if the result is less than 1, it immediately returns 1-easy peasy, right? OTOH, if the initial result is greater than 1, it takes the current value of the input, divides it by 10, and feeds THAT value back into the function, repeating the process until the result IS less than 1, at which point it hits that initial `return` statement (called the "base case" in recursion-talk) and then (and this is the tricky part) it takes that return value of 1, and "backs out", adding 1 to the return result each time. In the example above, that looks like this: call #1: 1234 / 10 = 123.4 // result not < 1; divide by 10 and keep trying call #2: 123.4 / 10 = 12.34 // still not there... call #3: 12.34 / 10 = 1.234 // getting close... call #4: 1.234 / 10 = .1234 // base case reached! return 1 to the previous function call #3: // received return value of 1; return 1 + 1 to previous function call #2: // received return value of 2; return 2 + 1 to previous function call #1: // received return value of 3; return 3 + 1 to previous function console.log(): // received return value of 4; print it to the console!
@celidee
@celidee 6 лет назад
Wow thank you for the explanation, it make a little more sense now! I'm still a bit confused on the 'received return value' ie: the second #3. How are the returned values "stored" and added if there is no placeholder variable for them? I hope that makes sense. I consoled the num value above the if so I can see the base case being reached so that makes more sense.
@phow4rd
@phow4rd 6 лет назад
Yeah, that's why I noted that that was the "tricky" part. :-) Think of it this way: when you call a function that returns a value, you can use that value directly, without having to store it a variable, right? (That's why we could do something like, e.g., `console.log(countDigitsRecursively(1234) * 2);`, and expect it to print '8' to the console.) It's the same thing /inside/ the recursive function: once the base case is reached, it passes back the specified return value to the function that called it (which, in the case of a recursive function is itself, but it helps here to imagine different instances of the function, which is why I labelled them 'call #1, call #2, etc.). When the calling function receives a return value, it can then use that value and manipulate it in any way it wants without having to store it in a named variable. Does that help?
@PraneyBehl
@PraneyBehl 5 лет назад
For the second one it could be something like: const findNumLen = num => Math.ceil(Math.log10(num + 1));
@Techsithtube
@Techsithtube 5 лет назад
yep that is the simplest solution .
@cecekim5869
@cecekim5869 5 лет назад
// 1. Find the min and max sums of the remaining numbers in an array, after removing one number from the array. const maxMinSums = (arr) => { const max = Math.max(...arr); const min = Math.min(...arr); const sum = arr.reduce((acc, curr) => acc + curr); return [sum - max, sum - min]; } // 2. Find the length of an integer without converting it to a string. const intLength = (num) => { if (num === 0) { return 1; } let length = 0; let int = num; while (int > 0) { int = Math.floor(int/10); length++; } return length; }
@Techsithtube
@Techsithtube 5 лет назад
Good Solutions! :)
@swarnendughosh3481
@swarnendughosh3481 4 года назад
For Q2, I would follow the same approach only, but a little less complicated: function lengthOfNumber(num) { let count = 0; while (true) { num = num / 10; count++; if (num / 10
@Techsithtube
@Techsithtube 4 года назад
Thanks for sharing your solution.
@TauseefTSF
@TauseefTSF 6 лет назад
Math.ceil( Math.log10(number)); That's it!
@Techsithtube
@Techsithtube 6 лет назад
almost right . it should be Math.ceil( Math.log10(number)) + 1;
@TauseefTSF
@TauseefTSF 6 лет назад
+1 would be wrong in all cases except when the number is starting with 1 and all other digits are 0, like 1000 or 10000000.
@maxyankulov6539
@maxyankulov6539 6 лет назад
Math.ceil is wrong. It should be Math.floor(Math.log10(number))+1;
@sophialee3713
@sophialee3713 4 года назад
for me the second one, let count = 0; while(true){ x=x/10; count ++; if(!Math.floor(x)){ break; } }
@swarnendughosh3481
@swarnendughosh3481 4 года назад
I thought for Q1 this approach would be better: function getSumRange(arr) { let max = arr[0]; let min = arr[0] let total = 0; arr.forEach(elem => { total = total + elem; max = max < elem ? elem : max; min = min > elem ? elem : min; }); return [(total-max), (total-min)]; } As in this case the time complexity would be O(n) only.
@larbisahli2273
@larbisahli2273 4 года назад
let num = 131333; const findLengthOfNumber = (num) => { let dec = 1; let con = true; let counter = 0; while (con) { let n = num / dec; counter += 1; dec *= 10; if (n < 1) con = false; continue; } return counter - 1; }; console.log("Length is :", findLengthOfNumber(num));
@itspravas
@itspravas 5 лет назад
Third Question function findLength(num) { let len = 0; for(let i = 0; i < 17; i++) { if(Math.ceil(Math.pow(10, i)/num) == 1) { len = i + 1; } } return len; } let num = 13243546; console.log(findLength(num));
@katyasorok9536
@katyasorok9536 5 лет назад
I do not understand how maximum summary of numbers from an array after taking one number out is equal to summary -max. I would think that for maximum you have to minus smallest number in an array and for minimum summary you would need to minus largest number of the array.
@ralexand56
@ralexand56 5 лет назад
That's what I thought too.
@kwii22789
@kwii22789 5 лет назад
Using a binary search to find length of a number. I've seen everything now.
@Techsithtube
@Techsithtube 5 лет назад
Lol . yep its crazy
@gaurab1247
@gaurab1247 5 лет назад
Simple solution is using parseInt var number = 1234; var count = 0; while(number !=0) { number = number/10; number = parseInt(number); count++ } alert(count);
@Techsithtube
@Techsithtube 5 лет назад
Nice solution. :)
@VipinRawat_Offcial
@VipinRawat_Offcial 4 года назад
For finding number length why you didn't just call 1234.toString().length Or We can find this with for in loop
@erezlieberman
@erezlieberman 5 лет назад
here is my solution: let x = 1234; const findLength = n => { let results = 1; while( n > 1){ results++; n = n / 10; } return results; } console.log(findLength(x))
@iQwert789
@iQwert789 6 лет назад
First: const [min,max] =[arr.sort().slice(0, arr.length-1).reduce((a,b)=>a+b,0), arr.sort().slice(1, arr.length).reduce((a,b)=>a+b,0)] Second: let num =1234; let count=0; while(num!=0){ num = ~~(num /10); ++count} Third: const findNumLength = (num, left, right) =>{ const mid= Math.round((left+right)/2); const cmpNum = Math.pow(10,mid); return (Math.floor(num/cmpNum)>=1 && Math.floor(num/cmpNum) cmpNum)? findNumLength(num, mid+1, right) : findNumLength(num, left, mid-1); } const findNumLengthSafe = (num) =>{ return num === 0 ? 1 : findNumLength(num,0,String(Number.MAX_SAFE_INTEGER).length); } //To run console.log(findNumLengthSafe (12345));
@Techsithtube
@Techsithtube 6 лет назад
Brilliant! Thanks for the answers.
@Drvortext
@Drvortext 5 лет назад
Here’s my solution to the last problem. Hopefully, it will help anyone who struggled implementing the binary search part. function findLengthOfN(n) { // MAX_SAFE_INTEGER is the variable discussed in the video const max = Number.MAX_SAFE_INTEGER; if (n > max) return new Error("Javascript can't perform math with numbers this large :("); if (isSingleDigit(n) || n === 0) return 1; let maxLength = 16; // > StopIndex let minLength = 2; // > StartIndex - start at 2 because of the 2nd if statement above let currentLength = Math.floor((minLength + maxLength) / 2); // > Middle // Base case - When divided by the correct power of 10 AND rounded down: // the number should be a single digit while (!isSingleDigit(Math.floor(n/getCurrentPowerOfTen())) && currentLength < maxLength) { if (Math.floor(n/getCurrentPowerOfTen()) > minLength) { minLength = currentLength + 1; } else { maxLength = currentLength - 1; } currentLength = Math.floor((minLength + maxLength) / 2); } return currentLength; function getCurrentPowerOfTen() { return Math.pow(10, currentLength-1); } function isSingleDigit(number) { return (number >= 1 && number
@niteshsharma663
@niteshsharma663 Год назад
function findNumberLength(number) { for(let i=1; i number) { console.log(i); break; } } } findNumberLength(1234);
@orz5516
@orz5516 5 лет назад
hmm solution? x = 1234 var counter = 0; while(x > 0){ x = x / 10; x = parseInt(x) counter++ } console.log(counter)
@pratikgohil7821
@pratikgohil7821 4 года назад
let num = 123 let arr = [0] let i =10 while(Math.floor(x/i) !== 0) { arr.push(i*=10) } let numLenght = arr.length
@Techsithtube
@Techsithtube 4 года назад
Thanks for the solution and sharing!
@jeremyguan9591
@jeremyguan9591 5 лет назад
Just wonder and please help. What is wrong with this approach let x = 120312; function findLength(num){ let length = 0; if (x == 0) length = 1; while(x !=0){ x=Math.floor(x/10); length++; } }
@muralik5504
@muralik5504 5 лет назад
Great video
@creativeuk6882
@creativeuk6882 6 лет назад
Nice video
@emi22n
@emi22n 6 лет назад
Great series of videos!
@rajshinde2811
@rajshinde2811 3 года назад
is this correct?? var no = 1231234; function nolen(no) { var count = 0; while(no != 0){ no = parseInt(no/10); count++; } // return count; console.log(count); } // alert(nolen(no)); nolen(no);
@poamrongrith1563
@poamrongrith1563 6 лет назад
Again, so grateful^^
@kabuyedennis7985
@kabuyedennis7985 4 года назад
last one Math.ceil(Math.log10(number + 1));
@Techsithtube
@Techsithtube 4 года назад
Kabuye, thanks for sharing the solution :)
@shashankmishra9170
@shashankmishra9170 6 лет назад
I'm learning a lot from you ;) ...
@dragonstore6308
@dragonstore6308 2 года назад
function len(number) { let cont = 0; while (number > 1) { number = number / 10; cont++; } return { cont }; };
@themusclefairy
@themusclefairy 6 лет назад
let num = 1234 let count = 0 while (num / 10 > 0) { count++ num = Math.trunc(num / 10) } console.log(count)
@Techsithtube
@Techsithtube 6 лет назад
yep correct answer! You also need to cover for edge cases.
@Kailu_YT
@Kailu_YT 4 года назад
Hi, Is it right for your first question? // Find min and max no. let arryVal4 = [1,2,3,4,5]; (function minMax(arry) { let lng = arry.length; let copyary = [...arryVal4]; for(let i = 0; i< lng; i++){ copyary.push(removeAndTotal(i)); } let min = Math.min(...copyary); let max = Math.max(...copyary); console.log("min:",min," min:", max); })(arryVal4); function removeAndTotal(index){ let copyary = [...arryVal4]; copyary.splice(index,1); let total = copyary.reduce((ac,val)=> ac+val,0); console.log(total, copyary); return total; }
@debanjanbasu2597
@debanjanbasu2597 6 лет назад
var findLenghOfNumber = function(number){ var required_length = 0; do{ var last_number = number%10; required_length += 1; x = parseInt(number/10); }while(number > 0) console.log(required_length); }
@NAMBINRAJAN
@NAMBINRAJAN 5 лет назад
var x = 143531; var incrementer = 1; while(x>=10){ x = x/10; incrementer++; } if(!x){ incrementer = 0 } console.log(incrementer); Why is it so complicated....
@dostihamari.6596
@dostihamari.6596 6 лет назад
For 2nd problem can we use the below logic?, any suggestions ? this is more easy i guess without using any built-in function var abc=13233 var counter=0 while(abc>=1) { c++ abc=abc/10 } console.log(counter);
@arvindgupta-zm7lz
@arvindgupta-zm7lz 4 года назад
Sir please consider junior level engineer who just started career with less than 2 years experience
@eyalshnitzerful
@eyalshnitzerful 6 лет назад
Great video. Questions that make you think (:
@Techsithtube
@Techsithtube 6 лет назад
If it makes you think than my job is done :)
@SumitSharma-vc8ci
@SumitSharma-vc8ci 6 лет назад
math.trunc() method to get only integer part of the number to overcome the problem of floats number.
@robertkaminski1781
@robertkaminski1781 4 года назад
the length of number :: const number = 123497561456; console.log( Math.round( Math.log(number) / Math.log(10) + 1) );
@fadimoussa8382
@fadimoussa8382 4 года назад
His first approach would work had he done it like this: function getLength(n) { if (n < 10) return 1; var c = 0; while (n > 1) { c++; n = n / 10; } return c; } alert(getLength(2345)) ;
@fadimoussa8382
@fadimoussa8382 4 года назад
A bit shorter: function getLength(n) { if (n < 10) return 1; var c = 0; while ((n = n /10) > 1) c++; return c+1; } alert(getLength(2345)) ;
@Shetu_Sharma
@Shetu_Sharma 4 года назад
good job :)
@Techsithtube
@Techsithtube 4 года назад
Thanks for watching Shetu.
@intothenature437
@intothenature437 3 года назад
I would like to take interview with u on React or JS.
@vineetkumar5298
@vineetkumar5298 4 года назад
Hi Sir , why not we use parseInt for question 2 as Number =parseInt (Number/10);
@sol0matrix
@sol0matrix 6 лет назад
I couldn't find the length without converting into a string I wouldn't even think of his solution so what level am I currently?
@katyasorok9536
@katyasorok9536 5 лет назад
number=Math.trunc(number/10)
@sidheshwarkacharde4492
@sidheshwarkacharde4492 4 года назад
Sir please create video on Array function
@vigneshswaminathan7954
@vigneshswaminathan7954 4 года назад
and for the second problem cant we just use parseint ?
@thippaniravinder3323
@thippaniravinder3323 6 лет назад
Super sir
@thippaniravinder3323
@thippaniravinder3323 6 лет назад
Commented before watch😉
@psurekha3509
@psurekha3509 5 лет назад
For the second question, instead of while(number!=0) , if we use while(number >9) and start with (var numberLength =1), the code works fine, right?
@Techsithtube
@Techsithtube 5 лет назад
Yes I think that should work as well. :)
@shashankmishra9170
@shashankmishra9170 6 лет назад
/* finding length ....*/ function* tenGen(){ var index = 1; while(true){ yield index*=10; } } //for integer... const numLength = function(number){ //calling generator var gen = tenGen(); var count = 0; while(true){ var result = number%gen.next().value; count+=1; //check if(result == number || count > 16) { break; } } return count>16? "invalid number":count; }
@Techsithtube
@Techsithtube 6 лет назад
Really interesting solution. Thanks for providing.
@DanPatil123
@DanPatil123 5 лет назад
something like this I coded gave me the same result. I am wondering am I doing too much overthinking here let arr = [1,2,3,4]; let originalArr = [...arr]; let addedArr = []; for(let i = 0; i
@sundushussain4952
@sundushussain4952 Год назад
my concepts are so weak :(
@brewzonekeeone5724
@brewzonekeeone5724 6 лет назад
Good one tech! Regarding the 'Get the length of the number quiz' I took another approach using units, tens, hundreds, etc. You can check it out here jsfiddle.net/brewed100/rb4d01xs/25/ . I don't know that I would have properly solved this in the actual mock interview but I would have at least mentioned 'units, tens, hundreds, thousands'. That's a tricky one!
@Techsithtube
@Techsithtube 6 лет назад
Yep, this is a good approach. :)
@andrerothweiler9191
@andrerothweiler9191 6 лет назад
I would be more interesting to invite guys, who never worked in the field of IT.
@Techsithtube
@Techsithtube 6 лет назад
What would be the reason for that?
@andrerothweiler9191
@andrerothweiler9191 6 лет назад
More exciting and most interviews are for the Junior position anyway. Just my opinion. Btw you live in USA or Canada?
@Techsithtube
@Techsithtube 6 лет назад
I am in USA
@vikas2426
@vikas2426 6 лет назад
Hi @techsith, can you suggest series wise content to prepare for JavaScript interviews
@Techsithtube
@Techsithtube 6 лет назад
I coundnt find any good content outside to prepare for the javaScript interviews. So I am planning to create my own on udemy. It might take a month or so . Will let you know when its released.
@hatrick3117
@hatrick3117 6 лет назад
My brain got leaked at that last one task... I wanted to stringify that 1234 so hard :)
@Techsithtube
@Techsithtube 6 лет назад
lol. I have few good solutions on that in the description of the video. Please check it out.
@sarathkumar1000
@sarathkumar1000 6 лет назад
Hi Techsith, I am facing one interview question that Tell me about your project architect and how you start? plase give some suggestion how to give proper answer
@Techsithtube
@Techsithtube 6 лет назад
That is a good questions. You would explain first about the technology stack that you are using. explain the tooling around it like i18n, unit testing, end to end testing, deployment, devops, also any back-end that is involved. You can explain certain decision you or your team made and why.
@sarathkumar1000
@sarathkumar1000 6 лет назад
thanks
@sarathkumar1000
@sarathkumar1000 6 лет назад
Please give us some knowledge about writing test cases in React?
@Techsithtube
@Techsithtube 6 лет назад
You mean unit tests?
@darkDay9211
@darkDay9211 4 года назад
@@Techsithtube yes please
@borschetsky
@borschetsky 5 лет назад
Why the second is so complicated solution? It seems like this guy never solve algorithmic tasks. Like reverse integer without convert, or just swap values from var a = 5, var b = 7; with no extra vars. The best logic is. You have mod operator. So, do next. while yoo have value at number just find mod and substract it with deviding by 10 and count the operation. First solution: ----------------------- const findIntLenghtInterate = (num) => { if(num === 0) return 1; let counter = 0; while (num > 0) { num = (num - num % 10) / 10; counter++; } return counter; }; ------------------------ Second: -------------------------- const findNumLength = (num) => { return num === 0 ? 1 : Math.ceil(Math.log10(x)); };
@shellykapoor7331
@shellykapoor7331 6 лет назад
I don't get it how to find length of number
@Techsithtube
@Techsithtube 6 лет назад
you can divide the number by 10 and make it integer by flooring it. so let's say the number is 109 1) n = floor(109/10) = 10 2) n = floor(10/10) = 1 3) n = floor(1/10) = 0 it took three steps so the length is 3.
@shellykapoor7331
@shellykapoor7331 6 лет назад
techsith but how we find length u say it takes 3 steps OK but how we exactly write code
@anthonydagostino7782
@anthonydagostino7782 5 лет назад
function findNumberLength(num) { let numLen; if(num/ 10 >= 100) { numLen = 4; } else if(num/ 10 >= 10) { numLen = 3; } else if(num/ 10 >= 1) { numLen = 2; } else { numLen = 1; } return numLen; } this seems simpler to me.
@remariorichards8237
@remariorichards8237 5 лет назад
how do i set up a interview
@Techsithtube
@Techsithtube 5 лет назад
There is an email address in the description of my channel. feel free to email me and we will set it up.
@phow4rd
@phow4rd 6 лет назад
Here's my preferred solution to the second question: countDigitsFinal = num => { if (num === 0 || num === 1) { return 1; }; return Math.ceil(Math.log10(num)); }; I recorded a little bit of my progression and thought process here: codepen.io/phoward8020/pen/qJjyer?editors=0012
@phow4rd
@phow4rd 6 лет назад
Oops. Realized moments after posting that this results in an off-by-one error when the input is an actual power of ten. Updated: const countDigitsFinal = num => { if (num === 0 || num === 1) { return 1; } let logVal = Math.log10(num); if (logVal - Math.floor(logVal) === 0 ) { return logVal + 1; } return Math.ceil(logVal); }; codepen.io/phoward8020/pen/oawPGE/
@Albertmars32
@Albertmars32 6 лет назад
man im so bad at javascript mainly because i only mastered the fundamentals and went right straight to react
@Techsithtube
@Techsithtube 6 лет назад
lot of people take that path . And its fine and good enough to do react. Interviews are completely different world . these days, interviewer can ask anything.
@gghd2757
@gghd2757 6 лет назад
x.toString().split("").length
@MylesGmail
@MylesGmail 5 лет назад
I'll donate to ur channel soon when I have extra $, thx for the gr8 videos!
@Techsithtube
@Techsithtube 5 лет назад
Thanks for the support! :)
@asrockriel
@asrockriel 2 года назад
let number = 15487; function getNumberLength(numberParameter) { let numberLength = 0; while (numberParameter >= 1) { numberParameter /= 10; numberLength++; } return numberLength; } console.log(getNumberLength(number));
@vigneshswaminathan7954
@vigneshswaminathan7954 4 года назад
in the first question instead of using apply to send array to Math.min can we use spread as in Math.min(...arr) ?
@jahidhassanshovon
@jahidhassanshovon Год назад
I think this solution more easy let number = 3423234; let count = 0, result = number; while(result !== 0){ result = Math.floor(result / 10); count++; } console.log(`${number} Number length is: ${count}`) //Output: 3423234 Number length is: 7
@MrAndrewsome
@MrAndrewsome 4 года назад
let length = 0; const findIntgerLength = () => { if (x === 0) { length++; return length; } else { for(let i = 1; i < x; i = i *10) { length++; } return length; } } console.log(findIntegerLength(x)); should work
@amritchhetri06
@amritchhetri06 6 лет назад
function add(num){ var length=0; while(num>10){ num=num/10; length++; } return length+1; } var total=add(123234); console.log(total);
@Techsithtube
@Techsithtube 6 лет назад
Yep. that is a pretty good solution.
@assamaafzal3516
@assamaafzal3516 5 лет назад
Not the best answer but can work let len =1; function findLength(num){ while(num>=10){ num = Math.floor(num/10); len++; } return len; }
@Techsithtube
@Techsithtube 5 лет назад
I think its a reasonable answer.
@assamaafzal3516
@assamaafzal3516 5 лет назад
@@Techsithtube Thanks sir :)
Далее
We finally APPROVED @ZachChoi
00:31
Просмотров 3,2 млн
+1000 Aura For This Save! 🥵
00:19
Просмотров 4,1 млн
Async Await JavaScript ES7
26:39
Просмотров 120 тыс.
Live Mock Technical Interview - JavaScript
1:03:31
Просмотров 127 тыс.
We finally APPROVED @ZachChoi
00:31
Просмотров 3,2 млн