0
The code keeps returning undefined please can anyone help me out??
var myArray=[]; myArray[0] = "Daniel Bello"; myArray[1] = "enigma"; function cutName(){ var myNewArray = myArray[0].split(" ",2); document.write(myNewArray) } function myData(fullname , skype , github) { this.fullname = fullname; this.skype = skype; this.github = github; } var p1 = new myData(cutName(), myArray[1], "null") document.write(p1.fullname + "<br/>); document.write(p1.Skype + "<br/>"); document.write(p1.github);
9 Respuestas
+ 10
function "cutName()" does not accept parameters ("cutName(myArray)" <- wrong)
+ 9
function cutName(name){
return name.split(" ",2);
}
+ 8
Woah JS stuff.
@ValentinHacker @cheeze
+ 2
Thanks @valentinHacker tis working fine now
+ 1
ok for this purpose, Valentine's answer should be your answer
+ 1
@ValentinHacker. so how do I go about this please
0
Ok, I am wondering what are you want us to do?
Shall we debug this part?
/*var myData = {
fullname:cutName(),skype:myArray[1],github:"null"
};
var x = myData['skype'];
document.write(x);*/
or this one?
function myData(fullname , skype , github) {
this.fullname = fullname;
this.skype = skype;
this.github = github;
}
var p1 = new myData(cutName(myArray), myArray[1], "null")
document.write(p1.fullname)
0
the code in the comment isn't part of it... removed it
I'm supposed to input two strings into an array myArray the first being my full name and the second my Skype username the create a function cutName that sepetates the names still in the array eg "Daniel Bello" becomes "Daniel"," Bello". then input the this array into an object myData
0
You can overload your function or write a new function and add a parameter to its declaration