DEV Community

Cover image for Prank Your Coder Friend On April Fools With This!
MAFEE7
MAFEE7

Posted on

Prank Your Coder Friend On April Fools With This!

Get Ready To Prank Your Coder Friends With A Simple Code!

Just rewrite the console.log function with:

var $old_consoleLog = console.log;
console.log = function(String){
   $old_consoleLog("Bonkers: " + String);
}
Enter fullscreen mode Exit fullscreen mode

Explanation:

var $old_consoleLog = console.log; 
Enter fullscreen mode Exit fullscreen mode

Stores console.log function as another variable: "$old_consoleLog"

Don't let your coder friend find out this variable
console.log = function(String){
   $old_consoleLog("Bonkers: " + String);
}
Enter fullscreen mode Exit fullscreen mode

Rewrites original console.log function to output "Bonkers: ...";
Can also replace "Bonkers with any other Value as Prefix"

Can Revert Changes with:

console.log = $old_consoleLog;
Enter fullscreen mode Exit fullscreen mode

Reaction: What? Why Console.log Is Adding Bonkers to its output?

Top comments (4)

Collapse
 
itzsudhan profile image
Sudhan

Such a great idea XD

Collapse
 
mafee6 profile image
MAFEE7

XD

Collapse
 
mafee6 profile image
MAFEE7

:D XD

Collapse
 
mafee6 profile image
MAFEE7

Anyone Got Pranked With This Code?