From bf07c508df88597226acaca0d9d3a3b4174292fc Mon Sep 17 00:00:00 2001 From: sowmya Date: Fri, 5 May 2017 01:07:29 +0530 Subject: [PATCH 1/3] bonus function is added --- Day-2/salary-updater.js | 2 ++ Day-2/salary-updater.ts | 2 ++ Day-2/salary-upgrader.js | 7 ++++++- Day-2/salary-upgrader.ts | 7 ++++++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Day-2/salary-updater.js b/Day-2/salary-updater.js index a3a77b9..6c246f6 100644 --- a/Day-2/salary-updater.js +++ b/Day-2/salary-updater.js @@ -8,3 +8,5 @@ org.printEmployeesInfo(); var salaryUpgrader = new salary_upgrader_1.SalaryUpgrader(); salaryUpgrader.incrementSalary(10, org.getEmployeeList()); org.printEmployeesInfo(); +salaryUpgrader.addBonus(org.getEmployeeList()); +org.printEmployeesInfo(); diff --git a/Day-2/salary-updater.ts b/Day-2/salary-updater.ts index 159e761..928ff46 100644 --- a/Day-2/salary-updater.ts +++ b/Day-2/salary-updater.ts @@ -7,4 +7,6 @@ org.printEmployeesInfo(); let salaryUpgrader: SalaryUpgrader = new SalaryUpgrader(); salaryUpgrader.incrementSalary(10, org.getEmployeeList()); org.printEmployeesInfo(); +salaryUpgrader.addBonus(org.getEmployeeList()); +org.printEmployeesInfo(); diff --git a/Day-2/salary-upgrader.js b/Day-2/salary-upgrader.js index cc82f12..e6f6b61 100644 --- a/Day-2/salary-upgrader.js +++ b/Day-2/salary-upgrader.js @@ -10,7 +10,12 @@ var SalaryUpgrader = (function () { emp.updateSalary(newSalary); }); }; - SalaryUpgrader.prototype.addBonus = function () { + SalaryUpgrader.prototype.addBonus = function (empList) { + empList.map(function (emp) { + var origSalary = emp.getSalary(); + var bonusSalary = (origSalary < 5000 ? origSalary + 500 : origSalary); + emp.updateSalary(bonusSalary); + }); }; return SalaryUpgrader; }()); diff --git a/Day-2/salary-upgrader.ts b/Day-2/salary-upgrader.ts index 7d66855..0dc350d 100644 --- a/Day-2/salary-upgrader.ts +++ b/Day-2/salary-upgrader.ts @@ -10,7 +10,12 @@ export class SalaryUpgrader { emp.updateSalary(newSalary); }) } - addBonus() { + addBonus(empList: Employee[]) { + empList.map(emp => { + let origSalary = emp.getSalary(); + let bonusSalary = (origSalary<5000 ? origSalary+500 : origSalary); + emp.updateSalary(bonusSalary); + }) } } \ No newline at end of file From 74991ab6563adc4f95711c31c3d10fbb6a874541 Mon Sep 17 00:00:00 2001 From: Sowmya Thallapragada Date: Tue, 22 Aug 2017 19:19:24 +0530 Subject: [PATCH 2/3] solutions to day1" --- Day-1/Day-1_Solutions/10th/tenth.html | 15 +++++++++ Day-1/Day-1_Solutions/10th/tenth.js | 27 ++++++++++++++++ .../1factorial/factorial.html.html | 13 ++++++++ Day-1/Day-1_Solutions/1factorial/factorial.js | 10 ++++++ .../2sum of n nums/second.html | 17 ++++++++++ .../Day-1_Solutions/2sum of n nums/second.js | 11 +++++++ Day-1/Day-1_Solutions/3rd/third.html | 14 ++++++++ Day-1/Day-1_Solutions/3rd/third.js | 20 ++++++++++++ Day-1/Day-1_Solutions/4th/fourth.html | 14 ++++++++ Day-1/Day-1_Solutions/4th/fourth.js | 13 ++++++++ Day-1/Day-1_Solutions/5th/five.html | 14 ++++++++ Day-1/Day-1_Solutions/5th/five.js | 21 ++++++++++++ .../6array of integers/sixth.html | 15 +++++++++ .../6array of integers/sixth.js | 20 ++++++++++++ Day-1/Day-1_Solutions/7th/seven.html | 13 ++++++++ Day-1/Day-1_Solutions/7th/seven.js | 32 +++++++++++++++++++ Day-1/Day-1_Solutions/8th/eigth.html | 12 +++++++ Day-1/Day-1_Solutions/8th/eigth.js | 6 ++++ Day-1/Day-1_Solutions/9th/nine.html | 16 ++++++++++ Day-1/Day-1_Solutions/9th/nine.js | 18 +++++++++++ 20 files changed, 321 insertions(+) create mode 100644 Day-1/Day-1_Solutions/10th/tenth.html create mode 100644 Day-1/Day-1_Solutions/10th/tenth.js create mode 100644 Day-1/Day-1_Solutions/1factorial/factorial.html.html create mode 100644 Day-1/Day-1_Solutions/1factorial/factorial.js create mode 100644 Day-1/Day-1_Solutions/2sum of n nums/second.html create mode 100644 Day-1/Day-1_Solutions/2sum of n nums/second.js create mode 100644 Day-1/Day-1_Solutions/3rd/third.html create mode 100644 Day-1/Day-1_Solutions/3rd/third.js create mode 100644 Day-1/Day-1_Solutions/4th/fourth.html create mode 100644 Day-1/Day-1_Solutions/4th/fourth.js create mode 100644 Day-1/Day-1_Solutions/5th/five.html create mode 100644 Day-1/Day-1_Solutions/5th/five.js create mode 100644 Day-1/Day-1_Solutions/6array of integers/sixth.html create mode 100644 Day-1/Day-1_Solutions/6array of integers/sixth.js create mode 100644 Day-1/Day-1_Solutions/7th/seven.html create mode 100644 Day-1/Day-1_Solutions/7th/seven.js create mode 100644 Day-1/Day-1_Solutions/8th/eigth.html create mode 100644 Day-1/Day-1_Solutions/8th/eigth.js create mode 100644 Day-1/Day-1_Solutions/9th/nine.html create mode 100644 Day-1/Day-1_Solutions/9th/nine.js diff --git a/Day-1/Day-1_Solutions/10th/tenth.html b/Day-1/Day-1_Solutions/10th/tenth.html new file mode 100644 index 0000000..59d2601 --- /dev/null +++ b/Day-1/Day-1_Solutions/10th/tenth.html @@ -0,0 +1,15 @@ + + + + + + + +

Javascript Palindrome in an Array

+The array is + +

+ + + + diff --git a/Day-1/Day-1_Solutions/10th/tenth.js b/Day-1/Day-1_Solutions/10th/tenth.js new file mode 100644 index 0000000..c0777ed --- /dev/null +++ b/Day-1/Day-1_Solutions/10th/tenth.js @@ -0,0 +1,27 @@ + + +var array= ["Malayalam", "tree", "boat", "civic", "melt", "level"]; +var temp; + +function palindrome(){ +console.log(array[0]); +for(var i=0;i<=array.length;i++){ + + console.log(array[i]); +/* remove special characters, spaces and make lowercase*/ +//var removeChar = array[i].replace(/[^A-Z0-9]/ig, "").toLowerCase(); + +/* reverse removeChar for comparison*/ +//var checkPalindrome = removeChar.split('').reverse().join(''); + +/* Check to see if myString is a Palindrome*/ +//if(removeChar === checkPalindrome){ + + document.getElementById("abc").innerHTML="
"+ array[i] + " is a Palindrome
"; +//}else{ + + //document.getElementById("abc").innerHTML="
" + array[i] + " is not a Palindrome
"; +} +} +} + diff --git a/Day-1/Day-1_Solutions/1factorial/factorial.html.html b/Day-1/Day-1_Solutions/1factorial/factorial.html.html new file mode 100644 index 0000000..0ac9102 --- /dev/null +++ b/Day-1/Day-1_Solutions/1factorial/factorial.html.html @@ -0,0 +1,13 @@ + + + +factorial + + + +Enter a positive Input:
+

+Output: + + + \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/1factorial/factorial.js b/Day-1/Day-1_Solutions/1factorial/factorial.js new file mode 100644 index 0000000..c9d8e97 --- /dev/null +++ b/Day-1/Day-1_Solutions/1factorial/factorial.js @@ -0,0 +1,10 @@ +function factorial(){ + var fact=1, num=1,i; + num = document.getElementById("num").value; + for(i=1;i<=num;i++){ + fact = fact*i; + + } + document.getElementById("final").value = fact; + +} \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/2sum of n nums/second.html b/Day-1/Day-1_Solutions/2sum of n nums/second.html new file mode 100644 index 0000000..cc881ca --- /dev/null +++ b/Day-1/Day-1_Solutions/2sum of n nums/second.html @@ -0,0 +1,17 @@ + + + + + + +

Sum of first n natural numbers

+Enter num +Value: + + + + + + + + \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/2sum of n nums/second.js b/Day-1/Day-1_Solutions/2sum of n nums/second.js new file mode 100644 index 0000000..ecac4d3 --- /dev/null +++ b/Day-1/Day-1_Solutions/2sum of n nums/second.js @@ -0,0 +1,11 @@ +function total(){ + var num = 1, total=0; + num = document.getElementById("num").value; + //total = (num*(num+1))/2; + for(var i=1;i<=num;i++){ + total = total+i; + } + document.getElementById("val").value = total; + + +} \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/3rd/third.html b/Day-1/Day-1_Solutions/3rd/third.html new file mode 100644 index 0000000..c4675a5 --- /dev/null +++ b/Day-1/Day-1_Solutions/3rd/third.html @@ -0,0 +1,14 @@ + + + + + + + +

To find the sum of all the multiples of 3 or 5 below 1000

+ + + + + + \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/3rd/third.js b/Day-1/Day-1_Solutions/3rd/third.js new file mode 100644 index 0000000..79214b7 --- /dev/null +++ b/Day-1/Day-1_Solutions/3rd/third.js @@ -0,0 +1,20 @@ +function PrintStr(){ +var temp1=0,temp2=0,temp3=0,tot; +for(var i=1;i<=1000;i++){ + if(i%3==0 && i%5!=0){ + temp1= temp1+i; + } + else if(i%3!=0 && i%5==0){ + temp2= temp2+i; + } + else if(i%3==0 && i%5==0){ + temp3= temp3+i; + } + else{ + continue; + } +} +tot = temp1+temp2+temp3; +document.write("the sum of all the multiples of 3 or 5 below 1000 is"+ tot); + +} \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/4th/fourth.html b/Day-1/Day-1_Solutions/4th/fourth.html new file mode 100644 index 0000000..3997ddf --- /dev/null +++ b/Day-1/Day-1_Solutions/4th/fourth.html @@ -0,0 +1,14 @@ + + + + + + + +Enter a number: + + + + + + \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/4th/fourth.js b/Day-1/Day-1_Solutions/4th/fourth.js new file mode 100644 index 0000000..234ca12 --- /dev/null +++ b/Day-1/Day-1_Solutions/4th/fourth.js @@ -0,0 +1,13 @@ + +function findPower(){ + +var N = document.getElementById("num").value; +var v = 1; + +while (v <= N) + v *= 2 +v = v/2 + +console.log(v); +console.log(Math.log(v)); +} \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/5th/five.html b/Day-1/Day-1_Solutions/5th/five.html new file mode 100644 index 0000000..fdb1898 --- /dev/null +++ b/Day-1/Day-1_Solutions/5th/five.html @@ -0,0 +1,14 @@ + + + + + + + +Enter a number: + + + + + + \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/5th/five.js b/Day-1/Day-1_Solutions/5th/five.js new file mode 100644 index 0000000..38779ec --- /dev/null +++ b/Day-1/Day-1_Solutions/5th/five.js @@ -0,0 +1,21 @@ +function PrintStr(){ + +var num =1; +num = document.getElementById("last").value; +console.log(num); +for(i=1;i<=num;i++){ + if(i%3==0&&i%5!=0){ + document.write("Fizz,"); + } + else if(i%5==0&&i%3!=0){ + document.write("Buzz,"); + } + else if(i%5==0&&i%3!=0){ + document.write("FizzBuzz,"); + } + else{ + document.write(i+","); + } + +} +} \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/6array of integers/sixth.html b/Day-1/Day-1_Solutions/6array of integers/sixth.html new file mode 100644 index 0000000..5b54c82 --- /dev/null +++ b/Day-1/Day-1_Solutions/6array of integers/sixth.html @@ -0,0 +1,15 @@ + + + + + + +Enter a sum: +

The array is: [1, 4, 3, 5, 4, 6, 7, 8, 3]

+ + + + + + + \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/6array of integers/sixth.js b/Day-1/Day-1_Solutions/6array of integers/sixth.js new file mode 100644 index 0000000..ca8ccf1 --- /dev/null +++ b/Day-1/Day-1_Solutions/6array of integers/sixth.js @@ -0,0 +1,20 @@ +function findPairs(){ +var array = [1, 4, 3, 5, 4, 6, 7, 8, 3]; +var sum=0,i,temp=0; +sum= document.getElementById("sum").value; +for(i=0;i"); + temp++; + + } + + + } + +} +if(temp==0) +document.write("no such value as"+ sum); + +} diff --git a/Day-1/Day-1_Solutions/7th/seven.html b/Day-1/Day-1_Solutions/7th/seven.html new file mode 100644 index 0000000..bddf459 --- /dev/null +++ b/Day-1/Day-1_Solutions/7th/seven.html @@ -0,0 +1,13 @@ + + + + + + +

The array is [1, 2, 3, 5, 8, 4, 7, 9, 1, 4, 12, 5, 6, 5, 2, 1, 0, 8, 1]

+ + + + + + \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/7th/seven.js b/Day-1/Day-1_Solutions/7th/seven.js new file mode 100644 index 0000000..cad559d --- /dev/null +++ b/Day-1/Day-1_Solutions/7th/seven.js @@ -0,0 +1,32 @@ +/*function getRepeatedVal(){ + var array = [1, 2, 3, 5, 8, 4, 7, 9, 1, 4, 12, 5, 6, 5, 2, 1, 0, 8, 1]; + var repeatedVal =[]; + for(var i=0;i + + + + + +

to print sum of all values in an object

+ + + + + \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/8th/eigth.js b/Day-1/Day-1_Solutions/8th/eigth.js new file mode 100644 index 0000000..d47176c --- /dev/null +++ b/Day-1/Day-1_Solutions/8th/eigth.js @@ -0,0 +1,6 @@ +var obj = {"Rick": 85, "Amit": 42, "George": 53, "Tanya": 60, "Linda": 35}; +var sum = 0; +for(var key in obj){ + sum += parseInt(obj[key]); +} +alert("the sum of all values in object:"+ sum); \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/9th/nine.html b/Day-1/Day-1_Solutions/9th/nine.html new file mode 100644 index 0000000..94e2343 --- /dev/null +++ b/Day-1/Day-1_Solutions/9th/nine.html @@ -0,0 +1,16 @@ + + + + + + + +

Javascript Palindrome Checking Function

+Enter a string to check: + +

+ + + + + diff --git a/Day-1/Day-1_Solutions/9th/nine.js b/Day-1/Day-1_Solutions/9th/nine.js new file mode 100644 index 0000000..0a4952f --- /dev/null +++ b/Day-1/Day-1_Solutions/9th/nine.js @@ -0,0 +1,18 @@ +function palindrome(myString){ + +/* remove special characters, spaces and make lowercase*/ +var removeChar = myString.replace(/[^A-Z0-9]/ig, "").toLowerCase(); + +/* reverse removeChar for comparison*/ +var checkPalindrome = removeChar.split('').reverse().join(''); + +/* Check to see if myString is a Palindrome*/ +if(removeChar === checkPalindrome){ + + document.getElementById("abc").innerHTML="
"+ myString + " is a Palindrome
"; +}else{ + + document.getElementById("abc").innerHTML="
" + myString + " is not a Palindrome
"; +} +} + From 1ceef215bd166158f48ae91ed8aee31eca086cd8 Mon Sep 17 00:00:00 2001 From: sowmya Date: Tue, 22 Aug 2017 21:10:12 +0530 Subject: [PATCH 3/3] text file changed --- Day-1/Day-1_Solutions/7th/seven.html | 4 - Day-1/Day-1_Solutions/8th/eigth.html | 3 - Day-1/coding-questions.txt | 273 ++++++++++++++++++++++++++- 3 files changed, 272 insertions(+), 8 deletions(-) diff --git a/Day-1/Day-1_Solutions/7th/seven.html b/Day-1/Day-1_Solutions/7th/seven.html index bddf459..3de2bd2 100644 --- a/Day-1/Day-1_Solutions/7th/seven.html +++ b/Day-1/Day-1_Solutions/7th/seven.html @@ -5,9 +5,5 @@

The array is [1, 2, 3, 5, 8, 4, 7, 9, 1, 4, 12, 5, 6, 5, 2, 1, 0, 8, 1]

- - - - \ No newline at end of file diff --git a/Day-1/Day-1_Solutions/8th/eigth.html b/Day-1/Day-1_Solutions/8th/eigth.html index ccb474a..706d6f0 100644 --- a/Day-1/Day-1_Solutions/8th/eigth.html +++ b/Day-1/Day-1_Solutions/8th/eigth.html @@ -5,8 +5,5 @@

to print sum of all values in an object

- - - \ No newline at end of file diff --git a/Day-1/coding-questions.txt b/Day-1/coding-questions.txt index b2fe6a4..db282bf 100644 --- a/Day-1/coding-questions.txt +++ b/Day-1/coding-questions.txt @@ -1,24 +1,160 @@ 1) Find the factorial of a given number. If the given number is 5, factorial is computed as 5*4*3*2*1 which equates to 120. Please write a program which would find the factorial for any number. Input: 5 Output: 120 +HTML: + + + +factorial + + + +Enter a positive Input:
+

+Output: + + + +JS: +function factorial(){ + var fact=1, num=1,i; + num = document.getElementById("num").value; + for(i=1;i<=num;i++){ + fact = fact*i; + + } + document.getElementById("final").value = fact; + +} 2) If we list all the natural numbers till 10 i.e. 1 to 10, the sum of these numbers is 55. Find the sum of the first 500 natural numbers. Input: 10 Output: 45 +HTML: + + + + + + +

Sum of first n natural numbers

+Enter num +Value: + +JS: +function total(){ + var num = 1, total=0; + num = document.getElementById("num").value; + //total = (num*(num+1))/2; + for(var i=1;i<=num;i++){ + total = total+i; + } + document.getElementById("val").value = total; +} + + 3) If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. Input: 10 Output: 23 +HTML: + + + + + + +

To find the sum of all the multiples of 3 or 5 below 1000

+ + + +JS: +function PrintStr(){ +var temp1=0,temp2=0,temp3=0,tot; +for(var i=1;i<=1000;i++){ + if(i%3==0 && i%5!=0){ + temp1= temp1+i; + } + else if(i%3!=0 && i%5==0){ + temp2= temp2+i; + } + else if(i%3==0 && i%5==0){ + temp3= temp3+i; + } + else{ + continue; + } +} +tot = temp1+temp2+temp3; +document.write("the sum of all the multiples of 3 or 5 below 1000 is"+ tot); + +} 4) Given a number, find the closest power of 2 which is less than or equal to the number. If the number is 36, your answer should be 5 as 32 (2^5) is the closest power less than 36. Input: 36 Output: 5 +HTML: + + + + + + +Enter a number: + + + + +JS: +function findPower(){ +var N = document.getElementById("num").value; +var v = 1; +while (v <= N) + v *= 2 +v = v/2 + console.log(v); +console.log(Math.log(v)); +} 5) Write a program that prints the numbers from 1 to N. But, for multiples of three, print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”. Input: N = 17 Output: 1,2,Fizz,4,Buzz,Fizz,7,8,Fizz,Buzz,11,Fizz,13,14,FizzBuzz,16,17 +HTML: + + + + + + +Enter a number: + + + + +JS: +function PrintStr(){ + +var num =1; +num = document.getElementById("last").value; +console.log(num); +for(i=1;i<=num;i++){ + if(i%3==0&&i%5!=0){ + document.write("Fizz,"); + } + else if(i%5==0&&i%3!=0){ + document.write("Buzz,"); + } + else if(i%5==0&&i%3!=0){ + document.write("FizzBuzz,"); + } + else{ + document.write(i+","); + } + +} +} 6) Find all pairs in array of integers whose sum is equal to given number. Input: sum = 8 @@ -28,6 +164,25 @@ Output: "4, 4" "3, 5" "5, 3" +HTML: +JS: +function findPairs(){ +var array = [1, 4, 3, 5, 4, 6, 7, 8, 3]; +var sum=0,i,temp=0; +sum= document.getElementById("sum").value; +for(i=0;i"); + temp++; + + } + } + +} +if(temp==0) +document.write("no such value as"+ sum); +} 7) Given an array print all the numbers that are repeating in it. Input: [1, 2, 3, 5, 8, 4, 7, 9, 1, 4, 12, 5, 6, 5, 2, 1, 0, 8, 1] @@ -38,20 +193,136 @@ Output: "8" "4" Note: The final order of output need not be the same as above. +HTML: + + + + + + +

The array is [1, 2, 3, 5, 8, 4, 7, 9, 1, 4, 12, 5, 6, 5, 2, 1, 0, 8, 1]

+ + +JS: +var numbers = [1, 2, 3, 5, 8, 4, 7, 9, 1, 4, 12, 5, 6, 5, 2, 1, 0, 8, 1]; +var duplicates = []; +function goThroughArray(arr) { + for(var i = 0;i < arr.length; i++) { + if((arr.lastIndexOf(arr[i]) != i) && + (duplicates.indexOf(arr[i]) == -1)) { + duplicates += arr[i]; + } + } + return duplicates; +} + +alert(goThroughArray(numbers)); 8) Given an object, containing names as keys and amount_paid by each of them as values, write a function that takes such an object as input and calculates the total sum paid by them together. Input: {"Rick": 85, "Amit": 42, "George": 53, "Tanya": 60, "Linda": 35} Output: 275 - +HTML: + + + + + + +

to print sum of all values in an object

+ + +JS: +var obj = {"Rick": 85, "Amit": 42, "George": 53, "Tanya": 60, "Linda": 35}; +var sum = 0; +for(var key in obj){ + sum += parseInt(obj[key]); +} +alert("the sum of all values in object:"+ sum); 9) Write a function to check whether a given string is a palindrome or not. Input: "Mom" Output: true Input: "sister" Output: false +HTML: + + + + + + +

Javascript Palindrome Checking Function

+Enter a string to check: + +

+ + + +JS: +function palindrome(myString){ + +/* remove special characters, spaces and make lowercase*/ +var removeChar = myString.replace(/[^A-Z0-9]/ig, "").toLowerCase(); + +/* reverse removeChar for comparison*/ +var checkPalindrome = removeChar.split('').reverse().join(''); + +/* Check to see if myString is a Palindrome*/ +if(removeChar === checkPalindrome){ + + document.getElementById("abc").innerHTML="
"+ myString + " is a Palindrome
"; +}else{ + + document.getElementById("abc").innerHTML="
" + myString + " is not a Palindrome
"; +} +} + + 10) Write a function that takes an array of words and returns an array containing only of palindromes. Note: Use the above function to check if a word is a palindrome. Input: ["Malayalam", "tree", "boat", "civic", "melt", "level"] Output: ["Malayalam", "civic", "level"] +HTML: + + + + + + + +

Javascript Palindrome in an Array

+The array is + +

+ + + +JS: +var array= ["Malayalam", "tree", "boat", "civic", "melt", "level"]; +var temp; + +function palindrome(){ +console.log(array[0]); +for(var i=0;i<=array.length;i++){ + + console.log(array[i]); +/* remove special characters, spaces and make lowercase*/ +//var removeChar = array[i].replace(/[^A-Z0-9]/ig, "").toLowerCase(); + +/* reverse removeChar for comparison*/ +//var checkPalindrome = removeChar.split('').reverse().join(''); + +/* Check to see if myString is a Palindrome*/ +//if(removeChar === checkPalindrome){ + + document.getElementById("abc").innerHTML="
"+ array[i] + " is a Palindrome
"; +//}else{ + + //document.getElementById("abc").innerHTML="
" + array[i] + " is not a Palindrome
"; +} +} +} + +