fullname: cutName(namer) is not correct. you are expecting fullname to be a function but cutName(namer) is the return value of cutName() with param namer.
fullname: cutName
or
fullname: function () { cutName(namer) }
should work.
How can a function be added as a key-value pair in an object?
-
14-10-2022 - |
Question
I am working on the following code, and some sort of error is being found on the adding of 3 key-value pairs in the myData object:
var myArray = ["Francisco Souza Homem de Mello","franciscomello"];
var namer = myArray[0];
function cutName(namer) {
return namer.split(" ");
}
var boxy = cutName(namer);
var myData = {
fullname: cutName(namer),
skype: myArray[1],
github: "franciscomello"
};
The error is probaly on calling the cutName function on the myData object, but I cannot seem to find how to call it.
No correct solution
OTHER TIPS
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow