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);

17th Jan 2017, 1:16 PM
Daniel Oluwatobi Bello
Daniel Oluwatobi Bello - avatar
9 odpowiedzi
+ 10
function "cutName()" does not accept parameters ("cutName(myArray)" <- wrong)
17th Jan 2017, 1:38 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 9
function cutName(name){ return name.split(" ",2); }
17th Jan 2017, 1:53 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 8
Woah JS stuff. @ValentinHacker @cheeze
17th Jan 2017, 1:21 PM
Hatsy Rei
Hatsy Rei - avatar
+ 2
Thanks @valentinHacker tis working fine now
18th Jan 2017, 9:35 PM
Daniel Oluwatobi Bello
Daniel Oluwatobi Bello - avatar
+ 1
ok for this purpose, Valentine's answer should be your answer
17th Jan 2017, 1:46 PM
Andreas K
Andreas K - avatar
+ 1
@ValentinHacker. so how do I go about this please
17th Jan 2017, 1:49 PM
Daniel Oluwatobi Bello
Daniel Oluwatobi Bello - avatar
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)
17th Jan 2017, 1:40 PM
Andreas K
Andreas K - avatar
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
17th Jan 2017, 1:45 PM
Daniel Oluwatobi Bello
Daniel Oluwatobi Bello - avatar
0
You can overload your function or write a new function and add a parameter to its declaration
17th Jan 2017, 1:51 PM
Andreas K
Andreas K - avatar