Skip to content

Commit

Permalink
Merge pull request #48 from ChrisLebbano/master
Browse files Browse the repository at this point in the history
Prime #44
  • Loading branch information
bgates authored Mar 30, 2017
2 parents 10847c3 + d7f26c0 commit 0cc51f6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ <h3>Prime Number Button</h3>
<footer id="copyright">
<p>&copy; The Iron Yard 2017</p>
</footer>
<script src="prime.js"></script>
<script src="./index.js"></script>
<script src="fibbonaccisum.js"></script>
<script src="./fibonacci.js"></script>
<script src="./fizzbuzz.js"></script>
</body>
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// code below this line
/*function showSmallPic (){
console.log("http://fillmurray.com/100/100");
Expand All @@ -14,7 +15,7 @@ let picElement= document.querySelector("p img");
picElement.src="http://fillmurray.com/400/400";*/
}

let sizeButtons= document.querySelectorAll("button");
let sizeButtons= document.querySelectorAll("ul button");
//smallPic.addEventListener("click", showSmallPic);
for (let i=0; i < sizeButtons.length; i++){
let button = sizeButtons[i];
Expand Down
13 changes: 13 additions & 0 deletions prime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
let button = document.querySelector('button.prime');
let span = document.querySelector('span.number');
button.dataset.clicked = 0;
button.addEventListener('click', () => {
button.dataset.clicked++;
let num = button.dataset.clicked;
span.textContent = num;
let count = 0 ;
for(let i = 1; i <= num; i++) {
if (num % i === 0) count++;
}
if (count === 2) alert(`Prime number! ${num}`);
});

0 comments on commit 0cc51f6

Please sign in to comment.