'I'm trying to take the output of a console function and put it into an alert
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().
Solution 1:[1]
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);
Solution 2:[2]
Override the console.log function with a function that alert the input.
console.log = function(text){
alert(text);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alvaro Hernandorena |
| Solution 2 | I'm random |
