Web Development Articles

Page 347 of 801

Set the font weight with CSS

varun
varun
Updated on 15-Mar-2026 240 Views

The font-weight property controls how bold or light text appears. It accepts keyword values like normal and bold, or numeric values from 100 to 900. Syntax font-weight: normal | bold | bolder | lighter | 100-900; Font Weight Values Value Description Numeric Equivalent normal Regular text weight 400 bold Bold text weight 700 bolder Bolder than parent element Relative lighter Lighter than parent element Relative Example: Different Font Weights Font Weight Example ...

Read More

How to generate Prime Numbers in JavaScript?

Ayyan
Ayyan
Updated on 15-Mar-2026 3K+ Views

A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. In JavaScript, we can generate prime numbers using different approaches. Basic Prime Check Algorithm The most straightforward method checks if a number is divisible by any number from 2 to itself minus 1: JavaScript Prime Numbers for (var limit = 1; limit 1) { document.write(limit + ""); } } 2 3 5 7 11 13 17 19 Optimized Prime Generator Function For better performance, we only need to check divisors up to the square root of the number: function isPrime(num) { if (num

Read More

Set the font size with CSS

Sravani S
Sravani S
Updated on 15-Mar-2026 341 Views

The font-size property in CSS controls the size of text in your web pages. You can specify font sizes using various units and keyword values to create visual hierarchy and improve readability. Syntax font-size: value; Font Size Values The font-size property accepts several types of values: Keywords: xx-small, x-small, small, medium, large, x-large, xx-large Relative keywords: smaller, larger Units: pixels (px), percentages (%), em, rem Example: Different Font Size Values Font Size Examples This font ...

Read More

How do I replace a character at a particular index in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

JavaScript strings are immutable, meaning you can't directly replace a character at a specific index like in other languages. However, we can use several approaches to create a new string with the character replaced at the desired position. In this tutorial, we'll explore two effective methods to replace a character at a particular index in a JavaScript string. Replace Character by Converting String to Array Using String Slicing with substring() Replace Character by Converting String to Array This method converts the string to an array, modifies the character ...

Read More

How to create arrays in JavaScript?

Anjana
Anjana
Updated on 15-Mar-2026 569 Views

JavaScript provides multiple ways to create arrays. Arrays are used to store multiple values in a single variable and can hold different data types. Using Array Literal (Recommended) The most common and recommended way to create arrays is using square brackets: Array Literal Example var animals = ["Dog", "Cat", "Tiger"]; var numbers ...

Read More

Set the font family with CSS

vanithasree
vanithasree
Updated on 15-Mar-2026 501 Views

The font-family property is used to change the face of a font. You can specify multiple font names as fallbacks, and the browser will use the first available font from the list. Syntax font-family: "font-name", fallback-font, generic-family; Example: Setting Font Family This text is rendered in either georgia, garamond, or the default serif font depending ...

Read More

How to access properties of an array of objects in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 5K+ Views

In JavaScript, accessing properties of objects within an array is a common task. Whether you're working with a single object or an array of objects, there are several methods to retrieve property values effectively. JavaScript objects are collections of key-value pairs called properties. When you have an array containing multiple objects, you need specific techniques to access the properties of each object. Let's explore the main approaches. Using Dot Notation Dot notation is the most straightforward way to access object properties when the property name is known and is a valid JavaScript identifier. The syntax is object.propertyName. ...

Read More

How to merge two arrays in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 4K+ Views

In this tutorial, we will learn how to merge two arrays in JavaScript. In JavaScript, we can merge two arrays using different approaches. Here are the three most common methods: Using the Array concat() method Using the spread operator Using loop iteration Using the Array concat() Method The Array concat() method merges two or more arrays and returns a new array. This is one of the most popular methods for merging arrays in JavaScript. The method operates on an array, takes another array as a ...

Read More

How to extend an existing JavaScript array with another array?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 3K+ Views

In this tutorial, let's find out how to extend an existing JavaScript array with another array. There are multiple methods to accomplish this task, and choosing the right one depends on whether you want to modify the original array or create a new one. Using Array push() Method with Spread Syntax The push() method adds elements to the end of an array and modifies the original array. When combined with the spread operator, it can extend an array with all elements from another array. Syntax array1.push(...array2) Example This method modifies the original ...

Read More

How to randomize (shuffle) a JavaScript array?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

In this tutorial, we will learn different methods to randomize or shuffle a JavaScript array. Shuffling arrays is a common requirement in programming, useful for games, random sampling, or creating unpredictable sequences. Using the Fisher-Yates Algorithm The Fisher-Yates algorithm is the most reliable method for shuffling arrays. It iterates through the array from the last index to the first, swapping each element with a randomly selected element from the remaining unshuffled portion. Syntax for (var i = arr.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + ...

Read More
Showing 3461–3470 of 8,010 articles
« Prev 1 345 346 347 348 349 801 Next »
Advertisements