* chore(learn): audit basic algorithm scripting * chore(learn): audit basic data structures * chore(learn): audit basic javascript * chore(learn): audit debugging * chore(learn): audit es6 * chore(learn): audit functional programming * chore(learn): audit intermidate algorithms * chore(learn): audit js projects * chore(learn): audit object oriented programming * chore(learn): audit regex * fix(learn): remove stray . * fix(learn): string to code * fix(learn): missed some * fix(learn): clarify strings Based on Randy's feedback, clarifies string instances where quotes were removed in favour of back ticks. * fix: apply suggestions - thanks Randy! :) Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: non-suggestion comments * chore(learn): remove comments from codes Removes the comments from the description and instruction code blocks to ensure that all relevant information is translatable. * fix: Apply suggestions from code review Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * fix: revert crowdin fix * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: Apply suggestions from code review Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * fix: Apply suggestions from code review Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * chore: change voice * fix: Christopher Nolan * fix: expressions would evaluate * fix: will -> would * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: to work to push * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops.md Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2.5 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
aaa48de84e1ecc7c742e1124 | Palindrome Checker | 5 | 16004 | palindrome-checker |
--description--
Return true
if the given string is a palindrome. Otherwise, return false
.
A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.
Note: You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything into the same case (lower or upper case) in order to check for palindromes.
We'll pass strings with varying formats, such as racecar
, RaceCar
, and race CAR
among others.
We'll also pass strings with special symbols, such as 2A3*3a2
, 2A3 3a2
, and 2_A3*3#A2
.
--hints--
palindrome("eye")
should return a boolean.
assert(typeof palindrome('eye') === 'boolean');
palindrome("eye")
should return true
.
assert(palindrome('eye') === true);
palindrome("_eye")
should return true
.
assert(palindrome('_eye') === true);
palindrome("race car")
should return true
.
assert(palindrome('race car') === true);
palindrome("not a palindrome")
should return false
.
assert(palindrome('not a palindrome') === false);
palindrome("A man, a plan, a canal. Panama")
should return true
.
assert(palindrome('A man, a plan, a canal. Panama') === true);
palindrome("never odd or even")
should return true
.
assert(palindrome('never odd or even') === true);
palindrome("nope")
should return false
.
assert(palindrome('nope') === false);
palindrome("almostomla")
should return false
.
assert(palindrome('almostomla') === false);
palindrome("My age is 0, 0 si ega ym.")
should return true
.
assert(palindrome('My age is 0, 0 si ega ym.') === true);
palindrome("1 eye for of 1 eye.")
should return false
.
assert(palindrome('1 eye for of 1 eye.') === false);
palindrome("0_0 (: /-\ :) 0-0")
should return true
.
assert(palindrome('0_0 (: /- :) 0-0') === true);
palindrome("five|\_/|four")
should return false
.
assert(palindrome('five|_/|four') === false);
--seed--
--seed-contents--
function palindrome(str) {
return true;
}
palindrome("eye");
--solutions--
function palindrome(str) {
var string = str.toLowerCase().split(/[^A-Za-z0-9]/gi).join('');
var aux = string.split('');
if (aux.join('') === aux.reverse().join('')){
return true;
}
return false;
}