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]
3 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]3 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
Can i add ADSence on bangla content in blogsopt website?
Inga [223]

Answer:

I do not think you can! However, I am not sure since I mainly use Wix!!!

Explanation:

8 0
3 years ago
What should you follow when creating a newsletter ?
kenny6666 [7]
You should follow a set of directions

6 0
3 years ago
Read 2 more answers
What do you think about Naruto?
Natalka [10]

Answer:

AMAZINGGG

Explanation:

because it just is !!

3 0
2 years ago
Read 2 more answers
Which code segment results in "true" being returned if a number is odd? Replace "MISSING CONDITION" with the correct code segmen
seropon [69]

Answer:

b) num % 2 ==1;

Explanation:

Which code segment results in "true" being returned if a number is odd? Replace "MISSING CONDITION" with the correct code segment.

4 0
3 years ago
You need to increase the security of your linux system by finding and closing open ports. which of the following commands should
spayn [35]
Netstat -pan | more


-----------------------------------------------------
5 0
3 years ago
Other questions:
  • What is the difference between pulse code modulation and delta modulation? Provide examples.
    11·1 answer
  • PLEASE HURRY
    6·1 answer
  • You need a version of usb technology that will support older usb devices, of which you have many, as well as newer ones. what wo
    10·1 answer
  • Swapping two numbers
    10·1 answer
  • Your company received a call from a historical society inquiring about the possibility of networking a two-century-old building
    15·1 answer
  • Define a romanNumberToInt function that converts a RomanNumber value, which is a list of Roman digits, into an integer. Hints: -
    7·1 answer
  • Teaching Siri or the Google Assistant how to recognize your voice by reading to it is an example of ________.
    6·1 answer
  • What should you do if you forget your root password for MySQL?
    13·1 answer
  • Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
    7·1 answer
  • Management information system by different outhors<br>​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!