Javascript Mock Interview | online video interview Questions & Answers
HTML-код
- Опубликовано: 20 окт 2019
- Online Technical Mock Interview of one of my viewers. Where I ask JavaScript Fundamental Questions , algorithm questions aand give their answers
#javaScript #interview #questions
For mock interview email me at techlover2000@gmail.com
*My Udemy Courses
www.udemy.com/js-masterclass/
www.udemy.com/course/react-ho...
Follow me for technology updates
* / techsith
* / techsith
* / techsith1
* / 13677140
* / patelhemil
Help me translate this video.
* ruclips.net/user/timedtext_cs_...
Note: use translate.google.com/ to translate this video to your language. Let me know once you do that so i can give you credit. Thank you in advance. Наука
Keep zoom while candidate is writing code, its difficult to see
I stopped watching at 3:31 exactly because of that reason. I have no idea what is being written 😕
one basic solution to palindrome problem can be :
const isPalindrome = n => {
let final = 0;
let givenNumber = n;
while (givenNumber > 0) {
let remainder = givenNumber % 10;
givenNumber = parseInt(givenNumber / 10);
final = final * 10 + remainder;
}
return final === n;
};
this is wrong... it is not palidromic approach.. you are adding final to from backward which is same as n
Thanks for the video Sir🤩
Please make Angular Interview Question Series thank you techsit
I am backend developer. wanted to be fullstack developer. I see interview series to get idea and check my knowledge as well. This is really a good series for people like me. Thanks a lot sir. 🙃
Hi .....i tried to use the same "id value" for different element and it is working in HTML ? !!!
When I heard the questions in this interview my thoughts automatically route me to techsith videos where he would thought all these stuffs.
Please make data structures and algorithms video series.
Prabhu Shriram bless you Hemil 🙏 keep going bro
hi sir i loved each and every video of yours :). Can you please explain about JavaScript design patterns also
Number.prototype.isPalindrome = function(number = -1, result = []) {
if(number === -1) number = this.valueOf()
const evaluateResult = result => parseInt(result.join('')) === number
if(number > 0, result)
return evaluateResult(result)
}
const number = 101;
console.log(number.isPalindrome())
using a couple of techniques based on these interview videos of yours i have been watching. Many thanks learning allot!
My approach for Palindrome:
3) function numDigits(num) {
return Math.floor(Math.log10(num));
}
function palinCheck(number) {
if(Math.floor(number / 10) === 0) {
return true;
}
var num_digits = numDigits(number);
var right = Math.floor(number / Math.pow(10, num_digits));
var left = number % 10;
if(right !== left) {
return false;
}
var striped = number / 10; // strip the right
striped = Math.floor(striped % Math.pow(10, numDigits(striped)));
return palinCheck(striped);
}
console.log(palinCheck(12321));
why does it look pixelated?
Please, make a video about Polymorphism in JavaScrpt.
How about floating number palindrome, e.g. 1234.4321, which I don't think it will work in base 10, it only work for base 2 or base 2^n.
Thanks for the amazing video!
const isPalindrome = (num) => {
let numTemp = num;
let result = 0;
while (numTemp > 0) {
result = (result * 10) + Math.floor(numTemp % 10);
}
return (result === num) ? 'Palindrome' : 'Not Palindrome';
}
nice solution, i think you made a mistake inside the while on the `x` variable
This is really helpful, please do Angular 6+ interview also
Abhilasha, that is on my list . I will do it soon. Thanks for the suggestion
Can Object.seal be an alternative solution for preventing new property to be added to object ?
no, it does not allow delete operation
May some please explain the first question, please? because it took long and I need to understand
For last one, I will find last digit by moding the given number, and store it in a variable then cut down last digit of the number by dividing with 10. Now I will generate a reverse number(initial value is zero) by multiplying reverse number with 10 and add the extracted last digit to it. I will repeat this till number is greater than zero after cutting down the last digit.. finally I will get reversed number. I will compare with actual number..this is my approch.. pls suggest is this correct approch or not..
see my answer in below comment
`${number}`.split('').reverse().join('') === `${number}`
It is correct but in case of 123456789 your solution will still run through the length of the number whereas his solution would terminate at the first iteration.
I have tried a lengthy way:
var a=12521;
var b=c=a;
var lengthOfA=0
var s=0;
for(i=0;i
The correct answer to the first question is "I don't know. Let's google it and find out in 10 seconds." Like, make sure you rephrase the question back to show understanding about what is being asked, something like "I want to prevent new property definitions, but ensure the obj is still mutable" but why lose sleep over not knowing off the top of your head the exact api call.
I feel dont know is way better than trying to answer something that you dont know.
Not properly visible
I did it this way
(you can just copy and paste in jsfiddle or similar)
function reverseInt(n) {
let pal = "";
while (n > 1) {
n /= 10;
pal += Math.floor((n - Math.floor(n)) * 10);
}
return parseInt(pal);
}
let int = 123456;
console.log(reverseInt(int));
That is short and sweet. Thanks for sharing!
@@Techsithtube Thanks you for your job, I learned a lot through your (and your candidates) way of thinking. Please keep going ;)
This does not work for single digit numbers, returns NaN
Hi Sir,
In one of my recent interviews I was asked the below question,
let A={a:1,b:2};
let B=A;
B.x=20;
console.log(A.x) //20
I got the answer correct but couldn't explain why. Can You please explain? Thanks in advance.
When you do B=A you are setting reference of A to B. in a way they are now pointing to the same object. which means if you change one other gets impacted. that is why adding a new property in B also shows up in A.
This is what we call Shallow Copy right ?
because of shallow copy
@@ananyadwivedi5518 Yup
Here's my solution to the palindrome question.
Number.prototype.isPalindrome = function() {
let arr = [], quotient = 0, remainder = 0, init = this;
while(init > 0) {
quotient = Math.floor(init/10);
remainder = init%10;
arr.push(remainder);
init = quotient;
}
return this === Number(arr.join(""));
}
const num = 12521;
console.log(num.isPalindrome()); // returns true
--- Here is my take ---
function isPalindrome(number) {
// number -> 121
const stack = [];
const originalNumber = number;
while (number > 0) {
stack.push(number % 10);
number = Math.floor(number / 10);
}
const reversedNum = Number(stack.join(""));
return reversedNum === originalNumber;
}
console.log(isPalindrome(1001));
You will never get so much time for such a basic palindrome question. By that time interviewer will ask you to jump to next question.
Solution for first question?
apply The Object.freeze() method
@@n_fan329 can we do it with define property method
Object.freeze() doesnt work here.
What’s the first question
If you want to update/delete the existing one and don’t want to add a new prop. Then I guess Object.seal would be the best option. @Techsith correct me if I’m wrong
var a=12521;
var b=a;
var s=0
var length = 0;
for(i = a; i > 1; ++i){
++length;
i = Math.floor(i/10);
}
for(i=0;i
let number = 121;
let checkPalindrome = function( number ) {
let _numString = number.toString(10);
let _reverseString = '';
for (let i = _numString.length - 1; i >= 0; i = i - 1) {
_reverseString += _numString[i];
}
return ( _numString === _reverseString) ? true : false;
}
console.log( checkPalindrome( number ) );
Thanks for sharing the solution
@@Techsithtube Thanks a lot Sir. Your reply means a lot to me.
Too much useless talking from the interviewer for no reason 🤦🏻♂️