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]
2 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]2 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
"Create a Matlab Scrapt that will take the a Matrix A and Matrix B (of AX=B), then calculate the Determinant of Matrix A, Invers
prohojiy [21]

Answer:

see explaination

Explanation:

function [] =

inverse(A,B)

da = det(A);

disp("The det of A is");

disp(da);

inva = inv(A);

disp("The inverse of A is");

disp(inva);

x = inva*B;

disp("The value of X is");

disp(x);

rk = rank(A);

disp("The rank of X is");

disp(rk);

Di = eig(A);

disp("The eigen values of A is");

disp(Di);

[V,Di] = eig(A);

disp("The eigen vectors of A are (Each column represents one column vector)");

disp(V);

end

A = [1,2;4,5];

B = [1,2;4,5];

inverse(A,B);

%ab = [num2str(t)," ",num2str(dx)," ",num2str(dy)];

%disp(ab);

4 0
2 years ago
Which is the best and quickest way for Jim to share his scuba experience with everyone?
iren [92.7K]
Option B

Blog is the best way
7 0
3 years ago
HELP ME PLZZ FFFAAASSSTTTT
Dahasolnce [82]
The answer has to be A because we you get your licensed suspended you are un able to drive for a while Intel you take the test again and or pay a fine
6 0
2 years ago
Read 2 more answers
While the zyLab platform can be used without training, a bit of training may help some students avoid common issues. The assignm
slamgirl [31]

Answer:

hello please join the

Explanation:

you should join the green alien squad in gta

4 0
3 years ago
The Zoom slider will allow users to _____.
NeX [460]
The Zoom slider will allow users to change the way the document appears on the screen
3 0
2 years ago
Read 2 more answers
Other questions:
  • Regulatory control limits the activities of an organization in compliance with the organization's policies. True False
    14·2 answers
  • You can create a ____ partition to hold files that are created temporarily, such as files used for printing documents (spool fil
    11·1 answer
  • How to burn mp3 on dvd
    13·2 answers
  • A car holds 16 gallons of gasoline and can travel 312 miles before refueling. Write aC++ program that calculates the number of m
    9·1 answer
  • If you are viewing a webpage with customized or regenerated content, such as updated stock quotes, what type of webpage are you
    14·1 answer
  • Which best describes the differences between a resume and a CV?
    13·2 answers
  • ___signs tell you what you can or can't do, and what you must do ?
    5·2 answers
  • State True or False: 1. Application software can run without the presence of system software. 2. . A language processor translat
    14·1 answer
  • FIRST TO Answer for free brainlest. GOG GOGOGO
    6·1 answer
  • Why is a Quality assurance tester needed on a software development team?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!