I Have this problem and honestly have no idea where or how to start this, can anyone give me an idea or help?

Write a JavaScript program to calculate the statistics of words in a web page. When running the program in a web page, the script should output all words in descending order of their number of occurrences. The number of occurrences should be displayed along with the words. When two or more words have the same number of occurrences, order them alphabetically. The output should show up as a new web page when the program runs. HTML tags and scripts inside web pages should not be considered as words by the program. The program should run in all web pages, not just one page.

I got python coding for it, but not sure for java, also how to order by descending order

import re

def addWord(token, frequencies):
    count = 0
    word = ''.join(token)
    if word in frequencies:
        count = frequencies[word]
    frequencies[word] = count + 1

def getWordFrequencies(text):
    pattern = re.compile('\w')
    frequencies = {}
    token = []
    for c in text:
        if pattern.search(c):
        elif token:
            addWord(token, frequencies)
            token = []
    if token:
        addWord(token, frequencies)

    return frequencies

wordCount = raw_input("Please Enter text here: ")

result = getWordFrequencies(wordCount)

for word, freq in result.iteritems():
    print freq, "\t", word

how to start
not sure for java

Why not look up the javascript commands and functions that match each python command and function?

BTW: javascript != java.