• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Any javascript gurus wanna help me solve a problem

new2AMD

Diamond Member
I have to solve a problem for my javascript class and I am hung up on it. It should mainly deal with arrays. Im taking a night class to get some experience in programming while working and have a few questions. If you have time to help please PM me. Id appreciate it.
 
This may be tough to explain but I will try.
Im confused as to wether I can take an input value (via a text box) and create an array from it. Then create an output that shows the contents of the array. The array would be the length of the user inputted number. The output would be that many rows long. each row would contain as many numbers as the row number it is. row 1 contains 1 number and so on.

make sense?
 
var count = Number(documenbt.getElementById('someid').value);
for(var i = 0; i < count; i++){
for(var j = 0; j<i; j++){
document.getElementById('someelement').innerHTML += j + ' ';
}
document.getElementById('someelement').innerHTML += '<br/>';
}
 
thanks that really helps. I placed that in my function and made a couple tweaks to get it to do what I needed. The only thing I need to do now is make the corresponding numbers in the row not be sequential but actually a sum of the previous 2 numbers in the row. So

1
1 1
1 1 2
1 1 2 3
 
Back
Top