#`I need help with coming up a code
23 messages · Page 1 of 1 (latest)
Wait I will show u
var addpositive = function(number) {
var number = parseInt(prompt("Enter a number greater than 1"))
var add = []
while (number > 1) {
for (var i = 1; i < number; i++) {
var num = number - i
add.push("(" + i + ", " + num + ")")
}
console.log ("The additive combinations are " + add + ".");
var number = parseInt(prompt("Enter a number greater than 1"))
var add = []
}
if (number < 2) {
console.log("Goodbye!")
}
}
addpositive()
I just need help with changing the code into short
Into short?
Yes and simpler
I mean it seems good enough why do you want to shorten it?
Shorter code != Better code
Also use codeblocks
!code
Cuz someone in my class has the same code so I need help changing it
Did you copy this code?
Well you could change var to let
That is generally a better practice
And could do function addPositive(number) {} if you really wanted to
Can u help me re write it just a bit so the loop is also different I need to submit this asap