-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise27.html
More file actions
32 lines (28 loc) · 1.12 KB
/
Exercise27.html
File metadata and controls
32 lines (28 loc) · 1.12 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Exercise 27</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<script type="text/javascript">
// Crear un programa que contenga una función esPalindromo(texto) y determine si dicho texto es un palíndromo.
function esPalindromo(text) {
let textWithoutSpacing = text.replace(/\s/g, "");
let textReverse = textWithoutSpacing.split('').reverse();
let result;
if(textWithoutSpacing === textReverse.join('')) {
result = 'El texto ingresado es Palíndromo';
}else {
result = 'El texto ingresado no es Palíndromo';
}
return result;
}
let text = prompt('Ingresa un texto, y te digo si es palíndromo')
alert(esPalindromo(text));
</script>
</body>
</html>