Session 2

Take home excercise

Write a function that accepts a single string-argument and returns 'true' if the string is a palindrome and 'false' if it is not - use the above examples (and any others you create/find) as test data.

In attempting this task, consider the question of 'scalability': what solution would work best with really massive strings (like the entire text of War and Peace, expressed as a single character sequence)? Naive solutions fail to address this point.

let Str = 'anna';
let Input = Str.split('');
let Reverse = Input.slice().reverse();
// console.log (Array)
// console.log (Reverse)
function Pallindrome() {
if (Input == Reverse.toString()) {
console.log('true');
} else {
console.log('false');
}
}
Pallindrome();

My solution clearly fails to address the "naive" part of the task that Richard was talking about. It was the "logical" way my brain worked to solve the problem. Or rather, the way I started to think about it when I was googling and looking at how to find answers to my questions.