1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
atroni [7]
3 years ago
6

4.Write a JavaScript program to find if a given word is a palindrome or not. Word is given by user via prompt command.

Computers and Technology
1 answer:
ad-work [718]3 years ago
4 0

Answer:

Here is the JavaScript program:

function Palindrome(word) {

   return word == word.toLowerCase().split("").reverse().join("") ? true : false; }

inputWord = prompt("Enter a word to check its if its palindrome or not?");  

alert(Palindrome(inputWord));

Explanation:

The function Palindrome takes a word as argument.

 return word == word.toLowerCase().split("").reverse().join("") ? true : false; }

This statement first converts the word, which is a string to lower case letters using toLowerCase() method. Next split() method splits the word string into an array of strings, then reverse() method reverses the this array and join() method joins all the elements of the array back to the string. At last the conditional statement checks if the resultant string (reverse of word) is equal  to the original word (that was input by user). If both the word and its reverse are equal/same then the program outputs true otherwise returns false.

inputWord = prompt("Enter a word to check its if its palindrome or not?");   statement uses prompt command to take input from the user. inputWord holds the word that user enters.

alert(Palindrome(inputWord)); statement calls Palindrome() method by passing the inputWord (word entered by user) to check if the input word is a palindrome or not. alert() method displays an alert box ( a message) with true if the inputWord is a palindrome otherwise it displays false.

You might be interested in
Do you want my hero academia?<br><br><br><br><br><br> if so, who's your favorite character :&gt;
VMariaS [17]

Shoto Todoroki and Katsuki Bakugo

4 0
3 years ago
Read 2 more answers
Read the excerpt from Act 111, scene iii of Romeo and Juliet. Which is the best paraphrase of this dialogue
Rufina [12.5K]
I think that D is the answer
8 0
3 years ago
What can be designed to create annoying glitches or destroy data
Katen [24]

I guess the best answer is Virus.

Virus is a malicious computer program that is designed to create annoying glitches or destroy data.

3 0
3 years ago
Read 2 more answers
Which three items might appear on the project plan when discussing an upcoming website with a design team? (Choose three)
stepladder [879]
Planning and analysis, due dates and payment details .
5 0
3 years ago
Develop a multithreaded app that can find the integer in the range 1 to 10000 that has the largest number of divisors. It should
skelet666 [1.2K]

Answer:

its not letting me Write out the code so here are screenshots

Explanation:

5 0
4 years ago
Other questions:
  • Create an enumeration named Month that holds values for the months of the year. With JANUARY equal to 1, FEBRUARY equal to 2, an
    13·1 answer
  • Stella is a bank executive. She is preparing a spreadsheet on the loan repayment schedules of customers. Which function can she
    12·1 answer
  • How does kinetic energy affect the stopping distance of a small vehicle compared to a large vehicle?
    14·2 answers
  • Jack is going for a safari. Which camera should he take with him and why?
    6·1 answer
  • Q13. On which option do you click to
    12·1 answer
  • Which of the following does NOT describe the characteristics of cyberbullying?
    15·2 answers
  • Which is the fastest memory in computer​
    9·2 answers
  • Why isn't image display working on wacom tablet.
    8·1 answer
  • What is the IT professional testing?
    15·1 answer
  • What type of attack uses many systems to flood the resources of a target, thus making the target unavailable?.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!