As I'm debugging, I'm consistently writing this bit of code:
a = 2;
// do some operation on variable a
console.log("The a variable is now " + a);
I wondered if I might create a function that shortens that process, like this,
function varlog(x) {
var vartext = // this is what I don't know
return "The " + vartext + " variable is now " + x;
}
var a = 2;
console.log(varlog(a));
Two questions,
- Is there a better way to solve this problem that I'm not seeing?
- If not, what should the vartext be to solve this problem?