the print is not working.
const print = console.log();
print("Hello World")
anyone have any ideas what is going on? I am trying to make a print function in JavaScript. I come from a Python environment... Please help me with this. I appreciate any help from someone who know how to solve this question. Thanks in advance.
console.log();returnsundefined... i.e. your code runsconsole.log()and the returned value is assigned toconst print-if you wantprintto do the same asconsole.logthen ... assign it the value ofconsole.log... not what it returns (or wait until someone spoon feeds you the solution)console.log. Don't force one language's idioms on other languages.p = print()p('Hello'). And you might see why that doesn't work…?console.logexample to all other methods, so understanding binding is still important, or you'll trip over it later. And lastly, the dupe contains a sample of the correct code.