Wimbledon 2008 Men's Final FedererSetsNadal 416 426 736 746 759 -3- Write a JavaScript function to print "X won Y-Z in W sets" onto the HTML element with id "result", where X is the winning player, Y-Z is the score in sets, and W is the total number of sets played. Also, explain where the function should be written within the HTML structure by referring to the line number. Note that your code should work for any result displayed in this way (not only for the above result).
<head>
<title>Wimbledon 2008 Men's Final</title> </head>
<body>
<table>
<tr id="players"> <th>Federer</th><th>Sets</th><th>Nadal</th> </tr>
<tr id="set1"><td>4</td><td>1</td><td>6</td></tr> <tr id="set2"><td>4</td><td>2</td><td>6</td></tr> <tr id="set3"><td>7</td><td>3</td><td>6</td></tr> <tr id="set4"><td>7</td><td>4</td><td>6</td></tr> <tr id="set5"><td>7</td><td>5</td><td>9</td></tr> </table>
<p id="result"></p>
</body>
</html>
-3-
Write a JavaScript function to print "X won Y-Z in W sets" onto the HTML element with id "result", where X is the winning player, Y-Z is the score in sets, and W is the total number of sets played. Also, explain where the function should be written within the HTML structure by referring to the line number. Note that your code should work for any result displayed in this way (not only for the above result).
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images