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
Which of the following best explains how algorithms that run on a computer can be used to solve problems?
timama [110]

The statement which best explains how algorithms running on a computer can be used to solve problems is; D. Some problems cannot be solved by an algorithm.

<h3>What is an algorithm?</h3>

An algorithm is simply a standard formula or procedures which is made up of a set of finite steps and instructions that must be executed on a computer, so as to proffer solutions to a problem or solve a problem under appropriate conditions.

However, it should be noted that it is not all problems that can be solved by an algorithm, especially because the required parameters and appropriate conditions are not feasible or met.

Read more on algorithm here: brainly.com/question/24793921

7 0
2 years ago
How do i use a computer (i'm 99999 years old)
AlekseyPX

Answer:

grandma?

Explanation:

is it you?

6 0
3 years ago
Read 2 more answers
Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
oksano4ka [1.4K]

Answer:

The program in Python is as follows:

def get_user_values():

   user_values = []

   n = int(input())

   for i in range(n+1):

       inp = int(input())

       user_values.append(inp)

   output_ints_less_than_or_equal_to_threshold(user_values,user_values[n])

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

   for i in user_values:

       if i <= upper_threshold:

           print(i,end=" ")

           

get_user_values()

Explanation:

This defins the get_user_values() method; it receives no parameter

def get_user_values():

This initializes user_values list

   user_values = []

This gets the number of inputs

   n = int(input())

This loop is repeated n+1 times to get all inputs and the upper threshold

<em>    for i in range(n+1):</em>

<em>        inp = int(input())</em>

<em>        user_values.append(inp)</em>

This passes the list and the upper threshold to the output..... list  output_ints_less_than_or_equal_to_threshold(user_values,user_values[n])

This defines the output.... list

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

This iterates through the list

   for i in user_values:

If current element is less or equal to the upper threshold, the element is printed

<em>        if i <= upper_threshold:</em>

<em>            print(i,end=" ")</em>

The main method begins here where the get_user_values() method is called

get_user_values()

7 0
3 years ago
Which of the following transferable skills are generally the most look for in the it <br> field
kherson [118]

Answer:

mechanical, encryptions, communication, network admin, leadership, and teambuilding

Explanation:

6 0
3 years ago
The operating cost of driving include
blagie [28]
And what is the question?
4 0
3 years ago
Other questions:
  • Bit rate is a measure of how many bits of data are transmitted per second. Compared to videos with a higher bit rate, the same v
    13·1 answer
  • Weather satellites orbit Earth at an altitude of 1,400,000 meters. What is this altitude in kilometers?
    7·1 answer
  • A software programâs _________ indicates what can legally be done with that program.]
    5·1 answer
  • ​When preparing a representative sample from a list of 200 customers who complained about errors in their statements, a _____ co
    7·1 answer
  • Which of the following commands would you use to start the program Main with four strings? a. java Main arg0 arg1 arg2 arg3 b. j
    11·1 answer
  • What emphasizes extensive user involvement in the rapid and evolutionary construction of working prototypes of a system to accel
    15·1 answer
  • What steps might a company or organization need take in order to keep its digital data secure online?
    8·1 answer
  • What are 3 ways to select an entire document?
    15·1 answer
  • What is cyber ethics​
    10·2 answers
  • What is the console.log function for?​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!