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.
JSbasic/Bonus task for HW #4.html

26 lines
760 B
HTML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!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>