These are chat archives for FreeCodeCamp/HelpJavaScript

13th
Jan 2017
Phil Seidel
@psbyron3
Jan 13 2017 00:00
There's no testArr, unless you establish one. You want these methods to interact with the input array. IN THIS CASE, it is called 'arr'
@Austiclyse bookmark MDN, it has documentation for everything, with examples
Phil Seidel
@psbyron3
Jan 13 2017 00:01
@Austiclyse @DanCouper just provided a great resource for more info on these two methods. MDN (Mozilla Developer Network)i s going to become one of your best friends
@Austiclyse But back to the task at hand. Are you understanding more clearly what you need to do?
Dan Couper
@DanCouper
Jan 13 2017 00:02
If you've got something like push, and you don't quite know how it works, Google "mdn push" and it'll be the first result
Tam Nguyen
@bankplank
Jan 13 2017 00:02
Can someone tell me why this is not fetching the JSON data from the Wiki Api?
Austiclyse
@Austiclyse
Jan 13 2017 00:02
Okay, so I "point" the .push at the parameter of the function called. That's what I was needing. Thank you. @psbyron3
CamperBot
@camperbot
Jan 13 2017 00:02
austiclyse sends brownie points to @psbyron3 :sparkles: :thumbsup: :sparkles:
:cookie: 30 | @psbyron3 |http://www.freecodecamp.com/psbyron3
Dan Couper
@DanCouper
Jan 13 2017 00:02
(and ask here, but look there first(
Tam Nguyen
@bankplank
Jan 13 2017 00:02
'''
CamperBot
@camperbot
Jan 13 2017 00:02
:bulb: to format code use backticks! ``` more info
Tam Nguyen
@bankplank
Jan 13 2017 00:03
$(document).ready(function() {
  //Take input from search form and build wiki api url
  $('form').submit(function() {
    var searchString = $('#searchBox').val().replace(/ /g, '+');
    var wikiApiUrl = "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=" + searchString + "&callback=?";
    console.log(wikiApiUrl);
  // Get JSON Data
    $.getJSON(wikiApiUrl, function(data){
      console.log(data);
     })
  })
})
Phil Seidel
@psbyron3
Jan 13 2017 00:03
In this case yes. You use .push() to whatever collection(array) you need to add an input to
@Austiclyse
Stephen James
@sjames1958gm
Jan 13 2017 00:03
@bankplank likely it is CORS issue - do you see errors in your browser console?
Phil Seidel
@psbyron3
Jan 13 2017 00:03
@bankplank Are you getting an error code?
Tam Nguyen
@bankplank
Jan 13 2017 00:03
Im running it through codepen
Dan Couper
@DanCouper
Jan 13 2017 00:04
@bankplank what is it putting into the console?
Stephen James
@sjames1958gm
Jan 13 2017 00:04
@bankplank Check your browser console.
Phil Seidel
@psbyron3
Jan 13 2017 00:04
Have you opened up your console in dev tools?
Jason Luboff
@JLuboff
Jan 13 2017 00:04
@bankplank http://codepen.io/... or https://codepen.io/....
Dan Couper
@DanCouper
Jan 13 2017 00:04
Codependen also has its own console
It's a button on the bottom bar
It should only show console log stuff
Jason Luboff
@JLuboff
Jan 13 2017 00:05
Ya codepen's console doesn't show everything unfortunately but its still a useful tool
Tam Nguyen
@bankplank
Jan 13 2017 00:05
Browser console is just showing the link getting fetched and only returning 1/10 parses
No errors
Jason Luboff
@JLuboff
Jan 13 2017 00:06
link your codepen
Dan Couper
@DanCouper
Jan 13 2017 00:06
What do you mean 1/10 parses
Tam Nguyen
@bankplank
Jan 13 2017 00:06
It's only fetching the JSON sometimes
Other times its not returning anything
Phil Seidel
@psbyron3
Jan 13 2017 00:06
click on the network tab of your console @bankplank What type of code are you getting? Is it a 200? 404?501?
For your request
Tam Nguyen
@bankplank
Jan 13 2017 00:07
Ah its saying cancelled
api.php?action=opensearch&format=json&search=Hello&callback=jQuery310073851827985330991484266018216&=1484266018217 (canceled) VM573 jquery.min.js:4 0 B 77 m
Phil Seidel
@psbyron3
Jan 13 2017 00:08
@bankplank I suspect it is a security issue. I haven't done the wiki project or used that API.. Do they require an API key?
Tam Nguyen
@bankplank
Jan 13 2017 00:09
Wikipedia doesnt
I used the openweathermap api just fine
gruanger
@gruanger
Jan 13 2017 00:11
Can anyone help me on the seek and destroy, I have it working if I test values individual, but when I throw it together with multiple values it fails, I think it has to do with the for loop, would someone help me, This is my first time using help, not sure what is proper protocol
Phil Seidel
@psbyron3
Jan 13 2017 00:13
@gruanger can you post your code? Remember use three backticks to on top and bottom to post code snippets
gruanger
@gruanger
Jan 13 2017 00:15

///function destroy(arr)
{
var myArray;
var myArray1;
var myArray2= [];
myArray1 = Array.prototype.slice.call(arguments[0]);
myArray = Array.prototype.slice.call(arguments,1);
function myFilter(value)
{

   for(i = 0; i < myArray.length; i++)
    {
      if (value !== myArray[i]){
          return true;
      }
      else
      {
        return false;
      }

            }

}

var myFiltered = myArray1.filter(myFilter);


//return myFilter;

return myFiltered;

}

destroy([1, 2, 3, 5, 1, 2, 3], 2, 3);

///

Phil Seidel
@psbyron3
Jan 13 2017 00:16
@bankplank Why do you use action=opensearch? Do you need to use action=query instead?
I'm just reading over the API docs now
@gruanger Where are you calling my filter?
sorry myFilter?
gruanger
@gruanger
Jan 13 2017 00:18
var myFiltered = myArray1.filter(myFilter);
Phil Seidel
@psbyron3
Jan 13 2017 00:18
If you are doing it this way you are not actually invoking it. You would need to do myFilter() with the parens
And what your myFilter function is doing is essentially what filter already does.
gruanger
@gruanger
Jan 13 2017 00:21
yeah, the way I wrote it works, it is a problem with the for loop. like if I do return value != 3 it will work, or value != 2, it works, just not with the loop that reads the array and test against the array values
Phil Seidel
@psbyron3
Jan 13 2017 00:21
so it's not really necessary what you could do instead would be to set up an anonymous function in .filter()
var myFiltered = myArray1.filter(function(value) {
    return *insert your condition here*
}
Just a heads up for later use with the .filter() method. It is a very powerful and wonderful tool
gruanger
@gruanger
Jan 13 2017 00:22
yeah, it is the same thing I think, I mean I am new, but mine just calls the function seperatley rather than in the same place

///
function destroy(arr)
{
var myArray;
var myArray1;
var myArray2;

myArray1 = Array.prototype.slice.call(arguments[0]);
myArray = Array.prototype.slice.call(arguments,1);

function myFilter(value)
{
return value !==3;

}

var myFiltered = myArray1.filter(myFilter);

return myFiltered;

}

destroy([1, 2, 3, 5, 1, 2, 3], 2, 3);

///

this works, just for one number
Phil Seidel
@psbyron3
Jan 13 2017 00:23

That last line should look like this:

var myFiltered = myFilter(myArray1);

Again the.filter is redundant

gruanger
@gruanger
Jan 13 2017 00:24
ah, ok
Arrow007
@Arrow007
Jan 13 2017 00:24
Hey guys
Hello world
CamperBot
@camperbot
Jan 13 2017 00:24

welcome to FreeCodeCamp @Arrow007!

kanwisher
@kanwisher
Jan 13 2017 00:24
hello Arrow007
gruanger
@gruanger
Jan 13 2017 00:25
Thanks, I think I am understanding, I am doing a function of a function that is all doing the same thing
Phil Seidel
@psbyron3
Jan 13 2017 00:25
Exactly.
Arrow007
@Arrow007
Jan 13 2017 00:25
So I am good at HTML, but suck at JS and I want to create a thing on Codepen in which a button increases a variable's value
How would I go about this?
Phil Seidel
@psbyron3
Jan 13 2017 00:25
So you just wrote the code that .filter() runs when you use it. (essentially)
Jason Luboff
@JLuboff
Jan 13 2017 00:26
@Arrow007 using jQuery click function would be relatively simple
Phil Seidel
@psbyron3
Jan 13 2017 00:26
@Arrow007 So when you click a button, it would increment a counter? Use a click handler
oo beat me to it haha
gruanger
@gruanger
Jan 13 2017 00:26
Thanks for the help, I am changing it now
Arrow007
@Arrow007
Jan 13 2017 00:26
What is that - ELI5
Phil Seidel
@psbyron3
Jan 13 2017 00:26
No worries
Arrow007
@Arrow007
Jan 13 2017 00:26
(explain like im 5)
Phil Seidel
@psbyron3
Jan 13 2017 00:26
Okay
CamperBot
@camperbot
Jan 13 2017 00:26
no wiki entry for: like im 5
Jason Luboff
@JLuboff
Jan 13 2017 00:26
Arrow007
@Arrow007
Jan 13 2017 00:27
Ok
Jason Luboff
@JLuboff
Jan 13 2017 00:27
Essentially
$("#myButtonID").click(function(){
counter++;
}
Sonali Shukla
@sonalikatara
Jan 13 2017 00:27
I need help with running a simple getJSON command. I don't understand what's going wrong in my code https://codepen.io/SonaliS/pen/VPaeve
Johnny
@JohnnyBizzel
Jan 13 2017 00:28
@gruanger Thanks for @psbyron3 I presume ;)
CamperBot
@camperbot
Jan 13 2017 00:28
:cookie: 31 | @psbyron3 |http://www.freecodecamp.com/psbyron3
johnnybizzel sends brownie points to @gruanger and @psbyron3 :sparkles: :thumbsup: :sparkles:
:cookie: 3 | @gruanger |http://www.freecodecamp.com/gruanger
Arrow007
@Arrow007
Jan 13 2017 00:28
@JLuboff Explain the code for me please lol
Phil Seidel
@psbyron3
Jan 13 2017 00:28
Haha nice!
Joseph
@revisualize
Jan 13 2017 00:28
@Arrow007 What is the action?
Johnny
@JohnnyBizzel
Jan 13 2017 00:28
@sonalikatara changeQuote is not defined
gruanger
@gruanger
Jan 13 2017 00:28
:) Thanks
Joseph
@revisualize
Jan 13 2017 00:28
@Arrow007 .click()
Allen Brady
@llexan
Jan 13 2017 00:28
Is there a bug with the Card Counting exercise? Running tests with the calls at the bottom seems to work but when I click "Run tests" it keeps failing.
Phil Seidel
@psbyron3
Jan 13 2017 00:29
Thanks @JohnnyBizzel for the cred
CamperBot
@camperbot
Jan 13 2017 00:29
:star2: 1118 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Jason Luboff
@JLuboff
Jan 13 2017 00:29
@Arrow007 When the button is clicked, it performs the action within the {} brackets
CamperBot
@camperbot
Jan 13 2017 00:29
psbyron3 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
David Marentette
@Silvertop1
Jan 13 2017 00:29

I keep getting an expected conditional expression but saw an assignment error here. Not really sure what that means to be 100% honest haha.

function golfScore(par, strokes) {

if (strokes = 1) {
return "Hole-in-one!";
} else if (strokes <= par -2) {
return "Eagle";
} else if (strokes = par -1) {
return "Birdie";
} else if (strokes = par) {
return "Par";
} else if (strokes = par +1) {
return "Bogey";
} else if (strokes = par + 2) {
return "Double Bogey";
} else if (strokes >= par + 3) {
return "Go Home!";
} else {
return "Change Me";
}
}

// Change these values to test
golfScore(4, 2);

Joseph
@revisualize
Jan 13 2017 00:29
@Arrow007 From the click it is calling the anonymous function.
Johnny
@JohnnyBizzel
Jan 13 2017 00:29
@psbyron3 Deserved!
Joseph
@revisualize
Jan 13 2017 00:29
@Silvertop1 = is assignment.
Arrow007
@Arrow007
Jan 13 2017 00:29
Oh ok
Joseph
@revisualize
Jan 13 2017 00:29
@Silvertop1 == and === are comparison.
David Marentette
@Silvertop1
Jan 13 2017 00:29
@revisualize ahhh crap thats right i need to sue ==
thank you :)
Jason Luboff
@JLuboff
Jan 13 2017 00:29
@llexan Show your code, most likely you have an error
David Marentette
@Silvertop1
Jan 13 2017 00:29
use*
Joseph
@revisualize
Jan 13 2017 00:30
@Silvertop1 Gift me my :cookie: ... WRAR! LOL.
David Marentette
@Silvertop1
Jan 13 2017 00:30
@revisualize thanks
CamperBot
@camperbot
Jan 13 2017 00:30
silvertop1 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2947 | @revisualize |http://www.freecodecamp.com/revisualize
Arrow007
@Arrow007
Jan 13 2017 00:30
So I have entered this into Codepen
Joseph
@revisualize
Jan 13 2017 00:30
Sometimes, I think I'm being funny. Sometimes. I'm not.
Jason Luboff
@JLuboff
Jan 13 2017 00:30
@revisualize You don't get :cookie: you get :star2:
David Marentette
@Silvertop1
Jan 13 2017 00:30
I sent you the brownie :P
Allen Brady
@llexan
Jan 13 2017 00:30
function cc(card) {
  // Only change code below this line
  switch(card) {
    case "2":
    case "3":
    case "4":
    case "5":
    case "6":
      count++;
      break;
    case "7":
    case "8":
    case "9":
      break;
    case "10":
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break;
  }

  if (count > 0) {
    return count + " Bet";
  } else {
    return count + " Hold";
  }
  // Only change code above this line
}
Joseph
@revisualize
Jan 13 2017 00:30
LOL!
@llexan Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
Tam Nguyen
@bankplank
Jan 13 2017 00:31
Okay so i've narrowed down by problem with fetching a json from wikipedias api
Joseph
@revisualize
Jan 13 2017 00:31
@llexan OH WAIT!
Tam Nguyen
@bankplank
Jan 13 2017 00:31
https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=Hello. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access.
Jason Luboff
@JLuboff
Jan 13 2017 00:31
@llexan Numbers should not be surrounded by quotes
Joseph
@revisualize
Jan 13 2017 00:31
@llexan 2 3 4 5 6 7 8 9 10 should be numbers.
Not strings
Allen Brady
@llexan
Jan 13 2017 00:31
Ooooh doi. Haha Thank you @revisualize !!
CamperBot
@camperbot
Jan 13 2017 00:31
llexan sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2948 | @revisualize |http://www.freecodecamp.com/revisualize
Arrow007
@Arrow007
Jan 13 2017 00:31
Wait I am still confused.
Jason Luboff
@JLuboff
Jan 13 2017 00:31
damn you @revisualize stealing my :cookie:
Joseph
@revisualize
Jan 13 2017 00:31
@JLuboff Thanks.
CamperBot
@camperbot
Jan 13 2017 00:31
:cookie: 617 | @jluboff |http://www.freecodecamp.com/jluboff
revisualize sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
Tam Nguyen
@bankplank
Jan 13 2017 00:31
I tried using crossorigin.me proxy, but now im getting 'Origin: header is required'
Jason Luboff
@JLuboff
Jan 13 2017 00:31
oh damn..
Sonali Shukla
@sonalikatara
Jan 13 2017 00:32
@JohnnyBizzel I just copied the link for getting random quotes from some example and now understand I need to dig into the url and understand it. what should I google to get links to some good articles on this topic.
Allen Brady
@llexan
Jan 13 2017 00:32
And thanks to @JLuboff :)
CamperBot
@camperbot
Jan 13 2017 00:32
llexan sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 618 | @jluboff |http://www.freecodecamp.com/jluboff
Arrow007
@Arrow007
Jan 13 2017 00:32
What I have is a variable established. It is var totalscore = 0 - now to have a button to increase that, what would I need?
Jason Luboff
@JLuboff
Jan 13 2017 00:32
@bankplank crossorigin.me doesn't work for me anymore and you shouldn't need it with the wiki project anyways
Johnny
@JohnnyBizzel
Jan 13 2017 00:32
@sonalikatara Did the example not come with some help?
Jason Luboff
@JLuboff
Jan 13 2017 00:32
@Arrow007 What do you mean?
liamllorin1
@liamllorin1
Jan 13 2017 00:33
'''
CamperBot
@camperbot
Jan 13 2017 00:33
:bulb: to format code use backticks! ``` more info
liamllorin1
@liamllorin1
Jan 13 2017 00:33
Can anyone help with my code?

var arrnew = [];
function chunkArrayInGroups(arr, size) {
for (var i = 0; i + size <= arr.length; i + size) {
arr = arr.slice(i, i + size);
arrnew.push(arr);
}

return arrnew;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
'''

CamperBot
@camperbot
Jan 13 2017 00:33
:bulb: to format code use backticks! ``` more info
Arrow007
@Arrow007
Jan 13 2017 00:33
@JLuboff I want to display that variable on the screen, then have a button increase it
Jason Luboff
@JLuboff
Jan 13 2017 00:33
@Arrow007 Then you'll want to use either .html http://api.jquery.com/html/ or .text http://api.jquery.com/text/
liamllorin1
@liamllorin1
Jan 13 2017 00:34

'''js
var arrnew = [];
function chunkArrayInGroups(arr, size) {
for (var i = 0; i + size <= arr.length; i + size) {
arr = arr.slice(i, i + size);
arrnew.push(arr);
}

return arrnew;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
'''

CamperBot
@camperbot
Jan 13 2017 00:34
:bulb: to format code use backticks! ``` more info
Jason Luboff
@JLuboff
Jan 13 2017 00:34
@liamllorin1 Its backticks ` not '
Tam Nguyen
@bankplank
Jan 13 2017 00:34
@JLuboff thanks, ill see if I can find a solution
CamperBot
@camperbot
Jan 13 2017 00:34
bankplank sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 619 | @jluboff |http://www.freecodecamp.com/jluboff
liamllorin1
@liamllorin1
Jan 13 2017 00:35
var arrnew = [];
function chunkArrayInGroups(arr, size) {
  for (var i = 0; i + size <= arr.length; i + size) {
    arr = arr.slice(i, i + size);
    arrnew.push(arr);
  }




  return arrnew;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Line 4 creates an infinite loop, why??
Here is the question: Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.
Sonali Shukla
@sonalikatara
Jan 13 2017 00:36

no the @JohnnyBizzel I understand the example uses an API on the FreecodeCamp server so it's getJSON call is very simple no function call in the url.

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

$("#getMessage").on("click", function(){
// Only change code below this line.
$.getJSON("/json/cats.json", function(json) {
$(".message").html(JSON.stringify(json));
});


// Only change code above this line.
});

});
</script>

David Marentette
@Silvertop1
Jan 13 2017 00:36
@JLuboff So more general question for you as I work through this .....It seems to me that the IF statements and SWITCH statements are essentially the same thing just written a bit differently...but still the same logic process.....I don't currently see when it would be more beneficial to use one over the other
Tam Nguyen
@bankplank
Jan 13 2017 00:37
Switch statements are alot simpler
Jason Luboff
@JLuboff
Jan 13 2017 00:37
Switch statements can save on writing things out..maybe..depends..
switch(val) {
case 1:
case 2:
case 3:
console.log("1-3 give the same answer");
break;
}
if (val == 1 || val == 2 || val == 3) {
console.log("Here's the answer for all three");
}
Tam Nguyen
@bankplank
Jan 13 2017 00:38
Writing 10 if statements would be pretty tedious
David Marentette
@Silvertop1
Jan 13 2017 00:38
@bankplank thanks! fair point ....so long as I remember to use the break haha :D
CamperBot
@camperbot
Jan 13 2017 00:38
:cookie: 276 | @bankplank |http://www.freecodecamp.com/bankplank
silvertop1 sends brownie points to @bankplank :sparkles: :thumbsup: :sparkles:
Johnny
@JohnnyBizzel
Jan 13 2017 00:39
@sonalikatara Where did you get your API from?
Jason Luboff
@JLuboff
Jan 13 2017 00:39
@JohnnyBizzel It looks like he is going through the jQuery challenges from FCC?
David Marentette
@Silvertop1
Jan 13 2017 00:39
@JLuboff ah thanks
CamperBot
@camperbot
Jan 13 2017 00:39
silvertop1 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 620 | @jluboff |http://www.freecodecamp.com/jluboff
Joseph
@revisualize
Jan 13 2017 00:40
@liamllorin1 Some advice. I've found that the tests don't run when you create some global variables. But, when you make something that could be local be local.. It works.
Sonali Shukla
@sonalikatara
Jan 13 2017 00:41
@JohnnyBizzel I tried all the API's I found online this is one of them
Johnny
@JohnnyBizzel
Jan 13 2017 00:41
@sonalikatara I think it's a terrible API personally.
Sonali Shukla
@sonalikatara
Jan 13 2017 00:42
any suggestions ?
I just want to try out the jQuery getJSON Method
Johnny
@JohnnyBizzel
Jan 13 2017 00:44
@sonalikatara use a better API
Arrow007
@Arrow007
Jan 13 2017 00:44
Hey - I'm back
So I dont know if you didnt notice, but i suck at coding
Jason Luboff
@JLuboff
Jan 13 2017 00:45
Hey I'm back, I'm jluboff
Arrow007
@Arrow007
Jan 13 2017 00:45
I am super confused on how to use different languages at once and im totally new to coding
Sonali Shukla
@sonalikatara
Jan 13 2017 00:45
@JohnnyBizzel How about this http://forismatic.com/en/api/ but I don't understand how to use it from their docs
Arrow007
@Arrow007
Jan 13 2017 00:45
I use to be great with HTML a few years ago
Now im lost
Jason Luboff
@JLuboff
Jan 13 2017 00:45
@Arrow007 Have you gone through FCC at all?
Arrow007
@Arrow007
Jan 13 2017 00:45
Looking for guidance in a herd of nerds
Yes I have
Jason Luboff
@JLuboff
Jan 13 2017 00:46
How far have you gotten?
Arrow007
@Arrow007
Jan 13 2017 00:46
Not too far
Jason Luboff
@JLuboff
Jan 13 2017 00:46
I'd recomend continuing with it then. They go over how to use the click function that I mentioned earlier in their jQuery courses
Arrow007
@Arrow007
Jan 13 2017 00:46
How far in is that though
I just want to make one simple program lol
After making it I would be happy to continue
Jason Luboff
@JLuboff
Jan 13 2017 00:47
Its right after the Html/CSS portion. You can get it done in a day or two if you really want to. Especially if you have html/css experience, it should be quick
Arrow007
@Arrow007
Jan 13 2017 00:47
Yeah I started with it today and most of it is easy thanks to experience
But before I continue can you just help me develop this one thing
I'll be out of your hair after that haha
Jason Luboff
@JLuboff
Jan 13 2017 00:48
What do you have so far?
You got me for 5 more minutes
Arrow007
@Arrow007
Jan 13 2017 00:48
Alrighty
I want to make this app in which I can have a total score. I want to have buttons to increase the score - each button increases it by a different value -
Johnny
@JohnnyBizzel
Jan 13 2017 00:49
@sonalikatara Forked your app using another api: http://codepen.io/JohnnyBizzel/pen/ggMYGj
This one: https://opentdb.com/api_config.php
Jason Luboff
@JLuboff
Jan 13 2017 00:49
@Arrow007 Ok. Do you have it in codepen?
Arrow007
@Arrow007
Jan 13 2017 00:50
I haven't really started
Johnny
@JohnnyBizzel
Jan 13 2017 00:50
I am off to bed now as it is :sleeping: gone :clock1230: :new_moon:
Arrow007
@Arrow007
Jan 13 2017 00:50
I have CodePen open though
@JohnnyBizzel Nice quote machine
Sonali Shukla
@sonalikatara
Jan 13 2017 00:50
@JohnnyBizzel THANK YOU :+1:
CamperBot
@camperbot
Jan 13 2017 00:50
sonalikatara sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1119 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Arrow007
@Arrow007
Jan 13 2017 00:51
@JLuboff You still with me?
liamllorin1
@liamllorin1
Jan 13 2017 00:51
A little help! The challenge: Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.
Elliott Alexander
@escottalexander
Jan 13 2017 00:51
Don't know if this is the right place to ask but I need some help with some non-functioning jQuery. https://gist.github.com/escottalexander/1edb1c50d0c59ff1d65c307164bcf877#file-gistfile1-js
liamllorin1
@liamllorin1
Jan 13 2017 00:52
A little help! The challenge: Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.
var arrnew = [];
function chunkArrayInGroups(arr, size) {
  for (var i = 0; i + size <= arr.length; i + size) {
    arr = arr.slice(i, i + size);
    arrnew.push(arr);
  }



}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
I have an infinite loop at line 4, why?
or 3 rather
Moisés Man
@moigithub
Jan 13 2017 00:52
ur i not increasing..
do i = i+size on ur loop @liamllorin1
Elliott Alexander
@escottalexander
Jan 13 2017 00:52
The $.getJSON thing doesn't work. It won't run at all. i don't understand.
liamllorin1
@liamllorin1
Jan 13 2017 00:53
okay thanks
Jason Luboff
@JLuboff
Jan 13 2017 00:53
@Arrow007 I went to take a piss haha
liamllorin1
@liamllorin1
Jan 13 2017 00:53
where? @moigithub
Arrow007
@Arrow007
Jan 13 2017 00:53
Oh lol
I thought I lost you there
Moisés Man
@moigithub
Jan 13 2017 00:53
for (var i = 0; i + size <= arr.length; i = i + size) { @liamllorin1
Tam Nguyen
@bankplank
Jan 13 2017 00:53
@escottalexander Are you running it in codepen?
Elliott Alexander
@escottalexander
Jan 13 2017 00:53
@bankplank yes.
liamllorin1
@liamllorin1
Jan 13 2017 00:53
so var = i + size?
Tam Nguyen
@bankplank
Jan 13 2017 00:53
@escottalexander It is most likely a cors error
liamllorin1
@liamllorin1
Jan 13 2017 00:53
@moigithub
Elliott Alexander
@escottalexander
Jan 13 2017 00:54
@bankplank how do I resolve it?
liamllorin1
@liamllorin1
Jan 13 2017 00:54
oooh thanks @moigithub !
CamperBot
@camperbot
Jan 13 2017 00:54
:star2: 2468 | @moigithub |http://www.freecodecamp.com/moigithub
liamllorin1 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
Tam Nguyen
@bankplank
Jan 13 2017 00:54
@escottalexander check your browser console, if you get an error that says control-allow-origin header or something like that
Krzysztof Burka
@kazcor
Jan 13 2017 00:54
hey how do I build my if function for testing if an object contains a property?
Tam Nguyen
@bankplank
Jan 13 2017 00:55
I band-aid fix it buy installing a chrome extensions that allows CORs
Elliott Alexander
@escottalexander
Jan 13 2017 00:55
@bankplank There are no errors in the console.
Krzysztof Burka
@kazcor
Jan 13 2017 00:55

If(myObj.hasOwnProperty(checkProp))
{return myObj.checkProp;}

Is that correct?

Tam Nguyen
@bankplank
Jan 13 2017 00:55
link code pen plz
Moisés Man
@moigithub
Jan 13 2017 00:55
the IF part yes... @kazcor
but.. to access object values with variables.. NO dot notation
Elliott Alexander
@escottalexander
Jan 13 2017 00:56
@bankplank http://codepen.io/escottalexander/pen/WRwXxw?editors=0010 Thanks for taking a look.
CamperBot
@camperbot
Jan 13 2017 00:56
escottalexander sends brownie points to @bankplank :sparkles: :thumbsup: :sparkles:
:cookie: 277 | @bankplank |http://www.freecodecamp.com/bankplank
mitron6
@mitron6
Jan 13 2017 00:56
@kazcor What is the exercise name?
Sonali Shukla
@sonalikatara
Jan 13 2017 00:57
@escottalexander I just got help on mine, do you have a link to your code ?
Elliott Alexander
@escottalexander
Jan 13 2017 00:57
Tam Nguyen
@bankplank
Jan 13 2017 00:58
@escottalexander Your request is getting cancelled in your network tabbed
Krzysztof Burka
@kazcor
Jan 13 2017 00:58
@mitron6 I've done it, changed to bracket notation and it worked :)
Moisés Man
@moigithub
Jan 13 2017 00:58
@escottalexander cuz u have a form.. default behavior is to refresh the page
u can remove it.. or add a preventDefault on ur code
  $("#search").click(function(e) {
      e.preventDefault();
Elliott Alexander
@escottalexander
Jan 13 2017 00:58
@bankplank I don't understand what that means. Can you give me a phrase to search? Thanks a ton.
CamperBot
@camperbot
Jan 13 2017 00:58
escottalexander sends brownie points to @bankplank :sparkles: :thumbsup: :sparkles:
:warning: escottalexander already gave bankplank points
liamllorin1
@liamllorin1
Jan 13 2017 00:59
A little help for this challenge! The challenge?
Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.
var arrnew = [];
function chunkArrayInGroups(arr, size) {
  for (var i = 0; i + size <= arr.length; i = i + size) {
    arr = arr.slice(i, i + size);
    arrnew.push(arr);
  }

  return arrnew;

}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2);
Krzysztof Burka
@kazcor
Jan 13 2017 00:59
thanks @moigithub
CamperBot
@camperbot
Jan 13 2017 00:59
:star2: 2469 | @moigithub |http://www.freecodecamp.com/moigithub
kazcor sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
john94
@lpy1994
Jan 13 2017 00:59
hello can anybody take a look at my codepen?
liamllorin1
@liamllorin1
Jan 13 2017 00:59
MY CODE IS ONLY RUNNING ONCE, WHY??
Elliott Alexander
@escottalexander
Jan 13 2017 00:59
@moigithub Oh, that makes sense. Hmm....
try to tweet out the quote but they are “undefined"
Moisés Man
@moigithub
Jan 13 2017 01:00
@liamllorin1 change ur loop condition to i < arr.length; maybe.. ?
mitron6
@mitron6
Jan 13 2017 01:00
@kazcor cool.
liamllorin1
@liamllorin1
Jan 13 2017 01:00
Okay thanks again @moigithub
CamperBot
@camperbot
Jan 13 2017 01:00
liamllorin1 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: liamllorin1 already gave moigithub points
Elliott Alexander
@escottalexander
Jan 13 2017 01:01
Thanks @moigithub !
CamperBot
@camperbot
Jan 13 2017 01:01
escottalexander sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2470 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jan 13 2017 01:01
@liamllorin1 and probably ur global variable arrnew will mess with tests
john94
@lpy1994
Jan 13 2017 01:03
can anybody help me with this ??
Elliott Alexander
@escottalexander
Jan 13 2017 01:03
@moigithub That works. Thanks so much.
CamperBot
@camperbot
Jan 13 2017 01:03
escottalexander sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: escottalexander already gave moigithub points
Moisés Man
@moigithub
Jan 13 2017 01:03
@lpy1994 var keyword is used to create/declare variables PER SCOPE
u have declared globals variables above...
but.. inside ur randomQuotes funciton u also use var
soo u creating locals variables (with same names) on this function
whatever changes u do to this locals variables wont affect the global ones ( the ones ur tweet uses)
john94
@lpy1994
Jan 13 2017 01:06
thx
thank you
Pericles
@periman2
Jan 13 2017 01:09
hi there can someone help me with the twich api ? I don't see how I'm going to get multiple getJSON calls . I've tried doing it in a for loop I've tried doing it recursively and with while loop but nothing works
I also tried using promises inside the for loop but still it doesn't work
var channels = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
  var displayname = [];
  var onlinestatus = [];
  var streamstatus = [];
  var logourl = [];
  var a = [];
  function getchannel(link) {
    return $.getJSON(link);
  }

  function getstream(link) {
    return $.getJSON(link);
  }
  for (var i = 0; i < channels.length; i ++) {
    (function (i) {
      var linkchannel = "https://wind-bow.gomix.me/twitch-api/channels/"+channels[i];
      getchannel(linkchannel);
      $.when(getchannel(linkchannel)).then(function (data) {
        displayname.push(data.display_name);
      });
    })(i);
  }
  console.log(displayname);
that's what I've got right now it's a weird method someone suggested on the internet
displayname here gives an object with 0 length in the console log but when I click on it it shows all the information that I want. But I can't seem to be able to manipulate it inside the code.
RadiophonicOddity09
@RadiophonicOddity09
Jan 13 2017 01:17
Could someone please help me with the stand in line challenge?
Walid Ashri
@walidashri
Jan 13 2017 01:20
@periman2 you can simply make a function that handles the api response for one channel , update the html and then call it with a for loop
@RadiophonicOddity09 u'll need to use the Array methods push and shift
RadiophonicOddity09
@RadiophonicOddity09
Jan 13 2017 01:23
@periman2 would you please write an example code if you can please?
@periman2 plus would we push and shift the variables to var testArr
Pericles
@periman2
Jan 13 2017 01:25
@walidashri hmm can you give me an example of this ? you mean I should write a function outside the getjson that does whatever I want the data to do and then update the html ?
john94
@lpy1994
Jan 13 2017 01:26
@moigithub thank you!
CamperBot
@camperbot
Jan 13 2017 01:26
lpy1994 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2471 | @moigithub |http://www.freecodecamp.com/moigithub
john94
@lpy1994
Jan 13 2017 01:29
@moigithub I get rid of the “var in the function, but it still won’t work
Walid Ashri
@walidashri
Jan 13 2017 01:30
@periman2 here is psedo code
func (channel){ getJson(api url-channel , callback func{ change html})}
doc.getReady( for loop with channels array and call the func)
RadiophonicOddity09
@RadiophonicOddity09
Jan 13 2017 01:30
@walidashri would you please write an example code if you can please?
Moisés Man
@moigithub
Jan 13 2017 01:30
@lpy1994 ?? which part dont work ?
Walid Ashri
@walidashri
Jan 13 2017 01:31
@lpy1994 u need to generate the qoute before u tweet
john94
@lpy1994
Jan 13 2017 01:32
@moigithub you are right
miguel ouellet thibault
@ot-1924
Jan 13 2017 01:32
blob
hey guys im having issues with a class can anyone help me with this?
john94
@lpy1994
Jan 13 2017 01:32
@walidashri i was being silly..
@walidashri thank you!
CamperBot
@camperbot
Jan 13 2017 01:32
lpy1994 sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 844 | @walidashri |http://www.freecodecamp.com/walidashri
Ken Haduch
@khaduch
Jan 13 2017 01:33
@ot-1924 - start with <script>, the document.ready part should be within the script tags, not inside of the <script angle brackets.
miguel ouellet thibault
@ot-1924
Jan 13 2017 01:34
@khaduch thanks mate
CamperBot
@camperbot
Jan 13 2017 01:34
ot-1924 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2261 | @khaduch |http://www.freecodecamp.com/khaduch
RadiophonicOddity09
@RadiophonicOddity09
Jan 13 2017 01:34
@walidashri can you please help me with an example code for the stand in line challenge
Walid Ashri
@walidashri
Jan 13 2017 01:35

@RadiophonicOddity09

myArray.push(item);
return myArray.shift();

just an example ...

oshane-willy99
@oshane-willy99
Jan 13 2017 01:35
Can anyone help me the Counting Cards problem?
Pericles
@periman2
Jan 13 2017 01:37
@walidashri I'll give it a try! thanks
CamperBot
@camperbot
Jan 13 2017 01:37
periman2 sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 845 | @walidashri |http://www.freecodecamp.com/walidashri
Walid Ashri
@walidashri
Jan 13 2017 01:37
@periman2 :+1:
@oshane-willy99 what is the problem?
Zak
@zaksanderford
Jan 13 2017 01:37
In the Mutations exercise (assuming that I've converted the passed in array argument into to 2 strings str0, str1 and iterating over characters in the ) is str0.indexOf(str1.charAt(i)) a good way to confirm a character exists in both strings
oshane-willy99
@oshane-willy99
Jan 13 2017 01:40
@walidashri can you explain the instructions
Walid Ashri
@walidashri
Jan 13 2017 01:43
@oshane-willy99 you need to write switch statement for the card and change the count according to the card value
then depending to the count value change what the function returns
oshane-willy99
@oshane-willy99
Jan 13 2017 01:45
@walidashri okay ill try, thanks
gant123
@gant123
Jan 13 2017 01:45
"jQuery.Deferred exception: position is not defined" "ReferenceError: position is not defined
at HTMLDocument.<anonymous> (pen.js:16:12)
at j (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js:2:29568)
at k (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js:2:29882)" undefined can someone help me fix this? i dont know what this means
CamperBot
@camperbot
Jan 13 2017 01:45
:cookie: 846 | @walidashri |http://www.freecodecamp.com/walidashri
oshane-willy99 sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
victordacc
@victordacc
Jan 13 2017 01:48
hey guys, i'm having trouble with a celsius to fahrenheit conversion problem. This is the code I have:

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

celsius = fahrenheit;
celsius *= 9;
celsius /= 5;
celsius += 32;

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

// Change the inputs below to test your code
convertToF(0);
convertToF(-30);
convertToF(-10);
convertToF(0);
convertToF(20);
convertToF(30);

I don't really know how to make the convertToF functions give a value
the error messages say that they are not giving the adequate ones. any ideas?
Walid Ashri
@walidashri
Jan 13 2017 01:49
@gant123 can u give the pen link ?
Jonathan Wright
@electricflannel
Jan 13 2017 01:50
@victordacc I think you’d be best to do your conversion in one line in stead of modifying celsius 3 times
Tam Nguyen
@bankplank
Jan 13 2017 01:50
@victordacc you are not returning fahrenheit
Nathan
@Renown0
Jan 13 2017 01:50
Hey everyone, I'm trying to figure out exactly how RegEx works. I cheated on one of the challenges and it told me to use this, but I want to actually understand what's going on before I clear the challenge. Can anyone break this down for me? I can't find a good breakdown elsewhere. (It's supposed to remove spaces from a string)
/[\W_]/g, ''
Emily Sperry
@sperrye
Jan 13 2017 01:50

```function diffArray(arr1, arr2) {
var newArr = [];
var length = arr1.length + arr2.length;

for (var i=0;newArr<=length;i++) {
if (arr2.indexOf(arr1[i]) == -1) {
if (arr2[i] !== null) {
newArr.push(arr2[i]);
}
else {
i++;
}
}
else {
i++;
}
}
return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
```
I'm getting [5,null] I'm feeling kind of stuck, so a nudge in the right direction would be much appreciated.

gant123
@gant123
Jan 13 2017 01:51
@walidashri im getting a console error
and therefore my information is not pulling to html
Jonathan Wright
@electricflannel
Jan 13 2017 01:52
@Renown0 You should plug that code into title, it will walk you through each part
Tam Nguyen
@bankplank
Jan 13 2017 01:53
@victordacc fahrenheit = celsius *(9/5) + 32;
Nathan
@Renown0
Jan 13 2017 01:53
Aw man, that is excellent @electricflannel
Thanks!
Pericles
@periman2
Jan 13 2017 01:53
@walidashri here's the thing. in the portion you say "change html" I don't actually want to change the html I want to update an array which is going to be inside the document ready function . how do I go about doing that outside of it?
Jonathan Wright
@electricflannel
Jan 13 2017 01:54
@Renown0 No prob! Good luck!
Nathan
@Renown0
Jan 13 2017 01:54
Hold up, that didn't give you a point or whatever. Thanks @electricflannel
CamperBot
@camperbot
Jan 13 2017 01:54
renown0 sends brownie points to @electricflannel :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @electricflannel |http://www.freecodecamp.com/electricflannel
Nathan
@Renown0
Jan 13 2017 01:54
There we go!
RadiophonicOddity09
@RadiophonicOddity09
Jan 13 2017 01:54
@walidashri I'm having trouble writing my code would you please help me with the full code if you can please
gant123
@gant123
Jan 13 2017 01:55
^^ what troubles are you having ??
Daniel
@doodleslr
Jan 13 2017 01:55

say i'm trying to find the largest integer in a sun array , would this be syntactically correct? strangely it voids my "return arrFinal" statement at the end of my algorithm

arrFinal.push(Math.max(subArr));

sub array*
it returns "illegal return statement"
Jonathan Wright
@electricflannel
Jan 13 2017 01:56
@doodleslr can you copy all your code into the chat?
Daniel
@doodleslr
Jan 13 2017 01:56

function largestOfFour(arr) {
var x = 0;

var arrFinal = [];

for (var a = 0; a < arr.length; a++){//1st lvl array
var subArr = arr[a];//defines sub array
for (var b = 0; b < subArr.length; b++){//2nd lvl array
arrFinal.push(Math.max(subArr));
}
}//end 2nd lvl array

}//end 1st lvl array

return arrFinal;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

Walid Ashri
@walidashri
Jan 13 2017 01:57
@periman2 getJson is synchronous func I think u can't get want u want
Daniel
@doodleslr
Jan 13 2017 01:57
ignroe var x thats leftover
Moisés Man
@moigithub
Jan 13 2017 01:57
@doodleslr subArr is an array.. Math.max do not accept arrays
Math.max([1,2,3])
// NaN
Tam Nguyen
@bankplank
Jan 13 2017 01:58
@doodleslr you can use .sort() to arrange the arrays from largest to smallest
then return the first array
Moisés Man
@moigithub
Jan 13 2017 01:58
@doodleslr if u wanna use array with Math.max u need to use apply method
Math.max.apply(null,[1,2,3])
// 3
Kathryn
@kathrynwiley
Jan 13 2017 01:59

Hey everyone! I have been struggling with this for the past hour or so, does anyone know why my code is not working?

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

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

function checkObj(checkProp) {
if (myObj.hasOwnProperty(checkProp) === true) {
return myObj.checkProp;
}
else {
return "Not found";
}
}

Daniel
@doodleslr
Jan 13 2017 01:59
alrighty ill give it a go, thank you @moigithub @bankplank!
CamperBot
@camperbot
Jan 13 2017 01:59
doodleslr sends brownie points to @moigithub and @bankplank :sparkles: :thumbsup: :sparkles:
:cookie: 278 | @bankplank |http://www.freecodecamp.com/bankplank
:star2: 2472 | @moigithub |http://www.freecodecamp.com/moigithub
Hugo
@ramirezhugo
Jan 13 2017 01:59

Hi, can someone help me please. Does anyone notice a difference between these two pieces of code? The top one is mine and the bottom is someone else's. When I run mine, the challenge doesn't let me continue, however, the other one passes. Am I missing something? - Thanks var total = 0;

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

var total = 0;

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

Moisés Man
@moigithub
Jan 13 2017 01:59
@kathrynwiley NO dot notation with variables (like checkProp )
Reggie
@Reggie01
Jan 13 2017 01:59
@ramirezhugo length is misspelled
Pericles
@periman2
Jan 13 2017 02:00
@walidashri so I can't get an array with all the displayed names for example ?
Zaluth
@Zaluth
Jan 13 2017 02:00
so, thisis returning an infinite loop, anyone knows why?
function sumPrimes(num) {

  var notPrimes = [];
  var primes = [];

  for (var i = 2; i <= num; i++) {
    for (var j = 1; j <= num; j++) {

    }
  }

  return primes;
}

sumPrimes(10);
Pericles
@periman2
Jan 13 2017 02:00
@walidashri or all the links for the logos or in general anything that comes from the api ?
Hugo
@ramirezhugo
Jan 13 2017 02:00
@Reggie01 wow, thanks!
CamperBot
@camperbot
Jan 13 2017 02:00
ramirezhugo sends brownie points to @reggie01 :sparkles: :thumbsup: :sparkles:
:cookie: 379 | @reggie01 |http://www.freecodecamp.com/reggie01
Kathryn
@kathrynwiley
Jan 13 2017 02:01
Thanks! I must have forgotten that part about dot notation. Now the first part works, but it won't return "Not found"
oshane-willy99
@oshane-willy99
Jan 13 2017 02:03
@walidashri i tried ... im doing something wrong ig.
gstpierre11
@gstpierre11
Jan 13 2017 02:03
for "Profile Lookup" (in basic javascript toward the end) - should I be using a for loop with if statements or should I be using switch statements?
Moisés Man
@moigithub
Jan 13 2017 02:04
@kathrynwiley which test fails.. whats the exact message they want ?
Joseph
@revisualize
Jan 13 2017 02:05
@gstpierre11 You have to look at the shape of your data. You'll realize that a switch is not needed.
gant123
@gant123
Jan 13 2017 02:05
can someone help figure out why im getting a concole error
Brian Rigoni
@BrianRigoni
Jan 13 2017 02:05
Hello people, Im stuck n "Escape sequences in Strings"
Kathryn
@kathrynwiley
Jan 13 2017 02:05
If the property is found, return that property's value. If not, return "Not Found". (checkObj("house") should return "Not Found".)
Brian Rigoni
@BrianRigoni
Jan 13 2017 02:05
can anyone help me please?
Moisés Man
@moigithub
Jan 13 2017 02:05
@kathrynwiley soo Found with uppercase F
Kathryn
@kathrynwiley
Jan 13 2017 02:05
oh damn. lol Thank you so much!
Moisés Man
@moigithub
Jan 13 2017 02:05
:)

@gant123

Uncaught ReferenceError: position is not defined

where that position variable is declared ??

  long = position.coords.logitude;
  lat = position.coords.latitude;
Joseph
@revisualize
Jan 13 2017 02:08
@kathrynwiley I was scrolling back up..
Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
Anh Nguyen
@tiremon112
Jan 13 2017 02:09
function orderMyLogic(val) {
  if (val < 10) {
    return "Less than 10";
  } else if (val < 5) {
    return "Less than 5";
  } else {
    return "Greater than or equal to 10";
  }
}

// Change this value to test
orderMyLogic(7);
Change the order of logic in the function so that it will return the correct statements in all cases. what does it want me to do change it? and how ? am i suppose to make it correct all case
gstpierre11
@gstpierre11
Jan 13 2017 02:09
@revisualize currently I'm using an if statement inside a for loop, but I can't figure out how to get the last 2 tests to pass (bob = no such contact, address = no such property)
gant123
@gant123
Jan 13 2017 02:09
@moigithub thanks
CamperBot
@camperbot
Jan 13 2017 02:09
gant123 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2473 | @moigithub |http://www.freecodecamp.com/moigithub
Joseph
@revisualize
Jan 13 2017 02:10
@gstpierre11 Here.. I'm gonna give you the too long didn't read.
gstpierre11
@gstpierre11
Jan 13 2017 02:10
@revisualize thank you!
CamperBot
@camperbot
Jan 13 2017 02:10
gstpierre11 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2949 | @revisualize |http://www.freecodecamp.com/revisualize
RadiophonicOddity09
@RadiophonicOddity09
Jan 13 2017 02:10
could someone please help me with the stand in line challenge?
Zaluth
@Zaluth
Jan 13 2017 02:10
this is returning an infinite loop, anyone knows why?
function sumPrimes(num) {

  var notPrimes = [];
  var primes = [];

  for (var i = 2; i <= num; i++) {
    for (var j = 1; j <= num; j++) {
      //code
    }
  }
  return primes;
}
sumPrimes(10);
Joseph
@revisualize
Jan 13 2017 02:11
@RadiophonicOddity09 What is the current state of your function?
Moisés Man
@moigithub
Jan 13 2017 02:11
@tiremon112 order matters... code run from top to bottom...
soo if u call ur funciton with 4 orderMyLogic(4);
it SHOULD say "less than 5"
but since 4 is less than 10 too.. it output "less than 10" instead
soo u need to REORDER the conditions
Ken Haduch
@khaduch
Jan 13 2017 02:12
@tiremon112 - look at the current order of the tests. If you have the value 3 in val, your first test if ( val < 10) will evaluate to true. But if you had the tests ordered differently, it would also evaluate to true for if ( val < 5 ). So you want to have the smallest condition checked first, then the next greater value, then finally all of the values above the specific values that you are testing.
Alison Yoon
@AlisonYoon
Jan 13 2017 02:12
Hi I'm doing Profile Lookup [map 235] on FFC
RadiophonicOddity09
@RadiophonicOddity09
Jan 13 2017 02:12
Well my code doesnt seem to work @revisualize
Alison Yoon
@AlisonYoon
Jan 13 2017 02:12
Could anyone help me figuring out what's wrong with solution?
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line

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



// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
RadiophonicOddity09
@RadiophonicOddity09
Jan 13 2017 02:13
@revisualize would you please be able to help me out with the right code
Alison Yoon
@AlisonYoon
Jan 13 2017 02:13
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line

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



// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Anh Nguyen
@tiremon112
Jan 13 2017 02:14
i got it forgot to change the return text
forgot that matter
:+1:
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:14
@AlisonYoon help format
Alison Yoon
@AlisonYoon
Jan 13 2017 02:15
@RonyVidaur I don't know why my code doesn't show up as markup
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:15
@AlisonYoon let me paste it on my editor real quick and I'll take a look, maybe I can help
Alison Yoon
@AlisonYoon
Jan 13 2017 02:15
@RonyVidaur ok !!
Joseph
@revisualize
Jan 13 2017 02:15
@RadiophonicOddity09 That didn't answer my question.. What is the current state of your function? I don't care if it is broken. I just want to see where you are at so I know how to drive forward.
cbot
CamperBot
@camperbot
Jan 13 2017 02:18
you called?
Alison Yoon
@AlisonYoon
Jan 13 2017 02:20
@RonyVidaur Oh I changed the format
[profile look up](https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%0A%20%20if(contacts.firstName%3D%3D%3Dtrue)%7B%0A%20%20for(i%3D0%3B%20i%3C%20contacts.length%3B%20i%2B%2B)%7B%0A%20%20%20%20firstName%20%3D%20contacts%5Bi%5D.firstName%3B%0A%20%20%20%20prop%20%3D%20contacts%5Bi%5D.prop%3B%0A%20%20%20%20return%20contacts%5Bi%5D.prop%3B%0A%7D%0A%20%20%7Delse%20if(contacts.firstName%3D%3D%3Dfalse)%7B%0A%20%20%20%20return%20%22No%20such%20contact%22%3B%0A%20%20%7Delse%20if(contacts%5Bi%5D.prop%3D%3D%3Dundefinded)%7B%0A%20%20%20%20return%20%22No%20such%20property%22%3B%0A%20%20%7D%0A%0A%0A%20%20%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A)
Igor Amidzic
@igoramidzic
Jan 13 2017 02:21
cbot
CamperBot
@camperbot
Jan 13 2017 02:21
you called?
Igor Amidzic
@igoramidzic
Jan 13 2017 02:21
no
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:22
@AlisonYoon hmmm on the first if I think you want to check if the firstName value that you're given exist in the contacts array right? but if you notice
you're just saying if(contacts.firstName === true)
Alison Yoon
@AlisonYoon
Jan 13 2017 02:23
right
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:23
I'll give you a hint and then if you
want we can go solving it step by step
RadiophonicOddity09
@RadiophonicOddity09
Jan 13 2017 02:23
@revisualize my function is written out
Lawanu Borthakur
@Lawanu
Jan 13 2017 02:23
can some one tell me,why cant we "prop===contacts[i].prop" instead os "has own property" in the below program
Alison Yoon
@AlisonYoon
Jan 13 2017 02:24
@RonyVidaur I've been stuck at this step for a couple of days so yeah I 'm up for anything
Lawanu Borthakur
@Lawanu
Jan 13 2017 02:24

function lookUpProfile(firstName, prop){
// Only change code below this line

for(i=0;i<contacts.length;i++)

{
if(firstName===contacts[i].firstName)
{
if(prop===contacts[i].prop)
{
return contacts[i][prop];
}
else
{
return "No such property";
}
}
}

return "No such contact";
// Only change code above this line
}

can some one tell me,why cant we "prop===contacts[i].prop" instead os "has own property" in the below program
Alison Yoon
@AlisonYoon
Jan 13 2017 02:25
@Lawanu we are on the same step now
Lawanu Borthakur
@Lawanu
Jan 13 2017 02:25

function lookUpProfile(firstName, prop){
// Only change code below this line

for(i=0;i<contacts.length;i++)

{
if(firstName===contacts[i].firstName)
{
if(prop===contacts[i].prop)
{
return contacts[i][prop];
}
else
{
return "No such property";
}
}
}

return "No such contact";
// Only change code above this line
}can some one tell me,why cant we "prop===contacts[i].prop" instead os "has own property" in the above program

Rony Vidaur
@RonyVidaur
Jan 13 2017 02:25
@AlisonYoon alright erase all of your code, we're gonna start clean
Alison Yoon
@AlisonYoon
Jan 13 2017 02:25
ok I did
Lawanu Borthakur
@Lawanu
Jan 13 2017 02:25
@AlisonYoon its confusing
Alison Yoon
@AlisonYoon
Jan 13 2017 02:26
@Lawanu it's killing me
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:26
first thing were gonna do is, as we need to go to every contact to check if that name exist we're gonna create a for loop for that
for(var i = 0; i < contacts.length; i++)
Alison Yoon
@AlisonYoon
Jan 13 2017 02:26
yes
Ken Haduch
@khaduch
Jan 13 2017 02:26
@Lawanu - prop is going to contain a property name, and contacts[i].prop is not a valid way to use a variable to access an object's property, so it's just broken...
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:26
like that, so that we can go trough every contact
Lawanu Borthakur
@Lawanu
Jan 13 2017 02:27
@khaduch thanks
CamperBot
@camperbot
Jan 13 2017 02:27
lawanu sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2263 | @khaduch |http://www.freecodecamp.com/khaduch
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:27
alright inside of that for loop the first thing we want to check is if that name is in the contacts array
Alison Yoon
@AlisonYoon
Jan 13 2017 02:27
yes
Ken Haduch
@khaduch
Jan 13 2017 02:28
@Lawanu - but if you did use the correct method of access the property, and there was such a property there, contacts[i][prop] would return the value of the property, which would probably not work, either. Unless the property name and value were the same - but that's probably of very limited usefulness.
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:28
hint: if(firstName === contacts[i]["firstName])
CamperBot
@camperbot
Jan 13 2017 02:28
Set a bonfire to talk about with bonfire name
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:28
that is the condition to check if that contact name is in the array
if(firstName === contacts[i]["firstName"])
sorry I forgot a quote mark at the end
Joe Escobedo
@joeEscob1023
Jan 13 2017 02:29

ok i have a question on the global scope and function lesson. // Declare your variable here
var myGlobal = 10;

function fun1() {
// Assign 5 to oopsGlobal Here
oopsGlobal = 5;
} //I understand all this but

// Only change code above this line
function fun2() { /i dont understand what this has to do with the lesson /
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

Rony Vidaur
@RonyVidaur
Jan 13 2017 02:29
@AlisonYoon remember how in a previous lesson you learned about how we can check for an specific value inside of an object
basically what we're saying is, if the fistName value that we're given is equals to the firstName value of the contact[i]
makes sense so far?
Alison Yoon
@AlisonYoon
Jan 13 2017 02:31
if(firstName===contacts[i]["firstName"]{
if(contacts.hasOwnProperty("prop")===prop){
return contacts[i]["prop"]
};
}
yes I understood
like that?
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:32
@AlisonYoon you're going good
just the second line should be if(contacts[i].hasOwnProperty(prop))
rubenoid
@rubenoid
Jan 13 2017 02:32

hi people. i have a question about Using Objects for Lookups (JavaScript)

this is the solution:


// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line


  var lookup = {
    "alpha": "Adams",
    "bravo": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot": "Frank"
  };

  result = lookup[val];


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

// Change this value to test
phoneticLookup("charlie");
Alison Yoon
@AlisonYoon
Jan 13 2017 02:32
oh right, because that itself gives true/false, right?
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:32
'cause the method hasOwnProperty will return true of false depending if the prop exist
Alison Yoon
@AlisonYoon
Jan 13 2017 02:33
yes
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:33
@AlisonYoon exactly, you got it
rubenoid
@rubenoid
Jan 13 2017 02:33

now why comes

result = lookup[val];

after var lookup and not before?

Rony Vidaur
@RonyVidaur
Jan 13 2017 02:33
change the third line aswell
just put prop without quotes
Alison Yoon
@AlisonYoon
Jan 13 2017 02:34
yes did it
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:34
alrigh so we're gonna return that if we found the name and it has the prop
Alison Yoon
@AlisonYoon
Jan 13 2017 02:34
yes
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:34
now write an else statement
in case we dont find the prop
Zak
@zaksanderford
Jan 13 2017 02:35
Woot! Got through the Mutations exercise.
Denise Bogarin
@MignonChatte1388
Jan 13 2017 02:36
@RadiophonicOddity09 take a look at your notes... remember the past challenges? look back at how to manipulate arrays
Alison Yoon
@AlisonYoon
Jan 13 2017 02:36
if(firstName===contacts[i].firstName){
if(contacts.hasOwnProperty(prop)){
return contacts[i][prop];} else {
return "No such property";}
}else {
return "No such contact";
}
Joseph
@revisualize
Jan 13 2017 02:36
@AlisonYoon You're returning too early.
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:36
@AlisonYoon going great!
Alison Yoon
@AlisonYoon
Jan 13 2017 02:36
@revisualize ahh is it?
Joseph
@revisualize
Jan 13 2017 02:36
@AlisonYoon Can I ask you a side question?
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:37
yeah the "no such contact"
Alison Yoon
@AlisonYoon
Jan 13 2017 02:37
@revisualize go ahead
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:37
we need to place it just in case
Joseph
@revisualize
Jan 13 2017 02:37
@AlisonYoon Let's say you were at a big business event and you're quite popular (with all those skills you have) throughout the event you got handed 200 business cards (Which will remain unordered). Now, I walk up to you at the end and ask you.. Do you have a Business Card for "Jane Smith"? Now you loop look through your stack of 200 business cards. When would you tell me that you didn't have a business card for Jane? (Simplest answer please.)
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:37
we finish looping trough the array and we were unable to find the contact
Alison Yoon
@AlisonYoon
Jan 13 2017 02:38
@RonyVidaur hmm so outside of for loop?
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:38
@AlisonYoon exactly
Alison Yoon
@AlisonYoon
Jan 13 2017 02:38
@revisualize after I look thru all 200 business cards
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:38
@AlisonYoon so delete that else and just return outside of the loop (as you said)
Alison Yoon
@AlisonYoon
Jan 13 2017 02:38
ok
Joseph
@revisualize
Jan 13 2017 02:39
@AlisonYoon So, you're saying that after you loop look through all of the contacts cards in your array of object stack. That you'd tell me you don't have one for the individual?
  // code before a for loop.
for (..........) {
  // Code inside of a for loop.
}
  // code after a for loop.
@AlisonYoon Basically what other people have said.
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:40
@revisualize that was a great explanation
Joseph
@revisualize
Jan 13 2017 02:40
@RonyVidaur Thanks. I pre-typed it.
CamperBot
@camperbot
Jan 13 2017 02:40
revisualize sends brownie points to @ronyvidaur :sparkles: :thumbsup: :sparkles:
Alison Yoon
@AlisonYoon
Jan 13 2017 02:40
@revisualize yes
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:40
@AlisonYoon give it a try now
Alison Yoon
@AlisonYoon
Jan 13 2017 02:41
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++){
  if(firstName===contacts[i].firstName){
  if(contacts.hasOwnProperty(prop)){
  return contacts[i][prop];
  }  else {
  return "No such property";
  }
}
} return "No such contact";
// Only change code above this line
}
Joseph
@revisualize
Jan 13 2017 02:41
@AlisonYoon Does that work?
Alison Yoon
@AlisonYoon
Jan 13 2017 02:41
I got 2 missions passed, the rest three , I didn't pass them
Joseph
@revisualize
Jan 13 2017 02:41
@AlisonYoon Oh. Your .hasOwnProperty() is broken.
@AlisonYoon You're not accessing the array element.
Alison Yoon
@AlisonYoon
Jan 13 2017 02:42
oh oh
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++){
  if(firstName===contacts[i].firstName){
  if(contacts.hasOwnProperty(contacts[i].prop)){
  return contacts[i][prop];
  }  else {
  return "No such property";
  }
}
} return "No such contact";
// Only change code above this line
}
still didn't pass it hm why
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:43
@AlisonYoon hmmm not quite, remember we are checking if an specific contact has that propery
Joseph
@revisualize
Jan 13 2017 02:43
@AlisonYoon Look at this line: if(contacts.hasOwnProperty(prop)){ read it from left to right.
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:43
property*
Alison Yoon
@AlisonYoon
Jan 13 2017 02:44
@revisualize I changed it to
Joseph
@revisualize
Jan 13 2017 02:44
Which was incorrect.
Alison Yoon
@AlisonYoon
Jan 13 2017 02:44
 if(contacts.hasOwnProperty(contacts[i].prop))
Joseph
@revisualize
Jan 13 2017 02:44
I deleted your change for a reason.
Alison Yoon
@AlisonYoon
Jan 13 2017 02:44
@RonyVidaur
if(contacts.hasOwnProperty(contacts[i].prop)
Joseph
@revisualize
Jan 13 2017 02:44
contacts is an array.
Alison Yoon
@AlisonYoon
Jan 13 2017 02:45
yes
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:45
@AlisonYoon you're very close, almost got it, @revisualize is giving you a great hint
Joseph
@revisualize
Jan 13 2017 02:45
contacts[i].firstName
contacts[i][prop]
Alison Yoon
@AlisonYoon
Jan 13 2017 02:45
yes
Joseph
@revisualize
Jan 13 2017 02:46
contacts.hasOwnProperty(prop) ???
Alison Yoon
@AlisonYoon
Jan 13 2017 02:46
ahhh I can't wait
ohohohoh
sorry
I got it
contacts[i].hasOwnProperty(prop)
??
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:46
@AlisonYoon +1
Joseph
@revisualize
Jan 13 2017 02:46
Does it work?
Alison Yoon
@AlisonYoon
Jan 13 2017 02:47
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++){
  if(firstName===contacts[i].firstName){
  if(contacts[i].hasOwnProperty(contacts[i].prop)){
  return contacts[i][prop];
  }  else {
  return "No such property";
  }
}
} return "No such contact";
// Only change code above this line
}
did this so far it doesn't work for some reason still
OH wiat
wait
I did it
did it
Joseph
@revisualize
Jan 13 2017 02:47
You need to change the .hasOwnProperty() argument.
Alison Yoon
@AlisonYoon
Jan 13 2017 02:47
DID IT
Joseph
@revisualize
Jan 13 2017 02:47
yeah.
Alison Yoon
@AlisonYoon
Jan 13 2017 02:47
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++){
  if(firstName===contacts[i].firstName){
  if(contacts[i].hasOwnProperty(prop)){
  return contacts[i][prop];
  }  else {
  return "No such property";
  }
}
} return "No such contact";
// Only change code above this line
}
this !!!
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:48
great you got it
Alison Yoon
@AlisonYoon
Jan 13 2017 02:48
@revisualize @RonyVidaur Thank you so much guys!!
CamperBot
@camperbot
Jan 13 2017 02:48
:cookie: 294 | @ronyvidaur |http://www.freecodecamp.com/ronyvidaur
alisonyoon sends brownie points to @revisualize and @ronyvidaur :sparkles: :thumbsup: :sparkles:
:star2: 2950 | @revisualize |http://www.freecodecamp.com/revisualize
Alison Yoon
@AlisonYoon
Jan 13 2017 02:48
I really appreciate it
Joseph
@revisualize
Jan 13 2017 02:48
Does it make sense?
Alison Yoon
@AlisonYoon
Jan 13 2017 02:48
I couldn't sleep well because of this
Joseph
@revisualize
Jan 13 2017 02:48
That sucks.
:P
Alison Yoon
@AlisonYoon
Jan 13 2017 02:48
yes it makes sense. Everything makes sense once I know the answer haha
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:49
@AlisonYoon you're welcome, read over every line again and make sure you understand the concepts and reasons behind that code
Alison Yoon
@AlisonYoon
Jan 13 2017 02:49
yes I will
thanks so much! :D
Joseph
@revisualize
Jan 13 2017 02:49
Yeah. It is really good lesson. It really uses a lot of your previous knowledge.
Record Collection is another good lesson. But, they moved it.
anyhow!
Tyler Beutel
@TylerBeutel
Jan 13 2017 02:50
Working on the Diff Two Arrays where I have to "Compare two arrays and return a new array with any items only found in one of the two given arrays, but not both." This seems to work for most, but not for all and I can't figure out why... can anyone help? Here is my code:

function notIn(val, arr) {
  for (var i=0; i<arr.length; i++) {
    if (arr[i] == val) {
      return false;
    }
  }
  return true;
}

function diffArray(arr1, arr2) {
  var newArr = [];

  // Check arr1 against arr2
  for (var i=0; i<arr1.length; i++) {
    if (notIn(arr1[i], arr2)) {
      if (notIn(arr1[i], newArr)) {
        if (arr1[i] !== null) {
          newArr.push(arr1[i]);
        }
      }
    }
  }

  // Check arr2 against arr1
  for (var j=0; j<arr1.length; j++) {
    if (notIn(arr2[j], arr1)) {
      if (notIn(arr2[j], newArr)) {
        if (arr2[j] !== null) {
          newArr.push(arr2[j]);
        }
      }
    }
  }

  return newArr;
}

diffArray([], ["snuffleupagus", "cookie monster", "elmo"]);
Joseph
@revisualize
Jan 13 2017 02:50
I'm sitting at the Seattle JS meetup. I should focus.
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:50
@revisualize hehehe multitasking
gstpierre11
@gstpierre11
Jan 13 2017 02:51
That last return in profile lookup is tricky
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:51
@TylerBeutel can you be a little bit more specific?
Tyler Beutel
@TylerBeutel
Jan 13 2017 02:52
These are the tests that I pass: http://prntscr.com/duz2zl
Joseph
@revisualize
Jan 13 2017 02:52
@gstpierre11 Yeah. It is changing your way of thinking.
Justin
@tanpaopao
Jan 13 2017 02:52
function queue(arr, item) {
  // Your code here
  queue.push(item);
  queue.shift();

  return arr;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Could some help me with this?
Alison Yoon
@AlisonYoon
Jan 13 2017 02:53
@revisualize what do they do in Seattle JS meet up ?
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:53
@TylerBeutel I'm going to take a look
Tyler Beutel
@TylerBeutel
Jan 13 2017 02:53
Thanks
Justin
@tanpaopao
Jan 13 2017 02:54
The course is <bold>Stand in Line</bold>, I really have no idea about it.
Austiclyse
@Austiclyse
Jan 13 2017 02:54

Hey, I'm working on Stand in Line challenge in the JS section and can someone tell me why "function nextInLine([], 1) would not equal "1". It's the only parameter on this challenge not met. ( Honestly, I don't under stand why it would equal anything at all...)

function nextInLine(arr, item) {
var newItem = arr.shift();
arr.push(item);
return newItem; // 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));

Alison Yoon
@AlisonYoon
Jan 13 2017 02:55
nice
there's not many js meet up here in seoul. at least not on meetup.com
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:57
@TylerBeutel hmmm there's a lot of loops tho, I would suggest looping to one array and see if that element exist in the other one using idexOf function
indexOf *
then you can push the elements that you need and can do the same process for the second array against the first one
Tyler Beutel
@TylerBeutel
Jan 13 2017 02:59
Yeah, would definately simplify my code a bit...
Rony Vidaur
@RonyVidaur
Jan 13 2017 02:59
@TylerBeutel try something like that and then tag me here if you have any question
Ken Haduch
@khaduch
Jan 13 2017 03:02
@Austiclyse @Austiclyse - the instructions say: Add the number to the end of the array, then remove the first element of array. Are you doing that? How are you adding a number to the end of the array?
Also, if you give some analysis to the conditions, you are starting with an empty array [] and want to be able to get the 1 into and out of it - how would you do that?
Austiclyse
@Austiclyse
Jan 13 2017 03:09
@khaduch ... i assumed I was adding a number to the end of the array because the console.log readout change from "before" and "after" being identical "[1, 2, 3, 4, 5]" to the new "after" readout being "[2, 3, 4, 5, 6]". As far as I can see I am meeting that requirement. If you're asking how I can provide the code again. And how I would get "1" from an empty array is exactly the thing that didn't make sense to me so if you're asking me, I really can't answer that.
Ken Haduch
@khaduch
Jan 13 2017 03:17

@Austiclyse - the instructions are specific -

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.

My question is: How are you adding the number to the end of the array. You are doing two things in your code, a .shift() and a .push() - which one is adding to the array, and which one is removing from the array? The one that adds should be first, and the one that removes should be second.

For most of the other cases, where the array is not empty, you are going to pass the tests for the most part no matter which order you do things in. For this one, it is very crucial to do things in the proper order.

Albert L. C.
@sirus3020
Jan 13 2017 03:18
x
Ken Haduch
@khaduch
Jan 13 2017 03:19
@sirus3020 -
y ?
Albert L. C.
@sirus3020
Jan 13 2017 03:19
how do you paste codes with the black box?
miner_paul
@aeselden92
Jan 13 2017 03:23
What am I missing here???

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (answer) {
case 1:
console.log("alpha");
break;
case 2:
console.log("beta");
break;
case 3:
console.log("gamma");
break;
case 4:
console.log("delta");
break;

}

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

Albert L. C.
@sirus3020
Jan 13 2017 03:24
s
Dominic Jones
@dhjfoodstech
Jan 13 2017 03:26
Heeelp I'm stuck lol
Austiclyse
@Austiclyse
Jan 13 2017 03:27
@revisualize Thank you for the link. @khaduch Okay, I did not realize the order was significant in this case. There are still several aspects about this problem I don't understand but for now I'm happy just move on from in and come back later with more experience. Thank you for informing me the order was important for the empty array qualifier.
CamperBot
@camperbot
Jan 13 2017 03:27
austiclyse sends brownie points to @revisualize and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2951 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 2264 | @khaduch |http://www.freecodecamp.com/khaduch
Joseph
@revisualize
Jan 13 2017 03:27
Except you need the knowledge for later lessons.
miner_paul
@aeselden92
Jan 13 2017 03:29
Im having trouble understanding wif in the Switch exercise they are looking for us to just display the option "beta" alpha etc... to the consol or show that they are equivalent.
or if there is a differnce
gwendel89
@gwendel89
Jan 13 2017 03:30
@aeselden92 You're changing the value of answer, no need to console.log
Austiclyse
@Austiclyse
Jan 13 2017 03:30
@revisualize I will just have to cross that bridge when I get to it. For now I'm moving on to booleans which I've already studied in other courses and have a firm grasp on.
miner_paul
@aeselden92
Jan 13 2017 03:31
@gwendel89 I realize but do I need to put some form of equivlence into the statement section?
Chris Wingler
@chriswingler
Jan 13 2017 03:31
any hints for chunky monkey?
miner_paul
@aeselden92
Jan 13 2017 03:31
Like if i just put alpha it shows error
gwendel89
@gwendel89
Jan 13 2017 03:31
@aeselden92 yep, so where you've currently got your console.log, should be changed to answer = "alpha"
miner_paul
@aeselden92
Jan 13 2017 03:32
I tryed that. will do again, Thank you @gwendel89
CamperBot
@camperbot
Jan 13 2017 03:32
aeselden92 sends brownie points to @gwendel89 :sparkles: :thumbsup: :sparkles:
:cookie: 127 | @gwendel89 |http://www.freecodecamp.com/gwendel89
miner_paul
@aeselden92
Jan 13 2017 03:34
still not going through
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (answer) {
case 1:
answer="alpha";
break;
case 2:
answer="beta";
break;
case 3:
answer="gamma";
break;
case 4:
answer="delta";
break; }
Patrick
@cyas87
Jan 13 2017 03:37
@miner_paul your expression for the switch value should be val
gwendel89
@gwendel89
Jan 13 2017 03:37
oh right, also your switch (answer) should be switch (val) because the input will be the val from the original heading
Vinicius Miranda da Silva
@vmsilva19
Jan 13 2017 03:38
hi
i' ve been tryin' solve the problem profile lookup
but i'm missing something, because until now i couldn't complete the task
miner_paul
@aeselden92
Jan 13 2017 03:39
Thank you!
Manish Giri
@Manish-Giri
Jan 13 2017 03:40
@vmsilva19 your code?
Vinicius Miranda da Silva
@vmsilva19
Jan 13 2017 03:40
I have already tried the following:
Joseph
@revisualize
Jan 13 2017 03:40
@Austiclyse youre skipping a lesson that is two or three lines of code.
Of additional code.
Vinicius Miranda da Silva
@vmsilva19
Jan 13 2017 03:41

for (var i in contacts) {
if (!contacts[count].hasOwnProperty("firstName")) {
response = "No such contact";

} else if (!contacts[count].hasOwnProperty(prop)) {
response = "No such property";

} else if (contacts[count].hasOwnProperty("firstName") && contacts[count].hasOwnProperty(prop)){
response = contacts[count][prop];

}
count++;

}
return response;

// Only change code above this line
}

Joseph
@revisualize
Jan 13 2017 03:41
Good luck on your journey.
Vinicius Miranda da Silva
@vmsilva19
Jan 13 2017 03:41

function lookUpProfile(firstName, prop){
// Only change code below this line
var obj, res;
for (var i = 0; i < contacts.length; i++) {
obj = contacts[i];
for (var x in obj){
if (obj.hasOwnProperty(x)) {
var attrName = x;
var attrValue = obj[x];
res = attrValue;
} else if (!obj.hasOwnProperty("firstName")) {
res = "No such contact";
} else if (!obj.hasOwnProperty(prop)) {
res = "No such property";
}

}

}
return res;

@Manish-Giri could you gave me some light on this topic?
GordonBombay88
@GordonBombay88
Jan 13 2017 03:46
Hey all. Have spent 4 hours trying to figure out wherefore-art-thou algorithm. At what point does everyone just say, "fuck it" and look at the somebody else's code and learn from that?
Guess that's not just a quesiton related to that algorithm but a general algorithm question. At some point I feel like the juice isn't worth the squeeze.
Manish Giri
@Manish-Giri
Jan 13 2017 03:47
@vmsilva19 first question, do you really need all the intermediate variables?
obj = contacts[i];
for (var x in obj){
if (obj.hasOwnProperty(x)) {
var attrName = x;
var attrValue = obj[x];
res = attrValue;
Dylan
@dhcodes
Jan 13 2017 03:48
@Manish-Giri graduated to HelpJavascript i see
Vinicius Miranda da Silva
@vmsilva19
Jan 13 2017 03:48
i'm just using for help in debug haha.. it's easier to change the response in return.. only for that
Dylan
@dhcodes
Jan 13 2017 03:48
;)
Manish Giri
@Manish-Giri
Jan 13 2017 03:48
@revisualize could you maybe link your gist to @vmsilva19 with the examples on business cards?
lol
@dhcodes :see_no_evil:
Dylan
@dhcodes
Jan 13 2017 03:48
soon you'll be in HelpBackEnd
Manish Giri
@Manish-Giri
Jan 13 2017 03:49
soon i'll be in a DeadEnd
:disappointed:
Joseph
@revisualize
Jan 13 2017 03:49
Yeah
Dylan
@dhcodes
Jan 13 2017 03:49
or helping me with react in HelpVisual
lol
Manish Giri
@Manish-Giri
Jan 13 2017 03:49
lol
wow I dint even know there was a HelpVisual room..
Dylan
@dhcodes
Jan 13 2017 03:49
i meant DataViz
Dylan
@dhcodes
Jan 13 2017 03:49
my bad
Manish Giri
@Manish-Giri
Jan 13 2017 03:49
or that too
no idea about DataViz either @dhcodes
Joseph
@revisualize
Jan 13 2017 03:50
Line 167
Manish Giri
@Manish-Giri
Jan 13 2017 03:50
I'll head back to my Java stuff :disappointed:
@revisualize thx..
Joseph
@revisualize
Jan 13 2017 03:51
Oh.
CamperBot
@camperbot
Jan 13 2017 03:51
:star2: 2952 | @revisualize |http://www.freecodecamp.com/revisualize
manish-giri sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
That?
Meh
I am on my phone
Manish Giri
@Manish-Giri
Jan 13 2017 03:51
@vmsilva19 if you're still around, @revisualize can help you out. Happy coding :tada:
Vinicius Miranda da Silva
@vmsilva19
Jan 13 2017 03:52
thx @Manish-Giri and @revisualize
CamperBot
@camperbot
Jan 13 2017 03:52
vmsilva19 sends brownie points to @manish-giri and @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3730 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 2953 | @revisualize |http://www.freecodecamp.com/revisualize
Vinicius Miranda da Silva
@vmsilva19
Jan 13 2017 03:52
i'll check these hints
RadiophonicOddity09
@RadiophonicOddity09
Jan 13 2017 03:53
could someone please help me with the stand in line challenge
this is what I have so far

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

return nextInline; // 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));

Dylan
@dhcodes
Jan 13 2017 03:54
@RadiophonicOddity09 use arr and item
you want to push item into arr
Matheus Vicente
@chamatt
Jan 13 2017 03:54

Does someone knows what i'm getting wrong?
https://www.freecodecamp.com/challenges/profile-lookup

function lookUpProfile(firstName, prop){
// Only change code below this line
var haveName = false;
var haveProp = false;
for(var i=0;i<contacts.length;i++)
{
if(contacts[i].firstName == firstName)
{
for(var j=0; j<contacts[i].length;j++)
{
haveName = true;
if(contact[j].hasOwnProperty(prop))
{
return contact[j][prop];
}
}
}
}
//errorcases
if(!haveName){
return "No such contact";
}
else{
return "No such property";
}
// Only change code above this line
}

Dylan
@dhcodes
Jan 13 2017 03:55
and then you want to use a method to return the first item from arr @RadiophonicOddity09
Manish Giri
@Manish-Giri
Jan 13 2017 03:56
@dhcodes quick question tho
Dylan
@dhcodes
Jan 13 2017 03:56
yo
Manish Giri
@Manish-Giri
Jan 13 2017 03:56
remember how if you make your solutions private you get a warning "this will disable your certificates"
what does "disable" mean exactly?
Dylan
@dhcodes
Jan 13 2017 03:58
@Manish-Giri idk, I think it means you won't have them until you show your solutions again
but i'm not sure
Eric Chung
@chungeric
Jan 13 2017 03:59
function titleCase(str) {
  var arr = [];
  var newStr = "";
  newStr = str.toLowerCase();
  arr = newStr.split(" ");

  for (var i = 0; i < arr.length; i++) {
    var word = arr[i];
    wordArr = word.split("");
    var capital = wordArr[0].toUpperCase();
    wordArr.shift();
    wordArr.unshift(capital);
    word = wordArr.join("");
    arr[i] = word;
  }
  str = arr.join(" ");
  console.log(str);
  return str;
}

titleCase("I'm a little tea pot");
Lol does this solution seem like an okay one for TitleCasing a sentence?
Dylan
@dhcodes
Jan 13 2017 04:00
@chungeric does it work?
Eric Chung
@chungeric
Jan 13 2017 04:00
It works but, I don't like making a solution that isn't reliable lol
Dylan
@dhcodes
Jan 13 2017 04:00
well... you could write like 80 more tests for it
Adeyemi Ademola
@deymow
Jan 13 2017 04:00
Hello
Dylan
@dhcodes
Jan 13 2017 04:00
but functional code that is readable is better than elegant code that is abstracted imho
Adeyemi Ademola
@deymow
Jan 13 2017 04:01
Pls I need help
Matheus Vicente
@chamatt
Jan 13 2017 04:01
How can i get the name of a property instead of it's content ???
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:01
@dhcodes i support that
Adeyemi Ademola
@deymow
Jan 13 2017 04:01
my code is not running properly
Manish Giri
@Manish-Giri
Jan 13 2017 04:01
@dhcodes ok ty
CamperBot
@camperbot
Jan 13 2017 04:01
manish-giri sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1691 | @dhcodes |http://www.freecodecamp.com/dhcodes
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:01
@chamatt you can use Object.keys
Eric Chung
@chungeric
Jan 13 2017 04:01
Right, so if that problem was like a real life thing though, i'd probably use more tests?
Dylan
@dhcodes
Jan 13 2017 04:02
@chungeric well more tests could prove your code's reliability
Matheus Vicente
@chamatt
Jan 13 2017 04:02
@chamatt you can use Object.keys
Thanks, i'll search more about it!
CamperBot
@camperbot
Jan 13 2017 04:02
sorry chamatt, you can't send brownie points to yourself! :sparkles: :sparkles:
Eric Chung
@chungeric
Jan 13 2017 04:02
Oh I see, you mean more tests other than what FCC provides?
Dylan
@dhcodes
Jan 13 2017 04:02
right
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:02
@deymow hey bro, what do you need help with
Dylan
@dhcodes
Jan 13 2017 04:02
you can plug your own tests into the editor
just replace the part between the () in your function call
Eric Chung
@chungeric
Jan 13 2017 04:03
Yeah that's true. Ahh okay, thanks! @dhcodes
CamperBot
@camperbot
Jan 13 2017 04:03
chungeric sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1692 | @dhcodes |http://www.freecodecamp.com/dhcodes
Adeyemi Ademola
@deymow
Jan 13 2017 04:03
@Lumexralph "my title case a sentence" task is not running properly
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:04
@deymow can you show your code?
Anh Nguyen
@tiremon112
Jan 13 2017 04:04

function golfScore(par, strokes) {
  // Only change code below this line


  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
the more i dive into javascript the more i am confuse.
Dylan
@dhcodes
Jan 13 2017 04:04
@chungeric looking at your code, I'm not sure why you need to assign arr[i] to word and then later assign word to arr[i] but otherwise looks similar to my first approach way back when
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:05
@tiremon112 just be patient, it'll click eventually
Matheus Vicente
@chamatt
Jan 13 2017 04:06
@tiremon112 , how do you post the code styled here?
Eric Chung
@chungeric
Jan 13 2017 04:06
@dhcodes I couldn't change the first letter of each array element otherwise. Couldn't figure it out
Anh Nguyen
@tiremon112
Jan 13 2017 04:06
@Lumexralph what i am suppose to do with this challenge i don't get it
it give me a big list and the instruction is so short. par and strokes will always be numeric and positive.
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:07
@tiremon112 what're your instructions?
Dylan
@dhcodes
Jan 13 2017 04:08
@chungeric oh I get it now
cool cool
Eric Chung
@chungeric
Jan 13 2017 04:09
@dhcodes Haha idk it feels too long... or is that how it's supposed to be
Anh Nguyen
@tiremon112
Jan 13 2017 04:10
@Lumexralph wait let me try
Dylan
@dhcodes
Jan 13 2017 04:12
@chungeric first time around yeah
once you learn regex it will be easier
Anh Nguyen
@tiremon112
Jan 13 2017 04:13
@Lumexralph Aha probably have something to do with if and else
Dylan
@dhcodes
Jan 13 2017 04:13
@chungeric also you can chain methods together. ex. var strArr = str.toLowerCase().split(" ");
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:14
@tiremon112 okay, try something out then
@deymow done anything?
Eric Chung
@chungeric
Jan 13 2017 04:16
@dhcodes Lol just saw your solution on github. It's so smalll. How are you pushing the challenges to github?
Adeyemi Ademola
@deymow
Jan 13 2017 04:16
@Lumexralph i have. I don't know how to show my solution rather than pasting the link
Anh Nguyen
@tiremon112
Jan 13 2017 04:17
@Lumexralph wow i actually did it without getting help :+1:
Dylan
@dhcodes
Jan 13 2017 04:17
@chungeric I made a github repo, cloned it to my computer, and then I copy/paste each challenge and instructions into a markdown file and then push it to github
it's mostly just for others and for trying es6
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:18
@tiremon112 you see, just lil patience
@tiremon112 :+1:
This message was deleted
Dylan
@dhcodes
Jan 13 2017 04:19
brb
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:20

@deymow

3 backticks (```)
newline
your codes
3 backticks (```)

can you try this?

Adeyemi Ademola
@deymow
Jan 13 2017 04:26
not working
@Lumexralph not working
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:27
@deymow it's a pseudocode remember? :point_up: January 13, 2017 5:20 AM
@deymow keep tring
Adeyemi Ademola
@deymow
Jan 13 2017 04:28

function titleCase(str) {
  var changeFirst = str.split('/\s+/g');
  var seeArray = ' ';
  for(var i =0; i<changeFirst.length; i++){
    var collectArray = changeFirst[i].split(' ');
    var firstLetter = collectArray[0];
    var capitalLetter = firstLetter.toUpperCase();
    seeArray += changeFirst.splice(0, 1, capitalLetter).join(' ');

  }

  return seeArray;
}

titleCase("I'm a little tea pot");
@Lumexralph thanks
CamperBot
@camperbot
Jan 13 2017 04:29
deymow sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 719 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:31
@deymow var changeFirst = str.split('/\s+/g'); what're you trying to do here
Miguel Benevento
@KSMOknot
Jan 13 2017 04:47
hey guys can anyone help out with indexOf problem?
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:49
@KSMOknot let's see
Miguel Benevento
@KSMOknot
Jan 13 2017 04:50

function mutation(arr) {
  var str = arr[0].indexOf(arr);
  var txt = arr[1].indexOf(arr);
  if (str === txt){
    return true;
  }else {
    return false;
  }
}

mutation(["hello", "hey"]);
so this is my code and this is the problem'

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.

For example, ["hello", "Hello"], should return true because all of the letters in the second string are present in the first, ignoring case.

The arguments ["hello", "hey"] should return false because the string "hello" does not contain a "y".

Lastly, ["Alien", "line"], should return true because all of the letters in "line" are present in "Alien".

Ogundele Olumide
@Lumexralph
Jan 13 2017 04:51
@KSMOknot first of all , var str = arr[0].indexOf(arr); var txt = arr[1].indexOf(arr); is wrong
Miguel Benevento
@KSMOknot
Jan 13 2017 04:52
should i remove [0] <-----
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:54
@KSMOknot you should just index arr since it's an array like this arr[0], arr[1] that will give you the two elements in array, then you can use a loop to go through the characters of the second element, using indexOf to check if it exists in the first element
Miguel Benevento
@KSMOknot
Jan 13 2017 04:55
alright Ill try it out. thanks!
Justin
@tanpaopao
Jan 13 2017 04:56
function queue(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift();  
  return arr;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Could someone help to solve this problem? If's difficult for me for the course stand in line.
heroiczero
@heroiczero
Jan 13 2017 04:58
@tanpaopao gotta store the shifted item in a variable
Ogundele Olumide
@Lumexralph
Jan 13 2017 04:59
@tanpaopao return arr.shift() this will return the first element, arr.shift() a value is returned, you either return it or store it , return arr; this will only return the array arr
Santiago
@santiduron
Jan 13 2017 05:05
Hello campers Santiago here
Ogundele Olumide
@Lumexralph
Jan 13 2017 05:06
@santiduron hi
Adeyemi Ademola
@deymow
Jan 13 2017 05:10
@Lumexralph was tryin to split all words into array in small letter
Ogundele Olumide
@Lumexralph
Jan 13 2017 05:11
@deymow why using regExp ?
@deymowthis is what you get from var changeFirst [ 'I\'m a little tea pot' ], the way you split only returned the words in an array as one an not split into words, try splitting with spaces
Wesley Handy
@wesleylhandy
Jan 13 2017 05:34

I posted this on the main chat, but probably should have posted here. Let me know if you need to see my code:

Hey everyone, I am working on some of the javascript algorithms, particularly the smallest common multiples. I have been trying this for several days, reading, checking Stackoverflow, the documentation, etc. Here's what I have so far.

I am keeping all the prime numbers in the series and reducing all nonprimes to a set of prime factors.

So, think a series of 1 - 13, you have 13, 11, 7, 5, 3, 2 and 322, 52, 33, 222, 32, 22.

The last six numbers are all arrays. I want to compare my array of primes with my arrays of prime factors and only merge from the prime factors only those factors that are missing.

So, looping backwards from 13 to 1 - I keep 13 for my final array, then need to add [3, 2, 2] to my final array (to represent 12), then I add 11, but when I only need [5] from my [5, 2] array (think, 10), since 2 is already there. Then only [3] from [3,3], and only 2 from [2, 2, 2]. You see where I'm going with that.

I can't for my mind think of how to accomplish this. It is probably so obvious is right in front of my face.

Any help out there would be appreciated.

heroiczero
@heroiczero
Jan 13 2017 05:36
Justin
@tanpaopao
Jan 13 2017 05:36
@Lumexralph Thank you, solved it perfect.
CamperBot
@camperbot
Jan 13 2017 05:36
tanpaopao sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 720 | @lumexralph |http://www.freecodecamp.com/lumexralph
tptynlr
@tptynlr
Jan 13 2017 05:37
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};
how to access glove boc property
heroiczero
@heroiczero
Jan 13 2017 05:40
@tptynlr myStorage.prop.prop.prop where props are the properties of javascript http://www.w3schools.com/js/js_properties.asp
tptynlr
@tptynlr
Jan 13 2017 05:41
var gloveBoxContents =myStorage.car["inside"].glove box
not working
Wesley Handy
@wesleylhandy
Jan 13 2017 05:41
@heroiczero I see that and will look into it, you can also see that I'm attempting the method in the same article directly under greatest common divisor.
Yellowswan
@Leon-Huang
Jan 13 2017 05:44
@tptynlr myStorage.car.inside["glove box"]
tptynlr
@tptynlr
Jan 13 2017 05:45
@Leon-Huang thnk u
Harish Gadiya
@harishgadiya
Jan 13 2017 05:47
@tptynlr never use spaces in variable names or object keys. It may be break your code
inomjon1993
@inomjon1993
Jan 13 2017 05:58
Hi everybody ! who can help me solve this task 'Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.' , I am new learner
Steven2493
@Steven2493
Jan 13 2017 06:00

function mutation(arr) {
  var newArr = [];
  for (var i = 0; i < arr.length; i++) {
    newArr.push(arr[i].toLowerCase());
      if(newArr == arr[i].indexOf() > - 1){
        return true;
       }else{
        return false;
  }
}

}

mutation(["hello", "hey"]);
Need some help on the mutations algorithm?
Not sure how to get mutation(["hello", "Hello"]) should return true. print true.
Hemant
@aherhemant
Jan 13 2017 06:01

Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

i dont get it
heroiczero
@heroiczero
Jan 13 2017 06:02
@aherhemant use \nfor newline and \r return carriage and escape your \ with another\ and make it look like
FirstLine
\SecondLine\
ThirdLine
@Steven2493 if(newArr == arr[i].indexOf() > - 1)this conditional statement seems wrong
Hemant
@aherhemant
Jan 13 2017 06:04
@heroiczero ok thanks
CamperBot
@camperbot
Jan 13 2017 06:04
aherhemant sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 662 | @heroiczero |http://www.freecodecamp.com/heroiczero
heroiczero
@heroiczero
Jan 13 2017 06:08
@Steven2493 remember you have a arr[0]= "hello" and a arr[1]="hey" in your example arr[0][0] is the h in hello
Alexander Køpke
@alexanderkopke
Jan 13 2017 06:08
@inomjon1993 what is your code so far?
i dont understand what exactly has to be done here! please help
heroiczero
@heroiczero
Jan 13 2017 06:10
@ajayporal review shift, unshift, push, and pop method for arrays in FCC map
@ajayporal two of the four method is the answer
ajayporal
@ajayporal
Jan 13 2017 06:11
Thanks
@heroiczero
wlagos1992
@wlagos1992
Jan 13 2017 06:13
Im on the Nesting for Loops challenge and i the example is nothing like what its asking me to do, can someone help point me in the right direction?
Alexander Køpke
@alexanderkopke
Jan 13 2017 06:14
@heroiczero I hacked it! muhahaha passed it without the use of those methods
function nextInLine(arr, item) {
  // Your code here
  arr.splice(4,0,item);
  return arr[0];  // Change this line
}
Theo M.
@cnngraphics
Jan 13 2017 06:15
@alexanderkopke how do you show the code like this?
wlagos1992
@wlagos1992
Jan 13 2017 06:15
``` before and after the code @cnngraphics
Alexander Køpke
@alexanderkopke
Jan 13 2017 06:15
``` + enter, paste in code, end with ctrl+enter
Theo M.
@cnngraphics
Jan 13 2017 06:16
thanks
Wesley Handy
@wesleylhandy
Jan 13 2017 06:18

Still looking for advice. How do you merge two arrays, so that the first array includes all its original elements, plus only those elements from the second array not in the first (which may be duplicate values).

Any ideas? Data conversion? recursion? anything.

wlagos1992
@wlagos1992
Jan 13 2017 06:20
why not use .push?
cant you use that to merge the data to the end of the array
oh but you want to take out duplicates, hmmm merge them then write something along the lines of var !== remove
Wesley Handy
@wesleylhandy
Jan 13 2017 06:21
Sure, but the logic has be able to identify the data is duplicated and should be included.
Think [1, 2, 3, 4, 5] plus [5, 2, 2] = [1, 2, 2, 3, 4, 5]
wlagos1992
@wlagos1992
Jan 13 2017 06:23
yeah thats above me haha im stuck on these vague early ones >.>
amarg26
@amarg26
Jan 13 2017 06:29
hi, does anyones knows about jquery datatable ??
vivekpadia70
@vivekpadia70
Jan 13 2017 06:33
can any one please help me with lcm challenge???
function smallestCommons(arr) {
  arr = arr.sort();
  function lcm(a,b){
    c = b/a;
    if(c === parseInt(c, 10)){
      return b;
    }
    else return a*b;
  }
  var total=arr[1];
  for(var i=arr[1]; i>=arr[0]; i--){
    if(i == 1)
      break;
    var c = lcm(i-1, total);
    total = c;
  }
  console.log(total);
  return total;
}
this is my code but i don't get exact answers for queries
wlagos1992
@wlagos1992
Jan 13 2017 06:34

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line


  // Only change code above this line
  return product;

}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
if anyone is familiar with this one can you help me? The example is written nothing like what its asking so i need some help.
vivekpadia70
@vivekpadia70
Jan 13 2017 06:35
first concat all arrays into one than use reduce function
@wlagos1992
wlagos1992
@wlagos1992
Jan 13 2017 06:36
concat?
this will help you
@wlagos1992
then take look at this for reduce method
wlagos1992
@wlagos1992
Jan 13 2017 06:38
@vivekpadia70 okay so i can do that and then i can use the for i=0; i<newarr3.length; i*i+1?
vivekpadia70
@vivekpadia70
Jan 13 2017 06:38
yes you can also do that
@wlagos1992
wlagos1992
@wlagos1992
Jan 13 2017 06:38
okay let me try that brb
wait how cna i use concat if they are sub arrays?
vivekpadia70
@vivekpadia70
Jan 13 2017 06:39
you have to use arguments
wlagos1992
@wlagos1992
Jan 13 2017 06:40
Sorry im still new you lost me, what arguement would i use when there can be any number of arr?
would i use the for( a;b;c) method?
vivekpadia70
@vivekpadia70
Jan 13 2017 06:41
its an array created by js for the parameters in the function
Liam Bang
@Liam345
Jan 13 2017 06:41
Hi I have a snippet of code in my react app that is, let snipp="<p>Wiki <bold>Viewer</bold></p>”; How do I render it without the html tags or better still applying the html tags to the element and then rendering it.
vivekpadia70
@vivekpadia70
Jan 13 2017 06:42
function smallestCommons(arr) {
  arr = arr.sort();
  function lcm(a,b){
    c = b/a;
    if(c === parseInt(c, 10)){
      return b;
    }
    else return a*b;
  }
  var total=arr[1];
  for(var i=arr[1]; i>=arr[0]; i--){
    if(i == 1)
      break;
    var c = lcm(i-1, total);
    total = c;
  }
  console.log(total);
  return total;
}
anyone for lcm???
smallest common multiple
wlagos1992
@wlagos1992
Jan 13 2017 06:43
@vivekpadia70 im sorry i dont see how it directly goes into this one.. the way the site teaches it doesnt always make sense to me..
So when the user can input any amount of sub arrays i have to argue it to concat the total arrays. I dont see how to do that
vivekpadia70
@vivekpadia70
Jan 13 2017 06:44
see in ur array the arguments are like thi
[1,2] = arguments[0];
[3,4] = arguments1;
[5,6,7] = arguments2;
wlagos1992
@wlagos1992
Jan 13 2017 06:45
okay that makes sense to me
vivekpadia70
@vivekpadia70
Jan 13 2017 06:45
it is already created by js for you
wlagos1992
@wlagos1992
Jan 13 2017 06:45
hold on let me try
Chung Ik Yu
@cjddlr
Jan 13 2017 06:45
is there anyone who solving 205?
Bigyan Karki
@bigyankarki
Jan 13 2017 06:45
guys i am stuck at this counting cards game
Chung Ik Yu
@cjddlr
Jan 13 2017 06:45
It's name is 'Testing Objects for Properties'
Bigyan Karki
@bigyankarki
Jan 13 2017 06:45

var count = 0;

function cc(card) {
// Only change code below this line
for (var i = 0; i < 5; i++) {
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;

case 7:
case 8:
case 9:
 count += 0;
  break;

case 10:
case "J":
case "Q":
case "K":
case "A":
  count--;
  break;

}
if (count > 0) {
return count + "Bet";
}

else {
  return count + " Hold";
}

}

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

var count = 0;

function cc(card) {
// Only change code below this line
for (var i = 0; i < 5; i++) {
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;

case 7:
case 8:
case 9:
 count += 0;
  break;

case 10:
case "J":
case "Q":
case "K":
case "A":
  count--;
  break;

}
if (count > 0) {
return count + "Bet";
}

else {
  return count + " Hold";
}

}

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

oops sorry
can anyone go through this?
wlagos1992
@wlagos1992
Jan 13 2017 06:48
@vivekpadia70 i am looking at the example it gives me trying to do something similar but it makes no sense to me is this the right path?
for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
    console.log(arr[i][j]);
  }
Coy Sanders
@coymeetsworld
Jan 13 2017 06:48

@bigyankarki

if (count > 0) {
return count + "Bet";
}

issue is there

forgot a space
Dipak Telangre
@dipaktelangre
Jan 13 2017 06:48
@wlagos1992 Code is correct for 2 D array
Bigyan Karki
@bigyankarki
Jan 13 2017 06:49
@coymeetsworld thanks
CamperBot
@camperbot
Jan 13 2017 06:49
bigyankarki sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1798 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Bigyan Karki
@bigyankarki
Jan 13 2017 06:49
i am so stupid lol
wlagos1992
@wlagos1992
Jan 13 2017 06:49
@dipaktelangre thats the example from the problem but i dont understand how it moves onto my problem? my problem is asking me to multiply every product
Bigyan Karki
@bigyankarki
Jan 13 2017 06:49
but trust instruction was so unclear
we havent even touched at loop and they give such problems..thats so unfair
vivekpadia70
@vivekpadia70
Jan 13 2017 06:50
yes you can try that @wlagos1992
Coy Sanders
@coymeetsworld
Jan 13 2017 06:50
at loop?
Dipak Telangre
@dipaktelangre
Jan 13 2017 06:50
@wlagos1992 Send me challenge link
Coy Sanders
@coymeetsworld
Jan 13 2017 06:50
@bigyankarki no everything in that challenge should've either been described in the instruction or covered in a previous one
FCC makes no assumptions you know anything about coding when you first start
vivekpadia70
@vivekpadia70
Jan 13 2017 06:51
does anybody here knows about smallest common multiple??
you should probably use 2 for loops only @wlagos1992
wlagos1992
@wlagos1992
Jan 13 2017 06:53
@vivekpadia70 i should use loops? haha FCC hasnt even gone over loops yet im not sure
Yellowswan
@Leon-Huang
Jan 13 2017 06:53
blob
vivekpadia70
@vivekpadia70
Jan 13 2017 06:53
for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
    console.log(arr[i][j]);
  }
this will help i think
Yellowswan
@Leon-Huang
Jan 13 2017 06:54
in the question "profile lookup", my function doesn't work ......
vivekpadia70
@vivekpadia70
Jan 13 2017 06:55
what's the error? @Leon-Huang
Yellowswan
@Leon-Huang
Jan 13 2017 06:55
no error, just doesn't pass the test
wlagos1992
@wlagos1992
Jan 13 2017 06:55
@vivekpadia70 i dont understand what that code does, it looks like it just displays an arr value?
vivekpadia70
@vivekpadia70
Jan 13 2017 06:56
try to console.log @Leon-Huang
Yellowswan
@Leon-Huang
Jan 13 2017 06:56
looks only match both return of both "no such ....."
OK ,let me try
Karan Vyas
@karanpvyas
Jan 13 2017 06:56
i got a code running perfectly in chrome, but seems like its a bug in safari, can anyine pplease have a look at it and let me know
vivekpadia70
@vivekpadia70
Jan 13 2017 06:56
yes that displays array value but you have to channge code between those arrays @wlagos1992
vivekpadia70
@vivekpadia70
Jan 13 2017 06:59
@wlagos1992
wlagos1992
@wlagos1992
Jan 13 2017 06:59
@vivekpadia70 im not getting it. I am not a fan of FCC way of teaching and this problem is one of the ones where i am lost
vivekpadia70
@vivekpadia70
Jan 13 2017 06:59
product = product*arr[i][j];
just put this instead of console.log
this problem is simple you just have to multiply all the numbers to product
wlagos1992
@wlagos1992
Jan 13 2017 07:00
so what is arr[i][j]
does that mean it will keep multipying to satisfy all numbers for i j?
vivekpadia70
@vivekpadia70
Jan 13 2017 07:00
do you know about loops?
wlagos1992
@wlagos1992
Jan 13 2017 07:00
no it hasnt gone over loops
vivekpadia70
@vivekpadia70
Jan 13 2017 07:01
ohh than first complete loops man
wlagos1992
@wlagos1992
Jan 13 2017 07:01
@vivekpadia70 i take that back it has
vivekpadia70
@vivekpadia70
Jan 13 2017 07:01
so its just loops nothing else
wlagos1992
@wlagos1992
Jan 13 2017 07:02
@vivekpadia70 i think ill re go over them
vivekpadia70
@vivekpadia70
Jan 13 2017 07:02
alright don't rush my friend @wlagos1992
Yellowswan
@Leon-Huang
Jan 13 2017 07:02
@vivekpadia70 I just add some console.log, but it seems doesn't work, I didn't see any output printed by console.log. what shall I do?
vivekpadia70
@vivekpadia70
Jan 13 2017 07:03
console.log prints output in you browser's console
@Leon-Huang
Yellowswan
@Leon-Huang
Jan 13 2017 07:03
blob
vivekpadia70
@vivekpadia70
Jan 13 2017 07:04
which browser do you use?
can you send me challenge link? @Leon-Huang
bilian shen
@bilianshen
Jan 13 2017 07:10

it doest
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 ++;
  break;
case 10:
case 'j':
case 'Q':
case 'K':
case 'A':
  count --;
  break;

}

var result = " Bet";
if(count <= 0) {
result = " Hold";
}

console.log(count + result);

// Only change code above this line
}

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

bilian shen
@bilianshen
Jan 13 2017 07:11
it do not work . anyone can help me
wlagos1992
@wlagos1992
Jan 13 2017 07:11
thats the next one i have haha
Jceciliani
@Jceciliani
Jan 13 2017 07:11
Can anyone help with this? Been doing this one for a couple hours with multiple combinations and I cant figure it out.. It is the Stand in Line challenge. This is what I have and it is asking for.. 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.

function nextInLine(arr, item) {
var nextInLine = ([], 1);
nextInLine.push(item);
nextInLine.shift(1);

return nextInLine; // 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));

vivekpadia70
@vivekpadia70
Jan 13 2017 07:13
first try that ur self @wlagos1992
Yellowswan
@Leon-Huang
Jan 13 2017 07:14
@vivekpadia70 http://www.freecodecamp.cn/challenges/profile-lookup#?solution=%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUp(name%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20contacts.length%3B%20i%2B%2B)%20%7B%0A%20%20%20%20%0A%20%20%20%20if%20(contacts%5Bi%5D.firstName%20%3D%3D%20name)%20%7B%0A%20%20%20%20%20%20if%20(contacts%5Bi%5D.hasOwnProperty(prop))%7B%0A%20%20%20%20%20%20%20%20console.log(contacts%5Bi%5D%5Bprop%5D)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20return%20%22No%20such%20property%22%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20return%20%22No%20such%20contact%22%3B%0A%20%20%7D%20%20%20%20%0A%20%20%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUp(%22Akira%22%2C%20%22likes%22)%3B%0A
wlagos1992
@wlagos1992
Jan 13 2017 07:14
@vivekpadia70 now that i solved the other one i understand how that looks through the arr
dfox789
@dfox789
Jan 13 2017 07:19
Why is 100% of 100% of Javascript problems a challenge to wrap my head around?
dfox789
@dfox789
Jan 13 2017 07:25
@Jceciliani its only asking to return the removed
Stanley Oguazu
@dearests
Jan 13 2017 07:26
@Leon-Huang your "no such contact"should be returned after the closing brace of "for loop"
Yellowswan
@Leon-Huang
Jan 13 2017 07:26
@dearests let me try it
@dearests yes, it worked, thank you
CamperBot
@camperbot
Jan 13 2017 07:28
leon-huang sends brownie points to @dearests :sparkles: :thumbsup: :sparkles:
:cookie: 263 | @dearests |http://www.freecodecamp.com/dearests
Yellowswan
@Leon-Huang
Jan 13 2017 07:28
blob
Jceciliani
@Jceciliani
Jan 13 2017 07:29
@dfox789 Sorry, I am quite new to JS, even coding for that matter, so what do you mean?
Stanley Oguazu
@dearests
Jan 13 2017 07:30
@Leon-Huang you should return return contacts[i][prop]; , not to output to the console.log
Andrei Constantin
@andrei-constantin
Jan 13 2017 07:31
@Leon-Huang you have to use a while loop not a for
Yellowswan
@Leon-Huang
Jan 13 2017 07:31
@dearests yes, I modified it, the passed.
Stanley Oguazu
@dearests
Jan 13 2017 07:32
@Leon-Huang :+1:
bejzik8
@bejzik8
Jan 13 2017 07:32
can i get a help with using objects for lookups?
Yellowswan
@Leon-Huang
Jan 13 2017 07:32
@andrei-constantin well, for or while both works, actually they're similar
wlagos1992
@wlagos1992
Jan 13 2017 07:33
  for (var i = 0; i < contacts.length; i++) {

    if (contacts[i].firstName != name) 


      return "No such property";

    if(contacts[i].hasOwnProperty(prop))
        return (contacts[name][prop]);

    return "No such contact";
    }
i left out an else at the last return
dfox789
@dfox789
Jan 13 2017 07:34
@Jceciliani new here too... its asking to return the removed which is the .shift item. for me I tried var removedFromList=arr.shift(); then called it by new name in the return.
wlagos1992
@wlagos1992
Jan 13 2017 07:34
i have it backwards though let me redo it i see my errors
Jceciliani
@Jceciliani
Jan 13 2017 07:34
I feel like I am closer but there is something missing. Still need to "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."

function nextInLine(arr, item) {
var nextInLine = ([], 1);
testArr.push(item);
testArr.shift(arr);

return nextInLine; // Change this line
}

// Test Setup
var testArr = [5,6,7,8,9];

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

wlagos1992
@wlagos1992
Jan 13 2017 07:35
  for (var i = 0; i < contacts.length; i++) {

    if (contacts[i].firstName != name) 


      return "No such contact";

    if(contacts[i].hasOwnProperty(prop))
        return (contacts[name][prop]);

    else return "No such property";
    }
i am getting an error saying it cannot read property 'likes' of an undefined.
Stanley Oguazu
@dearests
Jan 13 2017 07:36
@Jceciliani push the item @ the end of the array and you should return the return testArr.shift();
Yellowswan
@Leon-Huang
Jan 13 2017 07:38
@wlagos1992 return(contacts[name][prop]) --> return(contacts[i][prop])
dfox789
@dfox789
Jan 13 2017 07:39
like arr.push(item) I didn't use testArr in the function code
Darth Skywalker
@adityaparab
Jan 13 2017 07:40
@wlagos1992 you're returning way too early
wlagos1992
@wlagos1992
Jan 13 2017 07:41
@adityaparab okay so how would i return later?
Darth Skywalker
@adityaparab
Jan 13 2017 07:42
for (var i = 0; i < contacts.length; i++) {
  if (contacts[i].firstName == firstName){
    if(contacts[i].hasOwnProperty(prop))
      return contacts[i][prop];
  } else{
    return "No such property";
  }
}
return "No such contact";
In first iteration, if the firstNames don't match. You prematurely return No such contact
you want to do it AFTER you've checked all your contacts
so your return "No such contact"; should come after the for loop ends
wlagos1992
@wlagos1992
Jan 13 2017 07:43
ohhhh i see
Jceciliani
@Jceciliani
Jan 13 2017 07:47
@dfox789 I'm still not getting it.. I just need to see the right answer at this point. 2 hours on this seems like so much time.. I am sure it is something so small...
wlagos1992
@wlagos1992
Jan 13 2017 07:51
 for (var i = 0; i < contacts.length; i++) {

    if (contacts[i].firstName == name) {
    if(contacts[i].hasOwnProperty(prop))

    return (contacts[i][prop]); 
 } else {

   return "No such property";
  } 
  }
    return "No such contact";
now its saying no such property even when i have it
@jeangardy509 put your code inside ```
use the top left button on your keyboard then hit shift enter to start composing code. Let me see it there and ill help you
dfox789
@dfox789
Jan 13 2017 07:54
@Jceciliani function nextInLine(arr, item) {
// Your code here
arr.push(item);
var removedFromLine=arr.shift();
return removedFromLine; // Change this line
}
Darth Skywalker
@adityaparab
Jan 13 2017 07:54
@wlagos1992 show your full code
wlagos1992
@wlagos1992
Jan 13 2017 07:55
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(name, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length ; i++) {

    if (contacts[i].firstName == name) {
    if(contacts[i].hasOwnProperty(prop))

    return (contacts[i][prop]); 
 }  else {

   return "No such property";
  } 
  }
    return "No such contact";

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "address");
Darth Skywalker
@adityaparab
Jan 13 2017 07:59
@wlagos1992 There is no address property on
{
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    }
wlagos1992
@wlagos1992
Jan 13 2017 07:59
Yes but it is failing according to the FCC checklist
Darth Skywalker
@adityaparab
Jan 13 2017 08:00
@wlagos1992 : I see
check your curly braces
I see problem there
you have { for 1st if
there is no { for 2nd if
then after 2nd if you have }
and then you have else.
so you think you have else on 2nd if, but syntactically, that else belongs to first if
Jceciliani
@Jceciliani
Jan 13 2017 08:02
@dfox789 Thank you. I'll analyze it to make sure I truly understand what happens there.
CamperBot
@camperbot
Jan 13 2017 08:02
jceciliani sends brownie points to @dfox789 :sparkles: :thumbsup: :sparkles:
:cookie: 218 | @dfox789 |http://www.freecodecamp.com/dfox789
Darth Skywalker
@adityaparab
Jan 13 2017 08:03
@wlagos1992 This should work
function lookUp(name, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length ; i++) {
    if (contacts[i].firstName == name) {
      if(contacts[i].hasOwnProperty(prop)){
        return (contacts[i][prop]);
      }  else {
        return "No such property";
      } 
    }
  }
  return "No such contact";
// Only change code above this line
}
Darth Skywalker
@adityaparab
Jan 13 2017 08:06
@redoz94 var myStr="FirstLine\n\\SecondLine\\\rThirdLine";
wlagos1992
@wlagos1992
Jan 13 2017 08:07
It works for all of them but it wont pass my tests.....
redoz94
@redoz94
Jan 13 2017 08:08
@adityaparab thanks man! could you possibly elaborate on whats actually going on? bit confused here
CamperBot
@camperbot
Jan 13 2017 08:08
redoz94 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 823 | @adityaparab |http://www.freecodecamp.com/adityaparab
wlagos1992
@wlagos1992
Jan 13 2017 08:09
@adityaparab thanks i found the problem.
CamperBot
@camperbot
Jan 13 2017 08:09
wlagos1992 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 824 | @adityaparab |http://www.freecodecamp.com/adityaparab
help, anyone?
CamperBot
@camperbot
Jan 13 2017 08:12
no wiki entry for: anyone
Coy Sanders
@coymeetsworld
Jan 13 2017 08:14
@redoz94 look at the example
you need to write 2 lines, can't put it in 1 like that
Anivesh
@aniveshhere
Jan 13 2017 08:17

var code = "formatted";

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

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);

can anyone help me to get undefined output
wlagos1992
@wlagos1992
Jan 13 2017 08:18

function randomFraction() {

  // Only change code below this line.
var i =1; 
  Math.random(i);
  return 0+i;

  // Only change code above this line.
}
how do i use Math.random?
Yellowswan
@Leon-Huang
Jan 13 2017 08:18
@wlagos1992 Math.random() is OK
wlagos1992
@wlagos1992
Jan 13 2017 08:19
@Leon-Huang got it thanks
CamperBot
@camperbot
Jan 13 2017 08:19
wlagos1992 sends brownie points to @leon-huang :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for leon-huang
Markus Kiili
@Masd925
Jan 13 2017 08:27
@wlagos1992 return Math.random(); would return a random float between 0 and 1 (1 excluded).
BugsBuggy
@BugsBuggy
Jan 13 2017 08:37
I need to check if firstName is an actual contact's firstName and if the property is a given property. Can somebody help me?
function lookUpProfile(firstName, prop){
// Only change code below this line
if( (contacts.firstName ===firstName) && (contacts.hasOwnProperty(prop))){
  return contacts.firstName.prop;
}
// Only change code above this line
}
Markus Kiili
@Masd925
Jan 13 2017 08:37
@BugsBuggy First you need to loop or iterate through contacts array.
That way you can target each contact and test it for the correct first name.
Yellowswan
@Leon-Huang
Jan 13 2017 08:39
@BugsBuggy
function lookUp(name, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length ; i++) {
    if (contacts[i].firstName == name) {
      if(contacts[i].hasOwnProperty(prop)){
        return (contacts[i][prop]);
      }  else {
        return "No such property";
      } 
    }
  }
  return "No such contact";
// Only change code above this line
}
Markus Kiili
@Masd925
Jan 13 2017 08:40
@Leon-Huang Please don't post solutions here.
Try to help instead.
Yellowswan
@Leon-Huang
Jan 13 2017 08:41
@Masd925 OK
Jceciliani
@Jceciliani
Jan 13 2017 08:42
I am only having issues with Hole-in--One. Does anyone see the issue?

function golfScore(par, strokes) {
// Only change code below this line
if (strokes == 1) {
return "Hole-in-One";
}
else if (strokes <= par-2) {
return "Eagle";
}
else if (strokes == par-1) {
return "Birdie";
}
else if (strokes == par) {
return "Par";
}
else if (strokes == par+1) {
return "Bogey";
}
else if (strokes == par+2) {
return "Double Bogey";
}
else if (strokes >= par+3) {
return "Go Home!";
}

return "Change Me";
// Only change code above this line
}

// Change these values to test
golfScore(5, 4);

Yellowswan
@Leon-Huang
Jan 13 2017 08:43
@Jceciliani I remembered this should be done by switch/case
Jceciliani
@Jceciliani
Jan 13 2017 08:44
@Leon-Huang What do you mean?
Yellowswan
@Leon-Huang
Jan 13 2017 08:44
this question should be rewrite as switch/case keywords, is that one?
Jceciliani
@Jceciliani
Jan 13 2017 08:46
@Leon-Huang I have no idea. the past 6 challenges had me do what I did, so I figured thats what it wanted me to do.
Yellowswan
@Leon-Huang
Jan 13 2017 08:47
@Jceciliani maybe remove the line
return "Change Me";
CamperBot
@camperbot
Jan 13 2017 08:47
:bulb: to format code use backticks! ``` more info
Jceciliani
@Jceciliani
Jan 13 2017 08:50
@Leon-Huang nope.. Its definitely the code in Hole-in-One. Everything the other code works as it should
Jceciliani
@Jceciliani
Jan 13 2017 09:01
What's funny is that i used the values to test and it is all correct.. Lol.
llamatarianism
@llamatarianism
Jan 13 2017 09:02
@Leon-Huang can't be done with switch/case
that's not how switch works
@Jceciliani your capitalisation is probably wrong
or you're missing an exclamation mark somewhere
make sure you're returning exactly what the instructions say