Javascript Articles

Page 22 of 534

JavaScript function to take a number n and generate an array with first n prime numbers

Shriansh Kumar
Shriansh Kumar
Updated on 30-Sep-2024 2K+ Views

We are required to write a JavaScript function that takes in a number n and returns an array that contains first n prime numbers. We know that prime numbers are those numbers that are only divisible by 1 and themselves like 2, 3, 19, 37, 73 etc. Let's understand the problem with an example − Input: n = 6; Output: prime_numbers = [ 2, 3, 5, 7, 11, 13 ] Using Iteration We will first write a function that checks whether a given number is prime or not and then run a loop till the given number n ...

Read More

How to design a Loan EMI Calculator using HTML, CSS and JavaScript?

Kalyan Mishra
Kalyan Mishra
Updated on 26-Sep-2024 11K+ Views

To design a Loan EMI Calculator, we will be using HTML to create basic structure of EMI loan calcualtor, CSS to design the UI and JavaScript to add functionality of calculating the EMI based on user input of amount, rate per annum and time in months. In this article, we will be understanding the stepwise process and code of how to design a loan EMI calculator using HTML, CSS and JavaScript. Structuring Loan EMI Calculator using HTML Designing UI of Loan EMI Calculator using CSS Adding ...

Read More

How to open link in a new window using JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 25-Sep-2024 9K+ Views

If you want users to click on links and open those links in a new window becouse you want your user to stay on your site while they view the linked content. Then you need to use this solution. By using JavaScript you can easily configure all of your links so that they open in a new window when clicked. Approach to Open Link in a New Window Using window.open() Method Using window.open() Method JavaScript window.open() method allows you to open a new browser window or tab, with the specified URL. ...

Read More

How to read JSON file in JavaScript?

AmitDiwan
AmitDiwan
Updated on 24-Sep-2024 5K+ Views

There are three effective methods to read JSON files in JavaScript using fetch(), import statements, and require(). Please check this article which includes examples and outputs with the approach explanation. JSON (JavaScript Object Notation) is a lightweight data interchange format that's easy for humans to read and write and easy for machines to parse and generate. In this article, we'll explore three different approaches to reading JSON files in JavaScript: Approaches to Read JSON file Using the fetch() method Using the import statement Using the require ...

Read More

How to create a clickable dropdown menu with CSS and JavaScript?

Aman Kumar
Aman Kumar
Updated on 24-Sep-2024 15K+ Views

To create a clickable dropdown menu with CSS and JavaScript, it helps in adding more options, content or links in webpage while saving the space and not overcrowding the webpage. User should have basic knowldge of CSS and javascript to design and add interactivity to the dropdown menu. In this article, we are having a button and three links and our task is to create a clickable dropdown menu with CSS and JavaScript. Steps to Create a Clickable Dropdown Menu We will be following below mentioned steps to create a clickable dropdown menu with CSS and JavaScript: ...

Read More

How can I set the default value for an HTML \'select\' element?

usharani
usharani
Updated on 20-Sep-2024 863 Views

To set the default value for an HTML element, we can use HTML selected attribute. It is used when you want to display a predefined value on your drop down menu. In this article we are having a dropdown list of four options, our task is to set the default value for an HTML select element. Steps to Set Default Value for select Element We will be following below mentioned steps to set the default value for HTML select element: We have created a dropdown list using select tag and then added options ...

Read More

Convert text to lowercase with CSS

Samual Sam
Samual Sam
Updated on 11-Sep-2024 4K+ Views

To convert text to lowercase with CSS, we will be using the lowercase value of text-transform property. Example In this example, we are using text-transform property and displaying the result as before and after the conversion using p tag. #lcase{ text-transform:lowercase; } Convert Text ...

Read More

How to show images with a click in JavaScript using HTML?

Kalyan Mishra
Kalyan Mishra
Updated on 11-Sep-2024 38K+ Views

To display images on click using JavaScript and HTML. This article covers creating hidden images, adding click events, and revealing images dynamically for an interactive user experience. Users want to create an interactive web page where images are initially hidden and can be revealed with a click, enhancing user engagement and page load times. The challenge is implementing this functionality using JavaScript and HTML simply and efficiently. Approaches to Show Images with a Click Using the Style Display Property Using the classList.toggle() Method Using Hidden ...

Read More

JavaScript in filter an associative array with another array

Shriansh Kumar
Shriansh Kumar
Updated on 11-Sep-2024 1K+ Views

In this problem statement, our task is to write a JavaScript program by which we can simply filter an associative array with the help of another array. Before discussing the solution for the given problem, let's familiarize ourselves with associative array first. What is an associative array? An associative array is a data structure which is used to store the key and value pairs. In this each key is associated with a value given to the key. The keys in this array are unique identifiers that can be used to retrieve their respective values. In an associative array the keys ...

Read More

What are the advantages of CSS?

Ankitha Reddy
Ankitha Reddy
Updated on 28-Aug-2024 17K+ Views

CSS or Cascading Style Sheets is used to design the web pages, it helps web developers to control the layout and other visual aspects of the web pages. Using CSS, you can control the color of the text, the style of fonts, the spacing between paragraphs, how columns are sized and laid out, what background images or colors are used. In this article, we will be discussing various advatages of CSS Advantages of CSS Consistent Design: By using CSS, we can use same design across an entire website or on various web pages. This reduces ...

Read More
Showing 211–220 of 5,338 articles
« Prev 1 20 21 22 23 24 534 Next »
Advertisements