Skip to content

Commit 229a784

Browse files
authored
Create script.js
1 parent ca20370 commit 229a784

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Palindrome_Checker/script.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function palindrome(){
2+
var num = document.querySelector(".inputbox").value.toUpperCase();
3+
// The code that organises and checks if it is a palindrome
4+
var alpha = num
5+
.split('')
6+
.reverse()
7+
.join('');
8+
// This is an if statement for when the letters are less than or equal to 2 and an else if statement for when the letters are greater than or equal to 3 and whether or not num is strictly equal to alpha
9+
if(num.length<=2){
10+
document.querySelector(".list").innerHTML = "TYPE MORE VALUES"
11+
}else if(num.length>=3 && num===alpha){
12+
document.querySelector(".list").innerHTML =`<b>"${num}"</b> is a palindrome!`
13+
}else{
14+
document.querySelector(".list").innerHTML =`<b>"${num}"</b> is not a palindrome!`
15+
}
16+
}

0 commit comments

Comments
 (0)