Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 questions unanswered #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Question One: Text Duplicator

Make a website (`textDuplicator.html`) with a text input, a number input and a button. Clicking on the button should add that many copies of the text in the text input to a list.

# Question Two: Number Statistics

Make a website (`numberStatistics.html`) with a number input, a button, and 3 paragraphs. Clicking on the button should add the number to a list. The first paragraph should show the average of all the numbers, the second paragraph should show the maximum value, and the third paragraph should show the minimum value.
Expand Down
9 changes: 9 additions & 0 deletions numberStatistics.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
<title>Number Statistics</title>
<script src="numberStatistics.js"></script>
</head>
<body>
<h1>Number Statistics</h1>
Expand All @@ -24,5 +25,13 @@ <h1>Number Statistics</h1>
and the third paragraph should show the minimum value.
</li>
</ul>
<input type="text" name="" id="number-statistics-number-input" placeholder="enter number">
<button id="number-statistics-button" onclick="addingNumbers()">Submit</button>
<ul>
<li id="number-statistics-numbers"></li>
</ul>
<p id="number-statistics-average">Average value</p>
<p id="number-statistics-maximum">Maximum value</p>
<p id="number-statistics-minimum">Minimum value</p>
</body>
</html>
13 changes: 13 additions & 0 deletions numberStatistics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const addingNumbers = () => {
let input = Number(document.getElementById('number-statistics-number-input'));
let li = document.createElement('li');
let ul = document.getElementById('number-statistics-numbers');

li.textContent = input;

let allItems = document.querySelectorAll('#number-statistics-numbers li');

for (let i = 0; i < allItems.length; i++){
console.log(allItems[i]);
}
}
Loading