@@ -13,7 +13,7 @@ function checkValidity(number) {
1313
1414//clearing the input for any previous values
1515function clearPreviousInputs ( ) {
16- tableBody . innerText = '' ;
16+ tableBody . innerHTML = '' ;
1717 tableBody . classList . remove ( 'bg-red-400' ) ;
1818 tableBody . classList . remove ( 'text-white' ) ;
1919 numberTableInput . classList . remove ( 'border-red-400' ) ;
@@ -29,11 +29,25 @@ function showError() {
2929
3030//logic for generating table
3131function multiplicationLogic ( inputNumber ) {
32+ // Generating table rows and cells
33+ const tableRow = document . createElement ( 'tr' ) ;
34+ const cells = [ ] ;
35+
36+ // Adding flex and flex-col classes to table row
37+ tableRow . classList . add ( 'flex' ) ;
38+ tableRow . classList . add ( 'flex-col' ) ;
39+
40+ // Loop to create number table
3241 for ( i = 1 ; i <= 10 ; i ++ ) {
33- tableBody . innerText += `
34- ${ inputNumber } X ${ i } = ${ inputNumber * i }
35- ` ;
42+ const cell = document . createElement ( 'td' ) ;
43+ cell . classList . add ( 'border' ) ;
44+ cell . innerText = `${ inputNumber } X ${ i } = ${ inputNumber * i } ` ;
45+ cells . push ( cell ) ;
3646 }
47+
48+ // Appending cells to the row and row to the table body
49+ tableRow . append ( ...cells ) ;
50+ tableBody . appendChild ( tableRow ) ;
3751}
3852
3953// Generate Number Table
0 commit comments