Skip to content
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
50 changes: 26 additions & 24 deletions 05week/checkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
}

Expand All @@ -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
Expand All @@ -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{
Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion 07week/dodegeBall/dodgeBall.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
7 changes: 7 additions & 0 deletions 07week/marvelLookup/marvel.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* {
box-sizing: border-box;
}
main {
display: flex;
justify-content: space-evenly;
}
25 changes: 25 additions & 0 deletions 07week/marvelLookup/marvel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="./marvel.css">

<title>Document</title>
</head>
<body>
<div class="left">
<h1>Characters</h1>
<div id='characters'></div>
</div>

<div class="right">
<h1>Collected</h1>
<div id="collected"></div>
</div>


<script src="marvel.js"></script>
</body>

</html>
60 changes: 60 additions & 0 deletions 07week/marvelLookup/marvel.js
Original file line number Diff line number Diff line change
@@ -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<len; i++ ){
}
})
}

const collected = []
var charData = (charts) =>{
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()
// }










24 changes: 24 additions & 0 deletions 08week/recursion/recursion.js
Original file line number Diff line number Diff line change
@@ -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]));