diff --git a/README.md b/README.md index d02719c..4221fe8 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,16 @@ -## The Golden Rule: +![wireframe of MAGIC-8-BALL](assets/8BALLwireframe.png) -🦸 🦸♂️ `Stop starting and start finishing.` 🏁 +# HTML -If you work on more than one feature at a time, you are guaranteed to multiply your bugs and your anxiety. +- 2 sections +- h - for title and circles +- input - for question +- button -## Making a plan +# EVENT -1. **Make a drawing of your app. Simple "wireframes"** -1. **Look at the drawing and name the HTML elements you'll need to realize your vision** -1. **Look at the drawing and imagine using the app. What _state_ do you need to track?** -1. **For each HTML element ask: Why do I need this? (i.e., "we need div to display the results in")** -1. **Once we know _why_ we need each element, think about how to implement the "Why" as a "How" (i.e., `resultsEl.textContent = newResults`)** -1. **Find all the 'events' (user clicks, form submit, on load etc) in your app. Ask one by one, "What happens when" for each of these events. Does any state change? Does any DOM update?** -1. **Think about how to validate each of your features according to a Definition of Done. (Hint: console.log usually helps here.)** -1. **Consider what features _depend_ on what other features. Use this dependency logic to figure out what order to complete tasks.** - -Additional considerations: - -- Ask: which of your HTML elements need to be hard coded, and which need to be dynamically generated? -- Consider your data model. - - What kinds of objects (i.e., Dogs, Friends, Todos, etc) will you need? - - What are the key/value pairs? - - What arrays might you need? - - What needs to live in a persistence layer? -- Is there some state we need to initialize? -- Ask: should any of this work be abstracted into functions? (i.e., is the work complicated? can it be reused?) +- button click +- hide section +- display section +- pick a random number between 0 and length of array +- set the content of the answer to the random choice diff --git a/app.js b/app.js index 2a4309c..08c05df 100644 --- a/app.js +++ b/app.js @@ -1,11 +1,48 @@ -/* Imports */ +const questionSection = document.getElementById('question-section'); +const answerSection = document.getElementById('answer-section'); +const button = document.getElementById('button'); +const askAgain = document.getElementById('ask-button'); +const answer = document.getElementById('answer'); +const input = document.getElementById('input'); -/* Get DOM Elements */ +const answers = [ + 'Yes, definitely', + 'It is certain', + 'It is decidedly so', + 'Without a doubt', + 'You may rely on it', + 'As I see it, yes', + 'Most Likely', + 'Outlook good', + 'Signs point to yes', + 'Outlook hazy, try again', + 'Ask again later', + 'Better not tell you now', + 'Cannot predict now', + 'Concentrate and ask again', + 'Don’t count on it', + 'My reply is no', + 'My sources say no', + 'Outlook not so good', + 'Very doubtful', +]; -/* State */ +button.addEventListener('click', () => { + toggleSections(); -/* Events */ + const randomInt = Math.floor(Math.random() * answers.length); + const randomChoice = answers[randomInt]; + input.value = ''; + answer.textContent = randomChoice; +}); -/* Display Functions */ +function toggleSections() { + questionSection.classList.toggle('hide'); + answerSection.classList.toggle('hide'); +} -// (don't forget to call any display functions you want to run on page load!) +askAgain.addEventListener('click', () => { + toggleSections(); +}); + +answers.style.fontFamily = 'Fredoka One'; diff --git a/assets/8.png b/assets/8.png new file mode 100644 index 0000000..f6bba7b Binary files /dev/null and b/assets/8.png differ diff --git a/assets/8BALLwireframe.png b/assets/8BALLwireframe.png new file mode 100644 index 0000000..efb1284 Binary files /dev/null and b/assets/8BALLwireframe.png differ diff --git a/assets/8ball.png b/assets/8ball.png new file mode 100644 index 0000000..ddfaf40 Binary files /dev/null and b/assets/8ball.png differ diff --git a/index.html b/index.html index 7c510f1..843db79 100644 --- a/index.html +++ b/index.html @@ -1,39 +1,54 @@ - -
- - - - - - -