Splice() function

When I use a splice() function to add something to an array, can I make any necessary mathematical operations inside of it?
For example, take the following snippet of code:

var a=[]
for (var i=0, i<5; i++) {
  var b=prompt('', '');
  a.splice(i, 0, b+25);

Can I do b+25 or other mathematical operations like that or do I have to do them somewhere else?
Uptil now I’ve been first doing the mathematical operations and then putting the result in the array using the splice function

you can, but if the math gets complicated i would the math before splice to make the code easier to read.

next time, mention the language you are working in. I now had to guess wht languages you where using

1 Like