Showing posts with the label javascript

Random jokes generator using API (Free)

           Today let's see how to create a random joke generator which will basically fetch the data from a free API. My main target is to show how to use API and put the data in HTML using javaScript.      Today we will use JokeApi website -  . You can read the documentation from here. We will send an fetch request to -,sexist&type=single&idRange=0-319  . You can get this type of URL from JokeApi and any free API. You can replicate the same process for other APIs as well.      When we send request to this URL of the API, it will send back a response which is transformed into JSON format in JavaScript. Let's have a look on the sample JSON data -  { "error": false, "category": "Pun", "type": "single", "joke": "I bought some shoes from a drug dealer. I don't know what he laced them with, but I was trippi

Random Gradient Generator With CSS and Javascript

      Let's see how to generate random gradient background using JavaScript. This is very simple. We will use Math.random() of JavaScript to generate any random value we want to generate. We will have some functions in JavaScript :  1) randomElement() : To generate a random value between 0 to f or the hexadecimal digits. 2) randomColor() : To generate a random Hex color. 3) randomAngle() : To generate a random angle between 0 to 360. 4) applyBg() : To apply the background gradient to a particular element. Now , Let's see the live preview of our project. Change Background Let's understand in short how is it generating random gradient everytime. We have an inbuilt function in JavaScript called Math.rand() which generates random fraction value between 0 to 1. So if I multiply that with any number N and floor or round off the value, it will output any random value between 0 to N in integer format. This concept we have used here.  To generate the

GET URL Parameters Using JavaScript - Web Development

            What are URL parameters ? Let's say one URL of a site is like - In this URL we can see that some parameters are passed as arguments at the end like (name=John and id=23) . This means that this particular URL is trying to do something with John of id 23. Now, let's say you are the host of this site. How can you GET these parameter values which are being opened by a user. To make it simple, suppose your website provides data for some names with ids. The data which you will show in your website depends on this parameters provided on the URL. Today, we will learn how to fetch them using JavaScript .      Let's fix a goal that whatever parameters of name and id value are in the URL we are to print them on the webpage. In this case, we will print John and 23 on the webpage. So, let's begin.          In JavaScript, window.location returns the URL of the location bar. We will create an URLSearchParams() object

The Best Web Development Roadmap - Guide To Start Out

           Web development is one of the all time trending topic to techies. The learning curve of web development has never down-sloped. Today, I will tell you the complete roadmap to be a web developer and pursue your career. I will give you a sequential overview to learn topics one after another. After learning them you will be called "A WEB DEVELOPER". Web development is always a trending career option -- Here Why    We can divide the web development into two subparts- A. Frontend development and B. Backend development. The tasks which a developer has to do are --  Make a basic markup of a page using HTML Design the webpage using CSS or any library like - Bootstrap, Tailwind, Bulma Make the website interactive with JavaScript  These steps come under frontend part. So, to handle frontend learn -- HTML, CSS, JavaScript, any  CSS library. Learn these topics one after another. Completing these you will be able to design a website and can make beautiful templates for websites.

Toggle Sidebar Code Using JavaScript in Web Development

     In any modern responsive website you have surely seen an toggle sidebar which will open and close with an animation whenever the hamburger icon or menu icon is clicked. It looks nice with nice transition and is necessary to make your website responsive for mobiles.      Today, I will let you make your own toggle sidebar which you can implement in any website and give your website a modern enhancement. We will have to do three things,  1. Making the HTML of the menu button and sidebar 2. Adding CSS to the elements 3. Using JavaScript, enabling the toggle functionality. HTML:      One thing to be noted that the HTML code of the Menu and Sidebar can be given anywhere inside the body tag because we will finally give these elements fixed positions. Better put it just after the body.  <div id="mobile-navigation"> <ul> <li><a href="#">Home</a></li> <li><a href="#">Courses