Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
748d055
created html css & js files. imported previous tower code for html & css
r-pm Apr 18, 2020
25e390e
set styling
r-pm Apr 19, 2020
fbe905f
Create README.md
r-pm Apr 19, 2020
6478eb5
Update README.md
r-pm Apr 19, 2020
c3fc181
this is where i was at when i realized i was both trying to create a …
r-pm Apr 20, 2020
bad16a4
got my logic down, but need it to be checked
r-pm Apr 20, 2020
eb8ae5f
bebugged js. still need to review syntax
r-pm Apr 20, 2020
e9d4df4
Merge branch 'rpm/checkpoint1' of https://github.com/r-pm/javascript-…
r-pm Apr 20, 2020
583c924
edits from tutor sesh with emilio. almost there! start is not defined…
r-pm Apr 20, 2020
f9cd69f
updated html & css to connect to js more clearly. cleaned up js
r-pm Apr 21, 2020
a3302b1
added test code to js. seems to have resolved template code errors - …
r-pm Apr 21, 2020
f206c0f
fixed test code. still getting error from template code. will make al…
r-pm Apr 21, 2020
0c13573
more work on test code
r-pm Apr 22, 2020
e10e778
welp i solved the template code errors by removing all testing code. …
r-pm Apr 22, 2020
78488d4
ok fixed css so that i can see my game towers & disks. added a wrap t…
r-pm Apr 22, 2020
eb1a71b
error for undefined html element. think i went wrong somewhere with e…
r-pm Apr 22, 2020
4bfbeea
terminal app using towersOfHanoi template. finished with code but not…
r-pm Apr 22, 2020
4d7ef20
revised checkpoint code to pass tests. placed variables & parameters.
r-pm Apr 23, 2020
224c914
had a tutor look over my code. they also could not get it to pass tes…
r-pm Apr 23, 2020
9638a30
thiiink i fixed isLegal bug by changing conditionals on arrays & chan…
r-pm Apr 24, 2020
037f5f1
first attempt at function mastermind(). making sense
r-pm Apr 25, 2020
55d03dd
finally passes all tests! cleaned up & reduced code.test for win requ…
r-pm Apr 25, 2020
cc7609f
could not figure out how to do nested forEach so need nested for loop…
r-pm Apr 26, 2020
6652ed9
finished nested for loop. can not get it to console log the compariso…
r-pm Apr 26, 2020
cf7e49e
welp i cant figure out how to change specific iterations of the strin…
r-pm Apr 26, 2020
63fac4a
sigh. cleaned up code a bit. consolidated for loop functions into one…
r-pm Apr 28, 2020
a5ae2ad
higher order loops hw begun
r-pm Apr 28, 2020
be4929a
complete
r-pm Apr 28, 2020
d71e9fa
wont need the workbook js file
r-pm Apr 29, 2020
e7c7028
right now hangman terminal app works! about to attempt gui
r-pm May 1, 2020
f712739
classwork hangman. sad face gui is not working
r-pm May 1, 2020
d6aed06
started sorting hw. went thru & guessed higher order functions for ea
r-pm May 2, 2020
586061d
on 2
r-pm May 4, 2020
8d22ae2
some tips
r-pm May 5, 2020
b595b4f
not getting how to do higher order funct with #3
r-pm May 5, 2020
f9b3cd3
cant figure out how to delcare map() array in #4
r-pm May 5, 2020
a2ef38a
complete. not all tested. could not use higher order func for #5
r-pm May 5, 2020
e818383
classwork
r-pm May 6, 2020
f5107f1
class prep
r-pm May 9, 2020
e13128d
started files for checkpoint 2. read me code plan
r-pm May 13, 2020
5d9f942
pseudo code draft for js
r-pm May 13, 2020
97174f8
q
r-pm May 13, 2020
1d9694b
working on classes
r-pm May 15, 2020
bb2e28b
pool of people displays as i want. tweak event listener on select.
r-pm May 16, 2020
dc968c2
it all works hurray
r-pm May 16, 2020
24e2976
added error handling
r-pm May 16, 2020
c3a7955
added some tests
r-pm May 17, 2020
76f5949
some css
r-pm May 17, 2020
f1457d6
finished css
r-pm May 17, 2020
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
37 changes: 29 additions & 8 deletions 03week/towersOfHanoi.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,45 @@ function printStacks() {
console.log("c: " + stacks.c);
}

function movePiece() {
// Your code here
function movePiece(startStack,endStack) {
// console.log(start)
// console.log(end)
let disc = stacks[startStack].pop();
// console.log(disc)
stacks[endStack].push(disc);

}

function isLegal() {
// Your code here

function isLegal(startStack,endStack) {
let start = stacks[startStack];
let end = stacks[endStack];
let startDisc = start[start.length-1];
let endDisc = end[end.length-1];
// console.log(startDisc,endDisc)
if(start.length == 0 ){
return false;
}else if((startDisc < endDisc) ||(end.length == 0)){
return true;
}else{
console.log('invalid, did nothing')
return false;

}

}

function checkForWin() {
// Your code here

if (stacks.b.length === 4 || stacks.c.length === 4){
console.log('win!')
return true;
}else {
return false;
}
}

function towersOfHanoi(startStack, endStack) {
// Your code here

movePiece(startStack,endStack);
}

function getPrompt() {
Expand Down
68 changes: 68 additions & 0 deletions 04week/loop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Use a do...while loop to console.log the numbers from 1 to 1000.
let result = [,];
let i = 0;

do {
i = i + 1;
result = result + i;
} while (i <= 999);
console.log(result);

// Create an object (an array with keys and values) called person with the following data:
let person = {
firstName: "Jane",
lastName: "Doe",
birthDate: "Jan 5, 1925",
gender: "female"
}

// Use a for...in loop and if statement to console.log
//the value associated with the key birthDate if the birth year is an odd number.
for(birthDate in person){
if(birthDate % 2 !== 0){
console.log(person.birthDate);
};
}

// Create an arrayOfPersons that contains multiple objects.
//You can simply copy/paste the person object you made above multiple times.
//Feel free to change the values to reflect multiple people you might have in your database.
arrayOfPersons = [
{
firstName: "Jane",
lastName: "Doe",
birthDate: "Jan 5, 1925",
gender: "female"
},
{
firstName: "Bob",
lastName: "Doe",
birthDate: "Jan 5, 1925",
gender: "female"
},
{
firstName: "Steve",
lastName: "Doe",
birthDate: "Jan 5, 1925",
gender: "female"
},
{
firstName: "Marcus",
lastName: "Doe",
birthDate: "Jan 5, 1925",
gender: "female"
},
]

// Use .map() to map over the arrayOfPersons and console.log() their information.
let info = arrayOfPersons.map(arrayOfPersons);
console.log(info);

// Use .filter() to filter the persons array and console.log only males in the array.
const males = arrayOfPersons.filter(arrayOfPersons.gender !="female");
console.log(males);

// Use .filter() to filter the persons array and console.log only people that were born before Jan 1, 1990.
const thirty = arrayOfPersons.filter(arrayOfPersons.birthDate < "Jan 1, 1990");
console.log(thirty);

59 changes: 42 additions & 17 deletions 04week/mastermind.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const rl = readline.createInterface({
});

let board = [];
let solution = '';
let solution =['abcd'];
let letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];

function printBoard() {
Expand All @@ -17,31 +17,56 @@ function printBoard() {
}
}

function generateSolution() {
for (let i = 0; i < 4; i++) {
const randomIndex = getRandomInt(0, letters.length);
solution += letters[randomIndex];
}
}
// function generateSolution() { //creates the randomized solution
// for (let i = 0; i < 4; i++) {
// const randomIndex = getRandomInt(0, letters.length);
// solution += letters[randomIndex];
// }
// }

// function getRandomInt(min, max) { //creates rando interger to use in generate soln?
// return Math.floor(Math.random() * (max - min)) + min;
// }

function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}

function generateHint() {
// your code here
function generateHint(guess) {
let countExact = 0;
let countLetter = 0;
// could i have used: for (let i of guess){} ? //
for (let i= 0; i<= guess.length; i++) {
for (let j= 0; j< 4; j++) {//for each [i] of array, compare every [j] of array
if(guess[i] == solution[i]){ //for exact match
countExact ++; //add to count
solution[i] = 'null';//take it off soln [] so it won't be double counted
//add to board [] <- has all the exact matches //<- the test seems to use board.length for hints?


}else if(guess[i] == solution[j]){//for letter only match
countLetter++; //add to count
solution[j] = 'null';//take off solution
// board.push(solution[j]);//add to board [] <- now has all the exact & letter only matches, including doubles, in order:exact,letter
};
return `${countExact} - ${countLetter}`;
};
};
}

function mastermind(guess) {
solution = 'abcd'; // Comment this out to generate a random solution
// your code here

function mastermind(guess) {
// console.log(solution);
if(guess === solution){
console.log('You guessed it!');
}else{
generateHint(guess);
}

}


function getPrompt() {
printBoard();
rl.question('guess: ', (guess) => {
mastermind(guess);
printBoard();
getPrompt();
});
}
Expand Down Expand Up @@ -72,6 +97,6 @@ if (typeof describe === 'function') {

} else {

generateSolution();
// generateSolution();
getPrompt();
}
171 changes: 171 additions & 0 deletions 06week/hangman.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/* general */
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
/*
/* create a stick figure */
.person {
position: relative;
margin: 1 auto;
width: 150px;
height: 350px;
text-align: center;
}
.person > div {
margin: 1 auto;
position: absolute;
}
.person > div.center {
margin: 1 auto;
left: 50%;
transform: translateX(-50%);
}
.person .head {
height: 50px;
width: 50px;
border: solid 1px #000;
border-radius: 50%;
}
.person .torso {
width: 1px;
height: 85px;
background: #000;
top: 51px;
}
.person .arm {
width: 1px;
height: 35px;
background: #000;
top: 55px;
}
.person .arm.left {
left: calc(50% - 1px);
transform-origin: bottom;
transform: rotate(-45deg);
animation-name: wave;
animation-duration: 10s;
animation-iteration-count: infinite;
}
.person .arm.right {
left: calc(50% - 1px);
transform-origin: bottom;
transform: rotate(45deg);
}
.person .leg {
width: 1px;
height: 50px;
background: #000;
top: 85px;
}
.person .leg.left {
left: calc(50% - 1px);
transform-origin: bottom;
transform: rotate(-145deg);
}
.person .leg.right {
left: calc(50%);
transform-origin: bottom;
transform: rotate(145deg);
}

@keyframes wave {
0% {
transform-origin: bottom;
transform: rotate(-45deg);
}
10% {
transform-origin: bottom;
transform: rotate(-75deg);
}
20% {
transform-origin: bottom;
transform: rotate(-45deg);
}
}

/* .person {
position: relative;
margin: 0 auto;
width: 150px;
height: 350px;
text-align: center;
}
.head-center {
left: 50%;
transform: translateX(-50%);
}

.head {
height: 50px;
width: 50px;
border: solid 1px #000;
border-radius: 50%;
}

.torso-center {
width: 1px;
height: 85px;
background: #000;
top: 51px;
}

.arm-left{
width: 1px;
height: 35px;
background: #000;
top: 55px;
left: calc(50% - 1px);
transform-origin: bottom;
transform: rotate(-45deg);
animation-name: wave;
animation-duration: 10s;
animation-iteration-count: infinite;
}
.arm-right{
width: 1px;
height: 35px;
background: #000;
top: 55px;
left: calc(50% - 1px);
transform-origin: bottom;
transform: rotate(45deg);
}

.leg-left {
width: 1px;
height: 50px;
background: #000;
top: 85px;
left: calc(50% - 1px);
transform-origin: bottom;
transform: rotate(-145deg);
}
.leg-right {
width: 1px;
height: 50px;
background: #000;
top: 85px;
left: calc(50%);
transform-origin: bottom;
transform: rotate(145deg);
}

@keyframes wave {
0% {
transform-origin: bottom;
transform: rotate(-45deg);
}
10% {
transform-origin: bottom;
transform: rotate(-75deg);
}
20% {
transform-origin: bottom;
transform: rotate(-45deg);
}
} */
/* display hide */
if wrong guess, display on thru js */
Loading