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
maksim [4K]
3 years ago
11

Write a function named countWords that reads in a line of text into a string variable, counts and returns the number of words in

the line. For simplicity assume that the line entered only has characters and spaces.
Computers and Technology
1 answer:
algol133 years ago
3 0

Answer:

function countWords(sentence) {

return sentence.match(/\S+/g).length;

}

const sentence = 'This sentence  has five  words ';

console.log(`"${sentence}" has ${countWords(sentence)} words` );

Explanation:

Regular expressions are a powerful way to tackle this. One obvious cornercase is that multiple spaces could occur. The regex doesn't care.

You might be interested in
PLEASE HELP!!<br> Would you ever try and get famous off of social media? Why or why not?
Alexxandr [17]

Answer:

Yes because u could gain a lot of money from it

Explanation:

With more money you have, the more you can give to charity, and the more you can relax

3 0
2 years ago
Read 2 more answers
A document format is
anyanavicka [17]

Answer:

A document file format is a text or binary file format for storing documents on a storage media, especially for use by computers. There currently exist a multitude of incompatible document file formats.

Explanation:

8 0
3 years ago
Read 2 more answers
Which of the following resources is an example of a web-based application?
kompoz [17]
The answer will be google docs since it depends on a web and its an application. hope it helps

3 0
3 years ago
Regulatory and informational markers are easily identified through which features
Darina [25.2K]
Regulatory or informational markers are utilized to inform you with respect to circumstances, threats, or headings. They may show reefs, swim territories, speed zones, and so forth. They can be effectively distinguished by the orange groups on the top and base of each float.
3 0
3 years ago
To a traditional computer, one means
blagie [28]

a.on , off

In most computer processors, electron movement is controlled by tiny switches that turn this flow of electricity on and off...zero represents off and one represents on

4 0
3 years ago
Other questions:
  • Wich of these is an example of magnetic storage
    11·1 answer
  • Why are computer programs so much longer now than they were in the late 1980?
    8·1 answer
  • Advantages of a personal area network
    5·1 answer
  • 2. What are the pros and cons of Toyota structure?
    13·1 answer
  • Um can anyone who is really into science and physics answer this question
    7·1 answer
  • Impaired drivers are one of the many risks drivers face on the Highway Transportation System. List 3 signs that a driver could b
    10·2 answers
  • Explain why the process of sketching in engineering might resemble a loop or a cycle.
    15·2 answers
  • WILL GIVE BRAINLIEST!!! Danielle is warehouse supervisor for a large shipping company. Most shipments need to leave the warehous
    7·1 answer
  • What is a computer?write any four features of computer​
    14·2 answers
  • Why should we learn Ethereum? Explain.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!