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

initial commit #113

Open
wants to merge 5 commits 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
12 changes: 10 additions & 2 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" defer></script>
</head>
<body>
<h1>Number Statistics</h1>
Expand All @@ -19,10 +20,17 @@ <h1>Number Statistics</h1>
and id='number-statistics-minimum'.
</li>
<li>
The first paragraph should show the average of all the numbers,
the second paragraph should show the maximum value,
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.
</li>
</ul>
<input id="number-statistics-number-input" type="number" placeholder="here">
<p id="number-statistics-average" >Average :</p>
<p id="number-statistics-maximum">Maximum :</p>
<p id="number-statistics-minimum">Minimum :</p>
<ul id='number-statistics-numbers'>
</ul>
<button id='number-statistics-button' type="submit" onclick="statistics()">Submit</button>
</body>
</html>
29 changes: 29 additions & 0 deletions numberStatistics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
let sum = 0
let counter = 0
let min = Infinity
let max = -Infinity
function statistics() {
const num = document.getElementById('number-statistics-number-input').value
const num1 = Number(num)
const li = document.createElement('li')
li.textContent = num1
const list = document.getElementById('number-statistics-numbers')
list.appendChild(li)
let avg = 0
sum += num1
counter++
avg = Math.floor(sum / counter)
if (num1 < min) {
min = num1
}
if (num1 > max) {
max = num1
}
console.log(sum)
const firstParagraph = document.querySelector('#number-statistics-minimum')
firstParagraph.textContent = `Minimum: ${min}`
const secondParagraph = document.querySelector('#number-statistics-maximum')
secondParagraph.textContent = `Maximum: ${max}`
const thirdParagraph = document.querySelector('#number-statistics-average')
thirdParagraph.textContent = `Average: ${avg}`
}
90 changes: 48 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
},
"homepage": "https://github.com/joinpursuit/adding_elements_to_the_dom_lab#readme",
"devDependencies": {
"cypress": "^6.1.0"
"cypress": "^6.5.0"
}
}
14 changes: 14 additions & 0 deletions starWars.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="starWars.js" defer></script>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Star Wars</title>
</head>
<body>
<ul id="planets-list"></ul>

</body>
</html>
Loading