If the title is not clear...I have BIG function that I want its return value. But I also wanted to get what it's doing in the middle of the execution. I can see that by doing console.log...but is there a way to capture that and display it in the HTML ? Thanks
CodePudding user response:
I think you can achieve it with generator functions
CodePudding user response:
If you want to show something similar to console.log() inside the HTML, you can just create a div on the page and then put whatever you want to view inside the div. Something like this:
<div id="test"></div>
<script>
const x = "1234";
document.getElementById('test').innerHTML = x;
</script>
This page has some info on how to display the contents of objects and arrays in HTML. https://www.w3schools.com/js/js_object_display.asp
CodePudding user response:
The answer has been found, have attached it below ! Thanks everybody.
console.log = function(message) {
document.getElementById('result').innerHTML = message;
};
console.log('I love Panda');
<div id="result"></div>
