diff --git a/arrayProperty.js b/arrayProperty.js index 2287a36..9bc6de3 100644 --- a/arrayProperty.js +++ b/arrayProperty.js @@ -2,4 +2,12 @@ //Add a reverse method to the String 'class' so that every instance of String can call reverse and reverse itself. - //code here \ No newline at end of file + //code here + +String.prototype.reverse = function (str){ + str = this; + return str.split("").reverse().join(""); +} + +var str = 'Jules'; +console.log(str.reverse()); diff --git a/instanceArray.js b/instanceArray.js index ab752ac..d6a1092 100644 --- a/instanceArray.js +++ b/instanceArray.js @@ -14,28 +14,34 @@ var User = function(name, email, pw){ //Create an Array called 'users' that will store all our instances of User. //code here - +var users = []; //Now create and push into your users array 3 separate instances of User using the data from above in that exact order //code here +users[0] = new User('Aodhan', 'aodhan@boom.camp', 'iLoveJS'); +users[1] = new User('Greg', 'greg@boom.camp', 'iLovePython'); +users[2] = new User('Oscar', 'oscar@boom.camp', 'iLoveSoccer'); console.log('Aodhan\'s information is '); //Console.log all of Aodhan information //code here - +console.log(users[0].name, users[0].email, users[0].pw); console.log('Oscar\'s information is '); //Now console.log all of Oscars information //code here - +console.log(users[2].name, users[2].email, users[2].pw); //Now create another instance of User using your own information and then add that to your users array. //code here - +users[3] = new User('Jules', 'jules.ballaran@boom.camp', 'asd'); console.log('All my users names are '); //Now loop through your users Array and console.log every users name. //code here +for(let i=0; i