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.

Answers

Answer 1

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.


Related Questions

When using a touchscreen, which of the following actions is the same as clicking an item?

Answers

the side buttons ?? could u list what the following are-

Answer:

1) Tap the item

Explanation:

Write code which takes two inputs from the user, a number of sides followed by a side length, then creates a regular polygon with that number of sides and side length.Sample run:Type the number of sides:8Type a side length:7.5regular octagon with side length 7.5Hint: Make sure you use the right data types when taking user input.

Answers

Answer:

i need free point sorry lol

Explanation:

Answer:

import java.util.Scanner;

public class Polygon {

       public static void main(String[] args) {

               Scanner sc = new Scanner(System.in);

               System.out.println("Type the number of sides:");

               int sides = sc.nextInt();

               System.out.println("Type a side length:");

               double length = sc.nextDouble();

               if (sides== 5){

                      System.out.println("Pentagon, length "+length);

               } else if (sides == 6){

                      System.out.println("Hexagon, length "+length);

               } else if (sides == 7){

                      System.out.println("Heptagon length "+length);

               } else if (sides == 8){

                       System.out.println("Octagon, length "+length);

                } else if (sides == 9){

                       System.out.println("Nonagon, length "+length);

                 } else if (sides == 10){

                       System.out.println("Decagon, length "+length);

} else if (sides == 11){

                       System.out.println("Undecagon, length "+length);

} else if (sides == 12){

                       System.out.println("Dodecagon, length "+length);

} else {

                       System.out.println("Please choose a valid number.");

               }

       }

}

Explanation:

The Java source code defines a class called 'Polygon' the main method of the class prompts for user inputs for the sides and length variables. The nested if-statement prints the type of polygon with respect to the number of sides.

A proxy is something that​

Answers

Answer:

helps protects your data and you from viruses or bad things on the internet

Explanation:

UML gives two ways to show nesting. The first is very ______, as it shows modeling elements physically contained in the package. An alternative nesting _____ is useful when there is a lot of nesting, or complex nesting, that might be confusing to show with embedding. a. graphic, textualb. textual, syntaxc. textual, verbaged. graphic, syntax

Answers

Answer:

d. graphic, syntax

Explanation:

UML (Unified Modeling Language) is a software design standard used to visually describe or represent an object-oriented program. UML helps to organize, plan, and visualize a program as it provides visual documentations in the form of UML diagrams.  UML diagrams divide a software system into components and subcomponents.  In addition to being a universal design standard, it is also widely used and accepted as the language for outlining programs.

Data ____ refers to the accuracy of the data in a database

Answers

Accuracy or quality?

write an algorithm and draw a flowchart to calculate
2^4 using a loop approach?

Answers

Answer:

I'm not about to write a flow chart for you, but here's a quick demo of how to do it:

doPower(2, 4);

function doPower(base, power){

   var result = 1, p;

   for(p = 0; p < power; p++){

       result *= base;

   }

   return result;

}

That function will only work for positive integer exponents of course.

Which file type is best for saving audio files?

a
DOC

b
GIF

c
JPG

d
MP3

Answers

Answer:

d.MP3

Explanation:

Please mark my answer as a brainliest .❤❤❤❤

Answer:

MP3

Explanation:

It is the ONLY audio file out of these 4.

You would like to store the results of the ps command in a file named process_data. What command should you run?
a. ps | process_data
b. ps < process_data
c. ps > process_data
d. ps << process_data

Answers

Answer:

I'm not quit sure nut I think its b!

Explanation: Hope this helps!

Jason wants to add an animated image to his baseball team's web page. Which file format should he use?
GIF
IMG
JPG
MPG
PLZZ HELP THIS IS A BIG PART OF MY GRADE!

Answers

Answer:

Gif

Explanation:

A gif. It’s an animated image.

Aisha designed a web site for her school FBLA club. Which item should Aisha consider for improved responsive design?

a
Adding horizontal scroll

b
Including interesting text

c
Improving image quality

d
Removing horizontal scroll

Answers

A is the correct answer I studied it

The items that Aisha should consider for improved responsive design is a adding horizontal scroll.

What is meant by responsive design?

The term Responsive web design (RWD) is known to be a kind of web creation approach that is said to make a dynamic alterations to the view or appearance of a website.

Conclusively, Note that this often depends on the screen size and also the orientation of the device that is said to be used and as such, Aisha should consider for improved responsive design is a adding horizontal scroll.

Learn more about responsive design from

https://brainly.com/question/25941596

Consider the following skeletal and JavaScript-like program: function main() { var a, b, w, d; function sub1() { var a, c, w, v; function sub2() { var a, d; } ... } function sub3() { var x, w, v, d; .... } } 4.1. (4 points) List all the variables, along with the program units (sub1, sub2, sub3, or main) where they are declared, that are visible in the body of sub3, assuming that static scoping is used. 4.2. (4 points) List all the variables, along with the program units (sub1, sub2, sub3, or main) where they are declared, that are visible in the body of sub2, assuming that static scoping is used.

Answers

Answer:

A. Sub3 local variables are; x, w, v and d while the visible variables from the main variables; a and b.

B. Sub2 local variables are; a and d while the visible variables from the main and sub1 are; c, b, w and v

Explanation:

The variable name defined with the 'var' in the main is on a global scope to other functions defined in it. But when the same name of the variable is defined in the inner functions, its variable name is overridden with the newly defined variable.

When you hear music, read a printout, or view a video, you are using a computer's

Answers

Answer:

Output device.

Explanation:

An output device can be defined as a hardware device that typically receives processed data from the central processing unit (CPU) and converts these data into information that can be used by the end user of a computer system.

All of the output device of a computer are known as peripheral devices and they provide data (informations) to the end users in various formats such as video, audio, texts, images etc.

Since output devices are peripheral devices, they can be connected to the computer system wirelessly or through a wired-connection (cable).

Some examples of output devices are monitor, speakers, printer, projector etc.

Hence, when you hear music, read a printout, or view a video, you are using a computer's output device.

Binary numbers are based on __________.

a
letters (a and b)

b
16 digits

c
10 digits

d
two digits (1s and 0s)

Answers

D. Two digits (1s and 0s

Answer: 0 and 1s.

Explanation:

Discuss which employees and organizations have a deeper level of information assurance (IA) policy compliance.

Answers

Incomplete question. However, I inferred you want to understand what information assurance (IA) policy is.

Explanation:

Put simply, the term Information assurance refers to policies put in place to reduce any risk associated with the use and transfer of information.

In other words, the information assurance (IA) policy of an organization refers to policies drafted by the organization to protect the confidentiality or availability of the organization's internally generated information including that of their users. It is, therefore, also an information risk management policy.

100+20000000 please give answer and win iPhone 11 pro​

Answers

Answer:

20000100

Explanation:

can u help me please

Answers

Answer:

The first one is false

I think the second one is false as well... ( might be wrong)

Match each method of communication with its intended purpose.
a late-breaking news story
a poetry reading
an advertisement
a small group assignment

Answers

Answer:

1. a late breaking news story = to inform

2. a poetry reading = to entertain

3. an advertisement = to persuade

4. a small group assignment = to collaborate

Explanation:

1. A "breaking news" tells people of what is happening in the society. It informs them of the occurrence of an important event such as the plane crash of Kobe Bryant.

2. Poetry reading is meant to touch the attention of listeners. It tries to entertain them through the poem's interesting verses.

3. An advertisement is being shown/displayed in order to convince people to buy a particular product or service.

4. A group assignment allows the members of the group to contribute their ideas together. Such situation is known as "collaboration." They try to brainstorm together towards a common goal.

The efficiency of a sequential search can be improved by placing the records with the highest probability of retrieval at the ___. A search technique that uses this strategy is ____. A related strategy is "Move to the Front". Of these two, ____ is considered better because it responds more quickly to changes in retrieval patterns. If you do not know anything about the usage patterns of newly inserted items, then the best place to insert is at the ____ of the list.
SELECT FROM FOLLOWING CHOICES TO FILL IN THE BLANKS:
blank
middle
third
second
next to last
end
beginning
index sequential search
binary search
interpolation search
transposition
Move-To-The-Front
B-tree
AVL tree
sequential search

Answers

Answer:

Beginning, transposition, move-to-thr-front, middle.

Explanation:

Sequential search is a search algorithm that goes through the items in an array of list one at a time to get the searched item. The algorithm starts from the beginning of the list, comparing each items in the list with the searched term.

What does the icon look like to add a new worksheet to the current workbook?
O a paintbrush
O a triangle with an exclamation point inside
O a lightbulb
O a circle with a plus sign inside

Answers

Answer:

A circle with a plus sign inside

Explanation:

I took the test

Concerning network security, an attack that occurs when the attacker is able to learn or observe information that they were not supposed to is known as what?

Answers

Answer:

The answer is "Eavesdropping".

Explanation:

It is a personal discussion or communication with many other folks actually or slowly, without any of the consent of everyone else to gain knowledge. It starts by referring to water, which dropped off the building's roof, instead referring to a field the rain fell. The preacher finally told a person that was inside the house to have a discussion.

What is meant by a control plane that is based on logically centralized control? In such cases, are the data plane and the control plane implemented within the same device or in separate devices? Explain.

Answers

Answer:

A control plane which is based on a logically centralized control is one which knows all routing tables that are in the router of the network.

The data plane is made up of different network switches that are very simple and devices are fast. Such devices can carry out executions of of match plus action rules in flow tables. The switch glow table determines and also manages the different servers and softwares of the control plane.

The control plane and data plane are separated and implemented in different devices as it gives more flexibility and unique networking.

Describe how threat modeling helps development teams build best practices and how it takes preventative measures against attacks?

Answers

Answer:

Answered below

Explanation:

Threat modelling is the process of enhancing network security by seeking out possible threats, breaches and vulnerabilities of the network system. This helps the development team take proactive measures in preventing such breaches.

Threat modelling also helps the development team decide where to focus their resources the most, in making sure of a secured network system. It is a dynamic process whereby software and networks are updated, added and removed.

I need help picture above

Answers

Answer:

bank transfer or credit card

Explanation:

Bank or credit card because if your shopping online you can’t use cash

Please select the word from the list that best fits the definition

Halloween falls on October 31 every year.

Absolute
Or
Qualified

Answers

the best word that fits the definition is absolute.

Answer:

Absolute

Explanation:

Absolute means that it is a for sure thing. Halloween always falls on October 31st no matter what. So, the statement is absolute.

When should you create an outline?
OA. While you are creating your slides
OB. Before you create your first slide
O C. After you create your last slide
O D. After you have presented your slide presentation


Help need help now please!!!!!!!!

Answers

Answer:custom slide show

Explanation:

You know the office network is a

Answers

Answer:

it is a..

Explanation:

office for networks?

where they control the network maybe

I need help picture above

Answers

Answer:

The 2nd one on top and The Star ones.. (sorry if its wrong

Explanation:

“https” at the very beginning of the URL

This semester we have discussed the acronym S.O.L.I.D as it applies to Object Oriented Design and Programming.
The D stands for Dependency Inversion. Briefly explain the meaning of this letter/phrase.

Answers

Answer:

The Dependency Inversion principle is a basic principle of Object Oriented Programming and Part of SOLID principles. It states that: Entities must depend on abstractions, not on concretions. It states that the high-level module must not depend on the low-level module, but they should depend on abstractions

Explanation:

High-level modules, which provide complex logic, should be easily reusable and unaffected by changes in low-level modules, which provide utility features. To achieve that, you need to introduce an abstraction that decouples the high-level and low-level modules from each other.

Basically Dependency introduced interface abstraction between high level and low level modules which terminates their dependency on each other instead now they depend both on abstraction. This principle enables you to change higher-level and lower-level components without affecting any other classes, as long as you don’t change any interface abstractions.

A firm uses BitLocker for volume encryption. Normally, BitLocker performs its task well. However, an administrator was recently forced to decrypt and encrypt the entire volume. Why did the administrator take these actions?

Answers

Answer:

The BitLocker keys were compromised

Explanation:

Given that the act of decrypting and encrypting all over is a means of troubleshooting the issue of security in computing operations. Hence, when an administrator is forced to decrypt and encrypt the entire volume, the main reason for such action can be as a result of "BitLocker keys were compromised."

Hence, the right answer, in this case, is that "The BitLocker keys were compromised."

types of charts available in MS Word?

Answers

Pie chart , column charts , line graph, bar charts, area graphs, scatter graphs, stock charts, surface charts, radar graphs, bubble graphs, doughnut chart
Other Questions
A china dish falls from a height of 1.5 m above the floor. Calculate its velocity just before itreaches the ground. (ag = - g= -9.8 m/s^2) * Identify and explain one internal and one external cause for the fall of the Western Roman Empire A portfolio consists of two stocks: 30% of Stock 1 with standard deviation of 39.44% and 70% of Stock 2 with a standard deviation of 47.29%. The correlation of Stocks 1 and 2 is 0.4. What is the standard deviation of this portfolio? Emma comes in last place at her swim meet. Instead of giving up, she works harder and comes back to win second place at the next moet. Emma is:O emotionally unhealthybipolar.0 resilientNone of the choices are correct. Write a series of questions that automotiveengineers would need to answer about how theenergy trapped in algae could be used to poweran automobile engine. Which set of ordered pairs represents a function?{(7,-3), (9,-9), (7,9), (5, 1)}o {(2,8),(-1, -7), (-2,-3), (-8,7)}{(-2,7), (6,6), (9,-6), (6, -7)}{(5,7),(-9,-4), (0, -5), (0, -2)} trouve les mots et complte la grille1) RAGON2) TADOSCENLE3) ODETASENLEC4) MIA5) OMN6) LEFIL7) MAIE8) NOURMS9) NPMOR What is the slope of the line graphed on the coordinate plane? A graph with a line running through coordinates (0, 6) and coordinates (1, -2)Enter your answer in the box. Which is not an abundant natural resource found in Africa?DiamondsPalm oilCoalFarm land HELP. there are 45 coins consisting of nickels, dimes and quarter making a total of 7 dollars. the number of dimes exceeds the number of nickels by five how many quarters are there 3x+2i=30+4yiPlease help describe two key features of the Russian revolution of 1905 Which event most clearly expanded on the founding principle that "all men arecreated equal"?A. The 1867 purchase of AlaskaB. The 1887 Dawes ActC. The 1907 Gentlemen's AgreementD. The 1848 Seneca Falls Convention Which excerpt is part of the exposition of Robin Hood?A. Not only Robin himself but all the band were outlaws and dwelled apart from other men,B.the sheriff of Nottingham proclaimed a shooting match and offered a prizeC. I'll hold the best of you twenty marks," quoth bold Robin, "that I hit the clout at threescore rods, ..D. I would that thou hadst ne'er said one word to me, or that I had never passed thy way, An entrepreneur would most likely be interested inA. job security.B. financial gain.C. personal fulfillment.D. a flexible working environment. HELP! I NEED ANSWERS TO MY SPANISH THATS DUE IN 20 MINUTES!! Alicia runs for exercise. If Alicia runs 32 miles in six days, how many feet does she run per day? Caillou what was song It's A Girl 8) Find x if the bases of a trapezoid have lengths 2x + 4 and 8x -10 and the length of the medianis 3x + 21. Scores of gre are normally distributed with a mean of 505 and standard deviation of 146. Use the 68-95-99.7 rule to find the percentage of people taking the test who score between 213 and 797