Array Functions
by Carlos Ng
HTML
<h3>Array Functions</h3>
<h4>Tasks:</h4>
<ol>
<li>
Ask the user for a string, either a word or a phrase.</li>
<li>
Using only methods of the Array object to determine if the string is a Palindrome (words or phrases that can be read the same backwards as forwards). You can check at <a href="http://www.w3schools.com/jsref/">W3Schools</a> for Array functions.
</li>
<li>
Your goal is to determine if the user's input string is a palindrom word or phase, by printing both words (the original string and reverse) at the console.
</li>
</ol>
Your console should look like this:
<li>Original string: Civic</li>
<li>Reverse string: civiC</li>
JavaScript
//First you ask the user for the input word or phase
var input = prompt("Please enter a word of a phrase?");
//The new string becomes a new array
var splitString = input.split("");
//The array is reverse
var reverseArray = splitString.reverse();
//After the array is reversed, then it is joined
var joinArray = reverseArray.join("");
//You print both, the original string and the reverse string on the console
console.log("Original tring: "+ input)
console.log("Reverse string: "+ joinArray)