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
108 changes: 97 additions & 11 deletions day03-program-state/in-class/script.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,127 @@
// Global Variables

var winCount = 0;
var words = ["banana", "chisel", "faucet"];

var randomWord = function () {
var randomDecimal = Math.random() * 3;
var randomInteger = Math.floor(randomDecimal);
var randomWord = words[randomInteger];

return randomWord;
};

var secretWordBaseMain = function (input) {
// Complete the Base: Secret Word exercise below with secretWordBaseMain as the main function.
var myOutputValue = 'hello world';
return myOutputValue;
//randomly generated word
var chosenWord = randomWord();

// outerloop verifies randomword & input
if (input == chosenWord) {
winCount = winCount + 1;
// inner loop verifies count
if (winCount == 2) {
return `The word is ${chosenWord}.You've guessed correctly twice, Congrats!`;
} else {
return `You've got it right, the word is ${chosenWord}. Your number of wins is ${winCount}.`;
}
} else {
var myOutputValue = `The word is ${chosenWord}. You've got it wrong!`;
return myOutputValue;
}
};

var secretWordTwiceRowMain = function (input) {
// Complete the Comfortable: Secret Word Twice in a Row exercise below with secretWordTwiceRowMain as the main function.
var myOutputValue = 'hello world';
return myOutputValue;
var chosenWord = randomWord();
if (input == chosenWord) {
winCount = winCount + 1;
if (winCount >= 2) {
return `You've guess twice correctly!.The chosen word is ${chosenWord}`;
} else {
return `You've got it right, the word is ${chosenWord}. Guess one more time to win!`;
}
} else {
return `The chosen word is ${chosenWord}. You have guess incorrectly.`;
winCount = 0;
}
};

// Global Variables

var randomWinCount = 0;

var winsGenerator = function () {
var winCount = [2, 3, 4];
var randomDecimal = Math.random() * 3;
var randomInteger = Math.floor(randomDecimal);
var winsNeeded = winCount(randomInteger);
return winsNeeded;
};

var secretWordXRowMain = function (input) {
// Complete the Comfortable: Secret Word X in a Row exercise below with secretWordXRowMain as the main function.
var myOutputValue = 'hello world';
return myOutputValue;
// Generate a win count once each round
if (randomWinCount == 0) {
var randomWinCount = winsGenerator();
console.log(randomWinCount);
} else {
var chosenWord = randomWord();
if (input == chosenWord) {
winCount = winCount + 1;
if (winCount >= randomWinCount) {
return `Chosen word is ${chosenWord}.Win count needed is ${randomWinCount}.Congrats you won ${winCount}`;
} else {
return `You've got it right, the word is ${chosenWord}. Guess one more time to win!`;
}
} else {
return `The chosen word is ${chosenWord}. You have guess incorrectly.`;
winCount = 0;
}
}
};

var diceWithinMain = function (input) {
// Complete the More Comfortable: Dice Within exercise below with diceWithinMain as the main function.
var myOutputValue = 'hello world';
var myOutputValue = "hello world";
return myOutputValue;
};

var diceNumberGenerator = function () {
let randomDecimal = Math.random() * 6;
let randomInteger = Math.floor(randomDecimal) + 1;
return randomInteger;
};

var withinNumberGenerator = function () {
let randomDecimal = Math.random() * 3;
let randomInteger = Math.floor(randomDecimal) + 1;
return randomInteger;
};

var diceWithin2DiceMain = function (input) {
// Complete the More Comfortable: Dice Within with 2 Dice exercise below with diceWithin2DiceMain as the main function.
var myOutputValue = 'hello world';
return myOutputValue;
let diceNumber = diceNumberGenerator();
let withinNumber = withinNumberGenerator();

if (
input >= diceNumber - withinNumber ||
input <= diceNumber + withinNumber
) {
return `Dice number is ${diceNumber}. You win!`;
} else {
return `Dice number is ${diceNumber}. You lose.`;
}
};

var dice4DMain = function (input) {
// Complete the More Comfortable: Dice 4D exercise below with dice4DeMain as the main function.
var myOutputValue = 'hello world';
var myOutputValue = "hello world";
return myOutputValue;
};

var secretWordTwice2Main = function (input) {
// Complete the More Comfortable: Secret Word Twice in a Row 2 exercise below with secretWordTwice2Main as the main function.
var myOutputValue = 'hello world';
var myOutputValue = "hello world";
return myOutputValue;
};
44 changes: 34 additions & 10 deletions day03-program-state/pre-class/script.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,77 @@
var introScopeMain = function (input) {
// Attempt the Follow Along exercise from the Intro to Scope module below with introScopeMain as the main function.
var myOutputValue = 'hello world';
var myOutputValue = "hello world";
return myOutputValue;
};

var prevNumber;

var rollDice = function () {
// produces a decimal between 0 and 6
var randomDecimal = Math.random() * 6;

// take off the decimal
var randomInteger = Math.floor(randomDecimal);

// it's a number from 0 - 5 ... add 1
var diceNumber = randomInteger + 1;

return diceNumber;
};

var appSetupMain = function (input) {
// Attempt the Base: App Setup exercise from the Program Lifecycle and State module below with appSetupMain as the main function.
var myOutputValue = 'hello world';
var randomDiceNumber = rollDice();

var myOutputValue = `Your last roll was ${prevNumber}. You just rolled ${randomDiceNumber}. You guessed ${input}. You lose!`;
prevNumber = randomDiceNumber;

if (randomDiceNumber == input) {
myOutputValue = `Your last roll was ${prevNumber}. You just rolled ${randomDiceNumber}. You guessed ${input}. You win!`;
prevNumber = randomDiceNumber;
}

return myOutputValue;
};

var lastRollMain = function (input) {
// Attempt the Base: Last Roll exercise from the Program Lifecycle and State module below with lastRollMain as the main function.
var myOutputValue = 'hello world';
var myOutputValue = "hello world";
return myOutputValue;
};

var winLossMain = function (input) {
// Attempt the Base: Win / Loss exercise from the Program Lifecycle and State module below with winLossMain as the main function.
var myOutputValue = 'hello world';
var myOutputValue = "hello world";
return myOutputValue;
};

var mostRolledMain = function (input) {
// Attempt the More Comfortable: Most Rolled exercise from the Program Lifecycle and State module below with mostRolledMain as the main function.
var myOutputValue = 'hello world';
var myOutputValue = "hello world";
return myOutputValue;
};

var guessingMain = function (input) {
// Attempt the More Comfortable: Guessing exercise from the Program Lifecycle and State module below with guessingMain as the main function.
var myOutputValue = 'hello world';
var myOutputValue = "hello world";
return myOutputValue;
};

var advancedGuessingMain = function (input) {
// Attempt the More Comfortable: Advanced Guessing exercise from the Program Lifecycle and State module below with advancedGuessingMain as the main function.
var myOutputValue = 'hello world';
var myOutputValue = "hello world";
return myOutputValue;
};

var followAlongMain = function (input) {
// Attempt the Follow Along exercise from the Program State for Game Modes module below with followAlongMain as the main function.
var myOutputValue = 'hello world';
var myOutputValue = "hello world";
return myOutputValue;
};

var redModeMain = function (input) {
// Attempt the Red Mode exercise from the Program State for Game Modes module below with redModeMain as the main function.
var myOutputValue = 'hello world';
var myOutputValue = "hello world";
return myOutputValue;
};
};
102 changes: 93 additions & 9 deletions day04-loops/in-class/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,106 @@ var emojiCenterSquareMain = function (input) {
return myOutputValue;
};

var numberOfDiceRoll = 0;
var winCount = 0;
var loseCount = 0;
var isWon = false;

var generateDiceNumber = function () {
var randomDecimal = Math.random() * 6;
var randomInteger = Math.floor(randomDecimal) + 1;
return randomInteger;
};

var multiDiceBaseMain = function (input) {
// Complete the Base: Multi-Dice Game exercise below with multiDiceBaseMain as the main function.
var myOutputValue = "hello world";
return myOutputValue;
// User determine number of rounds
if (numberOfDiceRoll == 0) {
numberOfDiceRoll = input;
console.log(numberOfDiceRoll);
return `Number of rounds is ${numberOfDiceRoll}.Please make your guess.`;
} else {
// check for any correct guesses
for (var i = 0; i < numberOfDiceRoll; i += 1) {
var diceNumber = generateDiceNumber();
console.log(`Dice Number is ${diceNumber}.`);
if (diceNumber == input) {
var isWon = true;
}
}
if (isWon) {
winCount = winCount + 1;
var myOutputValue = "You Won";
} else {
loseCount = loseCount + 1;
var myOutputValue = "You Lost";
}
return `${myOutputValue}.Win Count is ${winCount}. Loss Count is ${loseCount}.`;
}
};

var multiDiceMultiRoundMain = function (input) {
// Complete the More Comfortable: Multi-Round Multi-Dice Game exercise below with multiDiceMultiRoundMain as the main function.
var myOutputValue = "hello world";
return myOutputValue;
if (numberOfDiceRoll == 0) {
numberOfDiceRoll = input;
console.log(numberOfDiceRoll);
return `Number of rounds is ${numberOfDiceRoll}.Please make your guess.`;
} else {
// check for any correct guesses
for (var i = 0; i < 4; i += 1) {
for (var j = 0; j < numberOfDiceRoll; j += 1) {
var diceNumber = generateDiceNumber();
console.log(`Dice Number is ${diceNumber}.`);
if (diceNumber == input) {
var isWon = true;
}
}
}
if (isWon) {
winCount = winCount + 1;
var myOutputValue = "You Won";
} else {
loseCount = loseCount + 1;
var myOutputValue = "You Lost";
}
return `${myOutputValue}.Win Count is ${winCount}. Loss Count is ${loseCount}.`;
}
};

var numberOfPlayers = 0;

var multiDiceTwoPlayerMain = function (input) {
// Complete the More Comfortable: Two Player Multi-Round Multi-Dice Game exercise below with multiDiceTwoPlayerMain as the main function.
var myOutputValue = "hello world";
return myOutputValue;
if (numberOfPlayers == 0) {
numberOfPlayers = input;
return `There are ${numberOfPlayers} players in this game. First player to first input the number of rounds.`;
} else {
for (var k = 1; k < numberOfPlayers + 1; k += 1) {
if (numberOfDiceRoll == 0) {
numberOfDiceRoll = input;
console.log(numberOfDiceRoll);
return `Number of rounds is ${numberOfDiceRoll}.Please make your guess.`;
} else {
// check for any correct guesses
for (var i = 0; i < 4; i += 1) {
for (var j = 0; j < numberOfDiceRoll; j += 1) {
var diceNumber = generateDiceNumber();
console.log(`Dice Number is ${diceNumber}.`);
if (diceNumber == input) {
var isWon = true;
}
}
}
if (isWon) {
winCount = winCount + 1;
var myOutputValue = "You Won";
} else {
loseCount = loseCount + 1;
var myOutputValue = "You Lost";
}
return `${myOutputValue}.Win Count is ${winCount}. Loss Count is ${loseCount}.Player ${
k + 1
} is next.`;
}
}
}
};

var multiDiceMultiPlayerMain = function (input) {
Expand Down
2 changes: 1 addition & 1 deletion day04-loops/pre-class/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var followAlongMain = function (input) {
// Attempt the Follow Along exercise from the Loops module below with followAlongMain as the main function.
var myOutputValue = "hello world";
var myOutputValue = "hello worl";
return myOutputValue;
};

Expand Down
8 changes: 8 additions & 0 deletions day05-mad-libs/in-class/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ var madLibsAdjectivesMain = function (input) {
return myOutputValue;
};


for (j=0, i<names.length, j+=1){
myOutputValue += "names.[i]" + "," + "</br>";
}

return myOutputValue


var madLibsInputCreateMain = function (input) {
// Complete the Comfortable: Input and Create Mode exercise below with madLibsInputCreateMain as the main function.
var myOutputValue = 'hello world';
Expand Down
Loading