Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,591 members, 7,809,145 topics. Date: Friday, 26 April 2024 at 01:15 AM

Javascript Study Group - Programming (5) - Nairaland

Nairaland Forum / Science/Technology / Programming / Javascript Study Group (13236 Views)

Lets Learn C# Here!(study Group For Beginners) / Study Group For C++ Learner (2) (3) (4)

(1) (2) (3) (4) (5) (6) (Reply) (Go Down)

Re: Javascript Study Group by TechCrunch909: 4:37pm On Dec 11, 2014
Does anyone have insight on BMC remedy software.
Re: Javascript Study Group by Nmeri17: 12:37am On Feb 25, 2015
blueyedgeek:

Using a for loop, write a program that makes seven calls to console.log to output the following triangle:

#
##
###
####
#####
######
#######

[size=pt]2. FizzBuzz[/size]
Using a for loop, write a program that uses console.log to print all the numbers from 1 to 100, with two exceptions. For numbers divisible by 3, print "Fizz" instead of the number, and for numbers divisible by 5 (and not 3), print "Buzz" instead.

When you have that working, modify your program to print "FizzBuzz" for numbers that are divisible by both 3 and 5.

aha!! its this 500 page book I'm using cheesy I was surprised u didn't mention it in yo recommended books to download

too bad I didn't come when blue eye was still a learner. now everything is an object to him embarassed

well sha I hope you're still available to help. I'll be grateful if u can refer to that book's page 75. the codes from that page down to the end of the chapter is making me lose touch with reality embarassed cry whenever I attempt to approach that side, my heart starts doing gidigbam gidigbam angry
Re: Javascript Study Group by blueyedgeek(m): 9:52am On Feb 25, 2015
Nmeri17:


aha!! its this 500 page book I'm using cheesy I was surprised u didn't mention it in yo recommended books to download

too bad I didn't come when blue eye was still a learner. now everything is an object to him embarassed

I'm still a learner oooo. There are just so many things to learn and I keep learning everyday. I've barely even scratched the surface and I don't think I've attained the mastery I seek.


well sha I hope you're still available to help. I'll be grateful if u can refer to that book's page 75. the codes from that page down to the end of the chapter is making me lose touch with reality embarassed cry whenever I attempt to approach that side, my heart starts doing gidigbam gidigbam angry
I wouldn't get to hung up if I were you. Take your time to re - read the chapter and re - read it until it becomes clear. If that doesn't help, skip the chapter and read other chapters and then after getting a better understanding you can go back to the chapter again.

You know what, how about we both read the chapter again and on Saturday / Sunday, we come here to discuss the chapter thoroughly and iron out every issue, sounds good?
Re: Javascript Study Group by Nmeri17: 2:36am On Feb 26, 2015
blueyedgeek:

sorry I didn't reply earlier. I was hoping I'd finish that chapter before today. I got around some of the difficulties tho progress is not fast at all. hopefully I'll finish it later today.

meanwhile Lemmi drop some questions to keep the thread alive:
1) what is the difference between the methods CharAt and indexOf??
2) how do u get to make a closure without causing a stack to over flow or explode?
3) function remove (array, index) {
return array.slice (0, index)
.concat (array.slice (index + 1));
}
console log (remove(["a", "b", "c", "d", "e"], 2) );
// ["a", "b", "d", "e"]

sir/ma kindly explain line 2&3 of the object above in lay man's terms
bonus: dyu use Phi
Re: Javascript Study Group by blueyedgeek(m): 7:44am On Feb 27, 2015
Nmeri17:

1) what is the difference between the methods CharAt and indexOf??
2) how do u get to make a closure without causing a stack to over flow or explode?
3) function remove (array, index) {
return array.slice (0, index)
.concat (array.slice (index + 1));
}
console log (remove(["a", "b", "c", "d", "e"], 2) );
// ["a", "b", "d", "e"]

Lemme attempt 1 and 3. I don't fully understand question 2.

1. The charAt method simply stands for 'character at', from this break down, you know the method is used to return a character at a specific position in a string. You could also use array notation [] on a string and it would do the same thing. Use case:

var myName = "Blueyedgeek";

console.log(myName.charAt(2)) // logs "u"


The indexOf method returns the index position of a particular string. Use case:

var myName = "Blueyedgeek";

console.log(myName.indexOf('u')) // logs 2


The difference is in the arguments passed, charAt expects a number while indexOf expects a string.


3. The remove function takes two arguments, the array to act on and an index position (this should have been named stop if you ask me) to stop.

When an array is passed in, the slice method is called on the array with a starting position of 0 and a stop position of anything passed to index. (0,0) should return the first item in the array. The array is then concatenated with a slice of the array starting at the stop position with an addition of one. I guess this isn't clear enough.


Please ignore syntax errors, I'm on phone

Let me try again, when the remove function is called with those arguments passed in, (a,b,c,d,e) and 2, the function first takes a slice of the array starting at position 0 (note that slice doesn't change the state of an array, it only returns a new modified array). Position 0 is "a", the stop position is 2. Note that the stop position isn't returned in the modified array. So let's break down what the function does in stages. It first returns a slice of the array with a stop position as specified by the argument passed in. The remove function is called with a stop position of 2 so calling (a,b,c,d,e).slice(0,2) will return a and b (note it doesn't return the item at the stop position). Now we have a and b. The function then calls concat on a slice of the array starting at the stop position plus one. When the slice method is called with only one argument, it returns everything from that position to the end of the array. So calling (a,b,c,d,e).slice(2 + 1) , 2 + 1 is 3. Let's rewrite to make it clearer (a,b,c,d,e).slice(3) will return d and e. Now we have a, b from the first operation and d , e from the second. The remove function concatenates these two arrays into one by calling the concat method. Concatenate is simply big word for join. Let's call the concat method on our values a, b, d , e. This returns (a,b,d,e). Hope this is clear

I'll attempt two when I have a better understanding of closures.
Re: Javascript Study Group by Nmeri17: 10:13pm On Feb 27, 2015
blueyedgeek:
Lemme attempt 1 and 3. I don't fully understand question 2.

1. The charAt method simply stands for 'character at', from this break down, you know the method is used to return a character at a specific position in a string. You could also use array notation [] on a string and it would do the same thing. Use case:

var myName = "Blueyedgeek";

console.log(myName.charAt(2)) // logs "u"


The indexOf method returns the index position of a particular string. Use case:

var myName = "Blueyedgeek";

console.log(myName.indexOf('u')) // logs 2


The difference is in the arguments passed, charAt expects a number while indexOf expects a string.


3. The remove function takes two arguments, the array to act on and an index position (this should have been named stop if you ask me) to stop.

When an array is passed in, the slice method is called on the array with a starting position of 0 and a stop position of anything passed to index. (0,0) should return the first item in the array. The array is then concatenated with a slice of the array starting at the stop position with an addition of one. I guess this isn't clear enough.


Please ignore syntax errors, I'm on phone

Let me try again, when the remove function is called with those arguments passed in, (a,b,c,d,e) and 2, the function first takes a slice of the array starting at position 0 (note that slice doesn't change the state of an array, it only returns a new modified array). Position 0 is "a", the stop position is 2. Note that the stop position isn't returned in the modified array. So let's break down what the function does in stages. It first returns a slice of the array with a stop position as specified by the argument passed in. The remove function is called with a stop position of 2 so calling (a,b,c,d,e).slice(0,2) will return a and b (note it doesn't return the item at the stop position). Now we have a and b. The function then calls concat on a slice of the array starting at the stop position plus one. When the slice method is called with only one argument, it returns everything from that position to the end of the array. So calling (a,b,c,d,e).slice(2 + 1) , 2 + 1 is 3. Let's rewrite to make it clearer (a,b,c,d,e).slice(3) will return d and e. Now we have a, b from the first operation and d , e from the second. The remove function concatenates these two arrays into one by calling the concat method. Concatenate is simply big word for join. Let's call the concat method on our values a, b, d , e. This returns (a,b,d,e). Hope this is clear

I'll attempt two when I have a better understanding of closures.
grin grin

see this wayo boy. and you said you're still a learner. I actually saw this yo mention in the morning but I wanno reply when I'm settled back home.

now let me read the explanation and modify wink
Re: Javascript Study Group by Nmeri17: 10:30pm On Feb 27, 2015
hmmmmm...behold my eyes have been opened shocked shocked

bro sup with that weekend class. u still game??
Re: Javascript Study Group by blueyedgeek(m): 5:50am On Feb 28, 2015
Nmeri17:
grin grin

see this wayo boy. and you said you're still a learner. I actually saw this yo mention in the morning but I wanno reply when I'm settled back home.

now let me read the explanation and modify wink
I'm still learning oo, so many things to learn sef. The learning never really stops.
Re: Javascript Study Group by blueyedgeek(m): 5:51am On Feb 28, 2015
Nmeri17:
hmmmmm...behold my eyes have been opened shocked shocked

bro sup with that weekend class. u still game??
Yeah, I'm game.

Side note: Ever heard of the odin project before?
Re: Javascript Study Group by Nmeri17: 8:39am On Feb 28, 2015
blueyedgeek:
Yeah, I'm game.

Side note: Ever heard of the odin project before?
yea I have. I've been at their website once but I've not signed up. I'm about to drop some questions. good morning
Re: Javascript Study Group by blueyedgeek(m): 10:17am On Feb 28, 2015
Nmeri17:
yea I have. I've been at their website once but I've not signed up. I'm about to drop some questions. good morning
Cool by me. I'll try my best to answer any questions you might have and also be ready to answer mine too ooo.


Regarding the odin project, I want to follow their guide and I wanted to know if you are interested. We could skip the html and css section and start with the javascript and continue from there.
Re: Javascript Study Group by Nmeri17: 8:42pm On Feb 28, 2015
blueyedgeek:
Cool by me. I'll try my best to answer any questions you might have and also be ready to answer mine too ooo.


Regarding the odin project, I want to follow their guide and I wanted to know if you are interested. We could skip the html and css section and start with the javascript and continue from there.
oh owky LOL. this one you said you'll ask me, my mind don dh cut angry

just kidding. I'll sign up on there this night. you kno this question write a range function that takes two arguments start and end and returns an array containing all the numbers from start up to (and including end)?? I wrote
function range (start, end) {
var gold = [];
gold.push = range;
for (start = 1; start <= end; start++);
return gold;}
console.log (range(1, 10));

and its saying
push: function cry cry cry
Re: Javascript Study Group by blueyedgeek(m): 9:14pm On Feb 28, 2015
Nmeri17:
oh owky LOL. this one you said you'll ask me, my mind don dh cut angry

just kidding. I'll sign up on there this night. you kno this question write a range function that takes two arguments start and end and returns an array containing all the numbers from start up to (and including end)?? I wrote
function range (start, end) {
var gold = [];
gold.push = range;
for (start = 1; start <= end; start++);
return gold;}
console.log (range(1, 10));

and its saying
push: function cry cry cry
well you assigned a property 'push' and passed the function range as the result and so it returns an array containing the function (I'm just guessing, I haven't tested it.) A simpler way to write this would be


function range(start, end) {
var arr = [];

for (var i = start; i <= end; i += 1) {
arr.push(i);
}
return arr;
}
Re: Javascript Study Group by blueyedgeek(m): 9:16pm On Feb 28, 2015
@nmeri17, you should also sign up for an account on codewars.com

Social network for programmers (na code challenges full there ooo).
Re: Javascript Study Group by Nmeri17: 9:20pm On Feb 28, 2015
blueyedgeek:
@nmeri17, you should also sign up for an account on codewars.com

Social network for programmers (na code challenges full there ooo).
code wars ke arr y'all tryna start a third world war with codes?? grin
Re: Javascript Study Group by blueyedgeek(m): 9:34pm On Feb 28, 2015
Nmeri17:
code wars ke arr y'all tryna start a third world war with codes?? grin
Trust me, it's refreshing.
Re: Javascript Study Group by Nmeri17: 12:25am On Mar 01, 2015
blueyedgeek:
Trust me, it's refreshing.
**update
github?? check
Odin project?? check
code wars pending. I need to answer questions from the secret life of objects before signing up and I'm not there yet sad those guys ain't joking at all

if you're around yo system now u can try that prev question. yo code is returning 11
Re: Javascript Study Group by blueyedgeek(m): 7:58am On Mar 01, 2015
Nmeri17:
**update
github?? check
Odin project?? check
code wars pending. I need to answer questions from the secret life of objects before signing up and I'm not there yet sad those guys ain't joking at all

if you're around yo system now u can try that prev question. yo code is returning 11
I'll check it when I'm on pc but I'm quite sure it should work. Morning.
Re: Javascript Study Group by Nmeri17: 12:27pm On Mar 01, 2015
blueyedgeek:
I'll check it when I'm on pc but I'm quite sure it should work. Morning.
morning bro. I've got another one: write a reverseArray function that takes an array as an argument and produces a new array that has the same elements in inverse order
me:

function reverseArray() {
var array = [];
array.unshift = reverseArray.slice;
return array};

or


function reverseArray() {
var array = [];
for (i = array.length-1; i> >= 0; i--);
array.push = i
return array};
but it seems I'm missing something
Re: Javascript Study Group by blueyedgeek(m): 1:05pm On Mar 01, 2015
Nmeri17:
morning bro. I've got another one: write a reverseArray function that takes an array as an argument and produces a new array that has the same elements in inverse order
me:

function reverseArray() {
var array = [];
array.unshift = reverseArray.slice;
return array};

or


function reverseArray() {
var array = [];
for (i = array.length-1; i> >= 0; i--);
array.push = i
return array};
but it seems I'm missing something
First off, there is a reverse method defined on Array.prototype that does this easily. A very simple reverse array function would look like this,


function reverseArray(arr) {
return arr.reverse();
}


Now to your question, your function is supposed to be passed an argument and it is that argument that the body of your function should work on. So pass in a parameter and it is that parameter that you manipulate inside the body of your function.
Re: Javascript Study Group by Nmeri17: 1:14pm On Mar 01, 2015
blueyedgeek:
First off, there is a reverse method defined on Array.prototype that does this easily. A very simple reverse array function would look like this,


function reverseArray(arr) {
return arr.reverse();
}


Now to your question, your function is supposed to be passed an argument and it is that argument that the body of your function should work on. So pass in a parameter and it is that parameter that you manipulate inside the body of your function.
sorry I failed to state you can't use the reverse method tongue yu should know this question
Re: Javascript Study Group by blueyedgeek(m): 1:53pm On Mar 01, 2015
Nmeri17:
sorry I failed to state you can't use the reverse method tongue yu should know this question
Okay, that should give me a workout and light no dey make I test for pc. I will try it out when I have access to a system.
I still think yours isn't working because of the parameter ish.

Edit:

This should work,
Create a function that accepts one parameter.

Create a locally scoped variable inside the function, it should be an empty array.

Loop through the passed in array (passed as an argument)

For each time the loop executes, the last item in the passed in array should be passed in to the temporary array as a first item.

Return the temporary array and it will have the reversed form of the passed in array.


Should look like this



function reverseArray(array) {
var tempArr = [];

for (var i = 0, len = array.length; i < len; i += 1) {
tempArr.push(array.pop())
}
return tempArr;
}
Re: Javascript Study Group by Nmeri17: 2:52pm On Mar 01, 2015
blueyedgeek:



Should look like this



function reverseArray(array) {
var tempArr = [];

for (var i = 0, len = array.length; i < len; i += 1) {
tempArr.push(array.pop())
}
return tempArr;
}
just tested it
cry embarassed
I wish I had good news

PS1: there arr two styles yu can uses. either simple input and return OR for statement. not both undecided
PS2: what's that len shii in line4

I'm going to pray that NEPA brings yo light. see u when my prayers arr answered wink
Re: Javascript Study Group by blueyedgeek(m): 3:08pm On Mar 01, 2015
Nmeri17:
just tested it
cry embarassed
I wish I had good news

PS1: there arr two styles yu can uses. either simple input and return OR for statement. not both undecided
PS2: what's that len shii in line4

I'm going to pray that NEPA brings yo light. see u when my prayers arr answered wink
I don't understand PS1.

PS2: len is just another variable to hold and cache the length of the array passed in, good for performance (if we have an array of say 50,000 items, it only has to search for the length once and not 50,000 times).
Re: Javascript Study Group by Nmeri17: 3:44pm On Mar 01, 2015
blueyedgeek:
I don't understand PS1.

PS2: len is just another variable to hold and cache the length of the array passed in, good for performance (if we have an array of say 50,000 items, it only has to search for the length once and not 50,000 times).
"input and return" as in u input the function value in yo array and return the reverse of yo input OR for statement. not both options. that's why my ist post had two options. dyu understand??
Re: Javascript Study Group by blueyedgeek(m): 4:27pm On Mar 01, 2015
Nmeri17:
"input and return" as in u input the function value in yo array and return the reverse of yo input OR for statement. not both options. that's why my ist post had two options. dyu understand??
Nope or do you mean that the function will be called as a method on the array?
Re: Javascript Study Group by Nmeri17: 7:51pm On Mar 01, 2015
blueyedgeek:
Nope or do you mean that the function will be called as a method on the array?
nigga sup?? smiley

I mean something like
function blueBoy(number){
var geek = []
for (i = 0; i <= 8; i++)
number.push = geek;
return geek

where you input and return number. comprende??
Re: Javascript Study Group by blueyedgeek(m): 8:00pm On Mar 01, 2015
Nmeri17:
nigga sup?? smiley

I mean something like
function blueBoy(number){
var geek = []
for (i = 0; i <= 8; i++)
number.push = geek;
return geek

where you input and return number. comprende??
You know what, why not post the question as is right here on this thread. Hope it won't be too much to type by hand?

Alternatively, tell me the chapter and I"ll check the online book and we'll come here to discuss.
Re: Javascript Study Group by Nmeri17: 8:05pm On Mar 01, 2015
blueyedgeek:
You know what, why not post the question as is right here on this thread. Hope it won't be too much to type by hand?

Alternatively, tell me the chapter and I"ll check the online book and we'll come here to discuss.
exercise name: reversing an array
page number 84
Re: Javascript Study Group by blueyedgeek(m): 8:13pm On Mar 01, 2015
Nmeri17:
exercise name: reversing an array
page number 84
cool, lemme check it

Edit:


You are asked to write two functions and for both you are not allowed to use the reverse method.

The first function reverses the array without changing it's original state.

E.g

var arr = [1,2,3,4,5];

reverseArray(arr) returns [5,4,3,2,1] but arr is still [1,2,3,4,5]


The second function reverses the array and changes the state of the array.

E.g

var arr = [1,2,3,4,5];

reverseInArray(arr) returns [5,4,3,2,1] and arr is now [5,4,3,2,1]

That's all there is to it really.
Re: Javascript Study Group by Nmeri17: 8:39pm On Mar 01, 2015
^^^ lmao grin
Oya write the code and test it let's see howfa
Re: Javascript Study Group by blueyedgeek(m): 9:05pm On Mar 01, 2015
Nmeri17:
^^^ lmao grin
Oya write the code and test it let's see howfa
cool, nepa bring light take am but small juice dey my laptop. Lemme try it out.

(1) (2) (3) (4) (5) (6) (Reply)

What Is The Average Salary Of A Php Programmer In Lagos / Keywords / Reserved word In Q-BASIC / Where Is That Female Geek: Any Good Female Developer Around?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 77
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.