From 2beb75b3c1f66b7460413df98290daaf52c62e02 Mon Sep 17 00:00:00 2001 From: Chris Trevino Date: Tue, 24 Mar 2020 19:41:52 -0500 Subject: [PATCH 1/4] changes --- 01week/helloworld.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 01week/helloworld.js diff --git a/01week/helloworld.js b/01week/helloworld.js new file mode 100644 index 000000000..3ae23b3df --- /dev/null +++ b/01week/helloworld.js @@ -0,0 +1,3 @@ +node"use strict" + + console.log("Hello World!"); \ No newline at end of file From 3f482adfbd35066151f2223268150c73b8f13974 Mon Sep 17 00:00:00 2001 From: Chris Trevino Date: Tue, 24 Mar 2020 19:49:19 -0500 Subject: [PATCH 2/4] 1stprogram --- 01week/helloworld.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01week/helloworld.js b/01week/helloworld.js index 3ae23b3df..8274abb6f 100644 --- a/01week/helloworld.js +++ b/01week/helloworld.js @@ -1,3 +1,3 @@ -node"use strict" +"use strict" console.log("Hello World!"); \ No newline at end of file From f83ca34f52454c058a51d1436bd4f3f42de2f463 Mon Sep 17 00:00:00 2001 From: Chris Trevino Date: Thu, 23 Apr 2020 00:34:50 -0500 Subject: [PATCH 3/4] changes --- 04week/loop.html | 22 ++++++++++++++++++++++ 04week/loop.js | 20 ++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 04week/loop.html diff --git a/04week/loop.html b/04week/loop.html new file mode 100644 index 000000000..5db6a6a42 --- /dev/null +++ b/04week/loop.html @@ -0,0 +1,22 @@ + + + + + + Document + + + + +
+ + +
+ +
+ + + + + + diff --git a/04week/loop.js b/04week/loop.js index e69de29bb..bc478b8ac 100644 --- a/04week/loop.js +++ b/04week/loop.js @@ -0,0 +1,20 @@ +alert("you've connected yo") +var result = ''; +var i = 0; +do { + i += 1; + result += i + ' '; +} while (i > 0 && i < 1000); // Despite i == 0 this will still loop as it starts off without the test + +console.log(result); + +let person = { + firstName: "Jane" + lastName: "Doe" + birthDate: "Jan 5, 1925" + gender: "female" +} + +for (const prop in person) { + console.log(`person.${prop} = ${person[prop]}`); +} From e7fb8f1c003b7ac2aeacef2987534d01ea2de590 Mon Sep 17 00:00:00 2001 From: Chris Trevino Date: Thu, 23 Apr 2020 12:41:19 -0500 Subject: [PATCH 4/4] changes --- 04week/mastermind.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/04week/mastermind.js b/04week/mastermind.js index 60e5cfa18..82bbcd59b 100644 --- a/04week/mastermind.js +++ b/04week/mastermind.js @@ -28,13 +28,42 @@ function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min)) + min; } -function generateHint() { +function generateHint(guess) { // your code here + let randomArray = guess.split(''); + let solutionArray = solution.split(''); + + let correctLetterLoc = 0; + let correctLetters = 0; + + for (let i = 0; i < 4; i++) { + let targetIndex = solutionArray.indexOf(randomArray[i]); + if (targetIndex > -1) { + correctLetters++; + solutionArray[targetIndex] = null; + console.log(solutionArray); + } + } + return correctLetterLoc + '-' + correctLetters; +} + + +function checkForWin (guess, solution) { + + if (guess === solution) { + return true; + } else { + return; + } } function mastermind(guess) { solution = 'abcd'; // Comment this out to generate a random solution - // your code here + let hint = generateHint(guess); + board.push(`Guess: ${guess} - Hint: ${hint}`); + if (checkForWin(guess, solution) == true) { + return "you guessed it!" + } }