
javascript - Applying math to values in an array - Stack Overflow
Apr 23, 2014 · Use map to loop over the array, converting the string to a pair of numbers, performing the addition ensuring that the decimal place is kept intact. var xy = el.split(',').map(Number); xy[1] = (xy[1] * 2).toFixed(1); return xy.join(','); Fiddle.
Performing calculations on an Integer array in Javascript
Jun 16, 2014 · When using the Array constructor, you use parentheses: var actor = new Array( ... ); You can also use the literal array syntax for the outer array, just as you do with the inner arrays: var actor = [ ... ];
javascript - performing math on an array of strings(with numbers inside ...
Oct 2, 2016 · How do I perform math on items in array, when some are strings and some are numbers?
JavaScript: 6 Ways to Calculate the Sum of an Array
Feb 19, 2023 · This practical, succinct article walks you through three examples that use three different approaches to find the sum of all elements of a given array in Javascript (suppose this array only contains numbers).
JavaScript Math Object - W3Schools
Math.sin() Math.sin(x) returns the sine (a value between -1 and 1) of the angle x (given in radians). If you want to use degrees instead of radians, you have to convert degrees to radians: Angle in radians = Angle in degrees x PI / 180.
javascript - Simple math using arrays - Code Review Stack Exchange
Oct 1, 2013 · The actual calculation can be easily implemented with Array.reduce. First we can define functions add and subtract. var methods = { add: function(a, b) { return a + b; }, subtract: function(a, b) { return a - b; } }; And then using Array.reduce we …
JavaScript Array map() Method - W3Schools
map() creates a new array from calling a function for every array element. map() does not execute the function for empty elements. map() does not change the original array.
Basic math in JavaScript — numbers and operators
Apr 11, 2025 · Basic number operations in JavaScript — add, subtract, multiply, and divide. numbers are not numbers if they are defined as strings, and can cause calculations to go wrong. Converting strings to numbers with Number(). Operator precedence. Incrementing and decrementing. Assignment and comparison operators.
JavaScript Arithmetic - W3Schools
Arithmetic operators perform arithmetic on numbers (literals or variables). A typical arithmetic operation operates on two numbers. The two numbers can be literals: or variables: or expressions: The numbers (in an arithmetic operation) are called operands. The operation (to be performed between the two operands) is defined by an operator.
javascript - How do I perform math on items in array, when …
Jun 24, 2019 · How do I perform math on items in array, when some are strings and some are numbers? I am attempting to create a calculator using jQuery and JavaScript. My approach involves adding each entry (numbers and operators) to …
- Some results have been removed