0
Is there any error ? And how to include this code to an html document ?
// program to generate a multiplication table // take input from the user let number = parseInt(prompt('Enter an integer: ')); //creating a multiplication table for(let i = 1; i <= 10; i++) { // multiply i with number result = i * number; // display the result console.log(`${number} * ${i} = ${result}`); } How to include it in an html document please nd is there any error ? This is my first program with js
9 Respostas
+ 1
If you're planning to do this in Code Playground, then you can paste the above code (just the code) in the JS section of a web code.
You can also embed it in a script block in an HTML document if you' re doing this on your own PC / laptop. Put the script block in between the /body and /html
No error as I tested it, except that it outputs the table into the JS console. Not that is a big problem, but you better learn how to output into the document body, by updating some element's content (can be done later).
+ 1
Thank you so much
+ 1
Ipang i just want to ask you about the extension when there is some Javascript code inside an HTML document is it .js or .html ?
+ 1
Use .htm or .html as the extension for the HTML document.
Use .js as extension for the Javascript file. This is a file that contains Javascript code only, can't mix HTML code inside it.
We still save a HTML document by .html even if we have embedded Javascript inside it ...
+ 1
Then it's. HTML cause i didn't an external reference
+ 1
Yes, it will be .html when no external reference used in HTML document đ
+ 1
I see thank you a lot đ
0
Do you understand what I wrote?
It is most important that you do.
If you still got any doubt, don't hesitate, just ask away ...
0
Ok happy coding đ