My favorite KZbin Professor. Intelligent, Educated, and Humane.
@princejaiswal4395 жыл бұрын
Love the way you explain things..Thanks a lot for this entire series.
@ylexisbutler8066 Жыл бұрын
You are a life saver and an incredible teacher. Thank you
@pablitoengineer Жыл бұрын
Thanks for the Video! I was wondering if you need the lines 8, 9, 10. I think it works only reversing the entire word, storging the result in a "reversed" variable, and return "word === reversed". Does that make sense?
@Optimized_Finance.2 жыл бұрын
Awesome, please do linked list, your teaching is magnanimous.
@ubermensch-mne5 жыл бұрын
Why don't you just write: return word === word.split('').reverse().join('');
@SteveGriffith-Prof3ssorSt3v35 жыл бұрын
You definitely could do that. Sometimes I just break things up into extra steps to improve readability or to let people who are less experienced understand it better.
@sergeyb60714 жыл бұрын
this actually evaluates to false if a palindrome is a phrase
@aleksamitic66553 жыл бұрын
Did the same thing.
@xXESproductionsXx3 жыл бұрын
Interviewers would probably like to see something more complex than using built-ins.
@Zonab3603 жыл бұрын
@@xXESproductionsXx Not nesciarly. Companies also want people who can utilize tools. If I had this question I would do the built in methods and if they push back then use another method
@iali39034 жыл бұрын
I try to solve all problems without using any native function like "reverse" in this problem! this is my solution using for Loop let wordArr = word.split(""); let revArr = []; let wordRev; for (let i = wordArr.length - 1; i >= 0; i--) { revArr.push(wordArr[i]); } wordRev = revArr.join(""); return word == wordRev;
@lastnamefirstname23905 жыл бұрын
I'm gonna like every single one of these videos. Amazing.
@nav01103 жыл бұрын
It was really helpful for me because I'm new in JS. Thank you...!
@braca864 жыл бұрын
let palindrome = function (word) { const reverse = word.split("").reverse().join(""); return word === reverse; };
@maxnag-devАй бұрын
you forgot about Case of letters
@braca86Ай бұрын
@maxnag-dev you are right. just chime in some toLowerCase
@giorgilomaia16232 жыл бұрын
Hello, I just found your youtube channel and I think it's very helpful, can you please make video about how to turn JS array, where all the integers are numbers into Palindrome? Thanks in advance .
@artvizi2 жыл бұрын
What are the time and space complexity of this algorithm?
@priyankajamwal9943 жыл бұрын
Thanku so much u did such a great work 👍👍. I got it each and every step very clearly 😊
@harshverma38824 жыл бұрын
how to take inputs from users??
@JohnDoe-rj2kf3 жыл бұрын
Dear Steve, so the point of Math.floor is to remove the uneven number in the middle to help with the equal division and better reverse checking. Am I right?
@SteveGriffith-Prof3ssorSt3v33 жыл бұрын
floor is to get rid of the possible decimal value you can get dividing an even number by two. There can't be an index number in an array like [3.5]
@Endorsun3 жыл бұрын
Dude... THANK YOU!
@rupbhaiya2 жыл бұрын
Why not this? function palindrome(str) { const gotStr = str.toLowerCase() const revStr = gotStr.split("").reverse().join("") return gotStr === revStr } console.log(palindrome("eye"))
@guyzohar37563 жыл бұрын
I did it this way: function palindrome(word){ for(let i = 0; i < word.length; i++){ const last = word.length-1 if( word.length % 2 !== 0 && (i === last - i) ) continue; if( word.charAt(i) !== word.charAt(last - i) ) return false } return true } I think its a bit more efficient no?