Skip to content

Commit 6e282b6

Browse files
author
Kevin Nadro
committed
fixed minor bugs
- fixed the input fields to be text for matrix tracers can store characters and not just numbers - fixed the output of the 1d tracer array because it was storing it as a 2d matrix
1 parent 10f14a3 commit 6e282b6

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

js/create/array2d.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const tableToInputFields = (numRows, numColumns) => {
3535
for(var i = 0; i < numRows; i++){
3636
for(var j = 0; j < numColumns; j++){
3737
var elem = document.createElement('input');
38-
elem.type = 'Number';
38+
elem.type = 'Text';
3939
elem.value = Math.floor(Math.random() * 10 + 1);
4040
elem.classList.add('mtbl-col','inputField');
4141
table.childNodes[i].childNodes[j].innerHTML = '';
@@ -56,22 +56,28 @@ const generateJS = (logger, tracer, tracerName) => {
5656
logger.print('Copy and paste this code in your data.js file!');
5757
logger.print('');
5858

59-
logger.print('let myTable = [');
59+
if(numRows > 1) {
60+
logger.print('let myTable = [');
61+
}
6062

61-
var line = '';
63+
var line = 'let myTable = [';
6264
var i;
6365
var j;
6466
var comma = ',';
6567
for(i = 0; i < numRows; i++){
66-
line = '[';
68+
if(numRows > 1){
69+
line = '[';
70+
}
6771
for(j = 0; j < numColumns-1; j++){
6872
line += table.childNodes[i].childNodes[j].childNodes[0].value + ',';
6973
}
7074
if(i === numRows - 1){comma = '';}
7175
line += table.childNodes[i].childNodes[j++].childNodes[0].value + ']' + comma;
7276
logger.print(line);
7377
}
74-
logger.print(']');
78+
if(numRows > 1){
79+
logger.print(']');
80+
}
7581

7682

7783
logger.print("let myTableTracer = new "+ tracer +" ('"+tracerName+"')");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy