From 72002c519274f5ec6dc48812ed8b71944969c851 Mon Sep 17 00:00:00 2001 From: Connor Yates Date: Mon, 7 Oct 2019 13:31:06 -0500 Subject: [PATCH 1/2] final marvel submition --- 07week/dodegeBall/dodgeBall.js | 2 +- 07week/marvelLookup/marvel.css | 7 ++++ 07week/marvelLookup/marvel.html | 25 ++++++++++++++ 07week/marvelLookup/marvel.js | 60 +++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 07week/marvelLookup/marvel.css create mode 100644 07week/marvelLookup/marvel.html create mode 100644 07week/marvelLookup/marvel.js diff --git a/07week/dodegeBall/dodgeBall.js b/07week/dodegeBall/dodgeBall.js index 518f6cd2d..2e6ee53f4 100644 --- a/07week/dodegeBall/dodgeBall.js +++ b/07week/dodegeBall/dodgeBall.js @@ -81,7 +81,7 @@ class redTeammate extends player{ constructor(canThrowBall,canDodgeBall,hasPaid,isHealthy,yearsExperience,mascot,teamColor){ super(canThrowBall,canDodgeBall,hasPaid,isHealthy,yearsExperience); this.mascot = RedRaiders; - this.teamColor = teamColor; + this.teamColor = teamColor; } } diff --git a/07week/marvelLookup/marvel.css b/07week/marvelLookup/marvel.css new file mode 100644 index 000000000..f8bdc7f50 --- /dev/null +++ b/07week/marvelLookup/marvel.css @@ -0,0 +1,7 @@ +* { + box-sizing: border-box; +} +main { + display: flex; + justify-content: space-evenly; +} \ No newline at end of file diff --git a/07week/marvelLookup/marvel.html b/07week/marvelLookup/marvel.html new file mode 100644 index 000000000..caa86b0a0 --- /dev/null +++ b/07week/marvelLookup/marvel.html @@ -0,0 +1,25 @@ + + + + + + + + Document + + +
+

Characters

+
+
+ +
+

Collected

+
+
+ + + + + + \ No newline at end of file diff --git a/07week/marvelLookup/marvel.js b/07week/marvelLookup/marvel.js new file mode 100644 index 000000000..052de84db --- /dev/null +++ b/07week/marvelLookup/marvel.js @@ -0,0 +1,60 @@ +// Create a request variable and assign a new XMLHttpRequest object to it. +var request = new XMLHttpRequest() +getCharacters(); +// var dataName = '' +function getCharacters (){ + + fetch("http://gateway.marvel.com/v1/public/characters?ts=1&apikey=fc273af0f86e9c39dc17cb69b19fa0c6&hash=706f0130c1217ad47bc6f5564ef70b00") + .then(response => { + return response.json() + }) + .then(data => { + charData(data.data); + for(let i=0, len=charData.length; i{ + var characters = document.getElementById('characters'); + characters.setAttribute('id','removeChar') + charts.results.map(results => { + const li = document.createElement("li") + let colButton = document.createElement("button") + colButton.setAttribute('id','removeButton') + colButton.innerHTML = "Collect Character" + colButton.addEventListener('click', function() {collected.push(results),{once:true}, + collect()}) + li.appendChild(colButton) + li.appendChild(document.createTextNode(results.name)) + characters.appendChild(li) + }) + }; + + + var collect = ()=> { + const collection = document.getElementById('collected') + removeButton.remove() + // removeChar.remove() + collection.innerHTML = null; + + collected.map(charts => { + const li = document.createElement('li') + li.append(document.createTextNode(charts.name)) + collection.append(li) + }) + } + // var removeButton = ()=> { + // removeChar.remove() + // } + + + + + + + + + + \ No newline at end of file From 2c9c9abfdf04d356df3de1cee477e2f9e4e55997 Mon Sep 17 00:00:00 2001 From: Connor Yates Date: Mon, 7 Oct 2019 13:33:24 -0500 Subject: [PATCH 2/2] submitting recursion --- 05week/checkers.js | 50 ++++++++++++++++++----------------- 08week/recursion/recursion.js | 24 +++++++++++++++++ 2 files changed, 50 insertions(+), 24 deletions(-) create mode 100644 08week/recursion/recursion.js diff --git a/05week/checkers.js b/05week/checkers.js index 01439f4e1..dc6716e46 100644 --- a/05week/checkers.js +++ b/05week/checkers.js @@ -52,6 +52,7 @@ class Board { [7, 0], [7, 2], [7, 4], [7, 6]]; //define positions for(let p = 0; p <= 11; p++){ + //create checker instances set to variables let whiteChecker = new Checker('white'); this.checkers.push(whiteChecker); let position = whitePositions[p]; @@ -68,13 +69,13 @@ class Board { legalMove(which,where) { console.log(which,where); - + //keeps players from going outside of the grid if(which.length !== 2 || which[0] > 7 || which[1] > 7){ - console.log('Please enter numbers less than 8') + console.log('Please enter a number within the grid') return false; } if(where.length !== 2 || where[0] > 7 || where[1] > 7){ - console.log('Please enter numbers less than 8') + console.log('Please enter a number within the grid') return false; } @@ -84,25 +85,23 @@ class Board { } validMove(whichPiece,toWhere){ - // white moves -var start = parseInt(whichPiece); -var end = parseInt(toWhere); - -console.log(start,end); + var start = parseInt(whichPiece); + var end = parseInt(toWhere); + + console.log(start,end); + + // only allows players to move diagonaly + //flip start and end so the value's not negative if(player == 'white'){ if(end - start !==9 && end - start !== 11){ console.log("Invalid Move"); return false } } - // if(start - end !== 18 || start - end !== 22){ - - // return false - // } + //black moves if(player == 'black' ){ - //flip start and end so the value's not negative if(start - end !== 9 && start - end !==11 ){ console.log("Invalid Move"); return false @@ -117,21 +116,23 @@ console.log(start,end); killChecker(whichPiece,toWhere){ var start = parseInt(whichPiece); var end = parseInt(toWhere); + console.log(start,end); var jumpRightWhite = this.board.grid[((start)[0]) +1][((start)[1]) +1] var jumpLeftWhite = this.board.grid[((start)[0]) +1][((start)[1]) -1] var jumpRightBlack = this.board.grid[((start)[0]) -1][((start)[1]) +1] var jumpLeftBlack = this.board.grid[((start)[0]) -1][((start)[1]) -1] if(player == 'white'){ - if(start - end !== 18 && start - end !== 22){ + if(end - start !== 18 && end - start !== 22){ return false - }else{ - if(jumpRightWhite === 'white' && whichPiece - toWhere === 18){ - this.board.grid[(start[0]) -1][(start[1]) +1] = null + } + else{ + if(jumpRightWhite === 'white' && end - start === 18){ + this.board.grid[(start[0]) +1][(start[1]) +1] = null return true; } - if(jumpLeftWhite === 'white' && whichPiece - toWhere === 18){ - this.board.grid[(start[0]) -1][(start[1]) -1] = null + if(jumpLeftWhite === 'white' && end - start === 18){ + this.board.grid[(start[0]) +1][(start[1]) -1] = null return true; } else{ @@ -143,13 +144,14 @@ console.log(start,end); if(player == 'black' ){ if(start - end !== 18 && start - end !== 22){ return false - }else{ - if(jumpRightBlack === 'black' && whichPiece - toWhere === 18){ - this.board.grid[(start[0]) +1][(start[1]) +1] = null + } + else{ + if(jumpRightBlack === 'black' && start - end === 18){ + this.board.grid[(start[0]) -1][(start[1]) +1] = null return true; } - if(jumpLeftBlack === 'black' && whichPiece - toWhere === 18){ - this.board.grid[(start[0]) +1][(start[1]) -1] = null + if(jumpLeftBlack === 'black' && start - end === 18){ + this.board.grid[(start[0]) -1][(start[1]) -1] = null return true; } else{ diff --git a/08week/recursion/recursion.js b/08week/recursion/recursion.js new file mode 100644 index 000000000..ed16a42d8 --- /dev/null +++ b/08week/recursion/recursion.js @@ -0,0 +1,24 @@ +let exponent = (c, n) => { + if (n === 0) + { + return 1; + } + else + { + return c * exponent(c, n-1); + } +}; + +console.log(exponent(5, 3)); + + +let arraySum = (myArray) => { + if (myArray.length === 1) { + return myArray[0]; + } + else { + return myArray.pop() + arraySum(myArray); + } +}; + +console.log(arraySum([24,45,34,69,55,69,71,86])); \ No newline at end of file