These are chat archives for FreeCodeCamp/HelpJavaScript

16th
Mar 2017
john94
@lpy1994
Mar 16 2017 00:00
@monkeyfingerz Object.keys(contacts[i]) forms a array, which containes all the objects in the contacts
then use indexOf to look for the prop. if it finds, then it will return the whole thing that has prop in it.
I think.
Stephen James
@sjames1958gm
Mar 16 2017 00:32
@monkeyfingerz it returns true of the prop is in the Object.keys array past index 0 - if so it returns the property value for prop.
It is subject to failure if the property happens to be in index zero of Object.keys
Object.keys(contacts[i]).indexOf(prop) >= 0 is equivalent to contacts[i].hasOwnProperty(prop)
Saboor Malik
@MathematicsCoding
Mar 16 2017 00:45
SIgh
Sigh
Can someone help me with this challenge
Donnie
@Donnie-D
Mar 16 2017 00:49

var myStr = "Jello World";

// Only change code below this line

myStr = "Hello World";
myStr[0] = "H"; // Fix Me
GUYS WHATS WRONG HERE??? CAN ANYONE FIND ANYTHING WRONG?

Saboor Malik
@MathematicsCoding
Mar 16 2017 00:50
Look at jello
Stephen James
@sjames1958gm
Mar 16 2017 00:50
@Donnie-D You didn't "Fix Me" that line is bad enough to cause the tests to fail
Saboor Malik
@MathematicsCoding
Mar 16 2017 00:51
H...
H = Hello
Donnie
@Donnie-D
Mar 16 2017 00:51
how should it be written?
@sjames1958gm
Conrad Kay
@conradkay
Mar 16 2017 00:52
it should be myStr = "Hello World";
you cant index a string
Stephen James
@sjames1958gm
Mar 16 2017 00:52
@Donnie-D You should have replaced that line, not added a new line, that line before it is correct, if you delete the line with [0]
Donnie
@Donnie-D
Mar 16 2017 00:52
@sjames1958gm replaced to myStr[0]="J"; ?
oh okay got it. let me try that buddy
Saboor Malik
@MathematicsCoding
Mar 16 2017 00:54
...
Donnie
@Donnie-D
Mar 16 2017 00:55
@sjames1958gm I owe you one ....Saboor and the rest!!! gracias all of you gracious fellas for the effort!!!
CamperBot
@camperbot
Mar 16 2017 00:55
donnie-d sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6189 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Mar 16 2017 00:55
@Donnie-D :+1:
Manish Giri
@Manish-Giri
Mar 16 2017 00:58
@sjames1958gm congrats on 6k!
Stephen James
@sjames1958gm
Mar 16 2017 00:59
@Manish-Giri thx
CamperBot
@camperbot
Mar 16 2017 00:59
sjames1958gm sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4763 | @manish-giri |http://www.freecodecamp.com/manish-giri
Joseph
@revisualize
Mar 16 2017 01:03
cbot
CamperBot
@camperbot
Mar 16 2017 01:03
you called?
Joseph
@revisualize
Mar 16 2017 01:03
I DID!
Hello
Chris Cullen
@123xylem
Mar 16 2017 01:07

Hello guys.. Im using mongo and accessing an object through its ID. However Mongo is storing the id in a way thats hard to read


{ "_id" : ObjectId("58c9e3007ce7be0f5f107f4e") //this is how mongo stores the id of following object
"name" : "Mt Cootha", "image" : "https://media-cdn.tripadvisor.com/media/photo-s/01/c6/2a/b7/mount-coot-tha-lookout.jpg", "description" : "City Views", "comments" : [ ObjectId("58c9e3007ce7be0f5f107f51") ], "__v" : 1 }

Below the only way i can find it with its ID is with this complicated camps.find

> db.camps.find({_id:ObjectId("58c9e3007ce7be0f5f107f4e")})

Which is a problem because in my app im using this to access it

            res.redirect("/camps/"+found.id);     
 //it goes to index site + the id of the object i have stored via object(found).id

So how do i access ({_id:ObjectId("58c9e3007ce7be0f5f107f4e")}) in a js file??

Im getting type cast errror cos it doesnt know what its looking for with .id
Kaveh
@Kavehbak
Mar 16 2017 01:39

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {

// Only change code below this line.
var gear=4;
this.getGear=function(){
return gear;

};
this.setGear=function(){

};

};

var myCar = new Car();

var myBike = new Bike();

myBike.setGear(3);

hi
Ayush Bahuguna
@relentless-coder
Mar 16 2017 01:40
@123xylem that is no issue. go ahead with your step
actually it is ._id
and not .id
Chris Cullen
@123xylem
Mar 16 2017 01:41
@relentless-coder yea i have tried both but no worky :(
Ayush Bahuguna
@relentless-coder
Mar 16 2017 01:41
that's why you are getting the error
what is found.id???
could you post the code please?
@Kavehbak Hi, how can I help? :)
@123xylem the problem isn't "_id" : ObjectId("58c9e3007ce7be0f5f107f4e") it's probably something in the rest of the code because that's how the mongodb stores documents
Chris Cullen
@123xylem
Mar 16 2017 01:44
@relentless-coder yes 1 sec
Its something to do higher up as its struggling at findById section .. Il show now
app.post("/camps/:id/comments",function(req,res){
    camp.findById(req.params.id,function(err,found){
        if(err){console.log(req.params.id,"HERE",err)
    }
    else{  console.log("HERE",req.params.id)}
    });
THis is the console.
{ _id: 58c9eda7c6955a106c192cb1,
  name: 'Mt Glorious',
  image: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR8fFROpqvrssT7Qj60xgTwsDsZpqetHnoBqAX9GOEr3j8Kzm7N',
  description: 'glorious and big',
  __v: 1,
  comments: 
   [ { _id: 58c9eda7c6955a106c192cb6,
       text: 'Nice PLace',
       author: 'Zubar',
       __v: 0 } ] }
:id HERE
Ayush Bahuguna
@relentless-coder
Mar 16 2017 01:45
and where does res.redirect("/camps/"+found.id); fit in your code?? how are you using it??
Chris Cullen
@123xylem
Mar 16 2017 01:47
@relentless-coder thats at the bottom
Kaveh
@Kavehbak
Mar 16 2017 01:47
@relentless-coder I am having problem with public and private property
Chris Cullen
@123xylem
Mar 16 2017 01:47
but its giving me error before i get there
David Amanze
@GodKingShogun
Mar 16 2017 01:47
hello everyone :smile:
Ayush Bahuguna
@relentless-coder
Mar 16 2017 01:48
@123xylem is it inside the same post route?? because found is a local variable
@Kavehbak so, what about it? you need to explain
Chris Cullen
@123xylem
Mar 16 2017 01:48
@relentless-coder yes i just commented it out because im getting an error at findByID
the req.params.id isnt giving a proper id
Kaveh
@Kavehbak
Mar 16 2017 01:49
@relentless-coder The method setGear of myBike should be accessible outside the object.
myBike.gear should remain undefined.
myBike.getGear() should return 4 after calling myBike.setGear(4).
myBike.getGear() should return 3 after calling myBike.setGear(3).
myBike.getGear() should return 1 after calling myBike.setGear(1).
Ayush Bahuguna
@relentless-coder
Mar 16 2017 01:49
@123xylem please post the whole code in focus. I don't know where did you use redirect. also, could you check the url in your browser, the id???
Chris Cullen
@123xylem
Mar 16 2017 01:51
@relentless-coder ok il show u the whole code. Im just saying that my error isnt to do with found.id as its erorring before it gets that far down. the req.params.id of my post req isnt giving it an id value it can use
Ayush Bahuguna
@relentless-coder
Mar 16 2017 01:51
@Kavehbak so what is the problem? did you not understand the question or what else??
@123xylem yeah so check the action of your form. have you interpolated values correctly?
mariozzm7
@mariozzm7
Mar 16 2017 01:52
I was learning javascript but wasn't sure if I was actually learning so I came here
Dyrajca93
@Dyrajca93
Mar 16 2017 01:53
Hey guys, i am doing one of the first Javascript lessons and I am already stuck -__- The instructions are: "Assign the value 7 to variable a.
Assign the contents of a to variable b." I thought that writing " var a= 7; var b= var a;" would work but it doesnt..
Kaveh
@Kavehbak
Mar 16 2017 01:53
@relentless-coder the problem is I have to allocate the number manually
I mean in order to change it
Saboor Malik
@MathematicsCoding
Mar 16 2017 01:54
@Dyrajca93
var b = a; NOT var b = var a;
One var only...
var must be before other code written in that line
Chris Cullen
@123xylem
Mar 16 2017 01:55
@relentless-coder well req.params.id should just take the Id of the pages request... for some reason its giving only this !! :id
console.log("==================="+req.params.id)
Dyrajca93
@Dyrajca93
Mar 16 2017 01:55
@MathematicsCoding Thank you so much!
CamperBot
@camperbot
Mar 16 2017 01:55
dyrajca93 sends brownie points to @mathematicscoding :sparkles: :thumbsup: :sparkles:
:cookie: 189 | @mathematicscoding |http://www.freecodecamp.com/mathematicscoding
whirlyshmily
@whirlyshmily
Mar 16 2017 01:56
who know where to learn python like freeCodeCamp?please help me!
Saboor Malik
@MathematicsCoding
Mar 16 2017 01:56
No problem
Chris Cullen
@123xylem
Mar 16 2017 01:56
console =
===================:id
Ayush Bahuguna
@relentless-coder
Mar 16 2017 01:56
@123xylem what is the action of your form?? the url to which you are sending the form??
@Kavehbak you need to create a local variable and do speed manipulations on it
Chris Cullen
@123xylem
Mar 16 2017 01:57
@relentless-coder the form
<form action="/camps/:id/comments" method="POST">
Ayush Bahuguna
@relentless-coder
Mar 16 2017 01:58
@123xylem lol. you need to put in some value instead of just :id
Kaveh
@Kavehbak
Mar 16 2017 01:58

@relentless-coder
var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {

// Only change code below this line.
var gear=4;
this.getGear=function(){
return gear;

};
this.setGear=function(){

};

};

var myCar = new Car();

var myBike = new Bike();

myBike.setGear(3);

Chris Cullen
@123xylem
Mar 16 2017 01:58
@relentless-coder HAHA yea i literally figured it out 1 sec before that.. Im such an idiot sometimes
thankyou so much . its always helpful to have someone (especially helpful) bounce ideas off
@relentless-coder thanks
CamperBot
@camperbot
Mar 16 2017 01:59
123xylem sends brownie points to @relentless-coder :sparkles: :thumbsup: :sparkles:
:cookie: 362 | @relentless-coder |http://www.freecodecamp.com/relentless-coder
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:00
@Kavehbak There is _=
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:00
@Kavehbak you need to use getgear and setgear to return values of gear and set new value of gear without someone being able to directly access gear, take hint from the Car function that way it does with speed :)
David Amanze
@GodKingShogun
Mar 16 2017 02:01
im about to post code that might cause a seizure lol. can someone tell me if my return in my loops will return for the function or do i have to write the return again outside some of the loops and if statements

function smallestCommons(arr) {
var remainder=0;
var counter1=2;
var counter=0;
var num1= arr[0];
var num2= arr[1];
var fnum1= arr[0];
var fnum2= arr[1];
  if (num1<num2){
  for (var i=2; counter===0; i++) {
    if (fnum1*i<fnum2) {

    } else if (fnum1*i>fnum2) {
      fnum2*=counter1;
      counter1++;
    } else if (fnum1*i===fnum2){
      for (var j=num2; j>=num1; j--) {
        if(fnum2%j===0) {

        } else{
          remainder+=1;
        }
      }
         if (remainder===0){
          return fnum2;
        } else {
          remainder=0;

        }
    }

   }

  } else {
     for (var k=2; counter===0; k++) {
    if (fnum2*k<fnum1) {

    } else if (fnum2*k>fnum1) {
      fnum2*=counter1;
      counter1++;
    } else if (fnum2*k===fnum1){
      for (var l=num1; l>=num2; l--) {
        if(fnum1%l===0) {

        } else{
          remainder+=1;
        }
      }
         if (remainder===0){
          return fnum1;
        } else {
          remainder=0;

        }
    }

   }
  }

}
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:04
@GodKingShogun why are your if statements empty??
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:05
@GodKingShogun this looks insanely complicated
David Amanze
@GodKingShogun
Mar 16 2017 02:05
i dont want anything to happen for that particular condition
@HeebieGeeBee :worried:
@HeebieGeeBee im a complicated man lol
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:06
@GodKingShogun like its not an easy task but i dunno how you follow everything thats happening
David Amanze
@GodKingShogun
Mar 16 2017 02:07
@HeebieGeeBee its really one if statement with nested if and loops
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:07
I thought C# was objective C...
David Amanze
@GodKingShogun
Mar 16 2017 02:08
@HeebieGeeBee @relentless-coder can you tell me if my return will stop the loop and print the results to my console where i have it
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:08
@GodKingShogun got no idea
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:09
yes it will. but doesn't mean you'll get desired results :smile: @GodKingShogun
David Amanze
@GodKingShogun
Mar 16 2017 02:09
@HeebieGeeBee :cry:
@relentless-coder @HeebieGeeBee am i doing anything technically wrong
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:09
damn, it's hard to even keep track of opening and closing brackets. let me figure out the nesting
David Amanze
@GodKingShogun
Mar 16 2017 02:10
@relentless-coder im sorry :worried:
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:10
@GodKingShogun you know theres a very easy way to find out the which is biggest and smallest out of two numbers
David Amanze
@GodKingShogun
Mar 16 2017 02:10
forgive me senpai lol
@HeebieGeeBee please inform me lol
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:10
Math.min and Math.max
David Amanze
@GodKingShogun
Mar 16 2017 02:11
how would you use it in an array
@HeebieGeeBee can you demonstrate
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:11
Where can I learn objective c for free?
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:11
@GodKingShogun Math.min and Math.max work on a collection of numbers, so array. Math.max(2,3)
David Amanze
@GodKingShogun
Mar 16 2017 02:11
if you had an array of [1,5] @HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:12
well like you can have var min = Math.min(arr[0], arr[1]) and var max= Math.max(arr[0], arr[1])
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:12
Math.max(arr[0], arr[1])
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:12
now you have have the smallest number stored in a variable and the biggest number stored in a variable
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:12
well, @HeebieGeeBee is faster at typing. probably has internet speed of 100mbps
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:13
my internet speed is potato @relentless-coder
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:13
@MathematicsCoding google
David Amanze
@GodKingShogun
Mar 16 2017 02:13
@HeebieGeeBee why do you have two elements in the min and max
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:13
because comparison @GodKingShogun
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:13
^
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:13
..
Well what is best site to learn objective c?
:p
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:14
@GodKingShogun think of it as if(a > b)
David Amanze
@GodKingShogun
Mar 16 2017 02:14
@relentless-coder @HeebieGeeBee ah i see the path now lol
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:14
not really that, but you understand why two elements are used
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:14
For some reason my internet speed is very slow...
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:15
@MathematicsCoding use google on lite mode
David Amanze
@GodKingShogun
Mar 16 2017 02:15
@relentless-coder @HeebieGeeBee what if you had an array of a lot of elements how would you find the min and max... you wouldn't want to write all the elements
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:16
@GodKingShogun id probably sort the array
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:16
@relentless-coder lite mode?
David Amanze
@GodKingShogun
Mar 16 2017 02:16
@HeebieGeeBee sorting is so fun :smile:
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:17
whatever floats your boat
David Amanze
@GodKingShogun
Mar 16 2017 02:17
@relentless-coder did you manage to follow the nests or did you give up lol
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:17
sort is basically what you are supposed to code in the first place :smile: but people don't realise that and instead use that directly?
David Amanze
@GodKingShogun
Mar 16 2017 02:17
@HeebieGeeBee lol jk
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:18
@GodKingShogun yes, I've figured out the nesting and that's enough for today
David Amanze
@GodKingShogun
Mar 16 2017 02:19
@relentless-coder lol i understand
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:19
@MathematicsCoding if you are using it on mobile, then google detects slow internet and presents you websites in their minimal form, so that they don't take much time to load
David Amanze
@GodKingShogun
Mar 16 2017 02:19
@relentless-coder im getting an infinite loop at line 11
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:20
@relentless-coder which programming languages do you know?
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 02:20

function nextInLine(arr, item) {
 testArr.push(item); // Your code here
 testArr.shift(arr) ;
  return arr;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
What am i goofing?
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:20
@GodKingShogun yes because you haven't set any condition for i..
@MathematicsCoding just js
David Amanze
@GodKingShogun
Mar 16 2017 02:20
@Tiff32 look back at the modifying array section
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:20
oh
David Amanze
@GodKingShogun
Mar 16 2017 02:21
@Tiff32 the unshift and shift modules
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:21
Html & css is just web development..
@relentless-coder Like JS? or just basic js what you have learned from here
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:21
@GodKingShogun for (var i=2; counter===0; i++) so you haven't set any condition that affects i in some way so it just keeps on going for ever
JacekWrycz-Rekowski
@JacekWrycz-Rekowski
Mar 16 2017 02:22
function timerStart(){
    var myVar = setInterval(timer(),1000);
}
function timer(){
    console.log("X");
}
Do You know why it logs only once? Wasn't it suppose to log every second?
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:22
@MathematicsCoding like JS. because I think I know more than basic js and don't know what, "like JS" means so I'd go with "like JS"
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:22
@Tiff32 youre not meant to use testArr in the code, just arr
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:22
Well JS tehn
then
David Amanze
@GodKingShogun
Mar 16 2017 02:23
@relentless-coder thats why i asked about the return. i need the code to go on until i return
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:23
@MathematicsCoding what languages do you know?
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:24
Well just more basicly js...
Since html and css isn't a programming language
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:25
@MathematicsCoding so why do you want to learn objective c?
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:25
I would've learn objective c or something a few months ago...
You sure type fast
David Amanze
@GodKingShogun
Mar 16 2017 02:25
i type faster lol
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:25
I just want to learn objective c so I will be able to build some ios apps or something
I have xcode but I do not know objective c yet
Im sure that I have enough experience to be ready to learn objective c
JacekWrycz-Rekowski
@JacekWrycz-Rekowski
Mar 16 2017 02:27
function timerStart(){
    var myVar = setInterval(timer(),1000);
}
function timer(){
    console.log("X");
}
Do You know why it logs only once? Wasn't it suppose to log every second?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:27
@MathematicsCoding well javascript can alway sbe converted to iphone apps
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:27
You mean apps can be built with just js? or objective c with some js
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:28
@GodKingShogun lol, no. that's not javascript compiles your code :)
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:28
Well android apps can be built in js
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:28
i mean you can convert a app built in js to run as an app on iphone
@MathematicsCoding but anyway
https://www.edx.org/course/introduction-computer-science-harvardx-cs50x this isnt objective c, but c might be a good place for you to start
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:29
if you want to learn Objective C, then go buy a book, or a course on udemy. and learn, why look for "free" courses. Are you not sure whether or not you want to learn Objective C?
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:29
No Why pay for something to learn...
@HeebieGeeBee C and objective c isn't the same?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:30
no
David Amanze
@GodKingShogun
Mar 16 2017 02:30
@relentless-coder sorry ran off for a sec i am back
@relentless-coder i thought return ended the function
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:30
I mean I have no idea what C do?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:31
its pretty much the fundation that all other languages that have c in their name were built upon
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:31
because someone worked hard to make it easier for you to learn, you can always refer this https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html if you just want to refer to something don't really care about whether or not it is easy to understand @MathematicsCoding
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:32
I went to that site :p
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:32
so study from it
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:32
apps dont have to be written in certain languages to be ported to iphones
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:32
@HeebieGeeBee Thanks for that site I will learn CS later
CamperBot
@camperbot
Mar 16 2017 02:32
mathematicscoding sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1056 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:32
its not CS either
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:32
Well yeah but objective c is main language to be used by apple
Whats not CS?
David Amanze
@GodKingShogun
Mar 16 2017 02:33
@relentless-coder ignored :cry:
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:33
the programming language C isnt CS
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:33
@GodKingShogun
@HeebieGeeBee I didnt say that lol
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:33
@GodKingShogun no so flow antonio. let me understand your problem
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:33
That site... to edx intro to CS
David Amanze
@GodKingShogun
Mar 16 2017 02:34
@relentless-coder no so flow Antonia?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:34
@MathematicsCoding yes
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:34
Well I have planned to take CS at my school...
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:35
great
so why dont you want to learn swift instead
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:35
It might not real "CS" like basic, learning history of computer, or intro to tools
swift?
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:35
javascript runs in two steps, first it compiles your code, and then it executes your code. it is in the compilation phase that js detects an infinite loop, so you never get anything executed. @GodKingShogun that is what my understanding of js is, other people who are far more knowledgeable than me can help you with it.
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:35
I see i googled swift
oscar carrillo
@oscarrillo90
Mar 16 2017 02:36

function nextInLine(arr, item) {
  // Your code here

  return item;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
How do i write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:36
@relentless-coder well if we want to be pickity JS isnt a compiled language
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:36
I think by a year from now I might will known some C, js, Java, and swift....
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:37
@HeebieGeeBee well, kyle simpson thinks differently about it. :smile:
David Amanze
@GodKingShogun
Mar 16 2017 02:37
@relentless-coder i will go on an adventure to find such person lol
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:37
@GodKingShogun Find a queen
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:37
@MathematicsCoding that'll be good
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:37
Or goddess
@HeebieGeeBee I have a question hold on
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:37
I have been following his course on PluralSight and in it he mentioned that it uses JIT compilation.
@HeebieGeeBee
David Amanze
@GodKingShogun
Mar 16 2017 02:38
@MathematicsCoding @HeebieGeeBee @relentless-coder ill be back in three years and i will bring with me the answer to al js questions lol
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:38
@GodKingShogun lol
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:38
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:38
Probably same here :p
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:38
@oscarrillo90 did you read what the push and shift functions do?
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:38
@HeebieGeeBee Is this good place to learn CS?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:38
@MathematicsCoding how would i know?
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:39
Well check it out...
Looks at these lessons? like good enough
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:39
@relentless-coder but its still not a compiled language is it
in the traditional sense
its an interpreted language
@MathematicsCoding i wouldnt know i havent done them
ebony821
@ebony821
Mar 16 2017 02:40
introducing else statements- error message testElse(4) should return "5 or Smaller". I have tested numbers 0-6. What number goes in the test and why
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:40
@ebony821 whats your code?
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:41
@HeebieGeeBee JIT is a mix of ahead of time compilation and iterpretation. So not really a technical compiled language, but it gets compiled in the run time. It has it's own meaning when it comes to compilation, can't really compare with C or others
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:41
Oh yeah I have enrolled a course at edx.org for html and JS
But they kinda sucks...
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:42
@MathematicsCoding they have very good lecturers and teachers from what i see
@relentless-coder yeah its definately somehing different
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:43
Yeah but that course doesnt have the videos just the notes and an example of code
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:43
@MathematicsCoding i mean the edx
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:43
Yeah I agree..
@HeebieGeeBee Anyway what does swift do?
Build iOS apps like objective c?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:44
yes
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:44
So there are more than a way to build iOS apps?
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:44
man, didn't know @HeebieGeeBee is the physical form of google. let me try, Hey @HeebieGeeBee what's the meaning of life??
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:44
...
David Amanze
@GodKingShogun
Mar 16 2017 02:45
@relentless-coder i have one last question about something you said earlier. you said my code would fail because i left my if blank but in the previous challenge i left it blank and my code worked perfectly
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:45
@HeebieGeeBee then would be named Gooogled
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:45
@relentless-coder lol
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:45
@GodKingShogun i didn't say it would fail. I was just curious why you left it empty :smile:
Adam
@GoingAllTheWayUp
Mar 16 2017 02:46
Can you break this? Anything you think I should address before submission? maybe like some nice rounded numbers is on the list already?
David Amanze
@GodKingShogun
Mar 16 2017 02:46
@relentless-coder oh okay... because i dont want anything to happen except go back to the loop and add +1 to i
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:47
@GoingAllTheWayUp you not gonna put a limit on how many numbers can be etered?>
Adam
@GoingAllTheWayUp
Mar 16 2017 02:48
I think shrink the font size on the fly
Ayush Bahuguna
@relentless-coder
Mar 16 2017 02:48
@GodKingShogun set the proper condition for the i, and then we'll see what happens. :)
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:48
@GoingAllTheWayUp but you might want a limit
Adam
@GoingAllTheWayUp
Mar 16 2017 02:49
your right, lol, sounded good
maybe alittle of both
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:49
blob
@GoingAllTheWayUp
Adam
@GoingAllTheWayUp
Mar 16 2017 02:50
maybe limit the current value, but shrink text of equation display
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:50
@GoingAllTheWayUp and some little touches like the cursor changing when hovering over the inputs might be nice
Adam
@GoingAllTheWayUp
Mar 16 2017 02:50
I can't belive i got it this far, lol that decimals thing killed me
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 02:51
@GoingAllTheWayUp well, well done
Adam
@GoingAllTheWayUp
Mar 16 2017 02:52
Thanks! more to come
@HeebieGeeBee thanks for input
CamperBot
@camperbot
Mar 16 2017 02:52
goingallthewayup sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1057 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:52
SOrry went to do something...
Im back
Kaveh
@Kavehbak
Mar 16 2017 02:53
@relentless-coder no success
!
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:53
Can you get a college degree from edx?
Kaveh
@Kavehbak
Mar 16 2017 02:53

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {

// Only change code below this line.
var gear=4;

this.getGear=function(change){
gear -= change;

};
this.setGear=function(){

gear-=4;

};

};

var myCar = new Car();

var myBike = new Bike();

//myBike.setGear();

Saboor Malik
@MathematicsCoding
Mar 16 2017 02:53
Just curious
Edx offer iOS programming course but they are in spanish...
@HeebieGeeBee
WHich is C?
C# or C++?
Or is just C?
Pengfei He
@umpengfei
Mar 16 2017 02:57
Could someone help me figure out what's wrong with this? Thanks..
function queue(arr, item) {
// Your code here
var newQueue = arr.push(item);
var deleted = newQueue[0];
newQueue.shift();
return deleted; // Change this line
}
Keon Samuel
@keonsam
Mar 16 2017 02:58
C is not to do
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:58
@keonsam what do you mean?
Keon Samuel
@keonsam
Mar 16 2017 02:58
lol according to guys all over the internet
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:58
What happen? :p
Keon Samuel
@keonsam
Mar 16 2017 02:59
I don't know honestly I am a newbie
Saboor Malik
@MathematicsCoding
Mar 16 2017 02:59
enrolling Introduction to C++ at edx is now closed...
Oh well
@keonsam same here lol
I dont even know what is C# or C++...
Manish Giri
@Manish-Giri
Mar 16 2017 03:00
@umpengfei you don't need all those new variables..
you can just use arr and item.
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:00
Hi
How does one complet the Word Blanks challenge?
complete*
I've been trying and i've gotten stuck
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:01
the madlibs?
post the code you have so far
jacob
@bjh2012
Mar 16 2017 03:01
var lookup = {
"alpha":"adams",
"bravo":"boston",
"Charlie":"Chicago",
"delta":"Denver",
"echo":"easy",
"foxtrot":"frank"
};
dose this satisfy the instructions:Convert the switch statement into a lookup table called lookup?
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:01
Yep the madlibs
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:01
@WaffleTrapHouse post the code you have so far so I can see it
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:01
@MathematicsCoding im beginning to think you are trolling, if C was the same as C++ or C# why would they call it something different?
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:01
"A" + myAdjective + "and firm" +myNoun + "had" +myVerb+"very"+myAdverb=;
Pengfei He
@umpengfei
Mar 16 2017 03:02
@Manish-Giri Thank you a lot! It works!
CamperBot
@camperbot
Mar 16 2017 03:02
umpengfei sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4769 | @manish-giri |http://www.freecodecamp.com/manish-giri
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:02
Ignore my extra words I just chose random terms
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:02
@WaffleTrapHouse i think you have to have something after the adverb. can't end on a dropped in thing.
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:02
@HeebieGeeBee Not really I thought you meant c as C# or C++...
If its not then what does C stand for...
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:03
@WaffleTrapHouse i think you're also missing spaces too which makes it one whole word in stead of a sentence.
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:03
@MathematicsCoding no ideagoogle it and find out
thunderbuns
@thunderbuns
Mar 16 2017 03:03
can I have help with the lesson Manipulating Complex Objects here is my code. var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true,
"artist2": "Kaleo",
"title2": "Way Down We Go",
"release_year2": 2016,
"formats2": [
"CS",
"8T",
"LP" ]
// Add record here
}
];
console.log(myMusic[1]);
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:03
I fixed those 2 things
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:03
@WaffleTrapHouse did it run?
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:03
what about the ending where I placed the =? I know there's something fishy with that
Nope
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:04
@WaffleTrapHouse you mean to have a + not a =
Nadia
@nadiaschutz
Mar 16 2017 03:04
// WHY DOES IT SAY "FOOD IS NOT DEFINED"? when i try to input(1223, 3 , food)


//* Without exception, there is a flat markup on all jobs of 5%
//* For each person that needs to work on the job, there is a markup of 1.2%

function input(basePrice, people, markup){
    var flatMarkupPrice=basePrice*0.05+basePrice;
    var peopleMarkupPrice=(people*0.012*flatMarkupPrice)+flatMarkupPrice;
 //Markups are also added depending on the types of materials involved:

//* If pharmaceuticals are involved, there is an immediate 7.5% markup
//* For food, there is a 13% markup
//* Electronics require a 2% markup
//* Everything else, there is no markup  
  if (markup=="drugs"){
      outputMarkup=peopleMarkupPrice*0.075+peopleMarkupPrice;
  }  else if (markup=="food"){
      outputMarkup=peopleMarkupPrice*0.13+peopleMarkupPrice;
  } else if(markup=="electronics"){
      outputMarkup=peopleMarkupPrice*0.02+peopleMarkupPrice;
  } else {
     outputMarkup=peopleMarkupPrice;
  }

 outputMarkup; 
}
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:04
What do you mean?
Can you elaborate
Manish Giri
@Manish-Giri
Mar 16 2017 03:04
@nadiaikon "food"
Nikhil KD
@kadyanikhil
Mar 16 2017 03:04
In this challenge 'Factorialize a Number' i got the right answers so whats the problem.
  var kd = [];
function factorialize(num) {
  for(var i = 1; i <= num ; i++){
    kd.push(i);  
  }
    var ans = kd.reduce(function(previousVal , currentVal){
      return previousVal * currentVal;
    });
    return ans;
}

factorialize(20);
Manish Giri
@Manish-Giri
Mar 16 2017 03:04
with the quotes @nadiaikon
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:04
after your adjective you have +adjective=
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:04
I think C stand for nothing...
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:04
@WaffleTrapHouse you need a plus on both ends
Ayush Bahuguna
@relentless-coder
Mar 16 2017 03:04
@Kavehbak oh no. with setGear you are just supposed to set a new value of gear, so this kind of operation gear = change
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:05
I am very confused. Which two ends are you regarding?
Nadia
@nadiaschutz
Mar 16 2017 03:05
@Manish-Giri now it says "undefined"
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:05

"A" + myAdjective + "and firm" +myNoun + "had" +myVerb+"very"+myAdverb=;

"A" + myAdjective + "and firm" +myNoun + "had" +myVerb+"very"+myAdverb+ " something " ;

HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:06
@kadyanikhil you need to do something if 0 is passed as the argument
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:06
I'm testing that
thunderbuns
@thunderbuns
Mar 16 2017 03:06
can I have help with the lesson Manipulating Complex Objects here is my code. var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true,
"artist2": "Kaleo",
"title2": "Way Down We Go",
"release_year2": 2016,
"formats2": [
"CS",
"8T",
"LP" ]
// Add record here
}
];
console.log(myMusic1);
Ayush Bahuguna
@relentless-coder
Mar 16 2017 03:06
@Manish-Giri I just confused with ++i and i++. let's say var i = 0; console.log(i++) this would return 0?? and console.log(++i) would return 1. so what is the use of i++???
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:06
Not even that works!
grantknaver
@grantknaver
Mar 16 2017 03:06
anyone free to answer a question
Ayush Bahuguna
@relentless-coder
Mar 16 2017 03:07
yes
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:07

"A " + myAdjective + " and firm " +myNoun + " had " +myVerb+ " very "+myAdverb+ " .";

@WaffleTrapHouse you see at the top where it says "var result = "";

Saboor Malik
@MathematicsCoding
Mar 16 2017 03:07
@Manish-Giri Nice website that you created
grantknaver
@grantknaver
Mar 16 2017 03:07
I have a problem with my current project
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:07
yeah @Tiff32
Ayush Bahuguna
@relentless-coder
Mar 16 2017 03:08
@grantknaver just ask away the problem
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:08
@nadiaikon when you call the function put food in quotes
Manish Giri
@Manish-Giri
Mar 16 2017 03:08
@relentless-coder um, I guess it's use would be in places where you know the order of execution (use current value of i first then increment it) won't create a problem..
grantknaver
@grantknaver
Mar 16 2017 03:08
when I try to increase the session length of my clock it glitches
here is my code
http://codepen.io/GrantKnaver/pen/YZrEeZ?editors=0110
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:08
@WaffleTrapHouse and it also says "return result" at the bottom ish. The "return result" needs to know that it's variable is "result". So do you have "var result = string"
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:09
@nadiaikon input(1223, 3 , 'food'); like that
Manish Giri
@Manish-Giri
Mar 16 2017 03:09
@nadiaikon change outputMarkup; to return outputMarkup;
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:09
and that
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:09
Yeah.. Don't mind me...
Ayush Bahuguna
@relentless-coder
Mar 16 2017 03:09
@Manish-Giri okay so, console.log(i++) and console.log(i) would be the same. is that correct?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:10
@grantknaver whats the glitch?
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:10
Ohhh now it works @Tiff32
thunderbuns
@thunderbuns
Mar 16 2017 03:10
can I have help with the lesson Manipulating Complex Objects here is my code. var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true,
"artist2": "Kaleo",
"title2": "Way Down We Go",
"release_year2": 2016,
"formats2": [
"CS",
"8T",
"LP" ]
// Add record here
}
];
console.log(myMusic[1]);
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:10
Thank you loads @Tiff32
CamperBot
@camperbot
Mar 16 2017 03:10
waffletraphouse sends brownie points to @tiff32 :sparkles: :thumbsup: :sparkles:
:cookie: 61 | @tiff32 |http://www.freecodecamp.com/tiff32
grantknaver
@grantknaver
Mar 16 2017 03:10
@HeebieGeeBee been minute
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:10
@WaffleTrapHouse good to hear! just remember that you need to have the variable if it's being returned :)
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:10
Yeah NOW I'm aware of this stuff
Manish Giri
@Manish-Giri
Mar 16 2017 03:10
@relentless-coder after you do console.log(i++) ; i has incremented to 1, so if you do console.log(i);, you'll now get 1, not 0..
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:10
once again thanks @Tiff32
CamperBot
@camperbot
Mar 16 2017 03:10
waffletraphouse sends brownie points to @tiff32 :sparkles: :thumbsup: :sparkles:
:warning: waffletraphouse already gave tiff32 points
grantknaver
@grantknaver
Mar 16 2017 03:11
the glitch is when I try to increase the session length for my clock the main display drags behind the session length
here is the code again
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:11
@WaffleTrapHouse oh you don't even know. I was the same. I just started the other day and almost pulled my hair out last night!
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:12
@Tiff32 are you on "Stand in line?"
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:12
It's such a burden. I read how JavaScript is like your first real coding language when it comes to web development since HTML and CSS are kind of for getting the content out there
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:12
@MathematicsCoding yeah bud. ii've hit a brick wall lmfao
grantknaver
@grantknaver
Mar 16 2017 03:12
click the addition sign in the session length div @HeebieGeeBee
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:12
lol
grantknaver
@grantknaver
Mar 16 2017 03:12
and you will see what I mean
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:12
@Tiff32 I will help you Im just 2 challenges ahead you
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:12
@WaffleTrapHouse agreed. my buddy just told me to skip those two for now. they're just for designing basically
grantknaver
@grantknaver
Mar 16 2017 03:12
its so weird.
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:12
@MathematicsCoding :)
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:13
So which function does it to remove first element?
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:13
@MathematicsCoding i just don't understand the testArr part. I'm getting the numbers to pull up correctly.
.push
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:13
No thats adding
grantknaver
@grantknaver
Mar 16 2017 03:13
it looks like the script attracted to the refresh class doesn't work than all of sudden starts working at 3 min
Tejinder Mann
@TJTheRandomCoder
Mar 16 2017 03:13
@Tiff32 They're actually the two "languages" i learned first. They're simple imo but the more advanced you get the less it makes sense :(
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:13
.shift smh
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:13
:p
grantknaver
@grantknaver
Mar 16 2017 03:13
hopefully that helps shine some light on the issue @HeebieGeeBee
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:13
Yeah do that then return an element that was removed
Nadia
@nadiaschutz
Mar 16 2017 03:14
@Manish-Giri thanks it worked....the output number is not exact right... but the function finally works!! yay
CamperBot
@camperbot
Mar 16 2017 03:14
nadiaikon sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4771 | @manish-giri |http://www.freecodecamp.com/manish-giri
Chris
@bestintown23
Mar 16 2017 03:14
how do I make a image in a slideshow stay still?
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:15
@MathematicsCoding so that's like variable [x] right
Manish Giri
@Manish-Giri
Mar 16 2017 03:15
@nadiaikon good job!
thunderbuns
@thunderbuns
Mar 16 2017 03:16
can I have help with the lesson Manipulating Complex Objects here is my code. var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true,
"artist2": "Kaleo",
"title2": "Way Down We Go",
"release_year2": 2016,
"formats2": [
"CS",
"8T",
"LP" ]
// Add record here
}
];
console.log(myMusic[1]);
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:16
@Tiff32 yeah
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:16
@MathematicsCoding but for this one we have to make a variable right? and not use the testArr?
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:16
Just return element that was removed remember what did you use .shift for?
Well any variable
Hold on Im making an example
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:17
okay sorry.
there's like a wall in my brain and i just can't understand this last part for some reason
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:18
function blah(fun, code) {
var boom = arr.shift();
return boom;
}
@Tiff32 lol same here
I didnt figure it out myself...
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:18
@MathematicsCoding oh damn. see that makes sense afer seeing it
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:19
Yeah
Nadia
@nadiaschutz
Mar 16 2017 03:19
@Manish-Giri :) :sparkles:
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:19
They teach didnt us that in previous challenges...
I dont really know what they wanted us to do...
Ayush Bahuguna
@relentless-coder
Mar 16 2017 03:19
@Manish-Giri so i++ and i + 1 are different things??
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:19
i agree, definitely threw me off.
grantknaver
@grantknaver
Mar 16 2017 03:20
@HeebieGeeBee any ideas
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:20
function nextInLine(arr, item) {
 var woof = arr.shift();
 testArr.shift(arr); 
 testArr.push(item); // Your code here

  return woof;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:21
@grantknaver what refreshes the the session clock when you increase the session time?
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:21
so why can't i get nextInLine([], 1) to return 1
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:21
...
just .shift()
Nothing inside
Manish Giri
@Manish-Giri
Mar 16 2017 03:21

@relentless-coder

@Manish-Giri so i++ and i + 1 are different things??

do you mean i = i + 1?

Saboor Malik
@MathematicsCoding
Mar 16 2017 03:22
.shift remove first element itself
testArr...
var...
return..
grantknaver
@grantknaver
Mar 16 2017 03:23
hmm
Manish Giri
@Manish-Giri
Mar 16 2017 03:23
@Tiff32 you need to use the array passed in to your function arr, not testArr.
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:23
@Tiff32 oh right one .shift only... not two
Remember that example I showed you? just like that
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:24
i am so braindead it hurts
i should be on life support
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:24
:p
grantknaver
@grantknaver
Mar 16 2017 03:24
one sec
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:25
Well Never thought of testArr
Arr, one .shift, and that example
Try do that..
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:25

@grantknaver

$(".refresh").click(function() {
  running = false;
  breakTime = false;
  sessionValue = $("#timerSetting").html();
  if(sessionValue.length === 1){
    sessionValue = "0" + sessionValue;
  }
  $("#sessionTimer").html(sessionValue + ":" + "00");
  savedMin = undefined;
  savedSeconds = undefined;
  clearInterval(int1);
}); //completely refreshes counter

i think its this becuase this is refreshing the session timer, but this probably happens before all the other things run in your add session on click function

Alexander Køpke
@alexanderkopke
Mar 16 2017 03:26
@bestintown23 like with mouseover? so when mouse hovers, you can have an eventhandler shift a run variable from true to false and then put the iterating part in an if that has that run variable as a condition. So when the mouse hovers or click if you prefer, you can make the iteration stop. haven't done this myself but that is how I would do it
grantknaver
@grantknaver
Mar 16 2017 03:27
here
Manish Giri
@Manish-Giri
Mar 16 2017 03:27
@relentless-coder i += 1 or i = i + 1 is like doing ++i, the value of i gets incremented first and it's value is then available for use, reverse of i++.
grantknaver
@grantknaver
Mar 16 2017 03:27
hmmm
reson
@resonin
Mar 16 2017 03:27
blob
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:28
i just can't comprehend it. i've been on it for an hour and i'm thankful for the help but i think i need to just take a break
i'm not joking either i just can't grasp it..
reson
@resonin
Mar 16 2017 03:28
can anyone tell me why it's not true
grantknaver
@grantknaver
Mar 16 2017 03:29
so just move down
```
  sessionValue = $("#timerSetting").html();
  if(sessionValue.length === 1){
    sessionValue = "0" + sessionValue;
  }
  $("#sessionTimer").html(sessionValue + ":" + "00");
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:29
@Tiff32 I actually have been on it for a day...
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:29
@grantknaver http://codepen.io/Geeheeb/pen/xqXJZv?editors=1111 if you look when i moved the the code into the session add and session subract functions
it doesnt lag anymore
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:29
Well I gave up on that yesterday but someone helped me today :p
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:29
@MathematicsCoding i just have a really hard time understanding a lot. it's all good, just need to know my limits osme times. haha
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:30
Alright lol
Just want you to pass that challenge
Rob Tieffenbacher III
@Tiff32
Mar 16 2017 03:30
i feel ya. i just need to see it sometimes to grasp it
it's like i'm climbing a mountain but stumbling when I get to the peak -.-
grantknaver
@grantknaver
Mar 16 2017 03:30
aaaaaaaa coool
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:31
Oh no
grantknaver
@grantknaver
Mar 16 2017 03:31
thx @HeebieGeeBee
CamperBot
@camperbot
Mar 16 2017 03:31
grantknaver sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1058 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:31
:star2: 0 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:31
@grantknaver np
Alexander Køpke
@alexanderkopke
Mar 16 2017 03:32
@resonin the text of the element with id target4 isn't jQuery Playground. Find the target4 element and see what the text is and replace jQuery Playground with that
grantknaver
@grantknaver
Mar 16 2017 03:32
it was driving me crazy
such a stupid thing, but it was driving me crazy
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:32
@grantknaver yeah i know how it is
you might want to make a refresh function and just have it run at the end of each click function or summin instead of having it attachedto that html class
@grantknaver also make sure youre using function something..... and var something = function...... in the places you want to there is a difference
@grantknaver closed the codepen now not saying there si something wrong there just noticed you used the two different kinds of functio declarations, so just making sure
Gersho
@Gersho
Mar 16 2017 03:37

i'm having troubles with string.slice()

function truncateString(str, num) {
var newStr;
newStr = str.slice(num);
return newStr;
}
truncateString("A-tisket a-tasket A green and yellow basket", 11);

and the return is the END of the sentence ?? (the reminder, rather than the sliced part)
but the link provided https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice

var str1 = 'The morning is upon us.', // the length of str1 is 23.
str2 = str1.slice(1, 8),
console.log(str2); // OUTPUT: he morn

so what obvious thing am i missing ?

grantknaver
@grantknaver
Mar 16 2017 03:37
awesome what is largest difference betweent the two
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:38
@grantknaver well its about how theyre hoisted
grantknaver
@grantknaver
Mar 16 2017 03:38
hmm I usually just declare I dont house a lot of functions
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:39
you can write function someting..... and put it anywhere in the code and aslong as its in scope you can call that function anywhere
grantknaver
@grantknaver
Mar 16 2017 03:39
gotcha
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:39
@grantknaver but var something = function.... will only run when the code gets to it
at least thats my understanding
grantknaver
@grantknaver
Mar 16 2017 03:40
gotcha... that seems far more limited
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:41
@Gersho still got a way to go on that code it seems
youre meant to be truncating hte string and concating ... to it
and depends on how long the string is and what the value of num is
Gersho
@Gersho
Mar 16 2017 03:42
@HeebieGeeBee i found my mistake, also yeah i started from scratch when i noticed everything was going horribly wrong
but at least retyping again helps to memorize ^^
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:43
@Gersho cool
@Gersho nothing wrong with scrapping code and re evaluating the plan
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:44

function testGreaterThan(val) {
  if (val > 101,150) {  // Change this line
    return "Over 100";
  }

  if (val > 11,99,100) {  // Change this line
    return "Over 10";
  }
if (val > 0,10) {
  return "10 or Under";
}
}
// Change this value to test
testGreaterThan(10);
Gersho
@Gersho
Mar 16 2017 03:44
especially for a mere dozen lines
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:45
See anything wrong with that code?
Gersho
@Gersho
Mar 16 2017 03:46
i've never seen that kind of notation, it makes no sense to me to be honest
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:47
@MathematicsCoding yup
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:47
Whats wrong with it?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:48
@MathematicsCoding the conditionals
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:48

testGreaterThan(0) should return "10 or Under"
testGreaterThan(10) should return "10 or Under"
testGreaterThan(11) should return "Over 10"
testGreaterThan(99) should return "Over 10"
testGreaterThan(100) should return "Over 10"
testGreaterThan(101) should return "Over 100"
testGreaterThan(150) should return "Over 100"
You should use the > operator at least twice

function testGreaterThan(val) {
  if (val > 101) {  // Change this line
    return "Over 100";
  }

  if (val > 11) {  // Change this line
    return "Over 10";
  }
if (val > 0) {
  return "10 or Under";
}
}
// Change this value to test
testGreaterThan(10);
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:51
is 101 greater than 101?
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:51
no
The same?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:51
is 100 greater than 100?
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:52
no...
Why?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:52
@MathematicsCoding so what do you think might be the problem with your logic
Gersho
@Gersho
Mar 16 2017 03:52
just read it at loud and type the code at the same time, you should see what he's telling you
Nikhil KD
@kadyanikhil
Mar 16 2017 03:52
how do we find how many values a array hold?
Gersho
@Gersho
Mar 16 2017 03:52
@kadyanikhil .length
thunderbuns
@thunderbuns
Mar 16 2017 03:52
whats the answer to Manipulating Complex Objects
Gersho
@Gersho
Mar 16 2017 03:54
@MathematicsCoding (out loud) is the value(val) superior(>) to 50(50) ?
Saboor Malik
@MathematicsCoding
Mar 16 2017 03:56
I have no idea what you are trying to say...
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 03:58
@MathematicsCoding 101 is greater than 100, but 101 is not greater than 101
so what will happen when 101 is passed into your function
Gersho
@Gersho
Mar 16 2017 04:00
if within a function i have a return, it exists right away right ? it won't try to run any if/then/else that are after it ?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:01
any time a function initialises a return the function is stopped
Saboor Malik
@MathematicsCoding
Mar 16 2017 04:01
Can you do an example?
code..
Gersho
@Gersho
Mar 16 2017 04:02
@HeebieGeeBee thanks, then it's even more of a good thing i started from scratch earlier, it'll look nicer now :)
CamperBot
@camperbot
Mar 16 2017 04:02
gersho sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1059 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Adam
@GoingAllTheWayUp
Mar 16 2017 04:02
Can This calculator be called complete?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:04
@GoingAllTheWayUp depends on your definition o complete
Saboor Malik
@MathematicsCoding
Mar 16 2017 04:05
Sigh im tired and too tired to understand things now...
Bye then
Good night
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:05
@MathematicsCoding sleep well
Adam
@GoingAllTheWayUp
Mar 16 2017 04:05
I am happy, I want to move on.
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:06
@GoingAllTheWayUp then do
Jim
@JLOSS1
Mar 16 2017 04:07
Got a quick question for someone on 'largest numbers in arrays'... not sure what i'm doing wrong...
function largestOfFour(arr) {
  // You can do this!
  var newArray [];
  for (var i = 0; i < arr.length; i++) {
    var n = arr[i];
    var answer = n[0];
    for (var j = 0; j > n.length; j++) {
      var element = answer[j];
      if (answer < element) {
        answer = element;
      }

    }
    newArray.push(answer);
  }


  return element;
}
Nikhil KD
@kadyanikhil
Mar 16 2017 04:07
how do we find length of first word in array
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:08
@JLOSS1 well your element is out o scope for the return for starters
Jim
@JLOSS1
Mar 16 2017 04:08
@HeebieGeeBee out of scope?
thunderbuns
@thunderbuns
Mar 16 2017 04:08

my lesson states that I need to use dot and bracket notation to access myStorage but thats what I did, can you guys help, here is my code? // Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents = myStorage.inside["glove box"]; // Change this line

HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:08
@JLOSS1 you declared the local variable within the for loop
then trying to return its value outside the for loop
@JLOSS1 what do you get in the console when you try and run the test?
Jim
@JLOSS1
Mar 16 2017 04:10
@HeebieGeeBee it's coming back with 'Expected ';'
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:10
@JLOSS1 really?
Jim
@JLOSS1
Mar 16 2017 04:11
yeah
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:11
maybe ive misunderstood the scope of for loops then
@JLOSS1 whats the challenge called?
Jim
@JLOSS1
Mar 16 2017 04:12
"Return Largest Number in Arrays"
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:12
@JLOSS1 oh
lol
i thought you meant you were getting a string returned
Jim
@JLOSS1
Mar 16 2017 04:13
lol yeah, its in the basic algorithms.
oh nah lol
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:13
its an error message
@JLOSS1 if you look at the side of the code
thunderbuns
@thunderbuns
Mar 16 2017 04:14

my lesson states that I need to use dot and bracket notation to access myStorage but thats what I did, can you guys help, here is my code? // Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents = myStorage.inside["glove box"]; // Change this line

Jim
@JLOSS1
Mar 16 2017 04:14
I've looked over and over and can't see where I could be missing a ';' but i'm wondering if i'm trying to return the wrong variable.
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:14
that you have written @JLOSS1 do you see the little red circles
its because you didnt use the = sign to assign the empty array to the variable
@JLOSS1 so should be var newArray = [];
Jim
@JLOSS1
Mar 16 2017 04:16
oh wait. it said 'element' out of scope next to result.
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:16
yes
Jim
@JLOSS1
Mar 16 2017 04:16
let me try maybe returning newArray
Kenny Korn
@KennyKorn
Mar 16 2017 04:16
I'm having trouble with 'Testing Objects for Properties'
I'm having trouble with 'Testing Objects for Properties'
Jim
@JLOSS1
Mar 16 2017 04:17
oh okay. hm
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:17
scratch that wrong challenge
@JLOSS1 yeah its looking for the array to be returned
Kenny Korn
@KennyKorn
Mar 16 2017 04:17

I'm having trouble with 'Testing Objects for Properties'. Could someone take a look at my code?

Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".


// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)) {
    return myObj.checkProp;
  } else {
    return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("gift");
thunderbuns
@thunderbuns
Mar 16 2017 04:18

my lesson states that I need to use dot and bracket notation to access myStorage but thats what I did, can you guys help, here is my code? // Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents = myStorage.inside["glove box"]; // Change this line

HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:19
@KennyKorn checkProp is a parameter not a string
@JLOSS1 but you need to rethink what your code is doing, at the moment its just pushing the first element from each array into the new array
Jim
@JLOSS1
Mar 16 2017 04:20
@HeebieGeeBee hm, I added the '=' obviously but also changed the result to call newArray.... now it's coming back with first number in the given arrays for the function being called.
lol yeah.
okay, well I got the errors, corrected. I guess i'll keep trying different stuff. thanks @HeebieGeeBee for the help!
CamperBot
@camperbot
Mar 16 2017 04:21
jloss1 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1060 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:21
@JLOSS1 there is a sort method that could come in handy in javascript
Jim
@JLOSS1
Mar 16 2017 04:21
@HeebieGeeBee i'm all ears to methods
but understand out it works cus its not as simple as it first seems
Jim
@JLOSS1
Mar 16 2017 04:22
oh shit. this is beautiful
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:23
cus [1,2,4,5,24,12].sort() will return [1,15,2,24,4,5]
you need to give it a function in its call back so it sorts it correctly
Jim
@JLOSS1
Mar 16 2017 04:23
@HeebieGeeBee damn hm
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:23
so read that webpage properly
Jim
@JLOSS1
Mar 16 2017 04:24
will do. I appreciate it.
Kenny Korn
@KennyKorn
Mar 16 2017 04:24

@HeebieGeeBee When I return it directly, it returns the value of true.

return myObj.hasOwnProperty(checkProp);  //this returns true

Why wouldn't it work in the if statement?

HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:24
@KennyKorn thats not the problem
@KennyKorn myObj.checkProp; this is the problem, whats the difference between dot notation and bracket notation?
Kenny Korn
@KennyKorn
Mar 16 2017 04:26
@HeebieGeeBee OH I see! Dot notation requires a string. Bracket can take in variables. Am I getting that right?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:26
@KennyKorn yes
Kenny Korn
@KennyKorn
Mar 16 2017 04:26
Thank you!
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:26
well you can use bracket notation with strings too you just need to use the quotes
@thunderbuns are you sure inside isnt inisde something before its inside the myStorage if you know what i mean
ivorygrant
@ivorygrant
Mar 16 2017 04:29

Hi everyone, working on "Return Early Pattern for Functions" exercise, i think i'm on the right track but not sure how to finish it. here's my code so far:

function abTest(a, b) {
// Only change code below this line

var undefinedN;

if (a,b<0)
return undefinedN;

Kenny Korn
@KennyKorn
Mar 16 2017 04:29
Ahh okay, I see. Is bracket generally more flexible than dot?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:29
@KennyKorn i guess you could say that
Kenny Korn
@KennyKorn
Mar 16 2017 04:30
I'll just look it up LOL Thanks again
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:30
@ivorygrant youre kinda on a big detour at the moment
ivorygrant
@ivorygrant
Mar 16 2017 04:31
@HeebieGeeBee hmm i'm getting green arrows for parts of the exercise so i assumed i was getting it
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:31
that could be deceptive
ivorygrant
@ivorygrant
Mar 16 2017 04:31
what do you suggest I relook?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:31
whats the first instruction of the challenge?
ivorygrant
@ivorygrant
Mar 16 2017 04:31
a or b is less than 0
if yes, exit
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:32
so how you do ask if a is less than 0?
Joshua Kennedy
@joshkennede
Mar 16 2017 04:33

Some help plzz.

function nextInLine(arr, item) {
  // Your code here
  testArr.push(item);
  item = testArr.shift();

  return item;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

How do i get nextInLine([5,6,7,8,9], 1) ?

ivorygrant
@ivorygrant
Mar 16 2017 04:33
ahh I see, i should break it up to something like:
a<0 || b<0
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:33
@joshkennede dont use testArr arr and dont asign your shift to item
just return your shift
@ivorygrant yes
and then dont do this var undefined
undefined is a keyword not a string
you just need to return undefined
ivorygrant
@ivorygrant
Mar 16 2017 04:35
ohhh ok, I was thinking I had to initialize a variable but not assign it anything. got it. TY!
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:35
@joshkennede sorry meant dont use testArr use the arr thats the functions parameter
and then all the rest of the stuf i said
Joshua Kennedy
@joshkennede
Mar 16 2017 04:37
@HeebieGeeBee thanks! i didn't pay attention to the // Change this line
CamperBot
@camperbot
Mar 16 2017 04:37
joshkennede sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1061 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Mac
@itchick85
Mar 16 2017 04:39
Whats wrong with this Modify Array Data With Indexes myArray [0] =3;
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:40
@itchick85 can you post all the code?
Matthew
@IMDBLM
Mar 16 2017 04:40

Hello everyone - I just passed this iterating through an array challenge, but I'm having a hard time understanding exactly what I did.

var myArr = [ 2, 3, 4, 5, 6];
var total = 0;

for (var i = 0; i < myArr.length; i++) {
  total += myArr[i];
}

As I'm looking I see: With i = 0, if i < 4, then add 1 to i. And then total needs to add.... and that's where I'm confused. How does it get to 20?

Mac
@itchick85
Mar 16 2017 04:40
@HeebieGeeBee Modify the data stored at index 0 of myArray to a value of 3.
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:41

@itchick85

// Example
var ourArray = [1,2,3];
ourArray[1] = 3; // ourArray now equals [1,3,3].

// Setup
var myArray = [1,2,3];

// Only change code below this line.
myArray[0] = 3;

does all your code looklike this?

Manish Giri
@Manish-Giri
Mar 16 2017 04:42
@IMDBLM you add each element in myArr to total one by one.
2+3+4+5+6
= 20
Mac
@itchick85
Mar 16 2017 04:42
@HeebieGeeBee yes
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:42
@itchick85 try refreshing your browser and running the code again
Matthew
@IMDBLM
Mar 16 2017 04:43
@Manish-Giri Ok. Then why does FCC make a point to say that the last element in the array is length - 1?
Mac
@itchick85
Mar 16 2017 04:43
@HeebieGeeBee I did
cameron nicklaus
@camnicklaus
Mar 16 2017 04:43
okay...who's good at regex!?
Manish Giri
@Manish-Giri
Mar 16 2017 04:44
@IMDBLM because that's the point you're looping to - i < myArr.length
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:44
@itchick85 can you take a screenshot
@camnicklaus no one on earth
Manish Giri
@Manish-Giri
Mar 16 2017 04:44
in other words, that is i <= myArr.length - 1; @IMDBLM
cameron nicklaus
@camnicklaus
Mar 16 2017 04:44
hahaha
@HeebieGeeBee truth
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:45
@camnicklaus whats the problem youre having?
@itchick85 or just copy your complete url and paste it into chat
cameron nicklaus
@camnicklaus
Mar 16 2017 04:45
I'm trying to match anything from one capture group if it's next to anything else in the same capture group
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:46
@camnicklaus got an example?
Mac
@itchick85
Mar 16 2017 04:46

@HeebieGeeBee
// Example
var ourArray = [1,2,3];
ourArray[1] = 3; // ourArray now equals [1,3,3].

// Setup
var myArray = [1,2,3];

// Only change code below this line.
myArray [0] = 3;

HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:46
@itchick85 youve got a space in there
cameron nicklaus
@camnicklaus
Mar 16 2017 04:46
/([\/*\+\.-])\1+/ this matches if two of the same keys are next to each other but not if two diff. keys from the same group are
Adam
@GoingAllTheWayUp
Mar 16 2017 04:46
@camnicklaus [a-z][A-Z] is a lower case and upper case next to each other i think.
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:46
between the myArray and the [0] @itchick85
Adam
@GoingAllTheWayUp
Mar 16 2017 04:47
@camnicklaus thats one group, you could have
cameron nicklaus
@camnicklaus
Mar 16 2017 04:47
@HeebieGeeBee so I've got it catching ** but i'd like it to match /* as well
opps...formatting
Mac
@itchick85
Mar 16 2017 04:48
@HeebieGeeBee Wow I am mad at that thanks
CamperBot
@camperbot
Mar 16 2017 04:48
:star2: 1062 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
itchick85 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
cameron nicklaus
@camnicklaus
Mar 16 2017 04:49
@GoingAllTheWayUp thanks, but that's not quite what I'm after
CamperBot
@camperbot
Mar 16 2017 04:49
camnicklaus sends brownie points to @goingallthewayup :sparkles: :thumbsup: :sparkles:
:cookie: 304 | @goingallthewayup |http://www.freecodecamp.com/goingallthewayup
cameron nicklaus
@camnicklaus
Mar 16 2017 04:50
basically, I'm working on the calculator and trying to weed out if the user enters two math operators next to each other, whether they are the same or different.
Gersho
@Gersho
Mar 16 2017 04:50
regular expression then ?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:50
@camnicklaus ([\/*\+\.-]{2}) maybe something like that?
Adam
@GoingAllTheWayUp
Mar 16 2017 04:51
@camnicklaus I only checked the last input given for that solution
cameron nicklaus
@camnicklaus
Mar 16 2017 04:52
@HeebieGeeBee oh yeah, that's really close. I think I maybe able to work it out from that...thanks!
CamperBot
@camperbot
Mar 16 2017 04:52
camnicklaus sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1063 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:52
@camnicklaus cool
Gersho
@Gersho
Mar 16 2017 04:53

function chunkArrayInGroups(arr, size) {
  var cutArr = [];
  var arrIndex = 0;

  if (size <= 0) { //infinite loop protection
    return;
  }

  for (i=0; i<arr.length;i=i+size){
   cutArr[arrIndex] = arr.slice(i,i+size);
   arrIndex += 1;
  }

  return cutArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
is that ok that way to avoid infinite loop ? or is it considered bad practice ?
thunderbuns
@thunderbuns
Mar 16 2017 04:53

can I have help have help with the lesson Nesting For Loops here is my code. function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (i = 0; i < arr.length; i++) {
for (p = 0; p < arr[i].length; p++) {
console.log(arr[i][p]);
}
}

// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1],[2],[3]]);

HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:54
@Gersho seems fine you me you could do i += size btw
Adam
@GoingAllTheWayUp
Mar 16 2017 04:54
@Gersho I would set a limit or double check on my length or something if I had this issue.
Gersho
@Gersho
Mar 16 2017 04:55
the challenge doesn't tell how big the array can get so i can't put arbitrary limit i think
Joseph
@revisualize
Mar 16 2017 04:55
hi.
cameron nicklaus
@camnicklaus
Mar 16 2017 04:55
@HeebieGeeBee thanks man...this wound up being it. you showing me the curly braces was the key! ([\/*\+\.-]{2,})
CamperBot
@camperbot
Mar 16 2017 04:55
:warning: camnicklaus already gave heebiegeebee points
camnicklaus sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
cameron nicklaus
@camnicklaus
Mar 16 2017 04:56
hey @revisualize
Joseph
@revisualize
Mar 16 2017 04:56
Hello people how can I help?
@camnicklaus How's things?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:56
@Gersho oh i see what youve done, why are you adding the slice to the array like that, do you remember what method we use to add elements to an array?
@revisualize yo
Adam
@GoingAllTheWayUp
Mar 16 2017 04:56
@Gersho there are the assertion test, thats all that needs to pass. think about that, I also had great ideas but when it comes to passing other means have beeen required
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:56
@camnicklaus cool
cameron nicklaus
@camnicklaus
Mar 16 2017 04:56
not bad...finally working through the last front end challenges. @revisualize
Gersho
@Gersho
Mar 16 2017 04:56
@HeebieGeeBee you mean push ?
cameron nicklaus
@camnicklaus
Mar 16 2017 04:56
you?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:56
@Gersho yes
@Gersho and rethink your slice arguments too
you sure you want the slice(i, i+size)?
Gersho
@Gersho
Mar 16 2017 04:58
not really but it seemed logical that way
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 04:59
@thunderbuns how would you multiply each element with the product variable?
@Gersho why i+size?
Gersho
@Gersho
Mar 16 2017 04:59
i need to select/slice them one way or another before pushing them anyway
cameron nicklaus
@camnicklaus
Mar 16 2017 04:59
I'm off to bed...thanks again guys and girls
Jeremy
@JeremyAntonoff
Mar 16 2017 04:59
can anyone help
Gersho
@Gersho
Mar 16 2017 04:59
@HeebieGeeBee so that it takes the number of values to slice (size) and the for is used to start at the needed spot
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:00
the first argument for the slice is the index right, and the second argument is how many get sliced @Gersho
Gersho
@Gersho
Mar 16 2017 05:00
(not sure if that made sense)
@HeebieGeeBee isn't the second the endpoint ?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:00
no
Adam
@GoingAllTheWayUp
Mar 16 2017 05:00
array?
Gersho
@Gersho
Mar 16 2017 05:01
it shouldn't work then (the challenge i mean)
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:01
@Gersho or sorry
think i might be thinking of splice
@Gersho yeah was thinking of splice ignore that then
Jeremy
@JeremyAntonoff
Mar 16 2017 05:02

function largestOfFour(arr) {
  // You can do this!
  var x = 0;
  var largestNumber = [];
  for (i = 0; i < arr.length; i++) {
    for (j = 0; j < arr[i].length; j++) {
      if (arr[i][j] > x) {
        x = arr[i][j];
          }

    }
    largestNumber.push(x);
          }

 return largestNumber;
}

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Gersho
@Gersho
Mar 16 2017 05:02
well it's getting late anyway, guess i'll just copy the chat we had and reread it tomorrow and try a few things with push too,
Jeremy
@JeremyAntonoff
Mar 16 2017 05:02
it wont work with that largestofFour
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:03
@Gersho and yeah that thing youre doing for the infinite loop protection isnt needed
@Gersho turns out i didnt really look at your code properly lol
Gersho
@Gersho
Mar 16 2017 05:04
@HeebieGeeBee 5 browser crash tend to disagree, but it shouldn't be an issue as long as size isn't 0 (and it shouldn't be, but you never know what people input)
anyway goodnight :) and thanks @HeebieGeeBee
CamperBot
@camperbot
Mar 16 2017 05:04
gersho sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1064 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Adam
@GoingAllTheWayUp
Mar 16 2017 05:04
@JToddFL x is a little fishy i think
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:05
@Gersho why would the size ever be zero?
Jeremy
@JeremyAntonoff
Mar 16 2017 05:05
@GoingAllTheWayUp fishy?
Adam
@GoingAllTheWayUp
Mar 16 2017 05:07
could you use reduce? Are you tring to find the largest sum from the groups
Jeremy
@JeremyAntonoff
Mar 16 2017 05:09
no
just largest number
Adam
@GoingAllTheWayUp
Mar 16 2017 05:09
whats the link to the problem on FCC please or title
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:10
@JToddFL you might want to look at the sort method
Jeremy
@JeremyAntonoff
Mar 16 2017 05:11
Return Largest Numbers in Arrays
Adam
@GoingAllTheWayUp
Mar 16 2017 05:12
Wghat if you pushed @JToddFL when you assiged x
Jeremy
@JeremyAntonoff
Mar 16 2017 05:12
I got it to work but dont understand how
i moved the var x = 0 into the outer loop
dont understand why that makes a diff
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:13

@JToddFL

   largestNumber[i] = x;
    x = 0;

this will fix your code

but might be better ways to complete the challenge
Adam
@GoingAllTheWayUp
Mar 16 2017 05:14
@JToddFL closure?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:14
function largestOfFour(arr) {
  // You can do this!
  var x = 0;
  var largestNumber = [];
  for (i = 0; i < arr.length; i++) {
    for (j = 0; j < arr[i].length; j++) {
      if (arr[i][j] > x) {
        x = arr[i][j];
          }

    }
    largestNumber[i] = x;
    x = 0;
          }

 return largestNumber;
}
if you need to see the complete code
Jeremy
@JeremyAntonoff
Mar 16 2017 05:14
i got it to work by doing:
function largestOfFour(arr) {
  // You can do this!

  var largestNumber = [];
  for (i = 0; i < arr.length; i++) {
    var x = 0;
    for (j = 0; j < arr[i].length; j++) {
      if (arr[i][j] > x) {
        x = arr[i][j];
          }

    }
    largestNumber[i] = x;
    x = 0;
          }

 return largestNumber;
}
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:15
lol yup
Jeremy
@JeremyAntonoff
Mar 16 2017 05:16
why does that work
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:16
@JToddFL do you understand why that made it work?
Jeremy
@JeremyAntonoff
Mar 16 2017 05:16
no idea
lol
i feel like the variable resets anyway
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:16
it doesnt
unless you tell it to
Jeremy
@JeremyAntonoff
Mar 16 2017 05:17
so if its outside the forloop it never resets?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:17
why would it reset if you dont tell it to
Joseph
@revisualize
Mar 16 2017 05:17
@JToddFL Awesome.
@JToddFL Do you know that with ES6 you can make that code a lot shorter?
Jeremy
@JeremyAntonoff
Mar 16 2017 05:18
@joseph no idea lol
Joseph
@revisualize
Mar 16 2017 05:19
I'm @revisualize
Jeremy
@JeremyAntonoff
Mar 16 2017 05:19
and @heebie why wouldnt that work if i set that variable to the inner loop instead
Joseph
@revisualize
Mar 16 2017 05:19
Someone else is @joseph
Jeremy
@JeremyAntonoff
Mar 16 2017 05:19
sorry! lol
just noticed
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:19
@JToddFL what do you mean?
Jeremy
@JeremyAntonoff
Mar 16 2017 05:19
if i set it to
Adam
@GoingAllTheWayUp
Mar 16 2017 05:19
you could if you assigned x there
Jeremy
@JeremyAntonoff
Mar 16 2017 05:20
oops
ugh
sorry
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:20
you can delete post
Joseph
@revisualize
Mar 16 2017 05:20
@JToddFL You can use .map() then just return Math.max() using the spread operator.
Jeremy
@JeremyAntonoff
Mar 16 2017 05:21
function largestOfFour(arr) {
  // You can do this!

  var largestNumber = [];
  for (i = 0; i < arr.length; i++) {

    for (j = 0; j < arr[i].length; j++) {
      var x = 0;
      if (arr[i][j] > x) {
        x = arr[i][j];
          }

    }
    largestNumber[i] = x;
    x = 0;
          }

 return largestNumber;
}
why wouldnt that work
setting the var x = 0 into the inner loop
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:21
because thats going to make x out of scope
Jeremy
@JeremyAntonoff
Mar 16 2017 05:21
why is it out of scope if its still in the function
@revisualize thanks ill have to look into that
CamperBot
@camperbot
Mar 16 2017 05:22
jtoddfl sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3530 | @revisualize |http://www.freecodecamp.com/revisualize
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:22
cus its in a for loop
Jeremy
@JeremyAntonoff
Mar 16 2017 05:22
but so is the way that worked
in the outer loop
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:22
and you dont want it reset on every iteration of the j loop anyway
otherwise you'll have nothing to comparethe array elements to
Jeremy
@JeremyAntonoff
Mar 16 2017 05:22
so by making it in the outer loop im making it reset every time it goes to the next sub array
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:23
yes
Jeremy
@JeremyAntonoff
Mar 16 2017 05:23
why is it out of scope tho
if i declare it as a global variable
Adam
@GoingAllTheWayUp
Mar 16 2017 05:23
We have like a chain of closure they call it
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:23
becuase for loops have scope
Jeremy
@JeremyAntonoff
Mar 16 2017 05:24
i dont understand how it works then
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:24
youre not declaring it as a global variable if youre declaring it in the for loop
Jeremy
@JeremyAntonoff
Mar 16 2017 05:24
if i have the var x = 0 underneath the outer loop
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:24
@JToddFL you realise i did it that way becuase thats the only way it would fix your code right?
Adam
@GoingAllTheWayUp
Mar 16 2017 05:25
unless you use the flaw in javascript and don't use var and just assgin it without var it becomes global.
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:25
@JToddFL then the loop will never see that x
until all the loops had iteratied
Jeremy
@JeremyAntonoff
Mar 16 2017 05:26
@HeebieGeeBee appreciate your help I'm having difficulty understanding why it works under the outer loop like this
function largestOfFour(arr) {
  // You can do this!

  var largestNumber = [];
  for (i = 0; i < arr.length; i++) {
    var x = 0;
    for (j = 0; j < arr[i].length; j++) {
      if (arr[i][j] > x) {
        x = arr[i][j];
          }

    }
    largestNumber[i] = x;
    x = 0;
          }

 return largestNumber;
}
and not the inner loop
its still within a for loop
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:26
yes?
Adam
@GoingAllTheWayUp
Mar 16 2017 05:26
its outside the inner and inside the outter
Jeremy
@JeremyAntonoff
Mar 16 2017 05:26
yes but tech still inside a for loop right?
Adam
@GoingAllTheWayUp
Mar 16 2017 05:27
the first one?
Jeremy
@JeremyAntonoff
Mar 16 2017 05:27
yes
Adam
@GoingAllTheWayUp
Mar 16 2017 05:27
thats where i is
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:27
@JToddFL becuase the code is run in a linear fashion
@JToddFL functions just dont do bits of code inside them randomly
Jeremy
@JeremyAntonoff
Mar 16 2017 05:28
ok and one last question
Adam
@GoingAllTheWayUp
Mar 16 2017 05:28
It only grabs one number at a time, then exits the inside loop with x
Jeremy
@JeremyAntonoff
Mar 16 2017 05:28
with the largest[i] = x
why wouldnt largest[i][j] = x work
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:29
@JToddFL becuase that would make sub arrays
and thats notwhat you want
Adam
@GoingAllTheWayUp
Mar 16 2017 05:29
your getting arrays in arrays but you want to make one straight array
Jeremy
@JeremyAntonoff
Mar 16 2017 05:30
so it would be four numbers like [][][][]
within 4 arrays
Adam
@GoingAllTheWayUp
Mar 16 2017 05:30
so we search arrays in arrays and push one new array
Jeremy
@JeremyAntonoff
Mar 16 2017 05:31
so what is the i in it
thats each array it searched?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:32
@JToddFL well it wouldnt actually work at all
Adam
@GoingAllTheWayUp
Mar 16 2017 05:32
your just reusing i
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:32
becuase the sub arrays hadnt been declared
but thats what you would be trying to do
well it would just have lots of errors and
just wouldnt work like that
Jeremy
@JeremyAntonoff
Mar 16 2017 05:33
why wouldnt i do largestNumber = arr[i]
Adam
@GoingAllTheWayUp
Mar 16 2017 05:33
It would be over written
you could push
Jeremy
@JeremyAntonoff
Mar 16 2017 05:35
i did push originally i just dont get the syntax of how i have it
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:35
@JToddFL arr[i] is also a whole array of numbers
Jeremy
@JeremyAntonoff
Mar 16 2017 05:35
with largestNumber[i]
Adam
@GoingAllTheWayUp
Mar 16 2017 05:36
Are you not happy with your solution or your understanding of it? I mean if we can agree it works this wy why not look at .sort() and maybe that will help
Jeremy
@JeremyAntonoff
Mar 16 2017 05:37
I am. I'm sorry
Adam
@GoingAllTheWayUp
Mar 16 2017 05:38
its cool i am there with you bro
Jeremy
@JeremyAntonoff
Mar 16 2017 05:38
I think I was just trying to understand the order of how things work
I'll get the hang of it lol
Adam
@GoingAllTheWayUp
Mar 16 2017 05:38
function largestOfFour(arr) {
  // You can do this!
var newArray = [];
  for (i=0 ; i < arr.length ; i++) {
     var catchValue = 0; 
    for (j=0 ; j < arr[i].length ; j++) {
      if (arr[i][j] > catchValue) {
        newArray[i] = arr[i][j];
        catchValue = arr[i][j];
        }
       } 
    }
return newArray; 
}
Conor Murphy
@cmurphy580
Mar 16 2017 05:38
anyone tell me why the small screen version of this game won't work?
http://codepen.io/cmurphy580/pen/rymERy?editors=0100
Adam
@GoingAllTheWayUp
Mar 16 2017 05:40
some times nameing things well helps understand it
Jeremy
@JeremyAntonoff
Mar 16 2017 05:40
is the [i] indicating the variable in the for loop
Adam
@GoingAllTheWayUp
Mar 16 2017 05:40
for the first loop only it stays the same as it cycles trhough j
Jeremy
@JeremyAntonoff
Mar 16 2017 05:40
i mean when you have newArray[i]
Adam
@GoingAllTheWayUp
Mar 16 2017 05:40
the j loop pass your x or catchValue around
Jeremy
@JeremyAntonoff
Mar 16 2017 05:40
its indicating the i in the for loop
right?
Adam
@GoingAllTheWayUp
Mar 16 2017 05:42
it would be like [0][0], [0][1], [0][2] then [1][0], [1][1], [1][2]
[i][j]
as it catchs the biggest number
Jeremy
@JeremyAntonoff
Mar 16 2017 05:43
i know what the for loop means
i mean the syntax
of newArray[i]
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:44
function largestOfFour(arr) {
  // You can do this!  
 return arr.map(i => i.sort((a, b) => b - a)[0]);
}
@revisualize
Jeremy
@JeremyAntonoff
Mar 16 2017 05:45
that would of been easier lol
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:46
just something i came up with
Adam
@GoingAllTheWayUp
Mar 16 2017 05:46
function (a, b) { return b-a; } ? long hand
Mridul
@mridulmishra22
Mar 16 2017 05:46
Why it's not working? why it's unable to call the function?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:46
yeah @GoingAllTheWayUp
thats the callback function for the sort
Jeremy
@JeremyAntonoff
Mar 16 2017 05:47
I appreciate both of your guys help
thanks again
Mridul
@mridulmishra22
Mar 16 2017 05:47

function telephoneCheck(str) {
function chkNum(a){return a;}

if(str.charAt(0)==1){
str=str.replace(/ /g,'');
str=str.substring(1);
chkNum(str);
}
}

telephoneCheck("1 555 555 5555");

function telephoneCheck(str) {
function chkNum(a){return a;}

if(str.charAt(0)==1){
str=str.replace(/ /g,'');
str=str.substring(1);
chkNum(str);
}
}

telephoneCheck("1 555 555 5555");

HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:49
@mridulmishra22 whats the problem?
Adam
@GoingAllTheWayUp
Mar 16 2017 05:49
str=str.replace(/ /g,''); white space?
\s?
Mridul
@mridulmishra22
Mar 16 2017 05:49
It is unable to call the function chkNum
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:50
@mridulmishra22 how do you know?
Mridul
@mridulmishra22
Mar 16 2017 05:50
@HeebieGeeBee see this:
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:51
@mridulmishra22 return chkNum(str);
Fanyusong
@Fanyusong
Mar 16 2017 05:51
some one can help me
https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20%20var%20i%20%3D%200%3B%0A%20%20%20var%20a%20%3D%20%5B%5D%3B%0A%20%20%20%20while(i%20%3C%20contacts.length)%7B%0A%20%20%20%20%20%20if(firstName%20%3D%3D%20contacts%5Bi%5D.firstName%20)%7B%0A%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20if(prop%20%3D%3D%20contacts%5Bi%5D.likes)%7B%0A%20%20%20%20%20%20%20%20%20%20%20a.push(contacts%5Bi%5D.lastName)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20a.push(contacts%5Bi%5D.likes)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20return%20%22No%20such%20property%22%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20else%20%7B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20return%20%22No%20such%20contact%22%3B%0A%20%20%20%20%20%20%7D%20%0A%20%20%20%20%20%20%0A%20%20%20%20%7D%0A%20%20return%20a%3B%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
Mridul
@mridulmishra22
Mar 16 2017 05:53
@HeebieGeeBee Thanks
CamperBot
@camperbot
Mar 16 2017 05:53
mridulmishra22 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1065 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:56
@Fanyusong a couple of hints, use the hasOwnProperty() method and you shouldnt return no such contacts until you've looked through all the contacts
ivorygrant
@ivorygrant
Mar 16 2017 05:57

Hi everyone, working on the card counting game and I feel like I'm way off :lol: hopefully someone can point me the right direction:

var count = 0;

function cc(card) {
// Only change code below this line

switch (card){

case 2:
case 3:
case 4:
case 5:
case 6:
  count++;      
  return count + " Bet";


case 7:
case 8:
case 9:
  count=0;
  return count +" Hold";

case 10:
case "J":
case "Q":
case "K":
case "A":
  count--;
  return count + " Hold";

}

return "Change Me";

any suggestions?
babyJXY
@babyJXY
Mar 16 2017 05:58

function palindrome(str) {

var string=str.replace(/[\s^0-9^a-z]*/gi,'');
string.toLowerCase();

var arr=string.split('');

arr.reverse();

var reString=arr.join('');

if(string===reString){
return true;

}else{

return false;

}

}

blob
Who can help me
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 05:59
@ivorygrant dont return inside the switch statement and dont fully reassign the value of count by doing count = 0
ivorygrant
@ivorygrant
Mar 16 2017 06:00
hmmm OK let me see.
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 06:00
@babyJXY your regex looks a bit wrong and you have to assign string methods dont only return a value to variables but you can chain methods
for example str = str.split('').reverse().join('');
@babyJXY http://www.regexpal.com/ you can use this site to test regex
but /[^0-9a-z]/gi should do you
babyJXY
@babyJXY
Mar 16 2017 06:03
thank you very much@HeebieGeeBee I try it again.
Kishan Khakhar
@kishankhakhar
Mar 16 2017 06:06
if(test.indexOf('target[i]') < 0)
if(test.indexOf(target[i]) < 0)
what is the difference between these two statements?
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 06:07
ones a string and one isnt
Kishan Khakhar
@kishankhakhar
Mar 16 2017 06:07
what is the significance of those single inverted commas?
does single inverted commas mean string in js??
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 06:08
they indicate that its a string
@kishankhakhar yes same as "
""
Kishan Khakhar
@kishankhakhar
Mar 16 2017 06:08
oh got it thanks @HeebieGeeBee
CamperBot
@camperbot
Mar 16 2017 06:08
kishankhakhar sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1066 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Joseph
@revisualize
Mar 16 2017 06:09
@HeebieGeeBee return arr.map(x => Math.max(...x));
Markus Kiili
@Masd925
Mar 16 2017 06:09
@revisualize @HeebieGeeBee Good morning.
Joseph
@revisualize
Mar 16 2017 06:09
Good Evening.
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 06:09
@revisualize i couldnt just copy you after you announced it
@Masd925 hey
Joseph
@revisualize
Mar 16 2017 06:10
Shit Who can I help?
I need to help someone.
ACK!
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 06:11
@revisualize patience
revisualize @revisualize is going to lose his streak. :(
HeebieGeeBee
@HeebieGeeBee
Mar 16 2017 06:11
@revisualize nice code though ty
CamperBot
@camperbot
Mar 16 2017 06:11
heebiegeebee sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3531 | @revisualize |http://www.freecodecamp.com/revisualize
Manish Giri
@Manish-Giri
Mar 16 2017 06:11
if all you need is a cookie, just ask!
ivorygrant
@ivorygrant