-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.js
More file actions
45 lines (38 loc) · 1.24 KB
/
Copy pathstrings.js
File metadata and controls
45 lines (38 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var textInput = document.getElementById("text");
var button = document.getElementById("button");
var output = document.getElementById("ouput");
textInput.addEventListener("keypress", pressed);
button.addEventListener("click", motherFunction);
function pressed(enterPress) {
// console.log(enterPress.keyCode);
if (enterPress.keyCode > 64 && enterPress.keyCode < 123) {
return true;
} else {
alert("Letters only, plz")
//how to keep numbers from still being registered?
};
}
var alphaba;
var reversed;
function reversal(s) {
reversed = s.split("").reverse().join("");
console.log("reversal", reversed);
}
function alphabits(s) {
alphaba = s.split("").sort().join("");
console.log("alphaba", alphaba)
}
function palindrome(s) {
var flipped = s.split("").reverse().join("");
var unflipped = s;
if (flipped === unflipped) {
output.innerHTML = "<h4>Your string <u>is</u> a palindrome.</h4>";
} else {
output.innerHTML = "<h4>Your string is <u>NOT</u> a palindrome.</h4>";
}}
function motherFunction() {
reversal(textInput.value);
alphabits(textInput.value);
palindrome(textInput.value);
ouput.innerHTML += "<h3>" + alphaba + "<br>" + reversed + "</h3><br>";
}