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
"Switches break up _______________ domains and routers break up _____________ domains."
mel-nik [20]

Answer:

Switches break up collision domains and routers break up broadcast domains.

Explanation:

  • Collision domain depicts the part within a network where a collision can happen.
  • Collision occurs when two hosts transmit data packet at the same time within a network. Theses packets collide and the hosts have to resend the data after some time.
  • Too many collisions can result in slow traffic speed and can effect network performance.
  • So switches break up collision domains between the devices on a network and each port in a switch depicts a collision domain. This reduces the chance of packet collisions between the devices or hosts.
  • When data is to be sent to a host, the switch keeps that data frame and waits for availability of the destination host before sending the data frame.
  • Moreover full duplex switch mode there is not chance of collision as the transmitting path on one host is the receiving path on other host.
  • Broadcast domain contains all the hosts that can reach each other at the Data Link layer via broadcast.
  • Routers break up broadcast domains as routers contain separate broadcast domains for each interface.
  • Routers do not forward broadcasts from one broadcast domain to other and drop the packet when they detect a broadcast address.
4 0
3 years ago
How to tell if screen or screen protector is cracked?
beks73 [17]
You will feel the screen protector crack
6 0
3 years ago
Read 2 more answers
After selecting a cell in the data range, what are some ways to create a table? Check all that apply.
lana66690 [7]

Answer: the answer is B /E

3 0
3 years ago
Read 2 more answers
Double any element's value that is less than controlValue. Ex: If controlValue = 10, then dataPoints = {2, 12, 9, 20} becomes {4
Aleksandr [31]

Answer:

import java.util.Scanner;

public class StudentScores

{

public static void main(String[] args) {

 Scanner scnr = new Scanner(System.in);

 final int NUM_POINTS = 4;

 int[] dataPoints = new int[NUM_POINTS];

 int controlValue;

 int i;

 controlValue = scnr.nextInt();

 for (i = 0; i < dataPoints.length; ++i) {

     dataPoints[i] = scnr.nextInt();

 }

 for (i = 0; i < dataPoints.length; ++i) {

     System.out.print(dataPoints[i] + " ");

 }

 System.out.println();

 for (i = 0; i < dataPoints.length; ++i) {

     if(dataPoints[i] < controlValue){

         dataPoints[i] = dataPoints[i] * 2;          

     }

     System.out.print(dataPoints[i] + " ");

 }

}

}

Explanation:

*Added parts highligted.

After getting the control value and values for the array, you printed them.

Create a for loop that iterates through the dataPoints. Inside the loop, check if a value in dataPoints is smaller than the contorolValue. If it is, multiply that value with 2 and assign it to the dataPoints array. Print the elements of the dataPoints

5 0
3 years ago
Read 2 more answers
Which of the following could occur when both strong and weak ciphers are configured on a VPN concentrator? (Select TWO) A. An at
Elza [17]

Answer:

A. An attacker could potentially perform a downgrade attack.

E. The IPSec payload reverted to 16-bit sequence numbers.

Explanation:

When both strong and weak ciphers are configured on a VPN concentrator, the following are likely to occur;

An attacker could potentially perform a downgrade attack

The IPSec payload reverted to 16-bit sequence numbers

3 0
3 years ago
Other questions:
  • Which best explains what a credit score represents
    10·2 answers
  • In order to make burger a chef needs the following ingredients one piece of chicken meat 3 lettuce leaves 6 tomato slices Write
    8·1 answer
  • A program runs from start to finish, producing unexpected results, though no error message is received. What most likely occurre
    15·1 answer
  • Do word provides an undo button that can be used to cancel the most recent command or action
    13·1 answer
  • Use the dropdown menus to complete the sentences about Live Preview and the Mini Toolbar Live Preview is a convenient way to see
    15·2 answers
  • What is the major difference between the intranet and extranet?
    11·1 answer
  • HELP PLSSS I WILL MARK U!!!!
    10·2 answers
  • Question 7 (True/False Worth 3 points)
    8·2 answers
  • Write, in your own words, a one-two paragraph summary on the Running Queries and Reports tutorials. Apply critical thinking and
    10·1 answer
  • Hi am feeling really happy just passed a test after a lot of tries :-)
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!