Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Answer #205

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
Binary file added .DS_Store
Binary file not shown.
46 changes: 24 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# 🎤 Week08 Bootcamp2019a Project: Wu-Tang Name Generator

### Goal: Create a Wu-Tang Clan name generator. Present the user with 5 survey questions and based on those answers randomly generate their name. The name doesn't have to be exact names, but Wu-Tang sounding-ish names. Ex: Childish Gambino (who actually got his name from a Wu-Tang name generator).

### How to submit your code for review:

- Fork and clone this repo
- Create a new branch called answer
- Checkout answer branch
- Push to your fork
- Issue a pull request
- Your pull request description should contain the following:
- (1 to 5 no 3) I completed the challenge
- (1 to 5 no 3) I feel good about my code
- Anything specific on which you want feedback!

Example:
```
I completed the challenge: 5
I feel good about my code: 4
I'm not sure if my constructors are setup cleanly...
```
# 🎤 Wu-Tang Name Generator

<img width="722" alt="wu-tang" src="https://github.com/JacinthaDev/wu-tang/assets/129231721/dc2f5714-4a81-45ef-af3f-8f612a58fa77">


Check out this project here: https://jacinthadev.github.io/wu-tang/

# About this project
This project uses a survey to generate Wu-Tang name for the user.

## How It's Made:
Tech used: HTML, CSS, JavaScript

## Lessons Learned:
This was my first time using a server to generate a response. It was a little tricky trying to keep track of points based off of survey results and make that correspond to an output. I'd like to practice more with survery and JavaScript.

### Examples:
Take a look at similar projects!

Palindrome Checker: https://github.com/JacinthaDev/Palindrome

Tic-Tac-Toe: https://github.com/JacinthaDev/Tic-Tac-Toe/tree/answer

Avatar The Last Airbender Slot Machine: https://github.com/JacinthaDev/Slot-Machine/tree/answer
3 changes: 3 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
h1{
color: red;
}
31 changes: 31 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Wu-Tang name selector</title>
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<h1>Answer the survey and get a Wu-Tang name!</h1>

<label>Do you like to cook?</label>
<input class = "cook" type="text" placeholder="Enter yes or no"></input><br>

<label>Are you vegetarian/vegan?</label>
<input class = "veg" type="text" placeholder="Enter yes or no"></input><br>

<label>Do you like video games?</label>
<input class = "games" type="text" placeholder="Enter yes or no"></input><br>

<label>Do you like science?</label>
<input class = "science" type="text" placeholder="Enter yes or no"></input><br>

<label>Do you play an instrument?</label>
<input class = "instrument" type="text" placeholder="Enter yes or no"></input><br>

<button id="clickMe" type="button" name="button">Click Me</button>
<h2 id="personName"></h2>

<script src="js/main.js"></script>
</body>
</html>
81 changes: 81 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
document.querySelector('#clickMe').addEventListener('click', getName)

function getName(){

//grab values from input in HTML
let games = document.querySelector('.games').value.toLowerCase().trim()
let cook = document.querySelector('.cook').value.toLowerCase().trim()
let veg = document.querySelector('.veg').value.toLowerCase().trim()
let science = document.querySelector('.science').value.toLowerCase().trim()
let instrument = document.querySelector('.instrument').value.toLowerCase().trim()


let firstName
let lastName
let points = 0

//store all the values from html in an array
let valueArray=[veg, cook, games, science, instrument]

let number = Math.round(Math.random() * 4)
let number2 = Math.round(Math.random() * 4)

//Wutang name values
let array = ["Shaolin", "Inspectah", "Method", "Killah", "Ghostface"]
let array2 = ["Uzi", "Mamba", "Gravedigga", "Tragedy", "Priest"]

//check to see if there is more than one yes
let yesses= valueArray.filter( element => element === 'yes')

//check for non-relevant values

let answers = valueArray.every(element => element === 'yes' || element ==="no")
console.log(answers)

if (!answers){
alert('Please answer all questions with yes or no')
return

}
if (yesses.length > 1){
firstName = array[number]
console.log(number)
} else {

if (instrument === 'yes'){

points += 0
firstName = array[points]

} else if(cook === 'yes'){

points += 1
firstName = array[points]

} else if(games === 'yes'){

points += 2
firstName = array[points]

} else if (veg === 'yes'){

points += 3
firstName = array[points]

} else if(science === 'yes'){

points += 4
firstName = array[points]

}
}


lastName = array2[number2]

document.querySelector('h2').textContent = `Your Wu-Tang name is ${firstName} ${lastName}`

}



Binary file added wu-tang.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.