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
solmaris [256]
4 years ago
5

Reverse Word Order: Write a program that reverses the order of the words in a given sentence. This program requires reversing th

e order of the words wherein the first and last words are swapped, followed by swapping the second word with the second to last word, followed by swapping the third word and the third to last words, and so on.
Computers and Technology
1 answer:
ElenaW [278]4 years ago
8 0

Answer:

function reverseArray(arr) {

   if (arr.length > 1) {

      arr = [arr[arr.length-1], ...reverseArray(arr.slice(1, -1)), arr[0]]

   }

   return arr;

}

function reverseSentence(sentence) {

   let words = reverseArray( sentence.split(" ") );

   return words.join(" ");

}

console.log( reverseSentence("The quick brown fox jumps over the lazy dog's back") );

console.log( reverseSentence("one two three") );

console.log( reverseSentence("one two") );

console.log( reverseSentence("Single") );

Explanation:

This is a solution in javascript leveraging several powerful constructs in that language, such as the spread operator.

You might be interested in
Access time is:________.
worty [1.4K]

Answer:

B) the time it takes for the required sector to position itself under the read/write head.

Explanation:

In Computer science, Access time is the time it takes for the required sector to position itself under the read/write head. It is usually measured in milliseconds.

It is the speed of the storage device.

5 0
4 years ago
Bruh why is everyone skipping my question!!!!!!!
DiKsa [7]

Answer:

What is your question?

Explanation:

7 0
3 years ago
SUWIDHA stands for .​
Anettt [7]
SUWIDHA stands for Single User-friendly Window Disposal & Help-line for Applicants.

Hope it helps
5 0
3 years ago
‘‘Anyone in the developed world can publish anything anytime, and the instant it is published, it is globally available and read
taurus [48]
The internet made huge changes to the way news and information were shared. While it was faster to use newspapers or magazines to spread information than it was to simply tell people, they were still very inefficient compared to today's technology. With the internet today, anyone can come online and learn about what's happening in the far corners of the world. Take your question, for instance. If there was no internet, you might have to post a notice somewhere, which could take days to answer. However, since you were able to post this on the internet, I'm able to answer it within five minutes of it being posted.
8 0
3 years ago
Please help me, I'll give you 15 points.
babunello [35]
Yep same, i don’t know what to write abt it is jus saying what to write and now what abt
4 0
3 years ago
Other questions:
  • Up to 10 people is a good guideline for the size of your study group.
    15·1 answer
  • A(n) monitoring vulnerability scanner is one that listens in on the network and determines vulnerable versions of both server an
    7·1 answer
  • I am in desperate need to graduate. Overloaded with tons of online homework to be completed before the school year ends. I don't
    5·1 answer
  • Which of the following means to find and fix errors in code?Which of the following means to find and fix errors in code?
    5·1 answer
  • In a well-developed paragraph - using domain-specific vocabulary and academic writing - address the following writing prompt:
    12·1 answer
  • ALSO PLZZZ HELP :P Suppose you are purchasing a game at a local retail store that comes on DVD. In order to install it on your l
    8·1 answer
  • Write a function named days() that determines the number of days since January 1, 1900 for any data passed as a structure. Use t
    5·1 answer
  • Click this link to view O*NET’s Work Activities section for Manicurists and Pedicurists. Note that common activities are listed
    8·1 answer
  • scheduling is approximated by predicting the next CPU burst with an exponential average of the measured lengths of previous CPU
    8·1 answer
  • Identify an internal user who uses product lifecycle management (plm) software and its data.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!