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
3 changes: 3 additions & 0 deletions 01week/helloworld.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict"

console.log("Hello World!");
22 changes: 22 additions & 0 deletions 04week/loop.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>


<div id="example"></div>


<div id="example1"></div>

<div id="example2"></div>

<script src="loop.js"></script>
</body>
</html>


20 changes: 20 additions & 0 deletions 04week/loop.js
Original file line number Diff line number Diff line change
@@ -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]}`);
}
33 changes: 31 additions & 2 deletions 04week/mastermind.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the part that checks for correctLetterLoc

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!"
}
}


Expand Down