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 391 of 534
How to replace leading zero with spaces - JavaScript
We are required to write a JavaScript function that takes in a string that represents a number. Replace the leading zero with spaces in the number. We need to make sure the prior spaces in number are retained. For example, If the string value is defined as − " 004590808" Then the output should come as − " 4590808" Example Following is the code − const str = ' 004590808'; const replaceWithSpace = str => { let replaced = ''; const regex = new RegExp(/^\s*0+/); ...
Read MoreUsage of CSS caption-side property
The caption-side property controls the position of a table's element relative to the table content. This CSS property allows you to place captions on any side of the table for better visual organization. Syntax caption-side: top | bottom | left | right | initial | inherit; Property Values Value Description top Caption appears above the table ...
Read MoreReturn 5 random numbers in range, first number cannot be zero - JavaScript
We are required to write a JavaScript function that generates an array of exactly five unique random numbers. The condition is that all the numbers have to be in the range [0, 9] and the first number cannot be 0. Example Following is the code − const fiveRandoms = () => { const arr = [] while (arr.length < 5) { const random = Math.floor(Math.random() * 10); if (arr.indexOf(random) > -1){ ...
Read MoreUsage of CSS empty-cells property
The empty-cells property specifies whether borders and backgrounds should be displayed for empty table cells. This property only works when border-collapse is set to separate. Syntax empty-cells: show | hide | inherit; Values show - Default value. Borders and backgrounds are displayed for empty cells hide - Borders and backgrounds are hidden for empty cells inherit - Inherits the value from the parent element Example: Hiding Empty Cells table.empty { ...
Read MoreValidating email and password - JavaScript
Suppose, we have this dummy array that contains the login info of two of many users of a social networking platform − const array = [{ email: 'usman@gmail.com', password: '123' }, { email: 'ali@gmail.com', password: '123' }]; We are required to write a JavaScript function that takes in an email string and a password string. The function should return a boolean based on the fact whether or not the user exists in the database. Example Following is the code − ...
Read MoreUsage of CSS border-spacing property
The border-spacing CSS property controls the distance between adjacent table cell borders. It only applies to tables with border-collapse: separate and accepts one or two length values. Syntax border-spacing: horizontal vertical; border-spacing: value; /* applies to both directions */ Parameters One value: Sets equal spacing horizontally and vertically Two values: First value sets horizontal spacing, second sets vertical spacing Units: Any CSS length unit (px, em, rem, etc.) Example: Different Spacing Values table { ...
Read MoreRepeat even number inside the same array - JavaScript
We are required to write a JavaScript function that should repeat the even number inside the same array. Therefore, for example given the following array − const arr = [1, 2, 5, 6, 8]; We should get the output − const output = [1, 2, 2, 5, 6, 6, 8, 8]; Example Following is the code − const arr = [1, 2, 5, 6, 8]; const repeatEvenNumbers = arr => { let end = arr.length - 1; for(let i = ...
Read MoreUsage of CSS table-layout property
The table-layout property controls how a browser calculates column widths in HTML tables. This property significantly affects rendering performance and layout behavior, especially with large tables or variable content. Syntax table-layout: auto | fixed | inherit; Property Values Value Description Performance auto Browser calculates widths based on cell content (default) Slower - requires content analysis fixed Uses first row to determine column widths Faster - renders immediately inherit Inherits value from parent element Depends on inherited value Example: Comparing auto vs fixed ...
Read MoreChange the style of top border with CSS
The border-top-style property in CSS defines the line style of an element's top border. It accepts various values like solid, dashed, dotted, double, and more. Syntax border-top-style: value; Common Values Value Description solid Single solid line dashed Dashed line dotted Dotted line double Two solid lines groove 3D grooved effect ridge 3D ridged effect none No border Example Here's how to apply different top border styles: ...
Read MoreChange the style of left border with CSS
The border-left-style property in CSS allows you to change the style of an element's left border. This property accepts various values like solid, dashed, dotted, double, and more to create different visual effects. Syntax border-left-style: value; Available Border Styles The border-left-style property accepts several values: solid - A single solid line dashed - A series of dashes dotted - A series of dots double - Two parallel lines groove - A 3D grooved border ridge - A 3D ridged border inset - A 3D inset border outset - A 3D outset border ...
Read More