+ 1

console.time doesn't work on web codes

I was running a code in web that computes execution time of a task.But it doesn't work: https://code.sololearn.com/WaJUgq9ziDSQ/?ref=app But the same code work in node.js : https://code.sololearn.com/cgV5LESa3gtC/?ref=app Why?

6th Jul 2021, 6:28 AM
Roopesh
Roopesh - avatar
8 Answers
+ 4
console object is emulated in sololearn web project (both in app and at web), so do not implement all console methods (all the more that console object is highly coupled with browser, and do not ever implement all sames methods or with same behavior) ^^ don't know how it is handled in nodejs project ;P
6th Jul 2021, 6:44 AM
visph
visph - avatar
+ 2
visph node js uses V8 engine. So possibly it will include almost everything. Thanks for answering
6th Jul 2021, 7:02 AM
Roopesh
Roopesh - avatar
0
nodejs is different from browser environment, so console is also at least quite different: output to terminal (stdout), while console in browser output in specific window frame, even if core engine used could be same (V8 for chrome/safari browsers if I do not say wrong)
6th Jul 2021, 7:06 AM
visph
visph - avatar
0
visph I think sololearn might be emulating node js. So it may behave unexpectedly. Try console.table
6th Jul 2021, 7:07 AM
Roopesh
Roopesh - avatar
0
maybe: I'm not a nodejs user, so I cannot say if sololearn less or more emulate it, or if console methods implementation differ from one version to another, or any other case ^^ I guess maybe sololearn use nodejs but could emulate console object as for web projects ;)
6th Jul 2021, 7:11 AM
visph
visph - avatar
0
Console.time does work on sololearn web, the problem is sololearn has put a limit on how many times a loop can iterate, hence the error message 'Error: Execution stopped as an infinite loop was detected.' What make this strange is that loops are only limited if the script is written in the js panel. You can put you script in the html panel and it runs with no problems. https://code.sololearn.com/W8a16a11A187
6th Jul 2021, 11:02 AM
ODLNT
ODLNT - avatar
0
ODLNT still it won't. I've updated the code and it iterates 10 times. Also printed result. https://code.sololearn.com/WaJUgq9ziDSQ/?ref=app
6th Jul 2021, 2:31 PM
Roopesh
Roopesh - avatar
0
It work on inspect tools in pc
7th Jul 2021, 8:48 AM
Frank J Abel
Frank J Abel - avatar