Skip to content

Tag: arrays

Javascript splice last element

I want to remove only the last element. Why does it remove every element except the last one? Answer You need to omit the assignment. If you like just to delete the last one, you could take a negative index with Array#splice. This works for any other index from the end.

A very big sum – Hacker Rank

I am trying to solve “A very big sum” challenge on Hacker Rank: https://www.hackerrank.com/challenges/a-very-big-sum/problem In there I have to sum all the numbers in the array given so I came up with two solutions: First solution Second Solution But none of them work and I don´t know why, I am th…

Javscript function running slow

I’m collecting a lot of data from an API with an async function that cycles through a lot of data with a loop, I’m making about 100 requests and it takes around 8 seconds. Are there any methods I can try to use, to speed up my script? Answer Instead of for loops with await inside, which runs in se…