Skip to main content

Generate Random Emoji

Hi , welcome to new JavaScript practice project "Random Emoji" for beginners along with explaination. You can copy the code by clicking the button just above the code. Read the explaiantion for better understanding. let's get started with index.html file:

index.html



style.css:



index.js:



Here is the explaination:

Fetching Emojis:

It defines an empty array emoji to store the fetched emojis.
The getEmoji() function is an asynchronous function that fetches emojis using the Emoji API.
It makes a GET request to the specified API endpoint and retrieves the response data.
The response data is an array of emoji objects.
The function loops through the data and extracts the emoji's name and Unicode code, then adds them to the emoji array.
Generating and Displaying Random Emoji:

It selects the HTML elements with IDs btn and emoji-name.
It adds an event listener to the button with the btn ID, which triggers a function when the button is clicked.
When the button is clicked, a random number is generated within the range of the emoji array's length.
The button's inner text is updated with the selected emoji's name, and the emoji-name element's inner text is updated with the selected emoji's Unicode code.
Additionally, there is another part of the code that displays animated text saying "Generate random emoji" in the container element. The updateText() function increments the characterIndex and extracts a substring of the text based on the characterIndex value. The container's HTML is then updated with the animated text. The function is called recursively using setTimeout() to create the animation effect.

FINAL WORDS:
Thank you Don't forget to leave your feedback in the comment section. Follow front.end24 on instagram for more project ideas

Comments

Popular posts from this blog

Project name: Profile statistics

Hi,My name is Maimoona and Welcome to my blog. In this post I will share code of the project profile statistics along with explaination. So let's get started: 1) index.html The first line, , is a document type declaration that tells the browser that this is an HTML5 document. The html element is the root element of the HTML document, and it contains two child elements: head and body. The head element contains meta information about the document, such as the character encoding, viewport settings, and title of the page. It also links to an external stylesheet called style.css, which is used to define the appearance of the webpage. The body element contains the content of the webpage, which is divided into two main sections: a profile container and a profile statistics container. The profile container contains an image, a text paragraph, and a username heading, which provide information about the owner of the Instagram page. The profile statistics container co...

Anmie Pics Generator

Hi Everone, welcome to my blog in this blog post i will share the code of JavaScript practice project (click it to view video) "Anmie Pics Generator" for beginners along with explaination. You can copy the code by clicking the button just above right corner of the code. Read the explaiantion for better understanding. I will also mention where you can do changes of your choice so let's get started with index.html file: INDEX.HTML: Anime Pics Generator Random Anime Pics Generator front.end24 Generate Anime Name Click to Copy Here is the explaination: 1. The code starts with the '!DOCTYPE html' declaration, which specifies that this is an HTML document. 2. The 'html' element represents the root of an HTML document. 3. The 'head' element contains meta-information about the HTML document, such as the character set, viewport s...

snack zilla : a responsive design with a slider

Hi Everone, welcome to my blog and and to new blog post in this blog post i will share the code of JavaScript practice project "Snack Zilla a responsive design with a slider" for beginners along with explaination. You can copy the code by clicking the button just above the code. Read the explaiantion for better understanding. let's get started with index.html file: index.html Snack Zilla Snack Zilla Home About Services Contact Us Welcome to Snack Zilla! your ultimate destination for mouthwatering snacks that will satisfy all your cravings! We are thrilled to have you here and can't wait to take you on a delicious journey.. View Menu Today's offer Get 50% discount on following items: View List ...