Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Javascript Articles
Page 387 of 534
Build maximum array based on a 2-D array - JavaScript
Let's say, we have an array of arrays of Numbers like below − const arr = [ [1, 16, 34, 48], [6, 66, 2, 98], [43, 8, 65, 43], [32, 98, 76, 83], [65, 89, 32, 4], ]; We are required to write a function that maps over this array of arrays and returns an array that contains the maximum (greatest) element from each subarray. So, for the above array, the output should be − [48, 98, 65, 98, 89] Using ...
Read MoreUsage of background property in CSS
The background property in CSS is a shorthand property that allows you to set multiple background-related properties in a single declaration. It can include background color, image, position, size, repeat behavior, and attachment. Syntax background: [color] [image] [repeat] [attachment] [position] / [size]; Individual Background Properties The background shorthand can include any combination of these properties: background-color - Sets the background color background-image - Sets the background image background-repeat - Controls image repetition background-attachment - Controls scrolling ...
Read MoreRemoving identical entries from an array keeping its length same - JavaScript
We have to write a function that takes in an array, removes all duplicates from it and inserts the same number of empty strings at the end. For example − If we find four duplicate values, we have to remove them all and insert four empty strings at the end. Understanding the Problem The goal is to: Remove duplicate elements from the array Keep only the last occurrence of each element Maintain the original array length by adding empty strings Example ...
Read MoreIncrease or decrease the size of a font with CSS
The font-size property in CSS controls the size of text elements. You can use various units and keywords to set font sizes, from absolute values like pixels to relative keywords like "small" and "large". Syntax font-size: value; Available Values The font-size property accepts several types of values: Absolute keywords: xx-small, x-small, small, medium, large, x-large, xx-large Relative keywords: smaller, larger Length units: pixels (px), points (pt), ems (em), rems (rem) Percentage: relative to parent element's font size Example: ...
Read MoreRemove elements from array using JavaScript filter - JavaScript
Suppose, we have two arrays of literals like these − const arr1 = [4, 23, 7, 6, 3, 6, 4, 3, 56, 4]; const arr2 = [4, 56, 23]; We are required to write a JavaScript function that takes in these two arrays and filters the first to contain only those elements that are not present in the second array. And then return the filtered array to get the below output − const output = [7, 6, 3, 6, 3]; Method 1: Using filter() with indexOf() The filter() method creates ...
Read MoreShorthand property to set the font with CSS
The CSS font property is a shorthand that allows you to set multiple font-related properties in a single declaration, including font style, variant, weight, size, line-height, and family. Syntax font: [font-style] [font-variant] [font-weight] font-size[/line-height] font-family; The font-size and font-family values are required, while other properties are optional. Example Here's how to use the font shorthand property to apply multiple font styles at once: .shorthand-example ...
Read MoreCompare array elements to equality - JavaScript
In JavaScript, you can compare array elements at corresponding positions to count how many values match. This is useful for analyzing similarities between two arrays in a sequence-dependent manner. For example, if you have two arrays: const arr1 = [4, 7, 4, 3, 3, 3, 7, 6, 5]; const arr2 = [6, 5, 4, 5, 3, 2, 5, 7, 5]; The function should compare arr1[0] with arr2[0], arr1[1] with arr2[1], and so on. In this case, positions 2, 4, and 7 have matching values, so the result is 3. Using a For Loop ...
Read MoreUsage of font-family property in CSS
The font-family property in CSS specifies the typeface or font family to be used for displaying text. It accepts a prioritized list of font names, allowing fallback options if the preferred font is not available on the user's system. Syntax font-family: "font-name", fallback1, fallback2, generic-family; Font Family Categories CSS defines five generic font families: serif - Fonts with decorative strokes (Times, Georgia) sans-serif - Clean fonts without strokes (Arial, Helvetica) monospace - Fixed-width fonts (Courier, Monaco) cursive - Script-like fonts (Comic Sans, Brush Script) fantasy - Decorative display fonts (Impact, Papyrus) ...
Read MoreConvert number to tens, hundreds, thousands and so on - JavaScript
We are required to write a function that, given a number, say, 123, will output an array − [100, 20, 3] Basically, the function is expected to return an array that contains the place value of all the digits present in the number taken as an argument by the function. We can solve this problem by using a recursive approach. Example Following is the code − const num = 123; const placeValue = (num, res = [], factor = 1) => { if(num){ ...
Read MoreUsage of font-variant property in CSS
The CSS font-variant property controls typographic variations of text, primarily creating small-caps effects where lowercase letters appear as smaller uppercase letters. Syntax font-variant: normal | small-caps | initial | inherit; Values normal - Default value, displays text normally small-caps - Converts lowercase letters to smaller uppercase letters initial - Sets to default value inherit - Inherits from parent element Example: Small Caps Effect .normal-text { ...
Read More