0

is there print() in JS?

I'm doing a JS exercise and I'm supposed to print the answer and there is a "print()" code already. But when I put a variable in there, it's error. And when I tried in code playground, when I run the code it shows a tab where I can print the result in the screen. Here - https://code.sololearn.com/Wx4M4GjBo0uq It's easier if I could just document.write or console.log the output so idk about this print stuff. Is this a bug? And is there a "print()" in javascript? I thought that's for python

4th Apr 2022, 5:09 AM
J4red
J4red - avatar
4 ответов
+ 1
Yes there is window.print(); But it used to print data on the real printer More: https://developer.mozilla.org/en-US/docs/Web/API/Window/print Use console.log(); to print something in the console and document.write() to display text to the web page.
5th Apr 2022, 5:02 PM
aewerdev
aewerdev - avatar
0
Yes there is a print( ) method under `window`. But it wasn't for printing anything on document or JS log. It rather allows page printing, to an actual printer device. https://developer.mozilla.org/en-US/docs/Web/API/Window/print
4th Apr 2022, 5:32 AM
Ipang
0
J4red Yes there is a print() function in JS but it's a function of window object So window.print() this function is used to print contents But to display content on browser use document.write() And to display content on console use console.log()
4th Apr 2022, 5:43 AM
A͢J
A͢J - avatar
- 1
J4red for debugging, use console.log let a = "Hi" console.log(a) then go to the output tab to view the result.
4th Apr 2022, 5:38 AM
Bob_Li
Bob_Li - avatar