Uncategorized

Build a Fortune Teller App

In this tutorial you will learn how to create a simple fortune teller app using basic JavaScript, HTML and CSS. Here’s a working example of what we’re going to build (with a limited set of assets for now).

See the last example on a standalone webpage

Reading: How to create an online fortune teller game app

For the full source code Simply right-click the link above and choose either “Save Link As…” (if you’re using Firefox or Chrome) or “Download Linked File” (if you’re using Safari).

What You Need

  1. This tutorial is intended for beginners, but things make more sense if you have at least a basic understanding of JavaScript, HTML, and CSS. If you haven’t already, please watch my tutorials:
    1. How to code a simple web page with HTML
    2. How to code a simple web page with HTML and CSS
    3. Intro to JavaScript
  2. You will need a code editor such as Atom, Brackets or Visual Studio Code.
  3. For this tutorial I will It may also be with the Google Chrome browser but you should be able to follow with other browsers like Firefox or Safari if you prefer.

Table of Contents

  1. What is an array?
  2. How do I create an array with JavaScript?
  3. How do I get a random element from an array with JavaScript?
  4. What is a function?
  5. li>
  6. Create a simple function using javascript
  7. Create the fortune teller HTML
  8. Add the code to update the HTML
  9. Add some style with CSS
  10. Add animations n
  11. Next steps

What is an array?

An array is a set of objects. Arrays are used in JavaScript to store multiple values ​​in a single variable. Arrays are very useful for working with sets of values.

See also: How to Set Up Environment To Test Websites Locally

You can find more information about arrays at w3Schools.

How to create an array with JavaScript

In your code editor creates a new HTML document named “fortune-teller.html” (or similar) and saves it in a convenient location on your computer.

The following example creates a variable named ” fortunesArray” and adds a simple array of values ​​to it. The values ​​of the array are enclosed between opening and closing square brackets, eg […].

Note that each value in the array is separated by a comma (and there is no comma after the last element). Also note that the values ​​in this case are strings, so they are enclosed in quotes.

Creating a simple function using Javascript

See also: Tech Thursday: 5 Secrets to Creating an Event in a Facebook Group That Gets Seen

So let’s create a simple function that generates a random element from our array and inserts it into an HTML page. We call this function via a button click (user input).

The code for our function looks like this:

I plan to create a tutorial series soon that will show you how to build progressive web apps.

I also plan to create some more tutorials that will make your JavaScript skills easier by creating JavaScript apps will improve.

Other than that, I hope you found this tutorial useful. I plan to add the next few tutorials in this series shortly, as well as a video demonstration to accompany this tutorial. Please don’t hesitate to email [email protected] if anything is unclear.

If you’d like to be kept informed when I post new content, it’s best to follow my mailing list as I don’t post my tutorials and articles on social media. Otherwise, you can always follow my work on Youtube, Twitter, Instagram, Reddit, Artstation, LinkedIn and Behance.

See also: Build an app for your luxury brand and optimize consumer loyalty

.

See also  How to Write an Awesome Blog Post in 5 Steps

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button