java-script:multiplication-table-generator
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
java-script:multiplication-table-generator [2023/08/03 02:13] – odefta | java-script:multiplication-table-generator [2023/08/09 20:14] (current) – ↷ Links adapted because of a move operation odefta | ||
---|---|---|---|
Line 3: | Line 3: | ||
===== For client side (web browser) ===== | ===== For client side (web browser) ===== | ||
- | This is a simple script to print a multiplication table generator using simple java script and html.\\ | + | This is a simple script to print a multiplication table generator using simple java script and html. \\ |
- | Ex: | + | Output example: |
- | < | + | |
- | 1 2 3 | + | {{: |
- | 2 4 6 | + | |
- | 3 6 9 | + | |
- | </ | + | |
- | All code js + html in the same file: | + | ==== All code js + html in the same file ==== |
<code javascript index.html> | <code javascript index.html> | ||
Line 25: | Line 22: | ||
html = html + '< | html = html + '< | ||
- | for(let columnNumber = 1; columnNumber <= rows; columnNumber++) { | + | for(let columnNumber = 1; columnNumber <= columns; columnNumber++) { |
html = html + `< | html = html + `< | ||
} | } | ||
Line 69: | Line 66: | ||
</ | </ | ||
- | Js code separated from html code: | + | ==== Js code separated from html code ==== |
<code html index.html> | <code html index.html> | ||
Line 98: | Line 95: | ||
html = html + '< | html = html + '< | ||
- | for(let columnNumber = 1; columnNumber <= rows; columnNumber++) { | + | for(let columnNumber = 1; columnNumber <= columns; columnNumber++) { |
html = html + `< | html = html + `< | ||
} | } | ||
Line 128: | Line 125: | ||
</ | </ | ||
- | ===== For server side (web browser) ===== | + | ===== For server side (node.js) ===== |
- | First you need to [[setup-nodejs|setup your node.js project]] | + | First you need to [[.node-js:setup|setup your node.js project]] |
Then create a src folder and inside it place index.js and generateTable.js: | Then create a src folder and inside it place index.js and generateTable.js: | ||
Line 139: | Line 136: | ||
for(let rowNumber = 1; rowNumber <= rows; rowNumber++) { | for(let rowNumber = 1; rowNumber <= rows; rowNumber++) { | ||
- | for(let columnNumber = 1; columnNumber <= rows; columnNumber++) { | + | for(let columnNumber = 1; columnNumber <= columns; columnNumber++) { |
tableString = tableString + ` ${rowNumber * columnNumber} `; | tableString = tableString + ` ${rowNumber * columnNumber} `; | ||
} | } |
java-script/multiplication-table-generator.1691018038.txt.gz · Last modified: 2023/08/03 02:13 by odefta