You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<title>Bonus task for HW #4. Prokhorova</title>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<script>
|
|
|
|
|
// Определить, является ли заданная строка (фраза) палиндромом
|
|
|
|
|
// var s = "А РОЗА УПАЛА НА ЛАПУ АЗОРА"; // палиндром
|
|
|
|
|
var arr = [];
|
|
|
|
|
var s = "А РОЗА УПАЛА НА ЛАПУ АЗОРА";
|
|
|
|
|
for (i = 0; i < s.length; i++) {
|
|
|
|
|
if (s[i] != " ") arr.push(s[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var arr1 = arr.reverse();
|
|
|
|
|
if (arr == arr1) {
|
|
|
|
|
console.log("This string is palendrom");
|
|
|
|
|
} else {
|
|
|
|
|
console.log("This string isn't palendrom");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|