These are chat archives for FreeCodeCamp/HelpJavaScript

20th
Jul 2016
Brian
@BrianCodes33
Jul 20 2016 00:00
grrr
Stephen James
@sjames1958gm
Jul 20 2016 00:00
@AngeloRwanda You would need to store something from the previous loop iteration, so you need a variable that is initialized before the first iteration.
bitgrower
@bitgrower
Jul 20 2016 00:00
fortunately, because it's a sub array, you can do that using array addressing ...
I think the code example in the instructions gives you a few clues ?
Brian
@BrianCodes33
Jul 20 2016 00:01
i am pissed off
Stephen James
@sjames1958gm
Jul 20 2016 00:01
@AngeloRwanda
var longest = 0;
for each word in array if longer than longest set new value for longest
Joseph
@revisualize
Jul 20 2016 00:01
@BrianCodes33 I understand that you're frustrated.
@BrianCodes33 But, you're not returning an array.
bitgrower
@bitgrower
Jul 20 2016 00:01
@BrianCodes33 -- not good for thinking ... I understand, but take a few breaths, a break, walk around ...
we don't think too well when we are stressed ... (human beings)
Joseph
@revisualize
Jul 20 2016 00:02
@BrianCodes33 When I get frustrated. I walk around my block. And come back around to the problem.
bitgrower
@bitgrower
Jul 20 2016 00:02
^^^ good strategy !
Fransisco Wiles
@fwiles
Jul 20 2016 00:02
Hey guys I'm having trouble with "Testing Objects for Properties" I don't know how I would return all of the object properties. Here's my code:
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};
function checkObj(checkProp) {
  // Your Code Here
  var obj = "gift";
   var answer = myObj.hasOwnProperty(checkProp);
 if (answer === true) {
   return myObj[obj];
 } else {
   return "Not Found";
 }
}
// Test your code by modifying these values
checkObj("gift");
Brian
@BrianCodes33
Jul 20 2016 00:02
function largestOfFour(arr) {
  var result;
  for (var i=0;i<arr.length;i++)  {
    var largestNum = 0;
    for (var j=0;j<arr.length;j++) {
       if (arr[i][j] > largestNum) {
         largestNum = arr[i][j];
       }
    }
is this part right
bitgrower
@bitgrower
Jul 20 2016 00:03
not quite ... but getting closer ...
Brian
@BrianCodes33
Jul 20 2016 00:03
then wtf is wrong with it
Alisdair Frost
@pacificfrost
Jul 20 2016 00:04
Okay, I'm struggling with how to understand nested array loops. Anyone got any links/resources?
bitgrower
@bitgrower
Jul 20 2016 00:04
for one thing, in your second loop, you are not comparing it to the length of the sub-array ...
bitgrower
@bitgrower
Jul 20 2016 00:05
not comparing your loop index to the length of the sub-array -- you are comparing it to the length of the outer array (same thing you are doing in the outer loop, where it makes sense to do...
Alisdair Frost
@pacificfrost
Jul 20 2016 00:05
@petegarvin1 Thanks Pete, I'll take a look
CamperBot
@camperbot
Jul 20 2016 00:05
pacificfrost sends brownie points to @petegarvin1 :sparkles: :thumbsup: :sparkles:
:cookie: 429 | @petegarvin1 |http://www.freecodecamp.com/petegarvin1
Pete
@petegarvin1
Jul 20 2016 00:06
@pacificfrost happy to talk through if you need
Joseph
@revisualize
Jul 20 2016 00:06
@BrianCodes33 ... That part alone.. Yes.
Brian
@BrianCodes33
Jul 20 2016 00:06
@bitgrower you are not making sense someone pm me so i can solve this or else im gonna start shitting bricks
Alisdair Frost
@pacificfrost
Jul 20 2016 00:06
@petegarvin1 That would be amazing, if you have time. Can we jump into a private chat?
Pete
@petegarvin1
Jul 20 2016 00:06
@BrianCodes33 you are so close! keep going...
Joseph
@revisualize
Jul 20 2016 00:07
@BrianCodes33 Wait.. var result = [];
Then that section by itself could be correct.
Brian
@BrianCodes33
Jul 20 2016 00:07
then why the f are people telling me that is wrong
it says return an array!!!!!!!!!
Joseph
@revisualize
Jul 20 2016 00:08

@BrianCodes33

function largestOfFour(arr) {
  var result = [];
  for (var i=0;i<arr.length;i++)  {
    var largestNum = 0;
    for (var j=0;j<arr.length;j++) {
       if (arr[i][j] > largestNum) {
         largestNum = arr[i][j];
       }
    }
// Code down here is missing.

I could solve it with this code.. I'd of course need to fill in more code.

Brian
@BrianCodes33
Jul 20 2016 00:09
im sorry but javascript makes no sense
Joseph
@revisualize
Jul 20 2016 00:09
@BrianCodes33 It is tough when you're learning.
Brian
@BrianCodes33
Jul 20 2016 00:10
how do we automatically know that nested loop is inside of the outer loop
anyway
just help me solve it
Santiago Gómez
@Sperkajugglite
Jul 20 2016 00:11
hi guys
Robert Richey
@0x0936
Jul 20 2016 00:12
@Sperkajugglite :wave:
Brian
@BrianCodes33
Jul 20 2016 00:12
guys you cant leave me hanging
Santiago Gómez
@Sperkajugglite
Jul 20 2016 00:13
i was using a few hours ago about REACT resources and i found this one
http://www.reactjsprogram.com, i just started the free version and thought might be helpful :)
Pete
@petegarvin1
Jul 20 2016 00:13
@BrianCodes33 pm me
i can give you a hand
Ismail Kheir
@Ismailkheir
Jul 20 2016 00:14
@BrianCodes33 you are returning nothing in your function
Fransisco Wiles
@fwiles
Jul 20 2016 00:14
Hey guys I'm having trouble with "Testing Objects for Properties" I don't know how I would return all of the object properties. Here's my code:
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};
function checkObj(checkProp) {
  // Your Code Here
  var obj = "gift";
   var answer = myObj.hasOwnProperty(checkProp);
 if (answer === true) {
   return myObj[obj];
 } else {
   return "Not Found";
 }
}
// Test your code by modifying these values
checkObj("gift");
Angelo C. IGITEGO
@AngeloRwanda
Jul 20 2016 00:14
@sjames1958gm After implementing the code, it looks like I am only touching the first element of the array. Please advise:

function findLongestWord(str) {
  var newstr = str.split(" ");
  console.log(newstr);

  var longest=0;

  for(  i=0;i<newstr.length;i++){
    if(newstr[i].length>longest){

      longest = newstr[i].length;

      console.log(longest);
      return longest;
    }
    }

}

findLongestWord("The quick brown fox jumped over the lazy dog");
Pete
@petegarvin1
Jul 20 2016 00:15
@fwiles you dont need most of that
bitgrower
@bitgrower
Jul 20 2016 00:15
@fwiles you only need to return one property at a time ...
...er, rather, the value of one property, at a time ...
Pete
@petegarvin1
Jul 20 2016 00:16
@fwiles you can just use .hasOwnProperty, it will auto return true if it does
Robert Richey
@0x0936
Jul 20 2016 00:16
@fwiles need to fix this line return myObj[obj]; instead of obj, use the function's parameter
Fransisco Wiles
@fwiles
Jul 20 2016 00:18
Would this be correct?
function checkObj(checkProp) {
  // Your Code Here
   var answer = myObj.hasOwnProperty(checkProp);
 if (answer === true) {
   return myObj[checkProp];
 } else {
   return "Not Found";
 }

}
That is being accepted
Stephen James
@sjames1958gm
Jul 20 2016 00:18
@AngeloRwanda I'll be back and check -
Ashlee Hayes
@shleehayes
Jul 20 2016 00:19
the lesson on global scope and functions, I'm declaring the global variable and giving it the value of 10. But I'm confused on how to assign a value to a variable without using the var keyword
Ralitza Iankova
@RIankova
Jul 20 2016 00:19
would you guys mind helping me out with the 'factoralize' challenge? my return result in my for loop is incorrect. it's currently returning the initial value of var 'i' which is 1.
function factoralize(num) {
  // if num is negative OR if num is not a number
  if (num < 0 || isNaN(num) === true) {
    return 'Invalid input. Positive numbers only.'
  }

  // 1 is to multiplication what 0 is to addition
  // in programming, we initialize counting variables as 0 but multiplying variables as 1.
  else if (num === 0) {
    return 1;
  }

  else { 
    for (var i = 1; i > num; i++) {
      i *= num
    }
    return i; // return after loop is done
  }
}
Ashlee Hayes
@shleehayes
Jul 20 2016 00:19

var myGlobal= 10;

function fun1() {
}

Stephen James
@sjames1958gm
Jul 20 2016 00:19
@AngeloRwanda Remember return exits the function - you don't want to return too early
Diego Mayer
@Chrono79
Jul 20 2016 00:20
@RIankova your loop condition is wrong
Stephen James
@sjames1958gm
Jul 20 2016 00:20
@RIankova You don't want to change your index variable i when you multiply
Angelo C. IGITEGO
@AngeloRwanda
Jul 20 2016 00:20
@sjames1958gm Thanks, Stephen.
CamperBot
@camperbot
Jul 20 2016 00:20
angelorwanda sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2026 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 20 2016 00:20
@RIankova Look at your loop i = 1 while i > num ??
Angelo C. IGITEGO
@AngeloRwanda
Jul 20 2016 00:21
@sjames1958gm I placed my return outside the for loop, basically, I gave it to the whole function. It worked like magic.
Suren VB
@surenz298
Jul 20 2016 00:21
Hi
Ashlee Hayes
@shleehayes
Jul 20 2016 00:21
Screen Shot 2016-07-19 at 5.21.17 PM.png
Screen Shot 2016-07-19 at 5.21.17 PM.png
Stephen James
@sjames1958gm
Jul 20 2016 00:22
@AngeloRwanda Woot Woot - that was a good job of translating the English algorithm to code, with only a misplaced return!
Angelo C. IGITEGO
@AngeloRwanda
Jul 20 2016 00:22
Is it ? @sjames1958gm
Suren VB
@surenz298
Jul 20 2016 00:22
I am struck with adding a onclick function to my span - though it looks simple - I am sure - there is something missing
https://jsfiddle.net/#&togetherjs=h6RCrc50hP
scarejar
@scarejar
Jul 20 2016 00:23
what is the flag to remove "_" ?
Stephen James
@sjames1958gm
Jul 20 2016 00:24
@scarejar Are you using a regex?
scarejar
@scarejar
Jul 20 2016 00:24
yeppers
only need 2 more cases
Stephen James
@sjames1958gm
Jul 20 2016 00:24
@scarejar Is it /\W/g
scarejar
@scarejar
Jul 20 2016 00:25
wait... wahh
Patirck
@SomeRandom42
Jul 20 2016 00:25
howdy I am having trouble converting a switch statement to lookup table, i followed the example but nothing happens
Stephen James
@sjames1958gm
Jul 20 2016 00:25
I am only guessing, don't even know which challenge
Joseph
@revisualize
Jul 20 2016 00:25
@BrianCodes33 You still around?
Ralitza Iankova
@RIankova
Jul 20 2016 00:25
@sjames1958gm @Chrono79 i see. i changed it to <= would you mind explaining why i shouldn't change the index variable i when multiplying? i
Stephen James
@sjames1958gm
Jul 20 2016 00:26
@RIankova You are using it to count from 1 to num if you change it it will mess up your count (and factorial)
@scarejar What is your Regex and challenge?
scarejar
@scarejar
Jul 20 2016 00:26
"Check for Palindromes"

function palindrome(str) {

  var rmsc = str.split("").reverse().join().replace(/\s|\W/g, "").toLowerCase();
  var org = str.replace(/\s|\W/g, "").toLowerCase();
  //rmsc.split("").reverse().join()
  //console.log(org);
  //console.log(rmsc);
  if(org == rmsc){
  return true;
     }else{
       return false;
     }
}



palindrome("eye");
Joseph
@revisualize
Jul 20 2016 00:26
@BrianCodes33 It is currently 530pm PST. I am going to go home. If you are around at about 615pm PST. I will be more than willing to sit down with you personally and get on a shared coding session and help you tackle the challenge.
Stephen James
@sjames1958gm
Jul 20 2016 00:27
@scarejar add |_ to your regex
Ismail Kheir
@Ismailkheir
Jul 20 2016 00:27

@RIankova ```function factorialize(num) {
if(num===0){
return 1;
}
else if(num>0){
for(var i=num-1;i>0;i--){
num*=i;
}
return num;
}
else {
return "Make sure to pass a positive number";
}
}

factorialize(5);

scarejar
@scarejar
Jul 20 2016 00:27
@sjames1958gm is /W supposed to remove the underscores?
Joseph
@revisualize
Jul 20 2016 00:28
@scarejar Is it?
Stephen James
@sjames1958gm
Jul 20 2016 00:28
@scarejar \W is everything but a-zA-Z0-9 and _ so \W won't match underscore
scarejar
@scarejar
Jul 20 2016 00:29
lol, not working, think I did something wrong ? str.replace(/\s|\W|_/g,
Stephen James
@sjames1958gm
Jul 20 2016 00:31
@scarejar Did you change both places?
scarejar
@scarejar
Jul 20 2016 00:31
@sjames1958gm ohhh..
Ralitza Iankova
@RIankova
Jul 20 2016 00:31
@sjames1958gm @Chrono79 great, thank you. that makes sense. you guys are always so helpful. really appreciate it! i changed my code to this and it passes my tests locally, but not the challenge. any ideas?
function factoralize(num) {
  // if num is negative OR if num is not a number
  if (num < 0 || isNaN(num) === true) {
    return 'Invalid input. Positive numbers only.'
  }

  // 1 is to multiplication what 0 is to addition
  // in programming, we initialize counting variables as 0 but multiplying variables as 1.
  else if (num === 0) {
    return 1;
  }

  else { 
    value = 1; 
    // needed because i should NOT be changed.
    for (var i = 1; i <= num; i++) {
      value *= i
    }
    return value; // return after loop is done
  }
}
CamperBot
@camperbot
Jul 20 2016 00:31
riankova sends brownie points to @sjames1958gm and @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 2027 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1582 | @chrono79 |http://www.freecodecamp.com/chrono79
scarejar
@scarejar
Jul 20 2016 00:32
@sjames1958gm thanks james lol. PHEW
CamperBot
@camperbot
Jul 20 2016 00:32
scarejar sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2028 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 20 2016 00:32
@RIankova Woot Woot
@scarejar So you have repeated code, not considered good practice.
Think about what you could do to only have one replace / toLowerCase
scarejar
@scarejar
Jul 20 2016 00:33
yeah, I think I can move some of it into 1 statement
Patirck
@SomeRandom42
Jul 20 2016 00:34
var lookup = {
"alpha": "Adams",
i am trying to do a lookup instead of a switch statement It does not appear to be working
Norvin Burrus
@ndburrus
Jul 20 2016 00:36
@SomeRandom42 is it resolved? lesson name?
Patirck
@SomeRandom42
Jul 20 2016 00:36
using-objects-for-lookups
scarejar
@scarejar
Jul 20 2016 00:36
got it P: , looks much more clean
Norvin Burrus
@ndburrus
Jul 20 2016 00:37
@SomeRandom42 well, what you have there looks good... i assume you have the complete object?
Patirck
@SomeRandom42
Jul 20 2016 00:37
my full conversion but when i run it nothing happens

var lookup = {
"alpha": "Adams",

 "bravo":   "Boston",

"charlie":  "Chicago",

"delta":    "Denver",

"echo":   "Easy",

"foxtrot":   "Frank"

};

Ismail Kheir
@Ismailkheir
Jul 20 2016 00:38
@RIankova Wich one didn't pass ?
Norvin Burrus
@ndburrus
Jul 20 2016 00:38
@SomeRandom42 where is the result? how is it handled? :sparkles:
note instructions, here: Use it [lookup table] to lookup val and assign the associated string to the result variable.
Ralitza Iankova
@RIankova
Jul 20 2016 00:39
@Hideontahm it just passed. i had i misspelt factorialize lol, whoops.
Patirck
@SomeRandom42
Jul 20 2016 00:40
@ndburrus that might be issue but when i try assign anything to result it does not work
Norvin Burrus
@ndburrus
Jul 20 2016 00:41
@SomeRandom42 are we doing this: "Use it [lookup table] to lookup val"
...what code are we using?
Patirck
@SomeRandom42
Jul 20 2016 00:42
@ndburrus phoneticLookup("charlie");
scarejar
@scarejar
Jul 20 2016 00:42
 var org = str.replace(/\s|\W|\_|/g, "").toLowerCase();
  var rmsc = org.split("").reverse().join().replace(/\W/g, "");
Is there anything else I can do to simplify this or is this the max it goes?
Norvin Burrus
@ndburrus
Jul 20 2016 00:43

@SomeRandom42 review the 2 sample code lines, here:

var value = 2;
alpha[value]; // "Y"

notice how:

  • the desired value is obtained using the object
Suren VB
@surenz298
Jul 20 2016 00:43
Hi - I am struck with adding a onclick function to my span - though it looks simple - I am sure - there is something missing
https://jsfiddle.net/#&togetherjs=h6RCrc50hP
Patirck
@SomeRandom42
Jul 20 2016 00:43
@ndburrus I get that, but when I try to assign anything to result it does not work
Norvin Burrus
@ndburrus
Jul 20 2016 00:44
@SomeRandom42 code, please?
Patirck
@SomeRandom42
Jul 20 2016 00:45
@ndburrus

var lookup = {
"alpha": "Adams",

 "bravo":   "Boston",

"charlie":  "Chicago",

"delta":     "Denver",

"echo":   "Easy",

"foxtrot":   "Frank"

};
My code but issue is i am not sure how to assign to resuly

result
Stephen James
@sjames1958gm
Jul 20 2016 00:45
@surenz298 It looked like it clicked once.
Norvin Burrus
@ndburrus
Jul 20 2016 00:45
@SomeRandom42 var lookup in the code uses an assignment....
getting clearer?
how would we make an assignment with result?
Fransisco Wiles
@fwiles
Jul 20 2016 00:46
Hey guys I did exactly as the lesson said, but it isn't taking my code:
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here

  {
    "artist": "Majestic",
    "title": "Track Title",
    "release_year": 2016,
    "formats": [
      "mp3",
      "FLAC",
      "Lossy"]

  }
];
Stephen James
@sjames1958gm
Jul 20 2016 00:46
@fwiles Arrays require commas between elements
Ismail Kheir
@Ismailkheir
Jul 20 2016 00:46
@SomeRandom42 You have to change the result variable
Joseph
@revisualize
Jul 20 2016 00:46
@fwiles missing a comma.
Norvin Burrus
@ndburrus
Jul 20 2016 00:46
@fwiles place a comma between the records :sparkles:
Fransisco Wiles
@fwiles
Jul 20 2016 00:47
oh wow lol
thanks @sjames1958gm @revisualize @ndburrus
CamperBot
@camperbot
Jul 20 2016 00:47
fwiles sends brownie points to @sjames1958gm and @revisualize and @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 1441 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 2029 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1044 | @ndburrus |http://www.freecodecamp.com/ndburrus
Patirck
@SomeRandom42
Jul 20 2016 00:48
@Hideontahm I know but how if i try "alpha": result = "Adams",
nothing happens or if I add ; i get an error
Norvin Burrus
@ndburrus
Jul 20 2016 00:48
@SomeRandom42 ok, the handling of the result variable occurs outside of the object. helpful?
look at this example code, here: alpha[value]; // "Y" - this code uses the lookup table to obtain a value... a value that needs to be, result?
Ismail Kheir
@Ismailkheir
Jul 20 2016 00:50
@SomeRandom42 Your variable lookup is great, the only thing that you have to do know is to return the value of the key
Norvin Burrus
@ndburrus
Jul 20 2016 00:51
@fwiles nice job :palm_tree:
Ismail Kheir
@Ismailkheir
Jul 20 2016 00:52
@SomeRandom42 for example lookup["bravo"] will return "Boston", lookup["charlie"] will return "Chicago" and your function take in arguments the keys, the keys here in your variable lookup are "alpha", "bravo", "charlie" ...
Patirck
@SomeRandom42
Jul 20 2016 00:53
Sorry had to see names my computer does not let me scroll well here, I try setting result = result[lookup]; but only the null case works not the other exampples
Ismail Kheir
@Ismailkheir
Jul 20 2016 00:54
@SomeRandom42 result[lookup] will return nothing, because result is empty
you have to search in your object lookup
and the index shouldn't be lookup
Patirck
@SomeRandom42
Jul 20 2016 00:56
Thanks I got it was result=lookup[val]; I forgot about the passed variable to solve that . Thanks for the help!
Ismail Kheir
@Ismailkheir
Jul 20 2016 00:56
@SomeRandom42 great job
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 00:57

Might someone be able to help me with this? I have a jquery hover function that either shows/hides text on mouseenter/mouseleave. Then, I want the text to stay onclick - this part I got, the problem is, if you hover back over the text again, it disappears as prescribed by the hover function. I only want the hover function to work before the div is clicked. Any help would be appreciated!

streamingButton.hover(function(e) {
    $(this).animate(e.type === "mouseenter" 
           ? {width: "60px"}
           : {width: "20px"}        
            );
    $(this).html(e.type === "mouseenter" 
           ? ("<div class='navText'>Online</div>")
           : (""))
});

streamingButton.click(function(e) {
  $(this).addClass("sliderWidth");
  $(".navText").replaceWith("<div class='navText showPerm'>Online</div>");
});

I tried adding a class with display: block !important but that didn't work

I tried messing with .append instead of .html, that made it even worse
Stephen James
@sjames1958gm
Jul 20 2016 00:59
@no-stack-dub-sack Can you remove the handler?
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 01:01
@sjames1958gm no, because the logic needs to remain circular, if I remove the handler, then it won't happen the next time you hover. The goal is to get the text to stick, regardless of hover, then remove it with a different click function on another div
Stephen James
@sjames1958gm
Jul 20 2016 01:02
@no-stack-dub-sack I guess you could add a flag that tells hover, don't do stuff, when you click
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 01:02
@sjames1958gm it's for buttons like these:
http://codepen.io/no_stack_dub_sack/pen/rLGzLK?editors=1100
@sjames1958gm took me forever last night just to get the circular animation down. How would I add a flag?
Stephen James
@sjames1958gm
Jul 20 2016 01:03
@no-stack-dub-sack You could add a class to the stuck guy and check that class in .hover.
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 01:04
@sjames1958gm with an if? I checked, jquery does not support that
because .hover is just shorthand for $( selector ).mouseenter( handlerIn ).mouseleave( handlerOut );
ShaadzillaFCC
@ShaadzillaFCC
Jul 20 2016 01:10

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber ; // Change this Line
var player = testObj; // Change this Line

Can someone help me access 16 in testObj using playerNumber?
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 01:14
@ShaadzillaFCC what have you tried already?
have you looked into bracket notation?
Live-Intuitive
@Live-Intuitive
Jul 20 2016 01:27
how do you do the Stand in Line challenge? I don't get how to do what it's asking

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

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.
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
Migs
@migsor3
Jul 20 2016 01:29
Hello
can somebody help em complete - Access MultiDimensional Arrays With Indexes
Joseph
@revisualize
Jul 20 2016 01:31
// Write a function nextInLine which takes 
// an array (arr) and a number (item) as arguments.
function nextInLine(arr, item) {
    // 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.
    return item; // Change this line
}
Diego Mayer
@Chrono79
Jul 20 2016 01:31
@Live-Intuitive review array manipulation methods
Migs
@migsor3
Jul 20 2016 01:32

// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

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

I need to solve this: myData should be equal to 8
Diego Mayer
@Chrono79
Jul 20 2016 01:32
@migsor3 you have to change those 0 for the right indices
if you had to look for 3
myArray[0] is [1,2,3]
so the 3 is myArray[0][2]
Migs
@migsor3
Jul 20 2016 01:34
thanks @chono79 but that did not work for me
CamperBot
@camperbot
Jul 20 2016 01:34
migsor3 sends brownie points to @chono79 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for chono79
Joseph
@revisualize
Jul 20 2016 01:34
@Live-Intuitive How do you add a number (item) to the end of an array ( arr)?
Migs
@migsor3
Jul 20 2016 01:34
@Chrono79
Nicolas Crumrine
@CrumrineCoder
Jul 20 2016 01:34
So uh, back again for "What obvious thing did I miss" Round 3, dog doesn't get logged to the console so for some reason the getJSON might be ending the function without completing? The GEOCODING link works also.

    function success(position){
    var lat = position.coords.latitude;
    var long = position.coords.longitude; 
    var GEOCODING = 'https://crossorigin.me/http://maps.googleapis.com/maps/api/geocode/json?latlng=' + lat + '%2C' + long + '&language=en' + "?callback=?" ;
    /*console.log(lat + " " + long); */
    console.log(GEOCODING);
    $.getJSON(GEOCODING, function(location) {
            console.log("cat");
            console.log(location);
            console.log(location.results[2].formatted_address);
          }
    ) /* End of GEOCODING JSON */

    console.log("dog");


    };

   function error(){
     console.log("error");


   }

  navigator.geolocation.getCurrentPosition(success, error);
My link starts with https://, so that's not the issue
It's getting the location, but the getJSON just doesn't run :/
Diego Mayer
@Chrono79
Jul 20 2016 01:36
@migsor3 arrays are 0 indexed, count in which subarray is the 8, that is your first indice, then do the same to address the 8 inside that subarray and get your second indice
Migs
@migsor3
Jul 20 2016 01:42
Im thinking 7?
Caleb
@SpikeSpiegal15
Jul 20 2016 01:42
@migsor3 var myData = myArray[2][1]
Migs
@migsor3
Jul 20 2016 01:44
@Chrono79 thank you so much I have been stuck here for hours.
CamperBot
@camperbot
Jul 20 2016 01:44
migsor3 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1583 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 20 2016 01:44
@migsor3 do you understand why is that the right answer?
Migs
@migsor3
Jul 20 2016 01:46
well I know the count starts at 0 but i donot now why the answer is [2][1] @chrono79
Nicolas Crumrine
@CrumrineCoder
Jul 20 2016 01:46
NEVERMIND, FIXED IT
Diego Mayer
@Chrono79
Jul 20 2016 01:47
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
myArray[2] is [7,8,9] because that's the third element of myArray (indice 2)
and the 8 is the second element of that subarray (indice 1)
Migs
@migsor3
Jul 20 2016 01:50
brilliant! @Chrono79 I got it
Diego Mayer
@Chrono79
Jul 20 2016 01:51
@migsor3 Good, tell me how you access the 13 then ;)
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 01:52
hey @Chrono79 , how well do you know jquery? I'm having some difficulty with something and you've been pretty helpful in the past!
Diego Mayer
@Chrono79
Jul 20 2016 01:53
I can take a look, no guarantees
Stephen James
@sjames1958gm
Jul 20 2016 01:53
@CrumrineCoder What was it?
Migs
@migsor3
Jul 20 2016 01:54
myArray4 @Chrono79
[0]
Joseph
@revisualize
Jul 20 2016 01:55
@Chrono79 I like using this ...
Diego Mayer
@Chrono79
Jul 20 2016 01:55
@migsor3 no, myArray has only 4 elements, so the indices for them go from 0 to 3
Joseph
@revisualize
Jul 20 2016 01:55
var arr = [["a1"], ["b2","c2"], ["d3","e3","f3"], ["g4","h4","i4","k4"]];
Do you understand that this is an array of arrays?
How do you access "_"?
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 01:56
@Chrono79 thanks - here's the pen, easier than posting code. Problem I'm having is getting text "offline" to stay in middle button after click. Right now it stays there, but after you hover over it a couple times, the text disappears. If I'm removing class test the first hover function shouldn't be happening at all!
CamperBot
@camperbot
Jul 20 2016 01:56
no-stack-dub-sack sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1584 | @chrono79 |http://www.freecodecamp.com/chrono79
kevinstonge
@kevinstonge
Jul 20 2016 02:01

I'm a bit stuck on my weather app - could somebody take a look at my codepen to see why geolocation isn't working? I've got my API link temporarily filled with arbitraty lat/long data ...; but I need to get it filled with browser detected lat/long data ... so the only part of my code giving me trouble is the geolocation bit at the top.

http://codepen.io/kevinstonge/pen/JKpXAP

Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:02
@kevinstonge there's a reason that the built in JS geolocation functions don't work in code pen anymore
kevinstonge
@kevinstonge
Jul 20 2016 02:02
?
Joseph
@revisualize
Jul 20 2016 02:02
help rooms
CamperBot
@camperbot
Jul 20 2016 02:02

:point_right: help rooms [wiki]

FreeCodeCamp Chat Rooms

Help Rooms

Chat Room Description Chat Room
HTML/CSS/Bootstrap FreeCodeCamp/Help
JavaScript/Algorithms FreeCodeCamp/HelpJavaScript
Front End FreeCodeCamp/HelpFrontEnd
Data Visualization FreeCodeCamp/HelpDataViz
Back End FreeCodeCamp/HelpBackEnd

Choose the right room for your questions!

See also: :earth_asia: Language Specific | :satellite: Technology | :crystal_ball: Miscellaneous

back to top ↑

:pencil: read more about help rooms on the FCC Wiki

bsandusky
@bsandusky
Jul 20 2016 02:03
@kevinstonge Check the console in your browser for some more information. You cannot use geolocation on http it has to be https
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:03
@kevinstonge you will need to use another API like IP-API
kevinstonge
@kevinstonge
Jul 20 2016 02:03
@bsandusky thanks
CamperBot
@camperbot
Jul 20 2016 02:03
kevinstonge sends brownie points to @bsandusky :sparkles: :thumbsup: :sparkles:
:cookie: 319 | @bsandusky |http://www.freecodecamp.com/bsandusky
bsandusky
@bsandusky
Jul 20 2016 02:03
@kevinstonge However, the free weather api only works on http so you need to use a different http based api for coordinates
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:03
and if you usse https weather api will not work
Migs
@migsor3
Jul 20 2016 02:03
so this counts as one element? [[10,11,12], 13, 14]]
@Chrono79
Diego Mayer
@Chrono79
Jul 20 2016 02:04
@migsor3 yes
Joseph
@revisualize
Jul 20 2016 02:04
If anyone needs help with anything before the "Intermediate Front End Development Projects" ... I'm available to assist.
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:04
@kevinstonge www.ip-api.com is what was suggested to me. pretty easy to use and works great
kevinstonge
@kevinstonge
Jul 20 2016 02:04
@no-stack-dub-sack thanks, that one looks cool!
CamperBot
@camperbot
Jul 20 2016 02:04
kevinstonge sends brownie points to @no-stack-dub-sack :sparkles: :thumbsup: :sparkles:
:cookie: 290 | @no-stack-dub-sack |http://www.freecodecamp.com/no-stack-dub-sack
Liam Bang
@Liam345
Jul 20 2016 02:04

I have an object collection that looks like this:

var collection = {
"5439": {
"album": "ABBA Gold"
}
};

And the function that I need to make should have:
If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.

And a part of my function that I solved looks like this:
function updateRecords(id, prop, value) {
if(prop==="tracks" && !collection.hasOwnProperty(collection[id][prop])){
collection[id][prop]=[];
collection[id][prop].push(value);
}
return collection;
}

It does not work and the problem lies because I am not sure how to declare an array inside tracks array inside the collection object. Also not entirely sure about the hasownproperty condition. Any help would be appreciated.

Joseph
@revisualize
Jul 20 2016 02:05
@Liam345 You're not doing .hasOwnProperty() correctly.
Diego Mayer
@Chrono79
Jul 20 2016 02:06

@no-stack-dub-sack

$(this).html(e.type === "mouseenter" 
           ? ("<div class='navText'>Online</div>")
           : ("<div class='navText hide'>Online</div>"));

This is hiding the text on mouseleave

zhouyou
@melancy
Jul 20 2016 02:06
Does anyone know Stand in Line how to works?
Joseph
@revisualize
Jul 20 2016 02:07
@melancy I do.
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:07
@Chrono79 precisely, but I added an IF before that function so that the hover should only work if streamingButton has class test, and in the click function I remove class test
Migs
@migsor3
Jul 20 2016 02:07
awesome! thank you @Chrono79
CamperBot
@camperbot
Jul 20 2016 02:07
migsor3 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: migsor3 already gave chrono79 points
Joseph
@revisualize
Jul 20 2016 02:08

@melancy

// Write a function nextInLine which takes 
// an array (arr) and a number (item) as arguments.
function nextInLine(arr, item) {
    // 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.
    return item; // Change this line
}

How do you add a number (item) to the end of an array (arr)?
How do you remove the first element from an array (arr)?

Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:08
@Chrono79 I need the text to hide on mouseleave becuase if the button is not clicked, the text can't remain
zhouyou
@melancy
Jul 20 2016 02:09
@revisualize Yeah,I dont konw how to add number to an arry
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:09
but the text should stay on click and then not be removed by hover. UNTIL - another button is clicked and it animates back to non-hover state
Joseph
@revisualize
Jul 20 2016 02:09
@melancy Well then.. I'd highly suggest that you go back SEVERAL lessons and learn how to work with arrays.
bsandusky
@bsandusky
Jul 20 2016 02:10
@revisualize Check out the Javascript documentation for push and shift. It will have info on how to do these things.
Diego Mayer
@Chrono79
Jul 20 2016 02:10
@no-stack-dub-sack I could be wrong but I think you've already bounded the hover and changing the class doesn't matter
Joseph
@revisualize
Jul 20 2016 02:11
@bsandusky I wasn't asking because I didn't know.. I was asking to help teach.
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:11
@Chrono79 Ahh, so I could unbind the hover maybe? I dunno maybe I should just come back to this problem, seems like it should be simple but clearly there's more than meets the eye. I've been stuck on it for too long...
Joseph
@revisualize
Jul 20 2016 02:11
@bsandusky I know how to work with arrays.
bsandusky
@bsandusky
Jul 20 2016 02:11
@revisualize sorry. meant to tag @melancy
Diego Mayer
@Chrono79
Jul 20 2016 02:11
@no-stack-dub-sack try unbinding it
Kevin K. Lee
@kevinkiklee
Jul 20 2016 02:11
@melancy aight, so this is a really crazy website i found. it has all the answers. ever. you can find how to work with an array here. http://bfy.tw/6p6a =D
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:11
@Chrono79 ok, hang tight
Joseph
@revisualize
Jul 20 2016 02:12
Also, I wasn't going to give them the answer because it is a learning process. Someone by the time that they get to "Stand in Line" should know how to work with arrays.
Kevin K. Lee
@kevinkiklee
Jul 20 2016 02:12
@revisualize i just gave him the answer in my link. =D
@melancy aight from now on, you solve everything with the method i just showed you. that is how you learn to code.
Joseph
@revisualize
Jul 20 2016 02:12
That's lame.
Kevin K. Lee
@kevinkiklee
Jul 20 2016 02:13
no it's not lame. he's coming in here askign how to add an element to an array. come on.
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:13
@Chrono79 Ha!!!!!!!!!!!!!!!!!!!!
@Chrono79 saves the day again
Diego Mayer
@Chrono79
Jul 20 2016 02:14
:+1:
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:14
@Chrono79 THANK. YOU.
CamperBot
@camperbot
Jul 20 2016 02:14
no-stack-dub-sack sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: no-stack-dub-sack already gave chrono79 points
Robinsond7691
@Robinsond7691
Jul 20 2016 02:14
hey guys i need some help on my profilelookup
for (i = 0; i < contacts.length; i++) {
    if (contacts[i][0] == firstName) {
        for (j = 0; j < contacts[i].length; j++) {
          if (contacts[i][j] == prop) {
            return contacts[i][j];
          }
        }
    }
  }
Am I on the right track?
Joseph
@revisualize
Jul 20 2016 02:15
No it really is lame. We should not be gifting people answers. We should be showing them how to research. We should be helping people solve problems on their own. That helps them learn the material better. If someone is at a lesson like "Stand in Line" and they don't know how to add an element to the end of an array .... It shows that they weren't focused on learning the material. It shows that they were pushing through to just get the correct answer and move on. We shouldn't be teaching people how to fish instead of gifting them fish.
zhouyou
@melancy
Jul 20 2016 02:15
@revisualize @revisualize arr.push(item);
item=arr.shift() ;
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:15
@Chrono79 now there's still some issues here, I'm going to need to rebind it (if possible) on the other button clicks, but this get's me closer to the end result
Kevin K. Lee
@kevinkiklee
Jul 20 2016 02:15
@revisualize ROFLCOCK. DID YOU EVEN CHECK MY LINK?????????
@revisualize did you really write all that without actually seeing what i sent him
Joseph
@revisualize
Jul 20 2016 02:15
@melancy Correct.. Except ... you don't need to item= that overwrites the item variable.
Patirck
@SomeRandom42
Jul 20 2016 02:16
i was wondering can someone help me with Record Collection, I think my logic is sound but, maybe not
Joseph
@revisualize
Jul 20 2016 02:16
@iserbit I see no links in this chat.
Let me refresh.
Kevin K. Lee
@kevinkiklee
Jul 20 2016 02:16
@melancy aight, so this is a really crazy website i found. it has all the answers. ever. you can find how to work with an array here. http://bfy.tw/6p6a =D
zhouyou
@melancy
Jul 20 2016 02:16
@revisualize thanks
CamperBot
@camperbot
Jul 20 2016 02:16
melancy sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1442 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jul 20 2016 02:17
@iserbit Odd. I didn't see that link until I refreshed.
@SomeRandom42 I can.
Kevin K. Lee
@kevinkiklee
Jul 20 2016 02:17
lol yea i was half trolling and half serious
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:17
@Chrono79 now the question is, if I add back the test class, will that reset the binding and allow the hover function to work again...
Joseph
@revisualize
Jul 20 2016 02:17
@SomeRandom42 What is your function? (just the function).
Patirck
@SomeRandom42
Jul 20 2016 02:18

function updateRecords(id, prop, value) {
if((prop !== "tracks") && (value !== "")){collection[id][prop].push(value);}
if((prop == "tracks") && (value !== "")){}
if(value === ""){ delete collection[id].prop;}

return collection;
}

@revisualize function updateRecords(id, prop, value) {
if((prop !== "tracks") && (value !== "")){collection[id][prop].push(value);}
if((prop == "tracks") && (value !== "")){}
if(value === ""){ delete collection[id].prop;}

return collection;
}

Joseph
@revisualize
Jul 20 2016 02:18
@SomeRandom42 You've started okay.
Diego Mayer
@Chrono79
Jul 20 2016 02:18
@no-stack-dub-sack My guess is no, but... again I could be wrong
Joseph
@revisualize
Jul 20 2016 02:19
You didn't need to post it twice.
@SomeRandom42 This: if((prop !== "tracks") && (value !== "")){collection[id][prop].push(value);} the evaluation is correct. However the {...} is not.
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:19
@Chrono79 meh, your guess is right. So now I'm almost back at square one. The text issue is solved, but unbinding seems to turn off the hover function permanently...
Patirck
@SomeRandom42
Jul 20 2016 02:20
@revisualize sorry I was doing the @ thing, my issue is when I try to figure out how to fix the {}
Diego Mayer
@Chrono79
Jul 20 2016 02:20
@no-stack-dub-sack I'm a very lucky guesser ;)
Joseph
@revisualize
Jul 20 2016 02:20
@SomeRandom42 Also. for delete collection[id].prop; that isn't correct. That is using dot notation which is a string literal.
@SomeRandom42 I'd suggest re-reading the instructions. Maybe this will help.
https://gist.github.com/revisualize/123deb77d85079f079020ac3cd6ea5ba
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:21
@Chrono79 I wish you could just rebind w/ .on just like you can unbind with .off
Greg Duncan
@GregatGit
Jul 20 2016 02:21
@SomeRandom42 you can only push to an array that is there - if the array is not there you have to create it before you push to it -
Patirck
@SomeRandom42
Jul 20 2016 02:22
@GregatGit how do i create the arrray, that is one of issues i know , I am aware i have not gotten all the requirements yet
Robinsond7691
@Robinsond7691
Jul 20 2016 02:23
Some one take a look at my code up there please?
Joseph
@revisualize
Jul 20 2016 02:25
@GregatGit I'm sorry, I don't understand your statement If I look at: if((prop !== "tracks") && (value !== "")){ } That means that prop is not tracks and the only arrays in the code are tracks. So prop would need to be "tracks" for your statement to be correct.
@SomeRandom42 How do you create an array?
Diego Mayer
@Chrono79
Jul 20 2016 02:25
@no-stack-dub-sack does this help? http://jsfiddle.net/8JHCe/8/
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:27
@Chrono79 hmmm... maybe, but it's going to take me some time to analyze that code and figure out what's going on there. The answer might be there though.
@Chrono79 actually, maybe yes. because you cannot do ifs within the hover functions, but if you do .bind, it looks like you can. That could pretty easily solve it I think.
I'll try and let you know.
Greg Duncan
@GregatGit
Jul 20 2016 02:30
@SomeRandom42 its pretty simple to create an array prop[id].tracks = []; or something close to that - first you have to check if it exists - hasOwnProperty
Patirck
@SomeRandom42
Jul 20 2016 02:34
@GregatGit gotcha, I think issue stems from trying to recall all these commands and small issues, plus this chat is not great on my little laptop so hard to keep track, I am just having slight issue say seeing issue with trying out all those line in my if statement and remembering to fix, the {..} (which i already forgot
Johnny Garces
@jginbound
Jul 20 2016 02:35
hey all- been having some trouble with "Title Case A Sentence"
so far, I've been able to capitalize the first letter of each word. but my issue is returning the complete string with the capitalized letter of each word
Greg Duncan
@GregatGit
Jul 20 2016 02:36
@SomeRandom42 try coping and pasting the problem at https://repl.it/ - and practice there with objects - adding and removing properties and values
Johnny Garces
@jginbound
Jul 20 2016 02:36
here's my code- appreciate any feedback!
  function titleCase(str) {
  var lowerStr = str.toLowerCase();
  var lowerArr = lowerStr.split(' ');
  console.log(lowerStr);
  console.log(lowerArr);
  for(var i = 0; i < lowerArr.length; i++){
      var firstLetter = lowerArr[i][0];
      var firstCapLetter = firstLetter.toUpperCase();
      var newCapWord = lowerArr[i].replace(firstLetter, firstCapLetter);
      console.log(newCapWord);
  }
}

titleCase("I'm a little tea pot");
Joseph
@revisualize
Jul 20 2016 02:37
@jginbound But, you're on the right track.
Greg Duncan
@GregatGit
Jul 20 2016 02:37
@jginbound use join the same way you split
Joseph
@revisualize
Jul 20 2016 02:37
You just need to end your function.
Johnny Garces
@jginbound
Jul 20 2016 02:38
wondering why console.log(newCapWord) only shows the last word "pot"
Aman
@asingh714
Jul 20 2016 02:38
@revisualize earlier today you, you asked me how I would get to f3. var arr = [["a1"], ["b2","c2"], ["d3","e3","f3"], ["g4","h4","i4","k4"]];
Stephen James
@sjames1958gm
Jul 20 2016 02:38
@jginbound Need to put your cap word back into the array (and join / return as said before)
Joseph
@revisualize
Jul 20 2016 02:39
@asingh714 I did.
Aman
@asingh714
Jul 20 2016 02:40
arr[2][2];
Johnny Garces
@jginbound
Jul 20 2016 02:40
cool i'll work on this and let y'all know how it goes! thanks @sjames1958gm @revisualize @GregatGit
CamperBot
@camperbot
Jul 20 2016 02:40
jginbound sends brownie points to @sjames1958gm and @revisualize and @gregatgit :sparkles: :thumbsup: :sparkles:
:star2: 2032 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1443 | @revisualize |http://www.freecodecamp.com/revisualize
:cookie: 699 | @gregatgit |http://www.freecodecamp.com/gregatgit
Joseph
@revisualize
Jul 20 2016 02:40
@jginbound Seriously. I just changed two lines of code and solved the challenge.
Stephen James
@sjames1958gm
Jul 20 2016 02:40
@revisualize :+1:
Aman
@asingh714
Jul 20 2016 02:41
@revisualize arr[2][2];
Stephen James
@sjames1958gm
Jul 20 2016 02:41
here is a little simpler way to title case val.charAt(0).toUpperCase() + val.toLowerCase().slice(1);
Joseph
@revisualize
Jul 20 2016 02:41
@jginbound I changed this var newCapWord to something else and added a return statement.
@asingh714 Okay.
Aman
@asingh714
Jul 20 2016 02:42
Is that correct? I went back to review
Johnny Garces
@jginbound
Jul 20 2016 02:42
success! thanks again everyone :)
Chris Katzmann
@cwkatzmann
Jul 20 2016 02:44
just starting the random quote machine
Joseph
@revisualize
Jul 20 2016 02:44
@jginbound I sent you a PM.
Chris Katzmann
@cwkatzmann
Jul 20 2016 02:44
anyone want to reccommend resources/give advice for learning to use APIs
?
Stephen James
@sjames1958gm
Jul 20 2016 02:46
@asingh714 Yes that is correct
Robinsond7691
@Robinsond7691
Jul 20 2016 02:50

guys, i noticed my for loop to iterate through an array isn't working. Can you see whats wrong?

for (i = 0; i < contacts.length; i++) {
    if (contacts[i][0] == firstName) {
console.log("got it!");
  }
 }

basically I want it to go through each object in the array and check the value of the first property of each object for firstName. If found, print out "got it!"

Diego Mayer
@Chrono79
Jul 20 2016 02:50
@Robinsond7691 contacts[i][0] is wrong, contacts is an array of objects, not an array of arrays
stevengalvis
@stevengalvis
Jul 20 2016 02:50
yeah that 0
Stephen James
@sjames1958gm
Jul 20 2016 02:51
@Robinsond7691 contacts[i] is an object with the property firstName you are accessing it like an array
Robinsond7691
@Robinsond7691
Jul 20 2016 02:51
why though? Wouldn't that be the first property of the first object?
Stephen James
@sjames1958gm
Jul 20 2016 02:51
@Robinsond7691 Doesn't work that way.
Joseph
@revisualize
Jul 20 2016 02:51
@Robinsond7691 You don't access Object Properties via indexes.
Robinsond7691
@Robinsond7691
Jul 20 2016 02:52
So how do I access the first property of the object?
Joseph
@revisualize
Jul 20 2016 02:52
@Robinsond7691 Ummm... Object.keys(). But, you don't need to use Object.keys() for that challenge.
Stephen James
@sjames1958gm
Jul 20 2016 02:53
Since your code "knows" there is a property firstName you can access it directly with that property name
Robinsond7691
@Robinsond7691
Jul 20 2016 02:54
Ok lemme think over here
Peter Weinberg
@no-stack-dub-sack
Jul 20 2016 02:55
@Chrono79 Diego, if you're still here - that fiddle did the trick.
Robinsond7691
@Robinsond7691
Jul 20 2016 02:55
OK i'm confused. There are multiple objects in the array contacts. How do I access each object then? @revisualize mentioned object.keys() but how would I refer to the object in the array?
Joseph
@revisualize
Jul 20 2016 02:55
@Robinsond7691 Let me write you a little bit of code.
Robinsond7691
@Robinsond7691
Jul 20 2016 02:56
ok
Joseph
@revisualize
Jul 20 2016 02:57
@Robinsond7691
var myObj = {
   name: "Joseph",
   user: "revisualize",
   sex: "Yes, please."
}
myObj.user; // Outputs what?
myObj.name; // Outputs what?
Robinsond7691
@Robinsond7691
Jul 20 2016 02:57
@revisualize revisualize. but what if that object is in an array?
Joseph
Joseph
@revisualize
Jul 20 2016 02:57
Great.
@Robinsond7691 So... Did you I need to use myObj[index]; ?
@Robinsond7691 I'm just talking about the object currently.
Robinsond7691
@Robinsond7691
Jul 20 2016 02:58
right
Joseph
@revisualize
Jul 20 2016 02:58
@Robinsond7691 Now what happens if I have an array of objects?
@Robinsond7691 Let me write you some code.

@Robinsond7691

var myArrObj = [ { username: "revisualize" }, { username:  "Robinsond7691" }, { username:  "sjames1958gm" } ];

How would I access your username?

Robinsond7691
@Robinsond7691
Jul 20 2016 03:00
aaah I'm looking over some lessons here. I think I would have to write contacts[i].firstName = firstName
Joseph
@revisualize
Jul 20 2016 03:00
Well, = is assignment.
Robinsond7691
@Robinsond7691
Jul 20 2016 03:01
ops
==*
ok let me look at your code
Joseph
@revisualize
Jul 20 2016 03:01
@Robinsond7691 :)
Robinsond7691
@Robinsond7691
Jul 20 2016 03:02
myArrObj[2][username]
wait
myArrObj[1][username]
Joseph
@revisualize
Jul 20 2016 03:02
nope.
Fransisco Wiles
@fwiles
Jul 20 2016 03:02
I'm completely stuck on "Record Collection"
I'm gettign so pissed off
Joseph
@revisualize
Jul 20 2016 03:03
@Robinsond7691 Next question (after you answer that one) would be: How does that apply to your code? But, you already answered that.
Robinsond7691
@Robinsond7691
Jul 20 2016 03:03
@fwiles took me about 2 hours on sunday to get it! Keep trying and remove some doubts here
Joseph
@revisualize
Jul 20 2016 03:03
@fwiles How can I help?
@fwiles What does your function (and only the function please) look like? (We do NOT need that huge ass object pasted into chat.)
Robinsond7691
@Robinsond7691
Jul 20 2016 03:04
@revisualize but to access my name in your code, it would be myArrObj[1]["firstname"] right?
Joseph
@revisualize
Jul 20 2016 03:05
@Robinsond7691 no. "username" ... There are no "firstname" properties in my code.
Bhushan933
@Bhushan933
Jul 20 2016 03:05
@scarejar checkout here in the console - http://codepen.io/Bhushan933/pen/EyQqVX?editors=1111
Fransisco Wiles
@fwiles
Jul 20 2016 03:05
Here is my code so far: (I've reset it like 20 times now)
function updateRecords(id, prop, value) {

    id = collection[id];
  prop = id[prop];
  value = id.prop[value];
  return collection;
}
Robinsond7691
@Robinsond7691
Jul 20 2016 03:05
@revisualize lol damn, ok. Well, thanks for the help.
CamperBot
@camperbot
Jul 20 2016 03:05
robinsond7691 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1444 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jul 20 2016 03:06
@fwiles umm. You're really not on the correct track.
Fransisco Wiles
@fwiles
Jul 20 2016 03:07
Please put me on it
Joseph
@revisualize
Jul 20 2016 03:07
@fwiles May I suggest that you read the gist that I posted.
@fwiles A lot of the code that you need to start writing is written out in the instructions as words.
Fransisco Wiles
@fwiles
Jul 20 2016 03:09
Thats whats making this so torturous. I know what I need to do, but I can't write the javascript to achieve it D;
Joseph
@revisualize
Jul 20 2016 03:09
@fwiles Let me break it down.
@fwiles Write this as javascript.
@fwiles // If prop isn't "tracks" and value isn't blank,
@fwiles Just a simple if line. Nothing too elaborate.
Fransisco Wiles
@fwiles
Jul 20 2016 03:13
would this be correct?
if (prop !== "tracks" && value !== "") {

   }
Joseph
@revisualize
Jul 20 2016 03:13
Yup!
Okay.. one if statement down.
@fwiles Next one... // If prop is "tracks" and value isn't blank,
Fransisco Wiles
@fwiles
Jul 20 2016 03:14
would I use a else if? or another if ?
Joseph
@revisualize
Jul 20 2016 03:15
@fwiles Do you see else if in that line?
Fransisco Wiles
@fwiles
Jul 20 2016 03:15
alrighty then
Joseph
@revisualize
Jul 20 2016 03:16
@fwiles So.. I'd suggest reading the instructions and just write the code that you can.
Silvano Rasta
@sirvanux
Jul 20 2016 03:17
wow what am I missing in this basic javascript excercise
Fransisco Wiles
@fwiles
Jul 20 2016 03:18
I didn't break it down like you did. Thanks for helping me @revisualize
CamperBot
@camperbot
Jul 20 2016 03:18
fwiles sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1445 | @revisualize |http://www.freecodecamp.com/revisualize
Silvano Rasta
@sirvanux
Jul 20 2016 03:18

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch(answer){
case "a":
answer = "apple";
break;

case "b":
  answer = "bird";
  break;

case "c":
  answer = "cat";
  break;

default:
answer = "stuff";
}

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

it goes directly to default
Joseph
@revisualize
Jul 20 2016 03:19
@sirvanux What is answer? At the start of your function before the switch starts.
Silvano Rasta
@sirvanux
Jul 20 2016 03:20
is a string
Joseph
@revisualize
Jul 20 2016 03:20
@sirvanux Great.
@sirvanux It is an empty string.
Silvano Rasta
@sirvanux
Jul 20 2016 03:20
yeah
Joseph
@revisualize
Jul 20 2016 03:20
So will it ever be "a"?
Silvano Rasta
@sirvanux
Jul 20 2016 03:21
if you run swicthOfStuff("a") you still get "stuff"
Joseph
@revisualize
Jul 20 2016 03:21
@sirvanux If not.. Maybe you shouldn't be using answer as your check for your switch.
Silvano Rasta
@sirvanux
Jul 20 2016 03:21
dont understand
Joseph
@revisualize
Jul 20 2016 03:22
If I do...
john alexis v. casupang
@shaider14
Jul 20 2016 03:22
why this is not working..?
var myStr="FirstLine\n\Secondline\\rThirdLine";//Change this line
is this a bug?
Joseph
@revisualize
Jul 20 2016 03:22
var answer = "";
if (answer === "a") { true; }
It will never be true.
@shaider14 No bug.
@shaider14 Your string isn't correct.
Silvano Rasta
@sirvanux
Jul 20 2016 03:23
oh i see
Joseph
@revisualize
Jul 20 2016 03:23
@shaider14 Secondline
john alexis v. casupang
@shaider14
Jul 20 2016 03:23
but is the correct answer..
Joseph
@revisualize
Jul 20 2016 03:23
@shaider14 No it isn't.
john alexis v. casupang
@shaider14
Jul 20 2016 03:23
the chat ommits the slashes
Silvano Rasta
@sirvanux
Jul 20 2016 03:23
switch(val)
Joseph
@revisualize
Jul 20 2016 03:23
@sirvanux :)
@shaider14 Look at your string line very closely. ..... Secondline
Silvano Rasta
@sirvanux
Jul 20 2016 03:24
thank you im still learning to work with switch
@revisualize thx
CamperBot
@camperbot
Jul 20 2016 03:24
sirvanux sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1446 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jul 20 2016 03:25
@shaider14 I was able to quote your chat statement to see what you actually wrote.
But, I didn't need to.
I saw the error before hand.
You have a misspelling.
Jonathon Vessal
@Jonnyvessal
Jul 20 2016 03:27
I do not understand the problem "Convert Celsius to Fahrenheit" for Javascript. I am lost from the beginning so any help is appreciated. Thanks!
john alexis v. casupang
@shaider14
Jul 20 2016 03:28
var myStr="FirstLine\n\Secondline\\rThirdLine";//Change this line
Joseph
@revisualize
Jul 20 2016 03:28
@Jonnyvessal How do you do the math to convert Celsius to Fahrenheit?
@shaider14 Still not doing Secondline correctly.
Maria Luciene
@lucienemlf
Jul 20 2016 03:28
I don't know why my tests are falling if my results are right. Can anyone help me?
function titleCase(str) {
  var arr = str.split(' ');
  var result = "";


  for(var i = 0; i < arr.length; i++) {
     result = result + " "+ arr[i][0].toUpperCase();
     for(var j = 1; j < arr[i].length; j++) {
       result = result +  arr[i][j].toLowerCase();
     }
  }

  return result;
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Joseph
@revisualize
Jul 20 2016 03:28
@shaider14 You have Secondline ... it should be SecondLine
john alexis v. casupang
@shaider14
Jul 20 2016 03:29
how to chat the code like them?
Joseph
@revisualize
Jul 20 2016 03:29
help format
CamperBot
@camperbot
Jul 20 2016 03:29

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Joseph
@revisualize
Jul 20 2016 03:29
```js [SHIFT+ENTER]
// your code here
```[CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
john alexis v. casupang
@shaider14
Jul 20 2016 03:30
var myStr="FirstLine\n\\Secondline\\\rThirdLine";//Change this line
is that wrong sir?
still giving me an error
Joseph
@revisualize
Jul 20 2016 03:31
@shaider14 Secondline ... look at the "l" vs... SecondLine
Olly Sholotan
@Ollysho
Jul 20 2016 03:31
help caesars cipher
CamperBot
@camperbot
Jul 20 2016 03:31

:point_right: algorithm caesars cipher [wiki]

Algorithm Caesars Cipher

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

  • You need to write a function, which will take a string encoded with Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is shifted by 13 places. e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.

Relevant Links

:pencil: read more about algorithm caesars cipher on the FCC Wiki

Patirck
@SomeRandom42
Jul 20 2016 03:31
hello I am working on "Profile Lookup" and I am trying to use for loops to navigate the object, but it does not seem to be working , I am trying to see if I understand that I can find a name by navigating with for loops, but it is not working I was wondering if someone could help me
Joseph
@revisualize
Jul 20 2016 03:32
@SomeRandom42 What is your function? (please don't include the array.)
Xavier Velez
@JonSnow08
Jul 20 2016 03:32
can I have some help with Smallest Common Multiple
function smallestCommons(arr) {
  var range = arr.sort(); 
  var array = [];
  for(var i = arr[0]; i <= arr[arr.length -1];i++){
    array.push(i); 
  }

  var x = true; 
  var lcm = 0; 
  while(x){
    lcm++; 
    for(var j = array[0]; j <= array[array.length-1];j++){
      if(lcm % j!==0){
        break; 
      }else if(j==array[array.length -1]){
        x = false; 
      }
    }
  }
  return lcm;
}


smallestCommons([1,5]);
im passing the first two but not the last two
john alexis v. casupang
@shaider14
Jul 20 2016 03:32
thanks sir
Patirck
@SomeRandom42
Jul 20 2016 03:33

for (i=0; i < contacts.length; i++)
{
if(contacts[i]==firstName)
{

    for (j=0; j < contacts[i].length; i++)
      {
        if(contacts[i][j]==prop)
          {
            return contacts[i][j];
          }
      }
  }
 else return "No such contact";

}
I am a ware the middle part is wrong, I am mostly right now trying to understand just to see if I can correctly lock onto the name "Akira"

Joseph
@revisualize
Jul 20 2016 03:34
@SomeRandom42 I don't understand why you have a second for loop
Colin
@breakpoint1025
Jul 20 2016 03:34

Why the code can't pass the test?

<script>$(document).ready(function(){})</script>

Joseph
@revisualize
Jul 20 2016 03:35
@SomeRandom42 You don't access objects via indexes.
Colin
@breakpoint1025
Jul 20 2016 03:35

'''
<!-- Only change code above this line. -->

<script>$(document).ready(function(){})</script>'''

CamperBot
@camperbot
Jul 20 2016 03:35
:bulb: to format code use backticks! ``` more info
Patirck
@SomeRandom42
Jul 20 2016 03:36
@revisualize I was thinking was needed to look at stuff but realized does not work, I think that might be my issue , trying to use via indexs, I need to use box notation correct? But use for loop to look through the arrays?
JaosnHsieh
@JaosnHsieh
Jul 20 2016 03:36
Hi , I made a simple 2 dimensions maze but it will crash in the function "createRoute" when I want to generate a bigger maze like ( 100 x 100 ) , I'm thinking how to make a more time consuming but not crash way to do it. Anyone has idea? Thanks ( http://codepen.io/jasonhsieh/pen/GqyZAG?editors=0010 )
Joseph
@revisualize
Jul 20 2016 03:37
@SomeRandom42 if(contacts[i]==firstName) What is contacts[0]?
@breakpoint1025 I'm sorry.. What challenge are you working on? I don't know what challenge that is.. So, I can't really tell you why that isn't passing the test.
Colin
@breakpoint1025
Jul 20 2016 03:38
Learn how Script Tags and Document Ready Work
Patirck
@SomeRandom42
Jul 20 2016 03:38
@revisualize I was thinking the first full array, but by that logic it could not ever = first name unless that was all in the array
Colin
@breakpoint1025
Jul 20 2016 03:39
@revisualize Learn how Script Tags and Document Ready Work
Fransisco Wiles
@fwiles
Jul 20 2016 03:41
I'm still stuck on Record Collection D:
Joseph
@revisualize
Jul 20 2016 03:41
@fwiles Okay. What is your function currently?
@breakpoint1025 You are missing the ;
@breakpoint1025 You have:
<script>$(document).ready(function(){})</script>
Then close it on the following line (still inside your script element) with: });
<script>$(document).ready(function() {});</script>
Fransisco Wiles
@fwiles
Jul 20 2016 03:43
function updateRecords(id, prop, value) {

   if (prop !== "tracks" && value !== "") {
     value = id.prop;
     return value;
   }

  if (prop === "tracks" && value !== "") {
    prop.push(value);
  }

  if (value === "") {
    delete id.prop;
  }

  if (prop === "tracks" && id.hasOwnProperty(prop) === false) {

  }
  return collection;
}
Joseph
@revisualize
Jul 20 2016 03:43
@fwiles Okay you're doing better. But... Yeah.. Everything inside of your { }s is incorrect.
@fwiles Have you done the other challenges related to objects?
Fransisco Wiles
@fwiles
Jul 20 2016 03:44
I've done all them tonight
Joseph
@revisualize
Jul 20 2016 03:45
@fwiles Record Collection is a Check Point. Not a regular challenge. It is designed to stress your knowledge about working with objects.
Patirck
@SomeRandom42
Jul 20 2016 03:45
what was the name of the .doescontain() I forgot the command, from the java script challenges
Joseph
@revisualize
Jul 20 2016 03:46
@SomeRandom42 I don't remember using .doesContain()
Nick Neuman
@neecholaus
Jul 20 2016 03:46

hey guys. i need help. how do i center the drop down menu? its shifting the whole site over every time it drops down or goes up and the buttons arent centered with the body.

http://codepen.io/neecholaus/pen/VjyVXX?editors=1100

Joseph
@revisualize
Jul 20 2016 03:47
@SomeRandom42 I can't find a js method that is .doesContain()
@fwiles I'd really suggest looking those lessons back over.
blob
Sandeep Gulati
@sandigul
Jul 20 2016 03:51
Hi
Fransisco Wiles
@fwiles
Jul 20 2016 03:51
I'll do that tomorrow morning. I'm tired and cranky now lol thanks a bunch for the help man!
Joseph
@revisualize
Jul 20 2016 03:54
@fwiles Take your time. Working with object is pretty important if you want to move into industry.
@sandigul Hi.
Vishal Bansal
@Vishal0024
Jul 20 2016 04:03
need help?

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

this code doesnt return property's value
waht ma i doing wrong?
bitgrower
@bitgrower
Jul 20 2016 04:06
@Vishal0024 -- do you understand the difference between using not and bracket notation with properties ?
Vishal Bansal
@Vishal0024
Jul 20 2016 04:07
yes
@bitgrower ..it worked with bracket notation
but i dont understand why it didnt work with dot notation
bitgrower
@bitgrower
Jul 20 2016 04:09
because you can't use dot notation with variables ... it's the rules...(of the language)
Vishal Bansal
@Vishal0024
Jul 20 2016 04:09
okay...i didnt know that..thank you @bitgrower ...:-)
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jul 20 2016 04:10
Ok guys, I solved the mutations problem
but there is some weird code that is working......and I have no clue how I got it to work
bitgrower
@bitgrower
Jul 20 2016 04:10
bracket notation is able to be used much more broadly, and dot notation, it has to be used with the actual property name (and, when you can't, because, say, the property name has a space in it, then you much use the bracket notaiton ...
where's @camperbot ?!?
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jul 20 2016 04:11
I don't want to post the code here since it has the full solution for it
anyone with enough experience care for a small private chat that would help me get through the part that I don't get?
bitgrower
@bitgrower
Jul 20 2016 04:11
wahhhh ... I want my brownie!!!!
thank you @camperbot
CamperBot
@camperbot
Jul 20 2016 04:12
bitgrower sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 2077 | @camperbot |http://www.freecodecamp.com/camperbot
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jul 20 2016 04:12
lmfao
now, any takers?
bitgrower
@bitgrower
Jul 20 2016 04:13
which challenge, @AleCx4
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jul 20 2016 04:13
@bitgrower 273: Mutations
help mutations
CamperBot
@camperbot
Jul 20 2016 04:13

:point_right: algorithm mutations [wiki]

Algorithm Mutations

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..

Relevant Links

:pencil: read more about algorithm mutations on the FCC Wiki

Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jul 20 2016 04:13
@bitgrower I solved the problem
but can't understand my implementation......you would be surprised how much that happens
bitgrower
@bitgrower
Jul 20 2016 04:14
LOL, why do you think I would be surprised ?!?
I can try ...
thanks for not posting your solution ...
James S.
@Mrblue27
Jul 20 2016 04:14
function testLogicalOr(val) {
  // Only change code below this line

  if (val > 10 || val < 20) {
    return "Inside";
  }

   {
    return "Outside";
  }

  // Only change code above this line
  return "Inside";
}

// Change this value to test
testLogicalOr(15);
Need help on returning the Outside along with the Inside for this scipt
bitgrower
@bitgrower
Jul 20 2016 04:15
is that an FCC challenge ?
@AleCx4 -- I hit you up ... or did someone beat me to it ?
This message was deleted
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jul 20 2016 04:19
@bitgrower just sent you a message back
bitgrower
@bitgrower
Jul 20 2016 04:19
@Mrblue27 if what you need to do is return inside if the number is BOTH greater than 10 and less than 20, then you need to use the AND logical operator: &&
try that instead of the || and see if that doesn't work for ya
Haylee Neal
@madmaverik
Jul 20 2016 04:22

I'm having issues with the card counting one and I would appreciate if anyone could let me know if I'm remotely on the right track?

'''

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 + 1;
break;
case 7:
case 8:
case 9:
count +0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count - 1;
break;
}
if (count < 0) {
return "Hold";
}
else (count >= 1){
return "Bet";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

'''

CamperBot
@camperbot
Jul 20 2016 04:22
:bulb: to format code use backticks! ``` more info
Duran Deari
@DuranDeari
Jul 20 2016 04:22
Does he need the return "Inside"; both on top and below the return "Outside;"? That seems odd.
scarejar
@scarejar
Jul 20 2016 04:22
Solved a problem but
I don't get why "var hn = Math.max.apply(Math,arr);" works. I know .apply binds the "this" keyword but what the hell is "Math"?
James S.
@Mrblue27
Jul 20 2016 04:22
@bitgrower however the task states to use the Or operator
Manish Giri
@Manish-Giri
Jul 20 2016 04:23
@scarejar it’s the Math object in JS
bitgrower
@bitgrower
Jul 20 2016 04:24
@Mrblue27 what is the name of the challenge, please ?
scarejar
@scarejar
Jul 20 2016 04:26
@Manish-Giri interesting....
James S.
@Mrblue27
Jul 20 2016 04:26
@bitgrower comparisons with the logical Or operator
scarejar
@scarejar
Jul 20 2016 04:26
think I need to review "this"
bitgrower
@bitgrower
Jul 20 2016 04:27

@madmaverik

these statements don't do anything:

count+1;
count+0;
count-1;

thanks ... I'll check it out ...
Duran Deari
@DuranDeari
Jul 20 2016 04:29
Not gonna lie, I'm really digging the else/else if features of JS.
bitgrower
@bitgrower
Jul 20 2016 04:30
@Mrblue27 ... okay ... as something called DeMorgan's theorem rings thru my brain ... :)
So -- here's the deal ... if you want to see if the value is outside of that range, how would you phrase it as an OR statement ...
what would have to be true ?
James S.
@Mrblue27
Jul 20 2016 04:35
@bitgrower if (val <10) { return "Outside"; } if (val > 20){
return "Inside"
}
bitgrower
@bitgrower
Jul 20 2016 04:36
wait ... isn't if the value is less than 10 or greater than 20 that it's outside ?
James S.
@Mrblue27
Jul 20 2016 04:38
@bitgrower I HAVE TRIED IT BOTH WAYS
bitgrower
@bitgrower
Jul 20 2016 04:39

@Mrblue27

if ( val < 10 || val > 20) { return outside; } <-- try that

James S.
@Mrblue27
Jul 20 2016 04:40
@bitgrower Sorry for the all caps. I tried that way as well
Colin
@breakpoint1025
Jul 20 2016 04:41
@revisualize Thanks~ I got it^_^
CamperBot
@camperbot
Jul 20 2016 04:41
breakpoint1025 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1448 | @revisualize |http://www.freecodecamp.com/revisualize
bitgrower
@bitgrower
Jul 20 2016 04:41
well, somewhere you didn't try it the way I did it, because that's how I did it, and it passed (but I did have to put in another line of code)
you can check it out on my profile and see ...
Duran Deari
@DuranDeari
Jul 20 2016 04:42
@Mrblue27 Did you make sure to do the proper format of return "Outside"; as well along with bitgrower's code?
Because technically what bitgrower posted is correct.
James S.
@Mrblue27
Jul 20 2016 04:42
@bitgrower I got it had to delete the second outside
bitgrower
@bitgrower
Jul 20 2016 04:42
good point ... I did screw up something there, didn't I ... dang details ...
James S.
@Mrblue27
Jul 20 2016 04:42
@bitgrower Thanks for your help
CamperBot
@camperbot
Jul 20 2016 04:42
mrblue27 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1144 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Jul 20 2016 04:43
YAYYYYYY!!!! Congrats, @Mrblue27 -- dang pesky details !!!
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jul 20 2016 04:43
@bitgrower hey man couldn't read the last message you sen't closed the conv on accident, thanks though!
CamperBot
@camperbot
Jul 20 2016 04:43
alecx4 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1145 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Jul 20 2016 04:43
yw -- gitter has a long memory ... :)
Duran Deari
@DuranDeari
Jul 20 2016 04:45
@bitgrower https://www.freecodecamp.com/challenges/golf-code Can you check that out for me please? I know what it's asking me to do in regards of the if/else if statements, but I'm confused on the naming I'm supposed to be using for the strokes/par stuff.
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jul 20 2016 04:45
@bitgrower didn't know that if we opened the chat it would still be there! aw man I think it would have been an interesting experience, this is what I would normally call an oddity in code, you def got the brain power for that
@bitgrower if I find out why I'll let you know haha
bitgrower
@bitgrower
Jul 20 2016 04:46
I'm not sure it will putt up your copy of golf-code, @DuranDeari -- the only code from someone else's account that is accessible is solutions ... code in progress is stored on your computer ...
@AleCx4 yeah, it's been a long day ... really long day. An online friend of mine (who I brought into FCC, in fact), took his life late last month, and today was the memorial service ...
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jul 20 2016 04:47
@bitgrower my condolences man
bitgrower
@bitgrower
Jul 20 2016 04:48
thanks. he was a super good guy ... he will be (heck, already is) missed ...
Duran Deari
@DuranDeari
Jul 20 2016 04:49
@bitgrower I'm not asking for a review of code or a straight-up answer per se, just an example of how you would go about doing the par/strokes functions in the if (stuffgoeshere) part.
The par/strokes and the index table is throwing me off.
bitgrower
@bitgrower
Jul 20 2016 04:50
help golf code
CamperBot
@camperbot
Jul 20 2016 04:50
no wiki entry for: golf code
bitgrower
@bitgrower
Jul 20 2016 04:50
bummer !
Duran Deari
@DuranDeari
Jul 20 2016 04:51
May have to go to the bug forum to look around, but I hate it cause I usually find the answer straight up posted there. :(
bitgrower
@bitgrower
Jul 20 2016 04:51
index table?
ah, in the instructions ...
basically you just need to check each value and depending on the results, either return a string, as appropriate, or do an "else if" to check the 'next' number in the table ... until you run out of numbers ... :)
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jul 20 2016 04:53
@bitgrower damn b, you gave me the feels. Hope you feel better about the loss of your friend soon
Subroto
@Shub1427
Jul 20 2016 04:54
myCar should have number values for the wheels, seats, and engines properties.
var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = wheels;
  this.seats = seats;
  this.engines = engines;
};

//Try it out here
var myCar;
Thai
@Thai56
Jul 20 2016 04:54
Hey guys i'm having a little trouble my for-in loop in this challenge :
In the "superSecret" function “spy” will be passed in as an object that represents a spy. Loop through all the properties on the spy object and change all values to the string “redacted”, then return the updated spy object.
This is what i have so far.....
var superSecret = function(spy){
var output = "" ;
for (var key in spy)
{
if (!spy.hasOwnProperty(spy))
{
output = key + spy[key];
// Code Here
}
return output ;
}
}
console.log(superSecret({"age":50,"name":"James Bond","id":"007"} ));
Any advice or suggestions will be greatly appreciated.
Subroto
@Shub1427
Jul 20 2016 04:54
what is wrong with my code
bitgrower
@bitgrower
Jul 20 2016 04:55
@AleCx4 Thanks -- I told Quincy about him, as well ... tis sad, for sure...
CamperBot
@camperbot
Jul 20 2016 04:55
bitgrower sends brownie points to @alecx4 :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @alecx4 |http://www.freecodecamp.com/alecx4
scarejar
@scarejar
Jul 20 2016 04:55
@Shub1427 call the function Car passing in parameters and assigning it to myCar
Thai
@Thai56
Jul 20 2016 04:55
i've done what ive could so but not sure what to use to replace the value in an object.
so far *
scarejar
@scarejar
Jul 20 2016 04:56
so myCar = Car(stuff, stuff, stuff);
Markus Kiili
@Masd925
Jul 20 2016 04:57
@Thai56 This seems wrong spy.hasOwnProperty(spy)
Subroto
@Shub1427
Jul 20 2016 04:57
thanx @scarejar
CamperBot
@camperbot
Jul 20 2016 04:57
shub1427 sends brownie points to @scarejar :sparkles: :thumbsup: :sparkles:
:cookie: 131 | @scarejar |http://www.freecodecamp.com/scarejar
scarejar
@scarejar
Jul 20 2016 04:58
@Shub1427 np.
Duran Deari
@DuranDeari
Jul 20 2016 05:01
@bitgrower I got some code put in if you wanna check it out again. Everything is good except the last three are showing incorrect for some reason.
Thai
@Thai56
Jul 20 2016 05:02
@Masd925
ok it seems to not show anything in the object when i put spy.hasOwnProperty(key)
Duran Deari
@DuranDeari
Jul 20 2016 05:02
@bitgrower Never mind, ignore that. I was stupid and forgot the return function. Woops
Markus Kiili
@Masd925
Jul 20 2016 05:02
@Thai56 Do you need a hasOwnPropererty check at all?
bitgrower @bitgrower looks innnocently around and says ... "me? Me? No, I'd NEVER do something silly like forget a return...no, not me, never... " :)
Markus Kiili
@Masd925
Jul 20 2016 05:03
@Thai56 Just the loop and spy[key]=...
You should return the object at the end I think.
Thai
@Thai56
Jul 20 2016 05:05
no i dont think it need the hasOwnProperty
Lee
@leebut
Jul 20 2016 05:06
@bitgrower Sorry to read about your friend. Very sad.
Andrew Rowe
@andrewrowe
Jul 20 2016 05:11
blob
Hey guys this code is passing 2 out of 3 tests, but I can't figure out why it's not passing the third... Any ideas?
Markus Kiili
@Masd925
Jul 20 2016 05:12
@andrewrowe Initialize the number for each subarray.
Thai
@Thai56
Jul 20 2016 05:12
@Masd925
any idea how to replace a value in the object?
Markus Kiili
@Masd925
Jul 20 2016 05:12
@Thai56 obj[key]=value;
Andrew Rowe
@andrewrowe
Jul 20 2016 05:15
@Masd925 What do you mean by that?
Lee
@leebut
Jul 20 2016 05:15
@madmaverik Have you got it working now?
With those counters, the counts are equal to what they are now + or - the new value. If there is no change the count is equal to its current count.
In your conditions at the end, you also need to include the count in your output, and check the syntax of that final 'else'. You have set up another if condition().
I hope I'm right with that.
Andrew Rowe
@andrewrowe
Jul 20 2016 05:15
@Masd925 Oooh, nevermind. I think I got you
@Masd925 Thanks!
CamperBot
@camperbot
Jul 20 2016 05:16
andrewrowe sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2169 | @masd925 |http://www.freecodecamp.com/masd925
Lee
@leebut
Jul 20 2016 05:18
Hello Folks! I'm working through the 'Title Case a Sentence' challenge. At the moment, the var currPos does count the letters in each word and resets to 0 at a space, but it makes the whole string uppercase when currPos=1, not just the first letter. And when currPos > 1 the whole string is lowercase. I think I'm almost there, but something is missing or wrong in my conditionals. If someone could point out where the error is, I'll try to work it out. Thank you.
function titleCase(str) {

    var string = str;
// iterate the string
     var currPos = 0;
     var len = string.length;

 for (i = 0; i < len; i++)
     {
         if(string[i] == " ")
         {
            currPos = 0; 
         }
            else 
            {
                currPos++;
            }
           if(currPos == 1)
                {
                string = string.toUpperCase();
                } else if(currPos > 1)
                    {
                    string = string.toLowerCase();
                    }

                console.log(currPos);
               console.log(string);
     }

}

titleCase("i'm a little tea pot");
scarejar
@scarejar
Jul 20 2016 05:19
how do I apply the str[0].toUpperCase(); to an array because it doesnt apply the changes >_>
when I try to print the string again, it will revert back to a lowercase...
guessing I need to store the value ?
Mariya
@mariyadiminsky
Jul 20 2016 05:20
This message was deleted
scarejar
@scarejar
Jul 20 2016 05:22
@leebut lol, we're stuck on the same problem..
Blauelf
@Blauelf
Jul 20 2016 05:23
@leebut You uppercase/lowercase the whole string, you could use something like string = string.slice(0, i) + string.charAt(i).toUpperCase() + string.slice(i+1);
Lee
@leebut
Jul 20 2016 05:23
@scarejar I'm not using an array, though.
scarejar
@scarejar
Jul 20 2016 05:23
@leebut me neither , but a string is an array itself
Patrick McCaffrey
@musedivision
Jul 20 2016 05:24
@scarejar yeah, .toUpperCase() returns the value. so you have to strore in an array
Blauelf
@Blauelf
Jul 20 2016 05:24
string is a string, which is array-like, but for example immutable.
scarejar
@scarejar
Jul 20 2016 05:24
var a = "hello" ; a[0] will equal "h"
Lee
@leebut
Jul 20 2016 05:24
@scarejar I get your point.
Magnus Holm
@mghlm
Jul 20 2016 05:25
Quick question: Is there a version of splice that works like slice where you put a start and a finish and then deletes the elements in between?
Lee
@leebut
Jul 20 2016 05:25
@Blauelf Ah, something new there. I'll give it a go. I'll also research charAt so I know what it's doing.
@Blauelf Thank you for the pointer.
CamperBot
@camperbot
Jul 20 2016 05:26
leebut sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2226 | @blauelf |http://www.freecodecamp.com/blauelf
scarejar
@scarejar
Jul 20 2016 05:27
@Blauelf wait, a string[0] cannot be changed?
Blauelf
@Blauelf
Jul 20 2016 05:27
@leebut charAt is about the same as [] on strings, with different edge cases only when the index is out of bounds (you don't need to use it here, as you have only valid indices)
@scarejar Strings are immutable, yes.
scarejar
@scarejar
Jul 20 2016 05:27
@Blauelf that explains a lot...
Blauelf
@Blauelf
Jul 20 2016 05:29
@scarejar You can replace a whole string in a variable, but not change the string itself.
bitgrower
@bitgrower
Jul 20 2016 05:30
@leebut thanks, appreciate it. :)
CamperBot
@camperbot
Jul 20 2016 05:30
bitgrower sends brownie points to @leebut :sparkles: :thumbsup: :sparkles:
:cookie: 259 | @leebut |http://www.freecodecamp.com/leebut
Patrick McCaffrey
@musedivision
Jul 20 2016 05:30
@leebut are you splitting up the string? looks like you might want to try split it into an array and maybe even each word! str.split() will help (+ arr.join() :)
)
eliza khachatryan
@Elijbet
Jul 20 2016 05:30
can you guys tell me if there is a method I can use instead of shift, that will let me purge first couple of elements at once?
function chunkArrayInGroups(arr, size) {
  var array = [];
  var numOfTimes = Math.ceil(arr.length/size); 


  for(i=0; i<numOfTimes; ++i) {
  var arrSlice = arr.slice(0, size);
  array.push(arrSlice);


  arr.shift(arrSlice);

  }
  // Break it up.
  return array;
}

chunkArrayInGroups(["a", "b", "c", "d", "e", "f", "g"], 2);
Thai
@Thai56
Jul 20 2016 05:31
@Masd925
I'm new to the concept of objects.
var superSecret = function(spy){
var output = "" ;
for (var key in spy){
output = key + spy[key];
// Code Here
var redacted = spy[key]["redacted"];
return output ;
}
return redacted;
}
console.log(superSecret({"age":50,"name":"James Bond","id":"007"} ));
eliza khachatryan
@Elijbet
Jul 20 2016 05:31
basically shift won't do what I'm trying to do, I sliced the first 2 elements into an array and put it into a variable, now I need it out of the old array at once,
I don't want to loop the arr.shift
Markus Kiili
@Masd925
Jul 20 2016 05:31
@Thai56 Maybe forget output and just do spy[key]="redacted"; and return spy at the end.
Patrick McCaffrey
@musedivision
Jul 20 2016 05:32
@Elijbet check out str.slice. it cuts out specified section and returns it
str.slice(beginSlice[, endSlice])
Blauelf
@Blauelf
Jul 20 2016 05:33
@Elijbet You could use splice instead of slice if you want to mutate the array. Or use slice with varying indices (i*size and (i+1)*size) and don't shift/splice at all.
eliza khachatryan
@Elijbet
Jul 20 2016 05:33
@musedivision thanks patrick I used that, but I need the initial array to loose that slice
CamperBot
@camperbot
Jul 20 2016 05:33
elijbet sends brownie points to @musedivision :sparkles: :thumbsup: :sparkles:
:cookie: 293 | @musedivision |http://www.freecodecamp.com/musedivision
eliza khachatryan
@Elijbet
Jul 20 2016 05:33
ok let me check splice
Blauelf
@Blauelf
Jul 20 2016 05:34
@Elijbet Please note that splice just like shift mutates the array, and that's the very same object the calling code passed to your function. Depending on your function specification, the calling code might not expect that.
smile
@mytreasures
Jul 20 2016 05:36
blob
eliza khachatryan
@Elijbet
Jul 20 2016 05:36
@Blauelf cool this looks like what I was looking for :)
smile
@mytreasures
Jul 20 2016 05:36
Should be how to return property rather than the property value
eliza khachatryan
@Elijbet
Jul 20 2016 05:36
@Blauelf how come this thing didn't give you thumbs up and cookies?
Blauelf
@Blauelf
Jul 20 2016 05:37
@Elijbet You can find several chunky monkey implementations on my profile.
eliza khachatryan
@Elijbet
Jul 20 2016 05:37
:) I cracked the thank you code with no pom-poms
@Blauelf coolio, can I add you to my pm list?
Blauelf
@Blauelf
Jul 20 2016 05:38
@mytreasures playerNumber should be the number, and on the next line be used as a property name/key to testObj.
scarejar
@scarejar
Jul 20 2016 05:42
@leebut did you solve it?
Patrick McCaffrey
@musedivision
Jul 20 2016 05:43
anyone have tips for converting binary to unicode ??
//I get these characters when i use
String.fromCharCode() with binary strings (eg. "01000001")
䘩", "", "", ""
scarejar
@scarejar
Jul 20 2016 05:44
@musedivision lol, no idea...
Blauelf
@Blauelf
Jul 20 2016 05:45
@musedivision Have you already used parseInt with its optional second parameter? If not, you should try it!
Lee
@leebut
Jul 20 2016 05:46
@scarejar Almost. Dealing with the second string now to make all other values lowercase.
@musedivision Not sure it this will help: http://stackoverflow.com/questions/10319415/unicode-to-binary
Thai
@Thai56
Jul 20 2016 05:47
thanks @Masd925
CamperBot
@camperbot
Jul 20 2016 05:47
thai56 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2170 | @masd925 |http://www.freecodecamp.com/masd925
Jaren Escueta
@jarenescueta731
Jul 20 2016 05:49
@musedivision check out converting strings into numbers using Number()
John Irle
@JohnIrle
Jul 20 2016 05:49
I need help changing the color of text displayed in an input if a number is over or under 0. can someone help me?
$(document).ready(function(){
    $('#time').on('change', function() {
        calculateFinance();
    });

    $('#cost').on('change', function() {
        calculateFinance();
    });

    $('#drive').on('input', function(){
      calculateTime();
    });

    $('#times').on('input', function(){
      calculateTime();
    });

  function calculateFinance() {
      var $cost = $('#cost').val();
      var $time = $('#time').val();
      var costResult = $cost * $time * 12;
      var firstsavings = costResult - 3090;
      var secondsavings = costResult - 480;


      $('#timeNum').val($time);
      $('#costResult').val("$" + costResult);
      $('#firstsavings').val("$" + firstsavings);
      $('#secondsavings').val("$" + secondsavings);

      if ($(':text').val().toNumber() < 0 ) {
        $(':text').css('color', 'red');
      }
  }

  function calculateTime() {
     var $drive = $('#drive').val();
     var $time = $('#time').val();
     var trip = $drive * $time * 2;
     var year = trip * 12;
     var hours = year / 60;


     $('#timeResult').val(hours + ' hours.');

  }
});
Faisal Zulfiqar
@faisal1337
Jul 20 2016 05:50
I can't embed the twitter button in my 'Random Quote Machine' page. Please guide me anyone?
Kevin
@KevinBruland
Jul 20 2016 05:50
@JohnIrle whivh cal?
@JohnIrle *val
Jaren Escueta
@jarenescueta731
Jul 20 2016 05:50
@musedivision you can convert binary numbers in string format into integers
Thai
@Thai56
Jul 20 2016 05:50
@Masd925
did you learn javascript or to program from anywhere else ?
John Irle
@JohnIrle
Jul 20 2016 05:51
@Benalron Well I was just kind of shot gun approaching just to see if I could do it
Lee
@leebut
Jul 20 2016 05:52
@scarejar Done it, which some wonderful input from @Blauelf, thank you. How about you?
CamperBot
@camperbot
Jul 20 2016 05:52
leebut sends brownie points to @scarejar and @blauelf :sparkles: :thumbsup: :sparkles:
:warning: leebut already gave blauelf points
:cookie: 132 | @scarejar |http://www.freecodecamp.com/scarejar
Kevin
@KevinBruland
Jul 20 2016 05:52
@JohnIrle if you can do an if statement in the val changing, if($(this).val() > num){ $(theInput).css(color: yellow);}
thats not the correct syntax, just the concept
need some quotes in there
John Irle
@JohnIrle
Jul 20 2016 05:53
So I should use "this"?
scarejar
@scarejar
Jul 20 2016 05:53
@leebut lol, still stuck >_>
Kevin
@KevinBruland
Jul 20 2016 05:53
or the ID, in this case it doesnt matter
if you have this on a page I can fork it and put it together really quick if you want
Markus Kiili
@Masd925
Jul 20 2016 05:54
@Thai56 I did a bachelors degree on IT, but it didn't have much to do with JS. Programming stuff there mostly using java+sql. JS I have learned on my own.
Kevin
@KevinBruland
Jul 20 2016 05:55
@JohnIrle which one do you want changed for an example, and at what value?
Thai
@Thai56
Jul 20 2016 05:55
Ok. What other sources did you use for J.S.?
@Masd925
if there were any?
Markus Kiili
@Masd925
Jul 20 2016 05:56
@Thai56 MDN and "Speaking javascript" book and this chat mainly.
Faisal Zulfiqar
@faisal1337
Jul 20 2016 05:57
@Benalron can you help me with embedding the twitter button?
Olly Sholotan
@Ollysho
Jul 20 2016 05:58
Caesars Cipher is kicking my butt this is hilarious
John Irle
@JohnIrle
Jul 20 2016 05:58
@Benalron It should be red if a number is negative and green if it's positive. I think the cost result and the time result
@JohnIrle I did it for first savings
@faisal1337 for the quote project?
John Irle
@JohnIrle
Jul 20 2016 06:01
@Benalron Damn that was easy. Thanks.
CamperBot
@camperbot
Jul 20 2016 06:01
johnirle sends brownie points to @benalron :sparkles: :thumbsup: :sparkles:
:cookie: 404 | @benalron |http://www.freecodecamp.com/benalron
Thai
@Thai56
Jul 20 2016 06:02
@Masd925
what resource would you suggest for learning programming as a beginner. I did see that "Speaking Javascript" was written for programmers. Maybe something Object oriented? maybe something else?
Kevin
@KevinBruland
Jul 20 2016 06:02
@JohnIrle yeah, it's pretty straight forward and literal. Good luck :)
Faisal Zulfiqar
@faisal1337
Jul 20 2016 06:02
@Benalron Yes.
Its been 2 days.
I cannot embed the button.
Kevin
@KevinBruland
Jul 20 2016 06:03
@faisal1337 can I see what you have?
Lee
@leebut
Jul 20 2016 06:03
@scarejar Check PM.
Faisal Zulfiqar
@faisal1337
Jul 20 2016 06:03
Manikanth
@manikanth1024
Jul 20 2016 06:03
Does anybody know how to crop an image?
Kevin
@KevinBruland
Jul 20 2016 06:04
@faisal1337 OK, so you are manually making one?
Faisal Zulfiqar
@faisal1337
Jul 20 2016 06:04
@Benalron on twitter dev website they want us to change the href="" attrib to share it to twitter.
<a class="twitter-share-button" href="https://twitter.com/intent/tweet"> Tweet</a>\
<a class="twitter-share-button"
  href="https://twitter.com/intent/tweet">
Tweet</a>
Kevin
@KevinBruland
Jul 20 2016 06:04
@faisal1337 theres a bunch of ways to do it
Faisal Zulfiqar
@faisal1337
Jul 20 2016 06:04
I want to change its href attrib with JS. But I don't know how to select it.
Tell me.
Markus Kiili
@Masd925
Jul 20 2016 06:04
@Thai56 Don't know any good books for that use. Pick a language and try to look for a good tutorial or intro level book.
Claudio Restifo
@Marmiz
Jul 20 2016 06:04
@Ollysho stuck on that challenge?
Kevin
@KevinBruland
Jul 20 2016 06:05
@faisal1337 my first advice would be to make it a button rather than just an <a>
Faisal Zulfiqar
@faisal1337
Jul 20 2016 06:05
Lemme.
Liam Bang
@Liam345
Jul 20 2016 06:05

var collection = { "2468": { "album": "1999", "artist": "Prince", "tracks": [ "1999", "Little Red Corvette" ] }};

How can I check whether 'artist' property exists in the collection object or not?

Manikanth
@manikanth1024
Jul 20 2016 06:05
I have a code could u explain wat it is?

//$('#jcrop_target').Jcrop({
onChange: showPreview,
onSelect: showPreview,
aspectRatio: 1
});
*/

});
function showPreview(coords)
{
var rx = 100 / coords.w;
var ry = 100 / coords.h;

$('#preview').css({
    width: Math.round(rx * 500) + 'px',
    height: Math.round(ry * 370) + 'px',
    marginLeft: '-' + Math.round(rx * coords.x) + 'px',
    marginTop: '-' + Math.round(ry * coords.y) + 'px'
});//
Markus Kiili
@Masd925
Jul 20 2016 06:06
@Liam345 if(collection[id].hasOwnProperty("artist"))
Faisal Zulfiqar
@faisal1337
Jul 20 2016 06:06
@Benalron check now. I've made the button.
Claudio Restifo
@Marmiz
Jul 20 2016 06:07
@manikanth1024 what you need to know?
Kevin
@KevinBruland
Jul 20 2016 06:08
@faisal1337 sending a direct message to go over it
Manikanth
@manikanth1024
Jul 20 2016 06:08
i want to know about dat code man@Claudio
Olly Sholotan
@Ollysho
Jul 20 2016 06:08
@Marmiz Not stuck particularly just sort of wondering how to start, I'm hammering at it though so I should get it soon maybe :D
Claudio Restifo
@Marmiz
Jul 20 2016 06:10

@manikanth1024 Using a Javascript function to make the #preview object appear in a different position according to different size of the screen.

basically instead of giving it a fixed size, it's telling it to change the element accordingly to the ratio.

Manikanth
@manikanth1024
Jul 20 2016 06:11
ok thank u
but i want to crop the image now so what do i do now?
Claudio Restifo
@Marmiz
Jul 20 2016 06:12
@Ollysho You can do it! and we're here to help!!! :)
@manikanth1024 2 things:
1- why are you dealing with a code you cannot understand? That's not really wise :)
2- some context? If it's a project provide the link or the full code of the rest of the elemnts :)
Manikanth
@manikanth1024
Jul 20 2016 06:14
its actually a project provided code
Hemant Bhankhar
@hbnker31
Jul 20 2016 06:14
hi, I am unable to understand this problem
https://www.freecodecamp.com/challenges/understanding-boolean-values
pls help
Manikanth
@manikanth1024
Jul 20 2016 06:16
<div class="form-group">

<label class="col-md-3 control-label profle" for=" ">Profile Picture</label>

<div class="col-md-6">

<input type="file" id=" " name="image" class="">


</div>
                        <?php if(!empty($doctor_image)){?>

       //                  <div class="form-group crop">

                             <div class="col-md-10">

                                <img src="<?php echo Yii::app()->request->baseUrl;?>/doctors_photo/<?php echo 'small'.$doctor_image;?>">

                             </div>
                         </div>

                        <?php } ?>

                   </div> //
this is the code snippet for a picture to insert
shubham
@shubham920
Jul 20 2016 06:16
hlo world I m shubham Bhardwaj
David Shin
@datadaveshin
Jul 20 2016 06:17
Hello @shubham920
Olly Sholotan
@Ollysho
Jul 20 2016 06:19
Hey is anything wrong with my for loop? It says words[i] is undefined

function rot13(str) { // LBH QVQ VG!
  var words = str.split(' ');

  for (var i = 0; i < str.length; i++) {
    for (var j = 0; j < str[i].length; j++) {
      words[i][j].charCodeAt();
    }
  }

  return words;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
shubham
@shubham920
Jul 20 2016 06:19
hlo bro
I m make a android aap tell me hoe yo make and hlp me
David Shin
@datadaveshin
Jul 20 2016 06:20
Exactly what don’t you understand @hbnker31 ?
Markus Kiili
@Masd925
Jul 20 2016 06:20
@Ollysho You need to split into array of characters, not words. Looping words just makes extra code.
Claudio Restifo
@Marmiz
Jul 20 2016 06:20
@manikanth1024 I don't recall that challenge.
What's the name / link .. so I can look at the request and try to help you better
shubham
@shubham920
Jul 20 2016 06:21
make aap for students for partise for govt job
Hemant Bhankhar
@hbnker31
Jul 20 2016 06:21
how am i supposed to write code for button click?
Manikanth
@manikanth1024
Jul 20 2016 06:21
ok
shubham
@shubham920
Jul 20 2016 06:21
he include test
Olly Sholotan
@Ollysho
Jul 20 2016 06:21
@Masd925 to the rescue again :') I'll play around with that. Thank you man
CamperBot
@camperbot
Jul 20 2016 06:21
ollysho sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2171 | @masd925 |http://www.freecodecamp.com/masd925
Hemant Bhankhar
@hbnker31
Jul 20 2016 06:22
got it
David Shin
@datadaveshin
Jul 20 2016 06:23
@hbnker31 - change the code in the black box on the right of the window…
@hbnker31 - then click the "Run tests (ctrl + enter)" button
Claudio Restifo
@Marmiz
Jul 20 2016 06:27

@manikanth1024 I am really confused about what you need?
And than you link me a website.
Some more context?

Sorry but I seriously have no idea. PM me if you think the explanation is too long.
Sorry 'bout that. <3

Olly Sholotan
@Ollysho
Jul 20 2016 06:29
Hey @Masd925 could you let me know why my second if statement doesn't seem to be running?

function rot13(str) { // LBH QVQ VG!
  str = str.split('');

  for (var i = 0; i < str.length; i++) {
    if (str[i].length === 1 && str[i].match(/[a-z]/i)) {
      str[i] = str[i].charCodeAt();
      if (str[i].length === 1 && str[i].match(/[a-z]/i)) {
              str[i] = str[i] + 13;
      }
    }

  }

  return str;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
alf
@alfmoh
Jul 20 2016 06:30

Hello, please what's the error in my code.

// 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 = 0;

this.setGear = function(change){
gear += change;
};

this.getGear = function(){
return gear;
};

};

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(1);
myBike.getGear();

Markus Kiili
@Masd925
Jul 20 2016 06:30
@Ollysho Try to use more descriptive variable names. str is not a good name for an array. var arr = str.split(""); for example.
Varun Sharma
@varun29
Jul 20 2016 06:30
please help
Olly Sholotan
@Ollysho
Jul 20 2016 06:31
@Masd925 I would imagine that makes my code easier to read, will do!
alf
@alfmoh
Jul 20 2016 06:31

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 = 0;

this.setGear = function(change){
gear += change;
};

this.getGear = function(){
return gear;
};

};

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(1);
myBike.getGear();

can't seem to find the error
Markus Kiili
@Masd925
Jul 20 2016 06:31
@Ollysho Yes, and helps to spot errors.
Varun Sharma
@varun29
Jul 20 2016 06:32
 function mutation(arr) {
 var main=arr[0].toLowerCase().split('');
  var match=arr[1].toLowerCase().split('');
 // return match.length;
 for(var i=0;i<match.length;i++){
  if( main.indexOf(match[i])===-1){
    return "false";}
   else{
     flag=1;
   }

 }
  if(flag===1){
    return "true";
  }


}
mutation(["Mary","Aarmy"]);
Olly Sholotan
@Ollysho
Jul 20 2016 06:32
Okay... here's the new code @Masd925

function rot13(str) { // LBH QVQ VG!
  var cypher = str.split('');

  for (var i = 0; i < cypher.length; i++) {
    if (cypher[i].length === 1 && cypher[i].match(/[a-z]/i)) {
      cypher[i] = cypher[i].charCodeAt();
      if (cypher[i].length === 1 && cypher[i].match(/[a-z]/i)) {
        cypher[i] = cypher[i] + 13;
      }
    }

  }

  return cypher;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Varun Sharma
@varun29
Jul 20 2016 06:33
the output is correct...but none of the checkbox are getting corrected
Markus Kiili
@Masd925
Jul 20 2016 06:33
@Ollysho Isn't cypher[i].length === 1 always true?
Olly Sholotan
@Ollysho
Jul 20 2016 06:34
@Masd925 do spaces count as length? I'm trying to change just the letters but keep the spaces existing
Markus Kiili
@Masd925
Jul 20 2016 06:34
@Ollysho Spaces are like " " so they have length 1 too. Space is also a character.
Olly Sholotan
@Ollysho
Jul 20 2016 06:34
@Masd925 Oh wait, I don't need another if statement, I just need to put the following code in there. Brain fart. Figured it out. Thanks though haha
CamperBot
@camperbot
Jul 20 2016 06:34
ollysho sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: ollysho already gave masd925 points
Manikanth
@manikanth1024
Jul 20 2016 06:34
Hey cluadio are you there?
Olly Sholotan
@Ollysho
Jul 20 2016 06:35
@Masd925 You're just a great presence to have :P You're like my javascript uncle that I can talk through problems with lol
Markus Kiili
@Masd925
Jul 20 2016 06:35
@Ollysho :)
tremenm
@tremenm
Jul 20 2016 06:36
hi guys,i need a help~
alf
@alfmoh
Jul 20 2016 06:36
@Masd925 please can you help with my code
tremenm
@tremenm
Jul 20 2016 06:36

// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;

alf
@alfmoh
Jul 20 2016 06:36

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 = 0;

this.setGear = function(change){
gear += change;
};

this.getGear = function(){
return gear;
};

};

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(1);
myBike.getGear();

tremenm
@tremenm
Jul 20 2016 06:36
Instructions
Modify the existing declarations and assignments so their names use camelCase.
Do not create any new variables.
how can i use camelCase to modify the declarations?
Olly Sholotan
@Ollysho
Jul 20 2016 06:37
@tremenm You just need to change the ariables so that the second "word" starts with a capital letter
@tremenm Like in the editor just change them it's not a formula or anything
Markus Kiili
@Masd925
Jul 20 2016 06:37
@alfmoh Assign, don't increment on setGear.
tremenm
@tremenm
Jul 20 2016 06:38
@Ollysho Instructions
Modify the existing declarations and assignments so their names use camelCase.
Do not create any new variables.
alf
@alfmoh
Jul 20 2016 06:38
Wow, Interesting. It worked. Thanks @Masd925
CamperBot
@camperbot
Jul 20 2016 06:38
alfmoh sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2172 | @masd925 |http://www.freecodecamp.com/masd925
tremenm
@tremenm
Jul 20 2016 06:38
but it says new variables is not allowed
was there sth i misunderstood?
Olly Sholotan
@Ollysho
Jul 20 2016 06:41
@tremenm Yeah it just means don't create new variables, just edit the names of the current ones. It's a weirdly written exercise
Markus Kiili
@Masd925
Jul 20 2016 06:42
@tremenm Descriptions can be confusing but they are getting better all the time when people submit issues about them.
tremenm
@tremenm
Jul 20 2016 06:44
@Ollysho thanks for your help!i just passed the quiz~
CamperBot
@camperbot
Jul 20 2016 06:44
tremenm sends brownie points to @ollysho :sparkles: :thumbsup: :sparkles:
:cookie: 261 | @ollysho |http://www.freecodecamp.com/ollysho
Andrew Kay
@andrewjkay
Jul 20 2016 06:52
I'm stuck on the Stand in Line exercise. Is this the first time queue and data structures are discussed? seems sparse to me
Markus Kiili
@Masd925
Jul 20 2016 06:55
@andrewjkay You just need to find two array methods that do those things and use them on arr and item.
Andrew Kay
@andrewjkay
Jul 20 2016 06:57
@Masd925 I'm unsure of how to return an element that i've physically deleted from the memory, how would it even know that? the only thing i
I can think of is to write a function that just subtracts 1 from the first item in the array, but of course the test isn't accepting that
Markus Kiili
@Masd925
Jul 20 2016 06:58
@andrewjkay There is a method that does that and also returns the removed element.
scarejar
@scarejar
Jul 20 2016 06:58

Stuck on "Title Case Sentence"

function titleCase(str) {

    var string = str;
// iterate the string
     var currPos = 0;
     var len = string.length;

 for (var i = 0; i < len; i++)
     {
         if(string[i] == " ")
         {
            currPos = 0; 
         }
            else{
                currPos = 1;
            }
          if(currPos == 1){
string = string.slice(0, i) + string.charAt(i).toUpperCase() + string.slice(i+1);}
 else if(currPos != 1) {
                    string = string.slice(0, i) + string.charAt(i).toLowerCase() + string.slice(i+1);
                    }

                console.log(currPos);
               console.log(string);
     }

}

titleCase("i'm a little tea pot");

How do I get it so that the "string.charAt(i).toUpperCase , only uppercases the first letter of a string rather than all of it slowly?

Andrew Kay
@andrewjkay
Jul 20 2016 06:58
@Masd925 do I need to remove the element from the function myself, or does my code need to do that?
Markus Kiili
@Masd925
Jul 20 2016 06:59
@andrewjkay You need to operate on the function parameters that hold the passed arguments.
In other words, you use the function input and produce output.
Andrew Kay
@andrewjkay
Jul 20 2016 07:00
I should know what that means, but I don't. Thanks anyway.
Markus Kiili
@Masd925
Jul 20 2016 07:00
@andrewjkay Inside the function, you need to operate on an array arr.
Andrew Kay
@andrewjkay
Jul 20 2016 07:01
I'm giving up on this for now, gonna go find more videos or something. I can't be the only one frustrated at how skeletal this JS course is. I feel like I may as well just read the documentation. I appreciate you trying to help me though, thanks.
Markus Kiili
@Masd925
Jul 20 2016 07:02
@andrewjkay These exercises are not meant to teach basics of programming. You should read some book or tutorial first.
Lee
@leebut
Jul 20 2016 07:10
@shubham920 I think you need Android Developer Tools to do that.
You could try here: http://www.codeproject.com/Learn/Android/ or here: https://developer.android.com/training/index.html
scarejar
@scarejar
Jul 20 2016 07:11
12 already .-.
BenjaminAct
@BenjaminAct
Jul 20 2016 07:17

// Setup
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (prop !== "tracks" && value !== "") {
collection[id][prop] = value;
} else if (prop === "tracks" && value !== "") {
collection[id][prop].push(value);
} else if (value === "") {
delete collection[id][prop];
} else if (prop === "tracks" && value === "") {
collection[id][prop] = Array;
}

return collection;
}

// Alter values below to test your code
updateRecords(5439, "tracks", "Take a Chance on Me");

I need help for this "If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array."

oops sorry how to i paste the code page?
Markus Kiili
@Masd925
Jul 20 2016 07:18
explain format
CamperBot
@camperbot
Jul 20 2016 07:18

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Magnus Holm
@mghlm
Jul 20 2016 07:18
I’m stuck on an assignment. I have an array with two string elements, and I need to check if the letters of the second element is also in the first. I am going to use indexOf method, but I have a hard time figuring out how to do that. I have written this code so far:
Olly Sholotan
@Ollysho
Jul 20 2016 07:18
@Masd925 you're literally god
Magnus Holm
@mghlm
Jul 20 2016 07:18
This message was deleted
Markus Kiili
@Masd925
Jul 20 2016 07:19
@Ollysho Stop eating mushroom you don't know ;)
Magnus Holm
@mghlm
Jul 20 2016 07:19

function mutation(arr) {

  var newArr = [];

  for(i=0; i<arr.length; i++) {
    newArr.push(arr[i].toLowerCase());

  }

   for(var i=0; i<newArr.length; i++) {
     if(newArr[0][i].indexOf(newArr[1])) {

     }
  }  
return newArr;

}

mutation(["Hello", "hello"]);
Markus Kiili
@Masd925
Jul 20 2016 07:20
@m4gnusholm You don't need arrays. You should loop second string characters and check them with indexOf.
First you should pick the strings into variables and lowercase them. (You can use them from arr, but don't make new arrays).
Magnus Holm
@mghlm
Jul 20 2016 07:22
@Masd925 Ok. My first loop makes them lowercase. So, make each of them into variables, then run a for loop on the second checking all characters with indexOf ?
Markus Kiili
@Masd925
Jul 20 2016 07:22
Yes, loop second string characters.
Magnus Holm
@mghlm
Jul 20 2016 07:22
@Masd925 Ok I’ll try
Olly Sholotan
@Ollysho
Jul 20 2016 07:23
@Masd925 So... I think I'm usding fromCharCode wrong but please have a look

function rot13(str) { // LBH QVQ VG!
  var cypher = str.split('');

  for (var i = 0; i < cypher.length; i++) {
    if (cypher[i].length === 1 && cypher[i].match(/[a-z]/i)) {
      cypher[i] = cypher[i].charCodeAt() + 13;
      cypher[i] = String.fromCharCode(i);
    }

  }

  return cypher;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Once I get this challenge done I'm off to using Api's I'm so excited
Markus Kiili
@Masd925
Jul 20 2016 07:25
@Ollysho Just +13 is not enough. The result needs to stay in A-Z range.
Magnus Holm
@mghlm
Jul 20 2016 07:26
@Masd925 something like this?
  var string1 = arr[0];
  var string2 = arr[1];

  for (var i=0; i<string2.length; i++) {
    string2[i].indexOf(string1);
  }