How do I create a function that would receive one argument and would print in the console the underlying value of that argument, whether it be a primitive type or a function?
value = function(args){
return args.valueOf() //Only working for line 36
};
var scary = 'boo';
var first = function() { return 'bar'; };
var second = function() {
return first;
};
var third = function() {
return second;
};
var nested = function() {
return function() {
return function() {
return function() {
return function() {
return function() {
return function() {
return function() {
return function() {
return 'super nested';
};
};
};
};
};
};
};
};
};
// expected values for all these assessments
console.log(value(scary)); // should be 'boo'
console.log(value(first)); // should be 'bar'
console.log(value(second)); // should also be 'bar'
console.log(value(third)); // should also be 'bar'
console.log(value(nested)); // should be 'super nested'
The value function I made here only gives me the first line for scary and just the functions for the rest, how do I get the values of the other functions?