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
shepuryov [24]
3 years ago
8

Implement the function calcWordFrequencies() that uses a single prompt to read a list of words (separated by spaces). Then, the

function outputs those words and their frequencies to the console.
Ex: If the prompt input is:

hey hi Mark hi mark
the console output is:

hey 1
hi 2
Mark 1
hi 2
mark 1
Computers and Technology
1 answer:
Novosadov [1.4K]3 years ago
5 0

Answer:

JavaScript code is given below

Explanation:

function calcWordFrequencies() {

   var words = prompt("Enter the sentence below").split(" ");

   var unique_words = [], freqencies = [], count = 0;

   for (var i = 0; i < words.length; i++) {

       var found = false;

       for (var j = 0; j < count; j++) {

           if (words[i] === unique_words[j]) {

               freqencies[j] = freqencies[j] + 1;

               found = true;

           }

       }

       if (!found) {

           unique_words[count] = words[i];

           freqencies[count] = 1;

           count++;

       }

   }

   for (var i = 0; i < words.length; i++) {

       var result = 0;

       for (var j = 0; j < count; j++) {

           if (words[i] === unique_words[j]) {

               result = freqencies[j];

               break;

           }

       }

       console.log(words[i] + " " + result);

   }

}

You might be interested in
Monero is cryptocurrency that focuses on transparency of ownership. True or false
dangina [55]

Answer:

TRUE

Explanation:

4 0
2 years ago
In this image, which feature did we most likely use to quickly change the background, fonts, and layout?
MAVERICK [17]

Answer: themes

Explanation:

Took the test

3 0
3 years ago
What do u mean by generation of computer
lesya [120]

Answer:

Generation in computer terminology is a change in technology a computer is/was being used. Initially, the generation term was used to distinguish between varying hardware technologies. Nowadays, generation includes both hardware and software, which together make up an entire computer system.

Explanation:

3 0
3 years ago
Which of the following describes the term "false information?"
pav-90 [236]
Inaccurate and misleading
3 0
3 years ago
A(n) _____ identifies how you feel about an activity or subject. computer calculator interest inventory both b and c
Alexeev081 [22]

Answer:

Interest

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • Define a function begins_with_line that consumes a string and returns a boolean indicating whether the string begins with a dash
    15·1 answer
  • Compare the logical link control and the media access control. Which of the following is a correct statement?
    7·2 answers
  • The top of a ladder must extend how many feet above the surface a worker is climbing onto?
    7·1 answer
  • When projecting a presentation on a large screen, what should your minimum font size be?
    6·2 answers
  • Which of the following describes ETL? a) A process that transforms information using a common set of enterprise definitions b) A
    14·1 answer
  • Ayudaa, 5 ejes de sistemas tecnológicos
    5·1 answer
  • True or false a computer with a high efficiency rating should stay cooler than one with a low effiency rating
    9·1 answer
  • Coffee shops worldwide throw away billions of paper cups each year. Discuss
    9·1 answer
  • Which of the following best explains how the Internet is a fault-tolerant system?
    7·2 answers
  • When would instant messaging be the least effective means of communication
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!