Project Euler 50: Consecutive prime sum
Improvement in function isprime:
for(let i = 2; i &lt;= number / 2; i++)

can be
for(let i = 2; i &lt;= Math.round(Math.sqrt(number)) + 1 ; i++)

Otherwise, the best easy to understand approach(in accordance to my knowledge) is to use the Sieve of Eratosthenes. Your problem can be a subset of the following problem Sieve of Eratosthenes JavaScript implementation - performance very slow over a certain number. Credits of the code below goes to the owner of this post.
function getPrimesUnder(number) {
  var start = new Date().getTime();

  var numbers = [2];
  var sqNum = Math.sqrt(number);
  var i, x;
  for (i = 3; i &lt; number; i = i + 2) {
    numbers.push(i);
  }
  for (x = 0; numbers[x] &lt; sqNum; x++) {
    for (i = 0; i &lt; numbers.length ; i++){
       if (numbers[i] &gt; numbers[x]) {
        if(numbers[i] % numbers[x] === 0){
          numbers.splice(i, 1)
        }
      }
    }
  }
  var end = new Date().getTime();
  var time = end - start;
  alert('Execution time: ' + time/1000 + ' seconds');
  return numbers;

} 

There is something much more efficient (Which is the fastest algorithm to find prime numbers?) known as Sieve of Atkin. You can do more research on it.