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
Will mark brainliest if correct. First come, first serve.
hram777 [196]

Answer:

option 2 and 4

Explanation:

I believe its those two

5 0
3 years ago
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
maxonik [38]

Answer:

IF Condition lol

Explanation:

3 0
3 years ago
A good machine should have the mechanical advantage of......?​
zavuch27 [327]

Answer:

The ideal mechanical advantage (IMA) of an inclined plane is the length of the incline divided by the vertical rise, the so-called run-to-rise ratio. The mechanical advantage increases as the slope of the incline decreases, but then the load will have to be moved a greater distance.

Explanation:

4 0
3 years ago
Which area would a Gaming Designer fall under? Research and explain why you think so. Make sure to site your source and where yo
pshichka [43]

Answer: Game Artist, Game Designer or Game Programmer.

Explanation:

All of which fall under a “Game Designer”

5 0
3 years ago
_______ are fasteners that connect parts and are intended to resist pulling forces. A. Extension springs B. Compression springs
madam [21]
The answer is Lock washers
6 0
4 years ago
Other questions:
  • To remove an embedded chart, you should _____ it and press the DELETE key.
    14·2 answers
  • A computer system has 9,850 processes and 172 of them were suspended while 276 of them were terminated. Explain why some of the
    12·1 answer
  • Melinda completed the Computer Programming Aptitude Test when she applied for a position with Beta Electronics. Six months later
    14·1 answer
  • Are high tech messages are always preferable to low tech messages
    8·1 answer
  • What type of data would a RDBMS store in a linked list, two-way linked list, or B-trees? What are the advantages and disadvantag
    5·1 answer
  • Match the title of the work of fiction to the description given.
    8·1 answer
  • Which is an effect of short-term environmental changes?
    8·1 answer
  • assume there are K sorted lists, each of n/k elements. We want to merge them into a single sorted list of n elements. Give an op
    7·1 answer
  • (50 POINTS)
    12·1 answer
  • Which hardware component interprets and carries out the instructions contained in the software.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!