From 8ee31ab4ff351c31bfa02eed47b2a0c7aaec31ff Mon Sep 17 00:00:00 2001 From: Emanuel Kywal Date: Sun, 26 Nov 2023 16:09:13 -0300 Subject: [PATCH] feat: fill matrix table in matrixPlayground page --- scripts/matrixGenerator.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/matrixGenerator.js b/scripts/matrixGenerator.js index e487929..454ffb3 100644 --- a/scripts/matrixGenerator.js +++ b/scripts/matrixGenerator.js @@ -69,7 +69,19 @@ function generateMatrixInput() { } function fillMatrix() { + const lines = sessionStorage.getItem("lines"); + const columns = sessionStorage.getItem("columns"); + const linesAmount = Number(lines); + const columnsAmount = Number(columns); + + const matrixString = sessionStorage.getItem("matrix"); + const matrix = jsonToMatrix(matrixString); + for (let i = 0; i < linesAmount; i++) { + for (let j = 0; j < columnsAmount; j++) { + document.getElementById(String(i) + String(j)).value = matrix[i][j]; + } + } } /**