-1
function timesTable(n) {
    for(var i = 1; i < 10; i++){
        document.write(n + "x"+ i + "=" + (n * i) + "<br>");
    };
};

timesTable(2); // 2단만 출력
timesTable(3); // 3단만 출력

whats wrong in my code?

error message in console.log are "Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened."

need help TT

when i was change document.write() -> console.log() its work in console. but still not worked in document...

1 Answers1

0
Hi Here You can use Window Open

function timesTable(n) {
    for(var i = 1; i `enter code here`< 10; i++){
        document.write(n + "x"+ i + "=" + (n * i) + "<br>");
    };
};
const myWindow = window.open();
timesTable(2); // 2단만 출력
timesTable(3);