Skip to content

Instantly share code, notes, and snippets.

@natafaye
Created July 20, 2022 03:34
Show Gist options
  • Select an option

  • Save natafaye/3ae9c3bf919087fa49ad47cb1b2b15da to your computer and use it in GitHub Desktop.

Select an option

Save natafaye/3ae9c3bf919087fa49ad47cb1b2b15da to your computer and use it in GitHub Desktop.
function countPositivesSumNegatives(input) {
// check for empty array or null
if(input === null || input.length === 0) {
return [];
}
// get the positive numbers
const positiveNumbers = input.filter(number => number > 0)
// count how many
const countOfPositive = positiveNumbers.length;
// get the negative numbers
const negativeNumbers = input.filter( number => number < 0 )
// add them all up
const sumOfNegative = negativeNumbers.reduce( (total, number) => total + number );
return [countOfPositive, sumOfNegative]
}
body {
font-family: 'Courier New', Courier, monospace;
color: black;
background-color: lightgray;
margin: 0;
}
ul, li {
margin: 0;
padding: 0;
list-style-type: none;
}
/***** Navbar *****/
.navbar {
background-color: black;
color: white;
font-family: Arial, Helvetica, sans-serif;
padding: 15px;
display: flex;
align-items: center;
}
.navbar ul {
display: flex;
justify-content: right;
flex-grow: 1;
}
.navbar li {
padding: 5px;
margin-left: 10px;
}
.navbar a {
color: white;
text-decoration: none;
}
.navbar a:hover {
color: darkgray;
}
/***** Button *****/
.btn {
border-radius: 5px;
border-width: 0;
padding: 10px;
background-color: darkgray;
}
.tn-pubrple {
background-color: purple;
color: white;
}
.btn-green {
background-color: darkgreen;
color: white;
}
/***** Triple Section *****/
.triple-section {
display: flex;
padding: 20px;
text-align: center;
}
.triple-section div {
background-color: white;
margin: 10px;
padding: 15px;
}
/***** Footer *****/
.footer {
background-color: darkgray;
color: black;
padding: 20px;
}
<!DOCTYPE html>
<html>
<head>
<title>Week 8</title>
<link rel="stylesheet" href="week8.css"/>
</head>
<body>
<nav class="navbar">
<div>Chairs</div>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<div>
<div>
<h2>This is a catchy sentence about chairs</h2>
<button>See More</button>
</div>
<div class="triple-section">
<div>
And here is some more
<button class="btn btn-purple">See More</button>
</div>
<div>
Text about nothing
<button class="btn btn-green">See More</button>
</div>
<div>
To take up space
<button class="btn">See More</button>
</div>
</div>
<div>
Mauris id hendrerit libero. Nunc pulvinar lorem at ligula sodales
suscipit ut vitae nisi. Proin nec eleifend nisi. Mauris augue quam,
semper et orci sed, rutrum luctus tortor. Donec tincidunt ex a nibh
euismod luctus. Sed facilisis metus at tortor sollicitudin, ac
suscipit risus hendrerit. Proin justo justo, consequat in maximus a,
rhoncus eget turpis. Morbi ac tellus nisi. Duis nisi odio, blandit
vitae risus ut, aliquet fermentum massa. In id velit vestibulum,
consequat mauris a, tincidunt felis. Cras dui sapien, faucibus id
semper vel, malesuada sit amet dui. Suspendisse finibus, dolor sed
fringilla condimentum, diam eros sagittis lectus, non aliquam nisl
nisi vitae nisl. Aliquam dictum, arcu eu scelerisque mollis, libero
nisi tempor magna, sit amet dictum leo nunc eget mauris.
</div>
</div>
<footer class="footer">
Copyright 2021
<ul>
<li>Extra Links</li>
<li>Extra Links</li>
<li>Extra Links</li>
</ul>
</footer>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment