In a seperate javascript file This step in brewing beer is to extract sugars from grains by soaking the grains in hot wate a different wor 3. JavaSeript/DOM Background: The first amount of sugar...
This step in brewing beer is to extract sugars from grains by soaking the grains in hot wate a different wor 3. JavaSeript/DOM Background: The first amount of sugar (the grain's yield) to the wort. Calculating the final amount of sugar in the wort is an imp ing a beer recipe, since the sugars will later ferment into alcohol. To measure the amount of sugar in designi step is called mashing, and the resulting sugar-water is called wort. Each variety of grain contributes we use specific gravity (SG), a decimal number (e.g., 1.054) which represents the ratio of the sugar-waters denso that of pure water (1.000 SG). Specific gravity measurements during the brewing process about 1.010 and 1.100. are typically between estimates the specific gravity of Your job is to write the JavaScript code to add behavior to the following page, which a list of user-entered grains: HTML: Mash-It! <h1>Mash-It!</h1> Male bill crieldset> clegendMalt billie/legend PPG Tbs Grain <table id-"malt biil /th></tr> 8.5 American 2-Row Pale 38 32 5 Cara-Pils/Dextrene <tdscinput type-"text class- amount /</td> 34 <tdcinput type-"text" class-"yield"/t /tr> 5 Crystal 20 5 Crystal 40 34 - additional grain entry rows are added here </table> </fieldset> cdiv id--operations> cbutton id-"add gzain" >Add another qrainc/button> <button id-"calculate Calculate sGe/button2 c/div Add another grain Calculate SG Estimated Specific Gravity: 1.068 atiomes a S 5 gallon batch cdiv id-"calculations"> Estimated Specific Gravit span id-specific qrvity your、calculated SG. goes hero--> /spanxbr/> Cspan class-"note"> (assumes a 5.5 gallon batch) </span> </div> The page consists of a table in which the user can enter grains. Every time the Add another grain button is clicked, a new row should be added at the bottom of the table. Each row consists of three text-entry fields, each in its own table cell, for entering the following values: an amount (in pounds), a name, and a sugar yield (in "PPG"). These entry fields should have the classes amount, name, and yield respectively. When the Calculate SG button is pressed, your code should estimate the specific gravity of the user-entered grains by performing the following calculation SG round(las + aya 5.5)/1000 +1 (Where a and yi represent the amount and yield of the first grain, and so on.) In other words, for each grain in the list, multiply its amount (the number in the "lbs" column) by its yield (the number in the "PPG" column), and take the sum of these products. Then divide that by 5.5 (which represents the volume of water it's dissolved in, in gallons). Round the result to the nearest integer, then to express it as a number 1 followed by 3 decimal places (e.g., 1.054), divide by 1000 and add 1 For example, using the values in the above screenshot, your calculation would be as follows: .5.34]/ 5.5) /1000+1-1.068 SGan round(8.5.38 +5.32 + .5.34 You should assume all input to text boxes is valid; that is, reasonable values will always be entered in the fields for amount and yield. You may assume the Prototype JavaScript library is loaded prior to your script being loaded. When injecting content into the page, you may use the innerHTML property for injecting plain text only; you may not use it to inject any HTML code