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
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,67 @@
Background Information:
Install a Package: npm inti -y
package json [allowing you to add packages to run using will be able to input things etc.]

.gitignore []


Notes:
const name =readLineSync.question ("What's your name?")
console.log("hello" + name + "it's nice to meet you!")

console.log("") //new line

const answer = readLineSync.keyInYN (Do you like soccer?")
console.log(answer)


if (readLineSync.keyInYN (Do you like soccer?")){
console.log (Yeah, Beckham is the best")
} else{
console.log(" I know and people think it's the same as footbal")
}

you think of a number between 1 and 1000, I get 15 guesses just tell me too high or too low

const play=()=>{


}


const gameOver = (computerWin)=>{
if (computerWin){
console.log("I win")
)
}
}
const startGame={} =>{
console.log(Think of a number between 1 and 10000)
let guessCount=15;
let bottom =1;
let top = 10_000;
While(guessCount > 0){
const guess= Maath.floor((bottom+top)/2)
console.log("my guess is, guess);

}
gameOver();
}
console.log ("Welcome")
const leaveGame={}=>{
console.log("Sad to see you go!Good Luck in life")
}










Second Round
[![Pursuit Logo](https://avatars1.githubusercontent.com/u/5825944?s=200&v=4)](https://pursuit.org)

# Guessing Game Lab
Expand Down
17 changes: 15 additions & 2 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ const rls = require('readline-sync')
* @returns {undefined}
*/
const startGame = () => {
if(rls.keyInYN("Would you like to play the game?")){
console.log("Let's start!")
gameLoop()
}else {
console.log("Have a nice life!")
quitGame()

}
}

/**
Expand All @@ -17,7 +24,8 @@ const startGame = () => {
* @returns {undefined}
*/
const quitGame = () => {

console.log("Goodbye!")
process.exit()
}

/**
Expand All @@ -28,6 +36,9 @@ const quitGame = () => {
* @returns {undefined}
*/
const gameLoop = () => {
console.log("I have a random number in mind")
console.log("It's between 1 and 1000")
console.log("You have 10 guesses total")
Copy link
Owner

Choose a reason for hiding this comment

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

Game logic belongs in this function.


}

Expand All @@ -38,7 +49,9 @@ const gameLoop = () => {
* @returns {number} - a number between 1 and 1000
*/
const generateRandomNumber = () => {

let x=(Math.floor(Math.random()*1000) +1);{
Copy link
Owner

Choose a reason for hiding this comment

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

We shouldn't have the extra {} at the end of this

}
return (x)
}

startGame()
Expand Down
Loading