Articles on Trending Technologies

Technical articles with clear explanations and examples

Tutorix - AI Tutor

Sum of nested object values in Array using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

When working with complex nested data structures in JavaScript, you often need to sum values from deeply nested objects within arrays. This guide demonstrates various approaches to calculate the sum of nested object values efficiently. Understanding the Data Structure Consider a JSON object with nested arrays and objects where we need to sum the costNum values: let json = { storeData: [ { items: [ ...

Read More

Aggregate records in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

Aggregating records in JavaScript involves combining multiple objects with the same identifier into a single object with accumulated values. This is commonly used for data analysis tasks like summing transactions by person or grouping sales by product. Let's say we have an array of objects that contains information about some random transactions carried out by some people: const transactions = [{ name: 'Rakesh', amount: 1500 }, { name: 'Rajesh', amount: 1200 }, { name: 'Ramesh', ...

Read More

How to count digits of given number? JavaScript

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

The requirements here are simple, we are required to write a JavaScript function that takes in a number and returns the number of digits in it. For example − The number of digits in 4567 is 4 The number of digits in 423467 is 6 The number of digits in 457 is 3 Let's explore different approaches to count digits in JavaScript. Method 1: Using Recursive Approach This method uses recursion to divide the number by 10 until it reaches zero: const num = 2353454; const digits = (num, count = ...

Read More

Split First name and Last name using JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

In JavaScript, you can split a full name into first and last name using the split() method. This method divides a string based on a specified separator and returns an array of substrings. Syntax string.split(separator) Basic Example var studentFullName = "John Smith"; var details = studentFullName.split(' '); console.log("Student First Name = " + details[0]); console.log("Student Last Name = " + details[1]); Student First Name = John Student Last Name = Smith Handling Multiple Names For names with more than two parts, you can extract the first ...

Read More

Checking Oddish and Evenish numbers - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 348 Views

A number is Oddish if the sum of all of its digits is odd, and a number is Evenish if the sum of all of its digits is even. We need to write a function that determines whether a number is Oddish or Evenish. The function should return true for Oddish values and false for Evenish values. How It Works The algorithm extracts each digit from the number, adds them up, and checks if the sum is odd or even: Extract digits using modulo (num % 10) and integer division (Math.floor(num / 10)) Sum all ...

Read More

How to show image in alert box using JavaScript?

Nancy Den
Nancy Den
Updated on 15-Mar-2026 2K+ Views

JavaScript's default alert() function cannot display images. To show an image in an alert-like dialog, you need to create a custom modal dialog using HTML, CSS, and JavaScript. Why Default alert() Cannot Show Images The browser's built-in alert() function only accepts text strings. It cannot render HTML elements like images, making a custom solution necessary. Creating a Custom Image Alert Here's a complete example that creates a custom alert dialog with an image: ...

Read More

How to convert Number to String in JavaScript?

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

This tutorial will teach us to convert the number to string in JavaScript. Changing the type of variable is called the type conversion of a variable. While coding, the programmer needs to deal with the different data types and might need to convert the variable's data type. Every programming language has different methods to convert one variable from one data type to another data type, and JavaScript also has some methods, which are explained below. Using the toString() Method Concatenating with an empty String Using ...

Read More

How to create a JavaScript code for multiple keys pressed at once?

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 803 Views

Use the keydown and keyup events in JavaScript to detect multiple keys pressed simultaneously. This technique tracks which keys are currently held down and updates the display accordingly. Example: Multiple Key Detection Multiple Keys Detection .key-up { color: red; } .key-down { color: green; } ul { list-style-type: none; } ...

Read More

Display video inside HTML5 canvas

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 651 Views

You can display video inside an HTML5 canvas by using the drawImage() method to render video frames onto the canvas. This technique is useful for applying real-time effects, overlays, or custom controls to video content. Basic Setup First, create the HTML structure with both video and canvas elements: Video in Canvas Your browser does not support the video tag. ...

Read More

Usage of border-bottom-color property in CSS

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 114 Views

The border-bottom-color CSS property sets the color of an element's bottom border. It only affects the color when a border style is already defined. Syntax border-bottom-color: color | transparent | inherit; Parameters The property accepts these values: color - Any valid CSS color value (hex, RGB, named colors) transparent - Makes the border invisible inherit - Inherits the color from parent element Example: Basic Usage ...

Read More
Showing 17181–17190 of 61,298 articles
Advertisements