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
How to take a key off a keyboard without breaking it?
klio [65]
You can carfully wedge something in between the key and gently pull up 
4 0
3 years ago
Can someone give me the code for the edhesive 3.7 code practice for python? Thanks.
belka [17]

Answer:

Its me I think u might be able to know :)

Explanation:

4 0
2 years ago
Which statement is NOT true:
RSB [31]

Answer:

The correct answer for the given question is   "Machine languages can be used to write programs that can run on any machine."

Explanation:

The machine language consist of binary digit i. e 0 and 1 .Computer can understand only the machine language .The machine language consist of code that is written in bits so it is used  to express algorithms.When any program is compiled the compiler are converted into machine code so the machine language is produced by the compiler .

Machine language cannot used to write a program that run on any machine.

5 0
3 years ago
A10:A20 Refer to values in
Keith_Richards [23]
The range of cells in column A and rows 10 through 20
8 0
2 years ago
Read the excerpt from The Common Sense of Bicycling: Bicycling for Ladies. To learn to balance, have the saddle raised as high a
kirill [66]

The answer is adjusting the seat.

3 0
3 years ago
Read 2 more answers
Other questions:
  • In the electric series, which one of the following materials is the most negatively charged? A. Silk B. Sealing wax C. Teflon D.
    7·2 answers
  • Erick, who is taking an online course, sent an e-mail to his
    14·2 answers
  • If you enter 234.567 into a cell that is formatted to display 1 decimal point place, what is the value stored in the cell
    9·1 answer
  • Entering the formula =SUM(C5:C18) in cell C19 will result in which of the following?
    10·1 answer
  • Want to.learn about computers​
    9·1 answer
  • Karen is designing a website for her uncle's landscaping business. She wants to ensure that it's engaging and provides a lot of
    5·1 answer
  • Which of these Logic Statement's are correct for the following diagram? *
    5·1 answer
  • Analyze the code and identity the value of variable a,b and c after the code execution. int a=40, b=50, c=60; if(! (a>=40)) b
    15·1 answer
  • Nia is editing a row in an Access table. The row contains the Pencil icon on the left end of the record
    12·2 answers
  • What is e banking effects
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!