Skip to content

Instantly share code, notes, and snippets.

/*
FEDERAL AUDIT
Create a function that reads the dictionary of government spendings and returns a number representing the sum of total spending.
ex)
var spending = {
Military : {
Pensions : 1000000,
var myTestText = 'In pre-revolutionary France, the president of a Parlement evolved into a powerful magistrate, a member of the so-called noblesse de robe ("nobility of the gown"), with considerable judicial as well as administrative authority. The name referred to her primary role of presiding over trials and other hearings. In the 17th and 18th centuries, seats in the Parlements, including presidencies, became effectively hereditary, since the holder of the office could ensure that it would pass to an heir by paying the crown a special tax known as the paulette. The post of "first president" (premier président), however, could only be held by the King\'s nominees. The Parlements were abolished by the French Revolution. In modern France the chief judge of a court is known as its president (président de la cour).'
function buildMarkovChain(str) {
var cleanStr = str.toLowerCase().replace(/[,.?()"]/g,''); // remove punctuation
// var cleanStr = str.toLowerCase().replace(/[^a-zA-Z0-9]/g,' '); // this approach