Sum of Squares of Even Numbers in an Array using JavaScript Last Updated : 14 Mar, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report JavaScript program allows us to compute the sum of squares of even numbers within a given array. The task involves iterating through the array, identifying even numbers, squaring them, and summing up the squares. There are several approaches to find the sum of the square of even numbers in an array using Javascript which are as follows: Table of Content Iterative ApproachUsing Array MethodsIterative ApproachIn this approach, we iterate through the array and for each element, check if it's even. If it is, we calculate its square and add it to the sum. Example: The below code Find Sum of Squares of Even Numbers in an Array using the iterative approach in JavaScript. JavaScript function sumOfSquaresOfEvenNumbers(arr) { let sum = 0; for (let i = 0; i < arr.length; i++) { if (arr[i] % 2 === 0) { sum += arr[i] * arr[i]; } } return sum; } const numbers = [1, 2, 3, 4, 5, 6, 67, 8]; console.log(sumOfSquaresOfEvenNumbers(numbers)); Output120 Using Array Methods JavaScript Array methods like filter() allows us to filter out the even numbers and reduce() is used to calculate the sum of squares. Example: The below code Find Sum of Squares of Even Numbers in an Array using array methods in JavaScript. JavaScript function sumOfSquaresOfEvenNumbers(arr) { return arr.filter(num => num % 2 === 0) .reduce((acc, curr) => acc + curr * curr, 0); } const numbers = [1, 2, 3, 4, 5, 6]; console.log(sumOfSquaresOfEvenNumbers(numbers)); Output56 Comment More infoAdvertise with us Next Article Sum of Squares of Odd Numbers in an Array in JavaScript A anjugaeu01 Follow Improve Article Tags : JavaScript Web Technologies Similar Reads Sum of Squares of Odd Numbers in an Array in JavaScript The task involves iterating through the array, identifying odd numbers, squaring them, and summing up the squares. The different approaches to accomplish this task are listed below.Table of ContentIterative ApproachUsing Array MethodsUsing map and reduce MethodsIterative ApproachIn this approach, we 3 min read How to get the standard deviation of an array of numbers using JavaScript ? Given an array and the task is to calculate the standard deviation using JavaScript. Example: Input: [1, 2, 3, 4, 5]Output: 1.4142135623730951Input: [23, 4, 6, 457, 65, 7, 45, 8]Output: 145.13565852332775Please refer to Mean, Variance, and Standard Deviation for details. Mean is average of element. 3 min read How to Find the Sum of an Array of Numbers in JavaScript ? To find the sum of an array of numbers in JavaScript, you can use several different methods.1. Using Array reduce() MethodThe array reduce() method can be used to find the sum of array. It executes the provided code for all the elements and returns a single output.Syntaxarr.reduce( callback( acc, el 2 min read JavaScript program to print even numbers in an array Given an array of numbers and the task is to write a JavaScript program to print all even numbers in that array. We will use the following methods to find even numbers in an array: Table of Content Method 1: Using for Loop Method 2: Using while Loop Method 3: Using forEach LoopMethod 4: Using filter 5 min read Sum of Squares of First N Natural Numbers in JavaScript The sum of squares of the first n natural numbers is a mathematical problem of finding the sum of squares of each number up to a given positive number n. We can find the sum of squares of first n natural numbers in JavaScript using the approaches listed below.Table of Content Sum of Square of First 3 min read Sum and Product of Array elements using JavaScript Given an array and is the task to find the Sum and Product of the values of an Array using JavaScript. Below are the approaches to find the sum and product of array elements using JavaScript:Table of ContentUsing Iterative methodUsing reduce() methodUsing Iterative methodIt uses a simple method to a 3 min read Like