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
Why the computer is known as versatile and diligent device ? explain.<br>​
Scrat [10]

Answer:

Computer is called versatile and diligent device because it is used in almost all the fields for various purposes and it can perform the task repeatedly without loosing its speed and accuracy for long time.

5 0
2 years ago
How has the shift to locally grown produce decreased greenhouse emissions?
Katen [24]

Answer:

How has the shift to locally grown produce decreased greenhouse emissions? 1 Large farms often create greenhouse emissions by poor farming practices. 2 Locally grown produce allows fewer dangerous toxins to seep into the soil and the atmosphere.

3 0
2 years ago
The main path of the Internet along which data travels the fastest is known as the Internet ________. Group of answer choices
Svetradugi [14.3K]

Answer:

<em>Internet backbone</em>

Explanation:

The internet backbone is made up of multiple networks from multiple users. It is the central data route between interconnected computer networks and core routers of the Internet on the large scale. This backbone does not have a unique central control or policies, and is hosted by big government, research and academic institutes, commercial organisations etc. Although it is governed by the principle of settlement-free peering, in which providers privately negotiate interconnection agreements, moves have been made to ensure that no particular internet backbone provider grows too large as to dominate the backbone market.

7 0
3 years ago
Which is the best method of marketing a game to casual players?
Phoenix [80]
A casual game is a video game targeted at or used by casual gamers. Casual games may exhibit any type of gameplay or genre. They are typically distinguished by simple rules and by reduced demands on time and learned skill, in contrast to more complex hardcore games. They typically impose low production and distribution costs on the producer. Casual games are often played on a personal computer online in web browsers, but are also popular on game consoles and mobile phones.

Hope this helped. Have a great day! :D
3 0
3 years ago
Read 2 more answers
What is a computer system?
klio [65]
A system of interconnected computers that share a central storage system and various peripheral devices such as a printers, scanners, or routers. Each computer connected to the system can operate independently, but has the ability to communicate with other external devices and computers

<span>Read more: http://www.businessdictionary.com/definition/computer-system.html</span>
4 0
3 years ago
Other questions:
  • Which of the following are peripheral devices?
    7·2 answers
  • Ooooooooooooooooooooooooooooh im blinded by the lightssssssssss
    11·1 answer
  • Which of the following best describes a proxy firewall? A. It sends traffic through another host. B. It acts as a gateway for re
    15·1 answer
  • Which of the following statements about take home pay is TRUE?
    10·1 answer
  • Your traffic light changes to yellow as you approach an intersection. In most cases, what action should you take?
    15·2 answers
  • Visit the quick access toolbar to find help when looking for certain commands. True False
    15·2 answers
  • Suppose that a 2M x 16 main memory is built using 256kB x 8 RAM chips and memory is word addressable, how many RAM chips are nec
    6·1 answer
  • What is the significance of the Abstract section of a research paper? A. It contains important information such as the author, c
    5·1 answer
  • Buying the newest phone as soon as it is released when your current phone works perfectly is not a good idea for all but which o
    10·2 answers
  • Which file contains full and incremental back-up information for use with the dump/restore utility?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!