JS Interview - Palindromes - Question 17

  Рет қаралды 16,046

Steve Griffith - Prof3ssorSt3v3

Steve Griffith - Prof3ssorSt3v3

Күн бұрын

Пікірлер: 38
@DmitriyMalayevProfile
@DmitriyMalayevProfile 3 жыл бұрын
My favorite KZbin Professor. Intelligent, Educated, and Humane.
@princejaiswal439
@princejaiswal439 5 жыл бұрын
Love the way you explain things..Thanks a lot for this entire series.
@ylexisbutler8066
@ylexisbutler8066 Жыл бұрын
You are a life saver and an incredible teacher. Thank you
@pablitoengineer
@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.
@Optimized_Finance. 2 жыл бұрын
Awesome, please do linked list, your teaching is magnanimous.
@ubermensch-mne
@ubermensch-mne 5 жыл бұрын
Why don't you just write: return word === word.split('').reverse().join('');
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 5 жыл бұрын
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.
@sergeyb6071
@sergeyb6071 4 жыл бұрын
this actually evaluates to false if a palindrome is a phrase
@aleksamitic6655
@aleksamitic6655 3 жыл бұрын
Did the same thing.
@xXESproductionsXx
@xXESproductionsXx 3 жыл бұрын
Interviewers would probably like to see something more complex than using built-ins.
@Zonab360
@Zonab360 3 жыл бұрын
@@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
@iali3903
@iali3903 4 жыл бұрын
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;
@lastnamefirstname2390
@lastnamefirstname2390 5 жыл бұрын
I'm gonna like every single one of these videos. Amazing.
@nav0110
@nav0110 3 жыл бұрын
It was really helpful for me because I'm new in JS. Thank you...!
@braca86
@braca86 4 жыл бұрын
let palindrome = function (word) { const reverse = word.split("").reverse().join(""); return word === reverse; };
@maxnag-dev
@maxnag-dev Ай бұрын
you forgot about Case of letters
@braca86
@braca86 Ай бұрын
@maxnag-dev you are right. just chime in some toLowerCase
@giorgilomaia1623
@giorgilomaia1623 2 жыл бұрын
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 .
@artvizi
@artvizi 2 жыл бұрын
What are the time and space complexity of this algorithm?
@priyankajamwal994
@priyankajamwal994 3 жыл бұрын
Thanku so much u did such a great work 👍👍. I got it each and every step very clearly 😊
@harshverma3882
@harshverma3882 4 жыл бұрын
how to take inputs from users??
@JohnDoe-rj2kf
@JohnDoe-rj2kf 3 жыл бұрын
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-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
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]
@Endorsun
@Endorsun 3 жыл бұрын
Dude... THANK YOU!
@rupbhaiya
@rupbhaiya 2 жыл бұрын
Why not this? function palindrome(str) { const gotStr = str.toLowerCase() const revStr = gotStr.split("").reverse().join("") return gotStr === revStr } console.log(palindrome("eye"))
@guyzohar3756
@guyzohar3756 3 жыл бұрын
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?
@Bruno-ds8ze
@Bruno-ds8ze 5 жыл бұрын
great tutorial
@fadiserapian1360
@fadiserapian1360 4 жыл бұрын
const isPalindrom = str => str === str.split('').reverse().join('');
@Banjer
@Banjer 5 жыл бұрын
Great!!Thanks
@abhishekkumar2526
@abhishekkumar2526 4 жыл бұрын
Nice try but it won't work for "A man, a plan, a canal: Panama"
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
That's not a valid palindrome
@abhishekkumar2526
@abhishekkumar2526 4 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 check it over here www.willpeavy.com/palindrome/
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
@@abhishekkumar2526 I am not removing punctuation in this demo.
@maksymantoshkin2896
@maksymantoshkin2896 5 жыл бұрын
Awesome
@71sux
@71sux 3 жыл бұрын
another approach: palindrome === Array.of(palindrome).reverse();
@Serjgap
@Serjgap 5 жыл бұрын
that fcking start=
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 5 жыл бұрын
what?
@arunputhiyidath
@arunputhiyidath 3 жыл бұрын
return word === word.split('').reverse().join(''); // is the best I think
JS Interview - Chained Variable Declarations - Question 18
7:30
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 3,5 М.
Become A Software Engineer For Free (Class 01) - 100Devs
3:23:06
Leon Noel
Рет қаралды 694 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
How to Check For A Palindrome - JavaScript
0:51
AlgoJS
Рет қаралды 18 М.
The Difference between JS Expressions and Statements
8:45
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 7 М.
How to Use parseInt and parseFloat
5:54
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 25 М.
Learn Regular Expressions In 20 Minutes
20:52
Web Dev Simplified
Рет қаралды 1,3 МЛН
Checking Palindromes in JavaScript
10:54
James Q Quick
Рет қаралды 4,3 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 309 М.
JS Interview - Practical Closures - Question 7
7:21
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 18 М.
3 Different Ways to Reverse a String in JavaScript
10:53
Javascript Interview Questions and Answers - Dominate Your Next Interview
1:02:33
Monsterlessons Academy
Рет қаралды 75 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН