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
What is the function of ctrl+Q​
vlabodo [156]

Answer:

Ctrl+Q is used to remove a paragraph's formatting

Explanation:

Hope that's the answer you're looking for!

5 0
2 years ago
Write a function that checks whether two words are anagrams. Two words are anagrams if they contain the same letters. For exampl
Masteriza [31]

Answer:

def isAnagram(s1, s2):

   list1=s1

   list2=s2

   sortedlist1 = sorted(list1)

   sortedlist2 = sorted(list2)

   if sortedlist1 == sortedlist2:

       print(list1+ " and "+list2+ " are anagram")

   else:

       print(list1+ " and "+list2+ " are not anagram")

Explanation:

Here is a call to the function isAnagram():

list1 =input("Enter String1 ")

list1 =input("Enter String2 ")

isAnagram(list1,list2)

Attached is the run and output for this program

4 0
3 years ago
What is the most useful advantage of social media in an emergency response effort?
gladu [14]
Being able to communicate directly with constituents.

ability to build situational awareness speed in which information can be delivered directly to the public
4 0
3 years ago
is an online collaborative event that may include such features as chat, slideshows, and PowerPoint presentations.
Lilit [14]

Answer

is number 4 or 3

Explanation:

5 0
3 years ago
Companies that develop software for sale are called software ____.
yanalaym [24]
Hello <span>Loveworld4058 
</span><span>
Answer: Companies that develop software for sale are called software vendors.


Hope This Helps
-Chris</span>
4 0
3 years ago
Other questions:
  • Which keyboard feature is a form feed character?
    14·1 answer
  • PPPLLLLEEEEAAASSSSEEEEE HHELLP me.Does anyone know how to copy an image onto a thing so i can post a real question on brainly. b
    8·2 answers
  • What tips or techniques should you keep in mind when shooting photographs on a rainy day?
    6·1 answer
  • One of the most toxic components of a computer is the
    11·1 answer
  • Which of the following is likely the cause of the bass from a sound system rattling the windows on your car?
    11·1 answer
  • You are responsible for performing all routine maintenance on your company's laser printers. Which of the following maintenance
    15·1 answer
  • What are the basic tools for coding HTML manually?
    10·2 answers
  • Pls help... : Slide layouts can be changed by _____.
    9·1 answer
  • Match the parts of the website address with its correct explanation. http://www.usa.gov/Agencies/federal.shtm/​
    5·2 answers
  • DERECTIONS: Identify all the computer software that you need for the following entrepreneurial activities. Refer your answer fro
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!