Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ module.exports = {
ecmaVersion: 11,
},
rules: {
// Don't enforce block scope on "var" variable declarations, let JS behave as intended.
'block-scoped-var': 'off',
// Don't enforce control flow closing curly brace needs to be
// on same line as next control flow opening statement
'brace-style': 'off',
// Don't enforce ===
eqeqeq: 'off',
// Disable func-names rule so that we can have anonymous functions
Expand All @@ -16,12 +21,16 @@ module.exports = {
'linebreak-style': 'off',
// Allow console for students to debug
'no-console': 'off',
// Allow function param reassign for object properties
'no-param-reassign': ['error', { props: false }],
// Do not complain about unused main function
'no-unused-vars': ['error', { varsIgnorePattern: 'main' }],
// Enable var instead of just let and const
'no-var': 'off',
// Don't require a += b instead of a = a + b
'operator-assignment': 'off',
// Don't require array and object destructuring for variable assignment
'prefer-destructuring': 'off',
// Enable + sign to concatenate strings
'prefer-template': 'off',
// Disable radix requirement for functions like parseInt
Expand Down
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Please fill out the survey before submitting the pull request. Thanks!

🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀

How many hours did you spend on this assignment?

Please fill in one error and/or error message you received while working on this assignment.

What part of the assignment did you spend the most time on?

Comfort Level (1-5):

Completeness Level (1-5):

What did you think of this deliverable?

Is there anything in this code that you feel pleased about?
1 change: 0 additions & 1 deletion README.md

This file was deleted.

4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>SWE101</title>
<title>Secret Word</title>
<style>
* {
box-sizing: border-box;
Expand Down Expand Up @@ -50,7 +50,7 @@
</head>

<body>
<h1 id="header">SWE101! 🚀</h1>
<h1 id="header">Secret Word! 🚀</h1>
<div id="container">
<p>Input:</p>
<input id="input-field" />
Expand Down
43 changes: 42 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,45 @@
var correctCounter = 0; //Define the default win counter as zero

var main = function (input) {
var myOutputValue = 'hello world';
var randomSecretWord = secretWordReturn ();
console.log (randomSecretWord);

// Perform input validation
if (input != "banana" && input != "chisel" && input != "faucet") {
var myOutputValue = 'Please enter "faucet", "chisel" or "banana" to play.'
}

// 1st win statement with counter increment by 1 to track win times
else if (input == randomSecretWord && correctCounter == 0 ) {
myOutputValue = `You guess ${input}, the secret word is ${randomSecretWord}, keep guessing to win the 2nd time.`
correctCounter = correctCounter + 1;
}

// 2nd win statement with counter reset to zero
else if (input == randomSecretWord && correctCounter == 1 ) {
myOutputValue = `You guess ${input}, the secret word is ${randomSecretWord}, you have win twice, good job!`
correctCounter = 0;
}

// Keep track of how many wins remaining in between losses
else if (input != randomSecretWord && correctCounter == 1) {
myOutputValue = `You guess ${input}, the secret word is ${randomSecretWord}, you have to guess correctly one more time.`
}

// Default statement for all non-defined conditions
else {
myOutputValue = `You guess ${input}, the secret word is ${randomSecretWord}, please try again.`
}

return myOutputValue;
};

// Use random numbers to generate word return logic
var secretWordReturn = function () {
var randomDecimal = Math.random () * 3; // Define random numbers between 0 to 3
var randomInteger = Math.floor (randomDecimal); // Define integers 0, 1 ,2

if (randomInteger == 0) return "banana"; // If random number is 0, return "banana"
else if (randomInteger == 1) return "chisel"; // If random number is 1, return "chisel"
else return "faucet"; // All other numbers, return "faucet"
}