Posts by Kvera • 313 points
6 posts
-
0
votes2
answers72
viewsA: Algorithm that checks whether the sum of any two items of an ordered array is equal to a number yielding wrong results
Two errors were complicating the solution of the algorithm: if (i=j) {return false} else { should be: if (i===j) {return false} else { This causes the algorithm to correctly evaluate the positive…
-
-2
votes2
answers72
viewsQ: Algorithm that checks whether the sum of any two items of an ordered array is equal to a number yielding wrong results
This pairSum algorithm should find if the sum of any two items in an array arr is equal to a given number target: function pairSum(arr, target){ for (var i=0; i<arr.length;){ for (var j =…
-
2
votes3
answers161
viewsQ: How can I make this code more functional in Javascript?
This code solves the problem of finding the in anth prime between 0 and 10,000: function PrimeMover(num) { var counter = 0; var primes = []; for (var i=2; i<=10000; i++){ for (var j = 2; j<i;…
-
3
votes3
answers161
viewsQ: This Javascript loop is taking down my browser. Any idea why?
I’m solving the following coderbyte Problem.com: Using the Javascript language, have the Function Runlength(str) take the str Parameter being passed and Return a Compressed version of the string…
-
9
votes8
answers794
viewsQ: Mapping an array with possible subarrays as elements
I am trying to create a function that files an array to another newArray. If one of the array elements is an array, I want to map all its subelements to newArray. Therefore: var array = [1,2,3,4,5,…
-
6
votes4
answers329
viewsQ: What’s wrong with my map version for a JS array?
var kiko = [1,2,3,4,5,6]; var forEach = function(array, newArray, action){ for (var i=0; i<array.length; i++){ var newArray = []; newArray.action(array[i]); }; }; forEach(kiko, newKiko, push)…
javascriptasked Kvera 313