I need to separate an integer into two numbers. Something like dividing by two but I only want integer components as a result, such as:
6 = 3 and 3 7 = 4 and
Your code can be simplified a bit:
var num = 7; var p1 = Math.floor(num / 2); var p2 = p1; if (num % 2 != 0) { p1++; } console.log(p1, p2);