Home > Enterprise >  I'm trying to take the output of a console function and put it into an alert
I'm trying to take the output of a console function and put it into an alert

Time:02-04

So, I've been trying to take the output of the console and put it into an alert(). The code that I have been using is as follows, var d = "x"; console.log(d);. Then I get stuck because I do not know how to take the output of the console.log().

CodePudding user response:

console.log just prints to console, if you want to show the same in an alert window, just do alert

 var d = "x"; 
 //console.log(d);
 alert(d);

CodePudding user response:

Override the console.log function with a function that alert the input.

    console.log = function(text){
        alert(text);
    }
  •  Tags:  
  • Related