こんにちは。
お世話になっております。
var Person = function(firstAndLast) { firstAndLast = firstAndLast.split(" "); // Complete the method below and implement the others similarly this.getFirstName = function() { return firstAndLast[0]; }; this.getLastName = function(){ return firstAndLast[1] }; this.getFullName = function(){ return firstAndLast[0] + " " + firstAndLast[1]; }; this.setFirstName = function(str){ firstAndLast[0] = str; }; this.setLastName = function(str){ firstAndLast[1] = str; }; this.setFullName = function(str){ str = str.split(" "); firstAndLast[0] = str[0]; firstAndLast[1] = str[1] } }; var bob = new Person('Bob Ross'); console.log(bob.getFullName());
上記のコードを実行すると
Uncaught TypeError: bob.getFullName is not a function
が出てしまいます。
何度も読み返したのですが、原因がわかりませんでした。
どなたか、よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー