how to code print in javascript

JavaScript
console.log("print")
//or
alert("Print")window.print();
Source

Also in JavaScript: