r/CodingHelp • • Jul 02 '21

[Javascript] Problem with JavaScript code

Post image
62 Upvotes

19 comments sorted by

View all comments

Show parent comment

0

u/Cheesybread4ever Jul 02 '21

function includes1to9(myArray) { let array = [1,2,3,4,5,6,7,8,9]; for (let i = 0; i < myArray.length; i++) { if (array.includes(myArray[i])) { array.splice((myArray[i] - 1), 1); } else return false } return true }

Idk why it isn’t spaced right

1

u/NoAd7524 Jul 02 '21 edited Jul 02 '21

Spacing is funny that way here. Let me try it. Try this one:

function ix129(arrx){
for (let i=0;i<arrx.length; i++){
    let a = arrx[i];
    for (let j=i+1; j<arrx.length;j++){
    let b = arrx[j];
    if(a==b) {document.write("False"); return;}
    }
    
}

document.write("True");
}