*hello guys,*

*i have a code writen in javascript and the code is fine but show output in 
terminal*

*so i want the code output writen on the browser by angularjs or ionic.*

*there a simple json if i can get external json url like 
get.http(https://domain.com/file.json*

<https://s31.postimg.org/hmcgjal3f/f10.jpg>



here is code:

function subsetSum(numbers, target, partial) {
  var s, n, remaining;
 partial = partial || [];
 s=0;
 for(var j=0;j<partial.length;j++){
    s=parseInt(partial[j].value)+ s;
  }

  // check if the partial sum is equals to target

  if (s === target) {
   console.log("combination is");
    partial.forEach(function(i){console.log(i.itemz);})

  }

  if (s >= target) {
    return;  // if we reach the number why bother to continue
  }

  for (var i = 0; i < numbers.length; i++) {
    n = numbers[i];
    remaining = numbers.slice(i + 1);
    subsetSum(remaining, target, partial.concat([n]));
  }
}
var obj = [
  { 'itemz': 'tomato', 'value': 5 },
  { 'itemz': 'potatos', 'value': 3 },
  { 'itemz': 'banana', 'value': 7 },
  { 'itemz': 'orange', 'value': 6 },
  { 'itemz': 'apple', 'value': 4 },
  { 'itemz': 'cherries', 'value': 5 },
  { 'itemz': 'watermelon', 'value': 9 },
  { 'itemz': 'orange', 'value': 8 }
];

subsetSum(obj,10);






Would appreciate any help that I can get.

Thanks in advance!



-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/1187b4db-a0d4-4aca-a241-fae54e97709a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to