These are chat archives for FreeCodeCamp/HelpJavaScript

16th
May 2017
Rick Brown
@RickBr0wn
May 16 2017 00:01
@cmccormack do u have 10 minutes free for a DM chat, about this problem?
Christopher McCormack
@cmccormack
May 16 2017 00:02
@RickBr0wn Sure
Stephen James
@sjames1958gm
May 16 2017 00:09
@JuanP97 All you need to do is find one letter in letters2ndWord that is not in arr[0].toLowerCase().split("")
And if so return false, otherwise return true. The first time you find a missing one return false.
wanglinke
@wanglinke
May 16 2017 00:12
@CBSpartan yeah,U're right 😬
Cara
@CaraLarissa
May 16 2017 00:19
Hello everyone! I'm on the Basic JavaScript challenge Stand in Line and I've solved most of it except for one and I can't seem to figure out what I'm doing wrong
Maximino V. Jardin III
@ma5one1
May 16 2017 00:19
Anyone recommend a good read to deeply understand JS?
Cara
@CaraLarissa
May 16 2017 00:20

Here's the code:

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

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

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

The part that I can't figure out is:
nextInLine([5,6,7,8,9], 1) should return 5
António Carvalho
@antoniomapc_twitter
May 16 2017 00:24
anyone experienced with fetch API ?
Juan Pablo Jaramillo
@JuanP97
May 16 2017 00:25
@sjames1958gm Thanks, Stephen. That makes a lot of sense, and it works!!
CamperBot
@camperbot
May 16 2017 00:25
juanp97 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7328 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
CyberBrick
@CyberBrick
May 16 2017 00:28
Hello World

Kind of stuck on Word Blanks. Here is my code any suggestions. result = "My" + myNoun + "toe" + myAdjective + "therefore" + myVerb + "excited" myAdverb;
// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("McDonalds", "circular", "run", "crooked");

Gulsvi
@gulsvi
May 16 2017 00:33
@CyberBrick There's a + missing before myAdverb and you'll want to add spaces or you'll end up with "MyMcDonaldstoecircularthereforerunexcitedcrooked"
@CaraLarissa Looks like you should be pushing and shifting arr not testArr.
CyberBrick
@CyberBrick
May 16 2017 00:35
ok Thanks @SkyCoder01
CamperBot
@camperbot
May 16 2017 00:35
cyberbrick sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:star2: 1395 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Gulsvi
@gulsvi
May 16 2017 00:35
testArr won't change from test case to test case, but arr will
@antoniomapc_twitter I've used fetch() in a few projects. What's your question?
3gimpfingers
@3gimpfingers
May 16 2017 00:36
@CyberBrick And the spaces are necessary. It doesn't pass without them.
Gene
@bginop
May 16 2017 00:41
hey guys i am working on the check for palindromes challenge and i was wondering if anyone knew of a work around for my logic i.e., to get the if statement to evaluate. Basically I wanted to learn about a double function technique used on the mozilla developer website. I figured out how to use the double functions for this challenge but i am having trouble figuring out how to test my results with a IF statement

function palindrome(str) {
function removeAndShrink(match, string){
return match.toLowerCase();

}
return str.replace(/[\w]/gi,removeAndShrink).split("").reverse().join("") ;

}

palindrome("eye strike dark");

if (str === convert){
return true;
}

Long Nguyen
@longnt80
May 16 2017 00:48
@bginop can you copy all your code?
Elmer Hdez
@ElmerHdez
May 16 2017 00:52
I'm new to JS! In the counting cards challenge should I use a for loop? or a switch? I don't know how should I do this. I know it is simple, but I can't think clear right now.
abraham anak agung
@padunk
May 16 2017 00:52
@ElmerHdez switch is easier
Gene
@bginop
May 16 2017 00:54
longnt80 thats all of the code
Moisés Man
@moigithub
May 16 2017 00:56
all ur code should be inside palindroe function @bginop
Long Nguyen
@longnt80
May 16 2017 00:56
@bginop what is convert? I don't see anything assign to it?
Gene
@bginop
May 16 2017 00:57
str is converted from upper case to lower case then it is reversed
the if statement is something i'm working on to try and evaluate the parameter that is converted
I'm just trying to figure that out because i exited both functions using return
and maybe the best move is to scrap the double function technique from mozilla and start over
Joseph
@revisualize
May 16 2017 01:01
hello
I'm at the Seattle office for General Assembly chatting in freeCodeCamp. LOL!
@bginop Your function is not returning a comparison.

@bginop I see that you have this:

function removeAndShrink(match, string){
return match.toLowerCase();
}

I don't see the logic in having that.. Could you explain it?

@CyberBrick Did you solve your challenge?
Long Nguyen
@longnt80
May 16 2017 01:08
@bginop you meant you wanted to see the reversed string?
Gene
@bginop
May 16 2017 01:09
i think the you need the .toLowerCase and .replace in two seperate return statements. However by simply adding this evaluation at the end of the line the return statement performs its own evalutation . thus removing the need for an if statement
longnt80 yes i did. Because the challange wants me to test that racecar spelt backwards is the same word. If it is return false
Joseph
@revisualize
May 16 2017 01:09
@bginop You don't.
Gene
@bginop
May 16 2017 01:10
my problem now is regex.
Joseph
@revisualize
May 16 2017 01:10
you can .toLowerCase() You don't need to create a new function for that.
@bginop Can you show me your function?
Gene
@bginop
May 16 2017 01:10
So i could put it all in one function?
Long Nguyen
@longnt80
May 16 2017 01:10
@bginop no you got it wrong
the return only return the str in reverse . It doesn't evaluate anything
Gene
@bginop
May 16 2017 01:10

function palindrome(str) {
var convert = str;
function removeAndShrink(match, string){
return match.toLowerCase();

}

return str.replace(/([\w])(\d)/gi,removeAndShrink).split("").reverse().join("") === convert;
}

palindrome("EyE Strike Dark123");

Joseph
@revisualize
May 16 2017 01:11
@bginop Okay. you have a few issues.
@bginop Fixing your regex won't solve your challenge. Although, you do need to fix your regex.
Gene
@bginop
May 16 2017 01:11
heh yeah this was a tough challenge. Plus i wanted to learn why mozilla developer network chained two functions together
Long Nguyen
@longnt80
May 16 2017 01:11
@bginop return will stop the function, you cannot do anything after that
Gene
@bginop
May 16 2017 01:12
longnt80. I know thats why i added the === at the end
I think that performs my logic test
Joseph
@revisualize
May 16 2017 01:12
@longnt80 They have the first return inside of a nested function.
Long Nguyen
@longnt80
May 16 2017 01:12
no you can't do that
Joseph
@revisualize
May 16 2017 01:12
@longnt80 Yes you can.
Gene
@bginop
May 16 2017 01:12
But it sounds like some how i need to convert this to one function
Long Nguyen
@longnt80
May 16 2017 01:13
oh yeah , sorry
Joseph
@revisualize
May 16 2017 01:13
function myFunc(x) {
     function innerFunc(y) {
     }
}
Gene
@bginop
May 16 2017 01:13
then somehow convert a variable with this return function
Joseph
@revisualize
May 16 2017 01:13
@longnt80 That syntax is valid.
@bginop Which return function?
Long Nguyen
@longnt80
May 16 2017 01:14
@revisualize I wasn't talking about that syxtax
Joseph
@revisualize
May 16 2017 01:15
@bginop I think you need to be more descriptive. I don't think you're using the correct terminology and that's okay. You'd just need to be more descriptive about what you're trying to get assistance with.
Long Nguyen
@longnt80
May 16 2017 01:15
@revisualize he was trying to put an if statement after the return of the main function
Joseph
@revisualize
May 16 2017 01:15
@longnt80 Not in the code that I saw him place when I asked them to post their code.
@longnt80 I saw that in a previous code block. But, I'm not focused on the past. Focus on the now and move forward.
:D
Gene
@bginop
May 16 2017 01:17
sorry guys i dont really know the terminology that well as i started coding about 3 weeks ago
Long Nguyen
@longnt80
May 16 2017 01:17
@revisualize I know, I was talking about the logic. He cannot put evaluation after the return because it won't do anything
Joseph
@revisualize
May 16 2017 01:17
@bginop It is okay. Just please describe what you're working with and what you're trying to do.
@bginop I don't understand the purpose of the inner function that you created.
Gene
@bginop
May 16 2017 01:18
I wanted to do two things: 1) solve his palendrome challenge 2) try and understand why mozilla developer website used two functions to replace capital letters with lower case
Long Nguyen
@longnt80
May 16 2017 01:18
@bginop you need to generate 2 string:
  • One in normal direction
  • One in reversed
  • Then compare those two
Gene
@bginop
May 16 2017 01:19
so i worked out how and why the chained functions work. Seems like the first function puts the parameters into lower case and the second function replaces the upper case with lower
Long Nguyen
@longnt80
May 16 2017 01:20
@bginop that's not 2 functions, it's the .replace() method with a function as parameter
@bginop from that page: Specifying a function as a parameter
Gene
@bginop
May 16 2017 01:21
I could be missing something but this seems like two functions to me:
function styleHyphenFormat(propertyName) {
function upperToHyphenLower(match, offset, string) {
return (offset ? '-' : '') + match.toLowerCase();
}
return propertyName.replace(/[A-Z]/g, upperToHyphenLower);
}
Joseph
@revisualize
May 16 2017 01:21
@bginop So, you need to use the .replace() method to remove all non-alphanumeric characters and replace them with nothing.
Gene
@bginop
May 16 2017 01:22
thats the mozilla code i attempted to convert to try and understand it
Joseph
@revisualize
May 16 2017 01:22
@bginop You don't need to create a new function for that challenge.
@bginop You're trying to over complicate the challenge then understand the over-complication.
Gene
@bginop
May 16 2017 01:23
I know that was my goal. I wanted to know why mozilla chose to use two functions
then i wanted to apply that logic to this challange to see if i understood their intent
Joseph
@revisualize
May 16 2017 01:23
@bginop Sometimes the examples on MDN are more advance that what you need.
Gene
@bginop
May 16 2017 01:23
yeah its been huge
thats what has been great about it because i'm learning a ton
of course i know im way over my head
but i'm close - i think?
Joseph
@revisualize
May 16 2017 01:24
@bginop You have an idea. Parts of that idea are valid.
Gene
@bginop
May 16 2017 01:26
well i believe this works
Joseph
@revisualize
May 16 2017 01:26
@bginop You have all of the methods that you need to use in your function. They're just out of order.
And your regex is incorrect.
Gene
@bginop
May 16 2017 01:26
ohh i know it. thats a beast in itself
Long Nguyen
@longnt80
May 16 2017 01:26
@bginop the example in MDN you gave is exactly what is going on with the challenge, you don't have to use 2 function
Gene
@bginop
May 16 2017 01:27
trying to decode regex and figure out what i am missing
Long Nguyen
@longnt80
May 16 2017 01:27
@bginop freecodecamp already give you 1 main function:
function palindrome(str) {
}
Joseph
@revisualize
May 16 2017 01:27
@bginop My problem is.. I don't know what you want to have your function accomplish.
@bginop Your regex is complete different depending on what you want your function to do .. If you really want to use that inner function.
Long Nguyen
@longnt80
May 16 2017 01:29
@revisualize I think he misunderstood the example in MDN
Joseph
@revisualize
May 16 2017 01:30
@longnt80 Maybe. I'm just here to help. I need a direction to help with though.
Long Nguyen
@longnt80
May 16 2017 01:32
@bginop have you passed the challenge without using function as a parameter of replace?
Keon Samuel
@keonsam
May 16 2017 01:33
yh babe.
Long Nguyen
@longnt80
May 16 2017 01:33
@bginop I think if you pass the challenge first, you might understand the example MDN gives you
Joseph
@revisualize
May 16 2017 01:33
I agree!
will
@uhohtrouble
May 16 2017 01:41
hi
Joseph
@revisualize
May 16 2017 01:41
Everyone remember to get their free book from https://www.packtpub.com/packt/offers/free-learning ???
@uhohtrouble Hello.
Long Nguyen
@longnt80
May 16 2017 01:46
@revisualize is it delivered outside of US?
Joseph
@revisualize
May 16 2017 01:47
@longnt80 It is an e-book.
Do you have an internet connection?
Long Nguyen
@longnt80
May 16 2017 01:48
@revisualize oh, didn't see that lol
thanks
CamperBot
@camperbot
May 16 2017 01:48
longnt80 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3970 | @revisualize |http://www.freecodecamp.com/revisualize
canoid
@canoid
May 16 2017 01:48
hi, Im struggling with this challenge "Selecting from many options with Switch Statements", what's wrong here??
Joseph
@revisualize
May 16 2017 01:48
@canoid What code do you have?
canoid
@canoid
May 16 2017 01:49
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  answer = val;
  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;  
}

// Change this value to test
caseInSwitch(1);
Joseph
@revisualize
May 16 2017 01:49
@canoid THere's your problem!
@canoid You're doing console.log.
@canoid Console.log doesn't do anything really for your function.
@canoid You should be reassigning the value of answer
canoid
@canoid
May 16 2017 01:50
but even without it, doesn't seem to work :/
Joseph
@revisualize
May 16 2017 01:50
@canoid Also, don't do this: answer = val;
canoid
@canoid
May 16 2017 01:50
why?
Joseph
@revisualize
May 16 2017 01:50
@canoid Show me what you did without console.log.
@canoid You should be assigning the values inside of your console.log to the variable answer.
@canoid Your function is returning answer
Greg Lawrence
@Chewieez
May 16 2017 01:51

I'm working on the first question for Switch statements and I got the code to successfully run, but the code threw some errors and I'd like a second opinion on whether I answered it 100% correctly.

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

// Change this value to test
caseInSwitch(4);

Thank you!

Joseph
@revisualize
May 16 2017 01:51
@Chewieez You should remove all of your breaks.
Greg Lawrence
@Chewieez
May 16 2017 01:51
There is an error next to every Break that says "Unreachable Break after Return".
PhoenixFarhan
@PhoenixFarhan
May 16 2017 01:51

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

function checkObj(checkProp) {
// Your Code Here
checkProp= myObj.hasOwnProperty();
if (checkProp === true) {
return myObj.gift;
}
else if (checkProp === true) {
return myObj.pet;
}
else if (checkProp === true) {
return myObj.bed;
}

else {
return "Not Found";
}}

HI
having ytouble with this
how do I pass my Obj to checkProp
Joseph
@revisualize
May 16 2017 01:52

@PhoenixFarhan So you have a function declaration of function checkObj(checkProp) { } .. With that function declaration you have a function name of checkObj and you have a parameter of checkProp.
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).
So, when you make a function call:
checkObj("pet") ... the parameter checkProp gets the value of the arguement "pet".
checkObj("horse") ... the parameter checkProp gets the value of the arguement "horse".
As mentioned above, you can then use the parameter inside of the function just like you'd use any other variable that holds a value.
Now, the lesson is trying to teach you about the object method .hasOwnProperty()

The hasOwnProperty() method returns a boolean (true/false) indicating whether the object has the specified property as own (not inherited) property.

@PhoenixFarhan You're overwriting your parameter which is causing you to have some serious code issues.
Greg Lawrence
@Chewieez
May 16 2017 01:53
What's the reasoning for not needing the breaks? Is it b/c that if I'm testing say caseInSwitch(3), and it goes to case1 and doesn't match, it hits the break and stops, instead of going to try case 2?
@revisualize
Joseph
@revisualize
May 16 2017 01:53
@Chewieez return does more than break does.
@Chewieez Once a return statement is triggered the function HALTS.
canoid
@canoid
May 16 2017 01:53
I typed the wrong statement .-.
@revisualize thx
CamperBot
@camperbot
May 16 2017 01:54
canoid sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3971 | @revisualize |http://www.freecodecamp.com/revisualize
Greg Lawrence
@Chewieez
May 16 2017 01:54
@revisualize ok. Is 'return' the correct method for this question? The instructions seem vague
Joseph
@revisualize
May 16 2017 01:54
@Chewieez Actually no.
Greg Lawrence
@Chewieez
May 16 2017 01:54
I tried console.log but it didn't like that, or I did it wrong
Long Nguyen
@longnt80
May 16 2017 01:54

@canoid

case 1:
      answer = "alpha";
      break;

remove answer = val;

Joseph
@revisualize
May 16 2017 01:54
@Chewieez Instead of doing return you should really be doing answer =
That.
What @longnt80 posted.
Stephen James
@sjames1958gm
May 16 2017 01:55
@Chewieez If you notice the return answer at the bottom - the expectation is that you set that variable
Greg Lawrence
@Chewieez
May 16 2017 01:55
@revisualize ahh ok. I wasn't sure, and saw the 'Return' at the end of the code and tried that.
canoid
@canoid
May 16 2017 01:56
@longnt80 thanks!
CamperBot
@camperbot
May 16 2017 01:56
canoid sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 258 | @longnt80 |http://www.freecodecamp.com/longnt80
PhoenixFarhan
@PhoenixFarhan
May 16 2017 01:57

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

function checkObj(checkProp) {
// Your Code Here

if (myObj.hasOwnProperty("gift") === true) {
return myObj.gift;
}
else if (myObj.hasOwnProperty("pet") === true) {
return myObj.pet;
}
else if (myObj.hasOwnProperty("bed") === true) {
return myObj.bed;
}

else {
return "Not Found";
}}

// Test your code by modifying these values
checkObj("pony");

how bout this?
it does not work either
Long Nguyen
@longnt80
May 16 2017 01:58
@PhoenixFarhan
myObj.hasOwnProperty("gift") === true
you don't have to set it equal to true
Greg Lawrence
@Chewieez
May 16 2017 01:58
Thanks! @revisualize @sjames1958gm @longnt80
CamperBot
@camperbot
May 16 2017 01:58
chewieez sends brownie points to @revisualize and @sjames1958gm and @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 259 | @longnt80 |http://www.freecodecamp.com/longnt80
:star2: 3972 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 7329 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Long Nguyen
@longnt80
May 16 2017 01:59
@PhoenixFarhan
myObj.hasOwnProperty("gift") already return true or false
Stephen James
@sjames1958gm
May 16 2017 02:00
@PhoenixFarhan The idea of a function is to provide a template that can be reused.
That is accomplished here through the checkProp variable/parameter
You should use the variable to check the property existence and to return the value
Long Nguyen
@longnt80
May 16 2017 02:00
Joseph
@revisualize
May 16 2017 02:00
@PhoenixFarhan You should be using the parameter
Joseph
@revisualize
May 16 2017 02:08

So you have a function declaration of function checkObj(checkProp) { } .. With that function declaration you have a function name of checkObj and you have a parameter of checkProp.
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).
So, when you make a function call:
checkObj("pet") ... the parameter checkProp gets the value of the arguement "pet".
checkObj("horse") ... the parameter checkProp gets the value of the arguement "horse".
As mentioned above, you can then use the parameter inside of the function just like you'd use any other variable that holds a value.
Now, the lesson is trying to teach you about the object method .hasOwnProperty()

The hasOwnProperty() method returns a boolean (true/false) indicating whether the object has the specified property as own (not inherited) property.

Adam
@adamakers
May 16 2017 02:17
I'm working with IIFE's right now. Why is this code
```
(function(){}())
Claudio Restifo
@Marmiz
May 16 2017 02:17
Hello coders! someone has experience with React-Router 4?
I am used to the v3; all I'm trying is a simple redirect if the user is authorized to see the message.
Kane Mcgukin
@kanemcgukin
May 16 2017 02:18
Hello coders. I'm a bit stuck on Profile Lookup #215
I have the following function function lookUpProfile(firstName, prop){
// Only change code below this line
for(i=0;i<contacts.length;i++){
if(firstName === contacts[i].firstName && prop === contacts[i].hasOwnProperty(prop)){
return contacts[prop];
}
else if (firstName != contacts[i].firstName){
return "No such contact";
}
else
return "No such property";
}
// Only change code above this line
}
It seems to work for the fail cases, anyone catch what I'm doing wrong with the loop? It's not catching the correct answers
Joseph
@revisualize
May 16 2017 02:19
@kanemcgukin return contacts[prop]; .. You're not accessing the element correctly.
@kanemcgukin Additionally, your for loop isn't looping.
Claudio Restifo
@Marmiz
May 16 2017 02:19
@adamakers that's an Immediatly Invoked Function Execution.
In short is a function that gets immediatly called after being created
Joseph
@revisualize
May 16 2017 02:20
@kanemcgukin How many times does this loop run:
for (var i = 0; i < 100000000; i++ ) {
    if (evaluation) {
        return "truth";
    } else {
        return "lies";
    }
 }
Kane Mcgukin
@kanemcgukin
May 16 2017 02:20
Thanks @revisualize, so should I being using . notation to access?
CamperBot
@camperbot
May 16 2017 02:20
kanemcgukin sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3973 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 16 2017 02:20
@kanemcgukin No.
Adam
@adamakers
May 16 2017 02:20
I'm working with IIFE's right now. The tutorial recommended to put in the window object, however, wouldnt I be able to access window properties without passing it in and instead just reassigning it? See below
(function(window){
    window.item = 'thing';
}(window));
-------------
(function(){
    window.item = 'thing';
}());
Kane Mcgukin
@kanemcgukin
May 16 2017 02:21
@revisualize a lot... it never breaks?
Joseph
@revisualize
May 16 2017 02:22
@kanemcgukin Incorrect.
@kanemcgukin I'm posting this..
@kanemcgukin
contacts[i].firstName
contacts[i].hasOwnProperty(prop)
contacts[prop];
Why are you using [i] ... Why don't you have [i] in the last iteration.
Kane Mcgukin
@kanemcgukin
May 16 2017 02:22
ahh. I see
Joseph
@revisualize
May 16 2017 02:22
@kanemcgukin Regarding...
The return statement ends function execution and specifies a value to be returned to the function caller.
Syntax
return [[expression]];
expression
The expression to return. If omitted, undefined is returned instead.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
Kane Mcgukin
@kanemcgukin
May 16 2017 02:23
I'm using [i] because there are multiple objects in the array
to get to each object and then check the name and if the property is there
Joseph
@revisualize
May 16 2017 02:23
@kanemcgukin But, contacts[prop]; ??
Claudio Restifo
@Marmiz
May 16 2017 02:23
@adamakers nope because everything in the function is not visible outside its scope. So unless you pass the window down (in the second set of parethesis) the window won't be visible outside
Kane Mcgukin
@kanemcgukin
May 16 2017 02:24
yeah, I see. let me add the [i] and see if it works @revisualize
Joseph
@revisualize
May 16 2017 02:24
@kanemcgukin It won't.
You have other issues.
Claudio Restifo
@Marmiz
May 16 2017 02:25
Basically the second sets of parenthesis calls the function that results from that evaluated expression of the first function.
More here
Adam
@adamakers
May 16 2017 02:25
@Marmiz but if I do this, I still get 'asdfasf'
(function(){
  window.greeting = 'asdfasdf';

}())

console.log(greeting);
Kane Mcgukin
@kanemcgukin
May 16 2017 02:25
@revisualize I see it's not working. I will research
was277
@was277
May 16 2017 02:26
how to make this sure "myStr should have encoded text with the proper escape sequences and no spacing."
Joseph
@revisualize
May 16 2017 02:26
@kanemcgukin Remember that for loop that I posted and asked you how many times it loops?
@kanemcgukin The answer is.. It doesn't loop.
Kane Mcgukin
@kanemcgukin
May 16 2017 02:27
var for i? @revisualize
left it out
nope
Joseph
@revisualize
May 16 2017 02:28
@kanemcgukin How many times does this loop run:
for (var i = 0; i < 100000000; i++ ) {
    if (evaluation) {
        return "truth";
    } else {
        return "lies";
    }
 }
@kanemcgukin 0 times.
Kane Mcgukin
@kanemcgukin
May 16 2017 02:28
until 1 less than 100000000
Joseph
@revisualize
May 16 2017 02:28
The return statement ends function execution and specifies a value to be returned to the function caller.
Syntax
return [[expression]];
expression
The expression to return. If omitted, undefined is returned instead.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
@kanemcgukin No. 0 times.
Kane Mcgukin
@kanemcgukin
May 16 2017 02:28
why? I
'm missing something here
Joseph
@revisualize
May 16 2017 02:29
@kanemcgukin Return statements HALT functions.
@kanemcgukin Halt the loop halt the whole function.
Kane Mcgukin
@kanemcgukin
May 16 2017 02:29
because it doesn't increment when it's right?
so move the return outside of the loop? @revisualize
Joseph
@revisualize
May 16 2017 02:29
@kanemcgukin Not always.
@kanemcgukin You need to change your logic a bit.
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?
Kane Mcgukin
@kanemcgukin
May 16 2017 02:30
so just assign the value and then return outside the loop @revisualize
Joseph
@revisualize
May 16 2017 02:30
@kanemcgukin You could but, not really.

@kanemcgukin

for (var i = 0; i < 100000000; i++ ) {
    if (evaluation) {
        return "truth";
    }
}

How many times could this function run?

Brittany Rutherford
@brittanyrutherford
May 16 2017 02:31
I have a weird question
Kane Mcgukin
@kanemcgukin
May 16 2017 02:31
once I'd gone through them all to see I didn't have one from Jane. after 200
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:31
probably repeated question
I can install git for windows, right? it will give me a windows application?
right?
Joseph
@revisualize
May 16 2017 02:31
@brittanyrutherford Yes.
I have git for windows installed on my computer
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:32
what is gitbash then?
is it bash + git?
Kane Mcgukin
@kanemcgukin
May 16 2017 02:32
all the way through because it doesn't stop even though it has return? it will always continue @revisualize
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:32
like 2 products in the same package?
Joseph
@revisualize
May 16 2017 02:33
@kanemcgukin You need to be very descriptive about when you trigger a return statement.
Claudio Restifo
@Marmiz
May 16 2017 02:33
@adamakers of course you can, but that's creating a global variable.
And IIEF are made specifically to avoid polluting the script with globals :)
Chelsey Jan
@ChelseyJan
May 16 2017 02:33
@brittanyrutherford think gitbash gives you command lines and git gui gives you a gui
Joseph
@revisualize
May 16 2017 02:33
Sorry. I actually need to go away and focus on the even that I'm at.
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:34
@ChelseyJan but gitbash gives me git as well, right?
revisualize @revisualize leaves. I'm at an event. Sorry.
Adam
@adamakers
May 16 2017 02:35
@brittanyrutherford so bash is a different kind of command line interface. Usually you find it on Linux machines and Mac. Windows just natively has CMD which a lot of people dont lilke
Chelsey Jan
@ChelseyJan
May 16 2017 02:35
@brittanyrutherford Yes. and i just looked it up, git cmd gives windows command lines and bash gives you linux commands, and they all give you git
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:35
@adamakers yeah, but is gitbash like 2 products in the same file?
Kane Mcgukin
@kanemcgukin
May 16 2017 02:36
thanks @revisualize
CamperBot
@camperbot
May 16 2017 02:36
kanemcgukin sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: kanemcgukin already gave revisualize points
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:36
so gitbash gives me git AND bash commands?
I can say that it's a downloadable package that gives me 2 functionalities, git + bash
Adam
@adamakers
May 16 2017 02:36
@brittanyrutherford i guess... It will install bash and a new terminal so that you can use bash and git. You dont HAVE to use git while using your bash.
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:36
yeah
hmmm
Claudio Restifo
@Marmiz
May 16 2017 02:37
@brittanyrutherford when you download Git for windows you have all the binaries. So you'll have git / git bash / git shell / git GUI
Chelsey Jan
@ChelseyJan
May 16 2017 02:37
@brittanyrutherford i think you consider all three different ways for using git
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:37
I am just confused about the thing, if I get git every time I wanna get bash
Keon Samuel
@keonsam
May 16 2017 02:37
codepen > github
Adam
@adamakers
May 16 2017 02:37
@brittanyrutherford but If you download git + bash then you need to use the bash and not cmd
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:38
@Marmiz i've never downloaded git for windows, I download gitbash, and when I wanna connect to github, it gives me this github local windows app popup that got installed with gitbash
Greg Lawrence
@Chewieez
May 16 2017 02:38
So in this code, should "undefined" be shown on the console? The code seems to "pass" and it says it's correct, but when I choose numbers that should return undefined, the console display is blank.
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a < 0 || b < 0) {
    return undefined;
}


  // 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);
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:38
i mean, git itself is something different than bash, right?
Adam
@adamakers
May 16 2017 02:38
@brittanyrutherford so that sounds like the GUI
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:39
@adamakers yeah, but I got this GUI when I installed gitbash
so seems like gitbash, installs git windows app + bash commands
right?
can u get bash commands without installing git?
Chelsey Jan
@ChelseyJan
May 16 2017 02:39
@brittanyrutherford i think you get it when you install a windows version of git regardless. so yes.
Adam
@adamakers
May 16 2017 02:39
@brittanyrutherford go to Start > Git > and then select Git Bash
grfraser
@grfraser
May 16 2017 02:40

anyone able to offer help with the weather app?

Adam
@adamakers
May 16 2017 02:40
@brittanyrutherford oh yes it will install 3 programs
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:40
@adamakers yeah, I have gitbash, git GUI and git CMD
@ChelseyJan yeah I just did that
interesting
so the question is, how can u install bash commands on windows?
Adam
@adamakers
May 16 2017 02:41
@brittanyrutherford yea. Sorry I guess i misunderstood. So a lot of people like to use the bash over the GUI. Not sure why, but its what is recommended so that what I've been learning
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:41
if u dont wanna get git
Chelsey Jan
@ChelseyJan
May 16 2017 02:41
@brittanyrutherford All 3 give you the same access to Git, just personal preference on which one to use. I learned Git on linux initially so I used gitbash
Adam
@adamakers
May 16 2017 02:41
@brittanyrutherford just use the bash terminal
Chelsey Jan
@ChelseyJan
May 16 2017 02:41
@brittanyrutherford i'm sure there's a way to install bash without git
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:41
@adamakers I have windows
@ChelseyJan aha
Chelsey Jan
@ChelseyJan
May 16 2017 02:42
@brittanyrutherford but I am not sure how. I think bash = linux style command line and all the things you can do with it
Adam
@adamakers
May 16 2017 02:42
@brittanyrutherford there is but it is buggy. I think Git for Bash w/ minty is probably the best for beginners
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:42
thanks all @ChelseyJan @adamakers @Marmiz
CamperBot
@camperbot
May 16 2017 02:42
brittanyrutherford sends brownie points to @chelseyjan and @adamakers and @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 226 | @chelseyjan |http://www.freecodecamp.com/chelseyjan
:cookie: 864 | @marmiz |http://www.freecodecamp.com/marmiz
:cookie: 326 | @adamakers |http://www.freecodecamp.com/adamakers
Chelsey Jan
@ChelseyJan
May 16 2017 02:43
@brittanyrutherford no problem!
Claudio Restifo
@Marmiz
May 16 2017 02:44

@brittanyrutherford

can u install bash commands on windows

As far as i know only windows 10 added a Linux subsystem... but I'm not a system engineer

So don't quote me on that :) better google it
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:44
linux subsystem on windows?
Claudio Restifo
@Marmiz
May 16 2017 02:44
Or directly run a Linux virtual machine :)
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:45
i just installed gitbash
Claudio Restifo
@Marmiz
May 16 2017 02:45
That's git
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:45
but I wanted to know what happened
git + bash
i can run bash commands
Claudio Restifo
@Marmiz
May 16 2017 02:45
git != bash
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:45
but I can run bash commands
it installs bash for u
:S
Claudio Restifo
@Marmiz
May 16 2017 02:46
for git. Not for Windos
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:46
am I right @ChelseyJan ?
@Marmiz no for windows too, I can create files, list docs
for example, CMD doesn't understand "ls"
from gitbash, I can do it
mkdir
ur confusing me now ..
Claudio Restifo
@Marmiz
May 16 2017 02:47
@brittanyrutherford try a vim?
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:47
:S
what vim?
Claudio Restifo
@Marmiz
May 16 2017 02:47
text editor
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:48
yea, I got a msg from bash
Claudio Restifo
@Marmiz
May 16 2017 02:48
that comes with every linnux-based system
Chelsey Jan
@ChelseyJan
May 16 2017 02:48
@brittanyrutherford gitbash installs git with the bash command line interface. You can probably do some stuff to windows with that bash command line. Such as mkdir, etc. But, it's not as complete as if you were using it on a linux machine. Like I don't think you're going to be able to make system changes, etc. but, since you modify files, directories, etc using git, gitbash includes that ability. That's the way i understand it anyway
Manish Giri
@Manish-Giri
May 16 2017 02:48
vim and emacs
Claudio Restifo
@Marmiz
May 16 2017 02:49

@brittanyrutherford

I got a msg from bash

that says?

Brittany Rutherford
@brittanyrutherford
May 16 2017 02:49
brb
Chelsey Jan
@ChelseyJan
May 16 2017 02:51
@brittanyrutherford also, bash is technically a shell/language that was created to use on the linux command line. So it has a lot of power to makes changes to multiple files, etc. in the way you're using it with git, it lets you make changes easily and quickly using command lines. You could technically achieve the same thing with git gui, but you need a mouse.
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:55
back
Chelsey Jan
@ChelseyJan
May 16 2017 02:56
@brittanyrutherford I spent a lot of time trying to install a lot of Linux style stuff on my windows computer, but I ended up reverting back (not using bash/vim/etc. anymore) It's all personal preference but if you want to use bash commands to do things other than Git related stuff on you comp. you'll probably have to install something else, like @adamakers said earlier
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:56
i ran vim, and I saw that:
Claudio Restifo
@Marmiz
May 16 2017 02:56

@ChelseyJan

I don't think you're going to be able to make system changes, etc. but, since you modify files, directories, etc using git, gitbash includes that ability. That's the way i understand it anyway

Suppose it's like this. @brittanyrutherford you can try a chmod (see permission on a file)
chmod -l /path/to/file.txt
And than try to change permission on that file:
chmod 755 /path/to/file.txt

If you can do that the bash version you're running is "powerful" enough to use for 90% of the every day coding needs

Brittany Rutherford
@brittanyrutherford
May 16 2017 02:56
image.png
so seems like vim is available
Chelsey Jan
@ChelseyJan
May 16 2017 02:58
Oh cool, I guess gitbash installs VIM for you as well? Which makes perfect sense once you think about it.
Brittany Rutherford
@brittanyrutherford
May 16 2017 02:59
although I don't know what vim does
Will Waymel
@willwaymel
May 16 2017 03:00
doing a simple javascript loop tutorial ... is this a bug that the result is 1? shouldn't it be 2? The challenge says I did the code correctly, but I thought it would be a result of 2.
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (i = 0; i < arr.length; i++) {
    for (j=0; j < arr[i].length; j++) {
      product *= arr[i][j];
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([1,2]);
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:00
@willwaymel arr[i] is not an array
Chelsey Jan
@ChelseyJan
May 16 2017 03:00
@brittanyrutherford It's basically a text editor that has a lot of preset stuff for different coding languages, and lets you type code very easily and quickly. It can be powerful but has a learning curve once you start learning things other than the basics
@brittanyrutherford also it lets you do everything with the keyboard, no mouse needed
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:01
do u use it? @ChelseyJan
Claudio Restifo
@Marmiz
May 16 2017 03:01

@brittanyrutherford and @ChelseyJan according to the creator(s) of GitBash:

Git for Windows is bundled with "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.

so you have a "lighter" version of Bash. you can do some basic stuff; which is probably enough for the work-flow

Brittany Rutherford
@brittanyrutherford
May 16 2017 03:02
aha
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:02
for development purposes, I guess that's enough
PhoenixFarhan
@PhoenixFarhan
May 16 2017 03:02

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

function checkObj(checkProp) {
// Your Code Here
result = myObj[checkProp];
return result;

}

Chelsey Jan
@ChelseyJan
May 16 2017 03:02
@brittanyrutherford I did for a while, I actually have been using Notepad ++ and sometimes visual studio lately. I like it in theory, but I don't have linux on my computer anymore, so went back to some windows style applications
PhoenixFarhan
@PhoenixFarhan
May 16 2017 03:02
i figured out that works
how do i add in Not Found if the function does not find the property
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:03
@ChelseyJan I am using atom at the moment
it's working very well for me
Manish Giri
@Manish-Giri
May 16 2017 03:03
@PhoenixFarhan should check if checkProp is a property or not, before.
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:03
I was just confused about this whole gitbash thing
Manish Giri
@Manish-Giri
May 16 2017 03:04
@brittanyrutherford atom has built in support for popular git commands..
Claudio Restifo
@Marmiz
May 16 2017 03:04
@Manish-Giri ?? what's that about? I miss some context
Chelsey Jan
@ChelseyJan
May 16 2017 03:04
@brittanyrutherford that looks pretty cool, I've heard of it but haven't used it.
Manish Giri
@Manish-Giri
May 16 2017 03:04
@Marmiz the title!!
Claudio Restifo
@Marmiz
May 16 2017 03:05
@Manish-Giri ...
:laughing: now that I read it :laughing:
Manish Giri
@Manish-Giri
May 16 2017 03:05
lol
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:05
@Manish-Giri didn't know that :(
Will Waymel
@willwaymel
May 16 2017 03:05
@brittanyrutherford what do you mean arr[i] is not an array?
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:06
@willwaymel in ur second loop, u r looping through arr[i] .. which = 1
Manish Giri
@Manish-Giri
May 16 2017 03:06
@brittanyrutherford check this out.
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:07
thank you @Manish-Giri
CamperBot
@camperbot
May 16 2017 03:07
brittanyrutherford sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5532 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
May 16 2017 03:07
@brittanyrutherford :+1:
Will Waymel
@willwaymel
May 16 2017 03:08
@brittanyrutherford the instructions for the tutorial say: "Note that for the inner loop, we are checking the .length of arr[i], since arr[i] is itself an array." and this is their example:
var arr = [
  [1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
    console.log(arr[i][j]);
  }
}
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:10

yes, but u r passing 1, 2, u r not passing arrays, you should do it like:

multiplyAll([ [1,2], [2,3,4]]);

@willwaymel

PhoenixFarhan
@PhoenixFarhan
May 16 2017 03:10

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

function checkObj(checkProp) {
// Your Code Here
if ((myObj.hasOwnProprety("gift") === false) && (myObj.hasOwnProperty("pet") === false) && (myObj.hasOwnProperty("bed") === false)){
return "Not found";
}
else {
result = myObj[checkProp];
return result;
}

}

// Test your code by modifying these values
checkObj("house");

Manish Giri
@Manish-Giri
May 16 2017 03:10
@willwaymel you have only one array.
why do you have two loops?
PhoenixFarhan
@PhoenixFarhan
May 16 2017 03:10

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

function checkObj(checkProp) {
// Your Code Here
if ((myObj.hasOwnProperty("gift") === false) && (myObj.hasOwnProperty("pet") === false) && (myObj.hasOwnProperty("bed") === false)){
return "Not found";
}
else {
result = myObj[checkProp];
return result;
}

}

// Test your code by modifying these values
checkObj("house");

comment out the second loop and you'll get 2
Erol Aliyev
@erolaliyev
May 16 2017 03:11
hi everyone!
PhoenixFarhan
@PhoenixFarhan
May 16 2017 03:11
it returns a black screen if i put the checkObj("house")' i want it to return Not found
Erol Aliyev
@erolaliyev
May 16 2017 03:11
can anybody help me with bonfire challenge chunky monkey?
CamperBot
@camperbot
May 16 2017 03:11
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Greg Lawrence
@Chewieez
May 16 2017 03:11
This code works, but it seems quite complicated. Is this the intended answer or, did I just find the longest way to the end result? :) Thanks!
var count = 0;

function cc(card) {
  // Only change code below this line
  if (card <= 6) {
    count++ ;
  }
  else {
    switch(card) {
      case 10:
        count--;
        break;
      case 'J':
        count--;
        break;
      case 'Q':
        count--;
        break;
      case 'K':
        count--;
        break;
      case 'A':
        count--;
        break;
    }
  }



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

  else if (count <=0) {
    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(4); cc(5); cc(6);
Will Waymel
@willwaymel
May 16 2017 03:11
@Manish-Giri i have 2 loops because it was the excercise
Manish Giri
@Manish-Giri
May 16 2017 03:12
@willwaymel yes, and they had arrays within arrays.
and you don't.
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:12
@willwaymel look at my code above
Will Waymel
@willwaymel
May 16 2017 03:12
i just removed the other loops to do the testing. it says it's correct, i already passed the exercise, but i wanted to se how it worked. shouldnn't it work just as well with one array vs many?
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:12
u need sub arrays ...
Manish Giri
@Manish-Giri
May 16 2017 03:12
@PhoenixFarhan use checkProp instead of all this
if ((myObj.hasOwnProperty("gift") === false) && (myObj.hasOwnProperty("pet") === false) && (myObj.hasOwnProperty("bed") === false)){
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:13
is there a plugin to darken chrome?
Manish Giri
@Manish-Giri
May 16 2017 03:13
yes
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:13
what is it?
i saw some, but they just inverse colors and so on
Manish Giri
@Manish-Giri
May 16 2017 03:13
the one I had is "Dark Reader"
yeah every extension would just inverse colors
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:14
yeah, I have this one
Manish Giri
@Manish-Giri
May 16 2017 03:14
which is why I stopped using it after a while
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:14
me too, I stopped using it
Manish Giri
@Manish-Giri
May 16 2017 03:14
doesn't look as good after some time
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:14
if there was only a color extension, that would give u nice colors when the background is black
Manish Giri
@Manish-Giri
May 16 2017 03:15
maybe you could make one!
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:15
me?
Manish Giri
@Manish-Giri
May 16 2017 03:15
yup
why not
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:15
i get stuck writing console.log
Manish Giri
@Manish-Giri
May 16 2017 03:15
so what
everyone does
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:15
hmm
aren't chrome extensions like a rocket science?
Manish Giri
@Manish-Giri
May 16 2017 03:15
you're not a dev if you don't get stuck at some point
nope
it's all just js
for the most part
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:16
any good tutorials?
Manish Giri
@Manish-Giri
May 16 2017 03:16
um
Will Waymel
@willwaymel
May 16 2017 03:16
... still not sure why the result wouldn't feed one array into the arr variable, and then loop through arr 0 and multiply 1 times 1 and 2 * 1 and store that in
product ... is [1,2] an array? @Manish-Giri @brittanyrutherford
Manish Giri
@Manish-Giri
May 16 2017 03:16
I tried building some safari extensions a while back
let me find it, will PM you
Brittany Rutherford
@brittanyrutherford
May 16 2017 03:17
ok
Manish Giri
@Manish-Giri
May 16 2017 03:17
@willwaymel [1,2] is an array yes
but is there another array in it?
Will Waymel
@willwaymel
May 16 2017 03:20
Does it matter with the code? Shouldn't the code loop through 1 array the same way it does with 2? One by one?
Manish Giri
@Manish-Giri
May 16 2017 03:21
Does it matter with the code?
yes it does
you cant tell it to loop through an array when one doesn't exist.
Will Waymel
@willwaymel
May 16 2017 03:24
@Manish-Giri aha ... i see what you are saying. I changed my code and added more brackets to the input multiplyAll([[1,2]]); instead of multiplyAll([1,2]); and got 2
Manish Giri
@Manish-Giri
May 16 2017 03:24
yeah
Will Waymel
@willwaymel
May 16 2017 03:24
@Manish-Giri @brittanyrutherford thanks for the help!
CamperBot
@camperbot
May 16 2017 03:24
willwaymel sends brownie points to @manish-giri and @brittanyrutherford :sparkles: :thumbsup: :sparkles:
:cookie: 2 | @brittanyrutherford |http://www.freecodecamp.com/brittanyrutherford
:star2: 5533 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
May 16 2017 03:24
@willwaymel :+1:
vince nguyen
@moomoo2202
May 16 2017 03:25
can someone help explain the instructions, because I don't get it 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.
Manish Giri
@Manish-Giri
May 16 2017 03:26
@moomoo2202 there are two steps in that challenge -
  1. add the number item to the end of the array arr
  2. remove the first element from the array arr and return it.
    The two functions - .push() and .shift() would be helfpul.
Duong Nguyen
@duongital
May 16 2017 03:28
Hi all, how can I call the number to destroyed in this function?
Just only call the 'arr' to be destroyed as I return 'arr'.
function destroyer(arr) {
  // Remove all the values
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
this is the exercise number 250
Manish Giri
@Manish-Giri
May 16 2017 03:29
@ocsenttdd you'd need to use arguments
XiaoJunling
@XiaoJunling
May 16 2017 03:36
what is meaning of the 166 "Word Blanks"?
Netrunner21
@Netrunner21
May 16 2017 03:36
@ocsenttdd make sure you read the documentation written above. Arguments give a lot of people trouble. You can call the arguments using arguments[0], arguments[1], etc. In some cases you may need to convert the argument to an array or string.
gerome0123
@gerome0123
May 16 2017 03:36
how to limit pagination for example i have 30 pages i want to limit to five like this << 1 2 3 4 5 >>
if iget into the current page 3 my pagination will add like this << 3 4 5 6 7 >>
Netrunner21
@Netrunner21
May 16 2017 03:37
@XiaoJunling can you clarify what you're asking?
@XiaoJunling I think I understand. Let me look at mine.
Long Nguyen
@longnt80
May 16 2017 03:38
@XiaoJunling @Netrunner21
yeah the Word Blank is really confusing if you never play that game before
XiaoJunling
@XiaoJunling
May 16 2017 03:39
@longnt80 game?
@Netrunner21 thanks
CamperBot
@camperbot
May 16 2017 03:39
xiaojunling sends brownie points to @netrunner21 :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @netrunner21 |http://www.freecodecamp.com/netrunner21
Netrunner21
@Netrunner21
May 16 2017 03:40
@XiaoJunling Yeah. basically, you're stringing together the arguments at the bottom of the function to make a sentence (or a "string" in javascript terminology)
@XiaoJunling You'll also need to add spaces. You can string the arguments together using the + operator.
Long Nguyen
@longnt80
May 16 2017 03:41
@XiaoJunling you need to construct a sentense with those words. For example, you can make a sentense as simple as this:
The big dog ran quickly
XiaoJunling
@XiaoJunling
May 16 2017 03:43
@Netrunner21 The sentence so long thay my poor English can not understand.
@longnt80 I will try
Netrunner21
@Netrunner21
May 16 2017 03:45
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
Long Nguyen
@longnt80
May 16 2017 03:45
@XiaoJunling are you chinese? there's a chinese FreeCodeCamp chat room
Netrunner21
@Netrunner21
May 16 2017 03:46
@XiaoJunling On the line above, you're going to connect those using the + operator and set it equal to result.
I did not know there was Chinese chat room. Neat.
@XiaoJunling You'll need spaces that look like this ==> " " between your + operators.
Sorry I can't help beyond that, hope you get it figured out.
Long Nguyen
@longnt80
May 16 2017 03:48

I did not know there was Chinese chat room. Neat.

https://gitter.im/FreeCodeCamp/chinese

@XiaoJunling

XiaoJunling
@XiaoJunling
May 16 2017 03:49
@longnt80 oh thanks a lot
CamperBot
@camperbot
May 16 2017 03:49
xiaojunling sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 260 | @longnt80 |http://www.freecodecamp.com/longnt80
XiaoJunling
@XiaoJunling
May 16 2017 03:49
@Netrunner21 best wishes for you,I can try myself
XiaoJunling
@XiaoJunling
May 16 2017 03:58
@longnt80 @Netrunner21 thanks you I have already solved the question
CamperBot
@camperbot
May 16 2017 03:58
xiaojunling sends brownie points to @longnt80 and @netrunner21 :sparkles: :thumbsup: :sparkles:
:warning: xiaojunling already gave longnt80 points
:warning: xiaojunling already gave netrunner21 points
Garo
@Garabed96
May 16 2017 04:00
you guys post the algorithms on github?
drew
@tindrew
May 16 2017 04:01
is there anything wrong with this line? var quotient = 4.4 / 2.0; // Fix this line
because it keeps saying that quotient can only be assigned once, and as far as I can tell it's only being assigned once
Manish Giri
@Manish-Giri
May 16 2017 04:03
@tindrew post your challenge URL here, click "run tests" first
drew
@tindrew
May 16 2017 04:04
I refreshed the page and it worked, thanks
I'm doing the beta stuff, apparently it's still pretty buggy
Jonathanwam
@Jonathanwam
May 16 2017 04:11

I'm working on the Wikipedia Viewer project and ran into a slight obstacle. I can't figure out how to traverse the data in this json file. It seems pretty simple, but I can't even get the title (very first item). Here's a sample:

https://en.wikipedia.org/w/api.php?action=opensearch&search=al&limit=10&namespace=0&format=json

How do I access elements of this? I tried treating it like an array. Such as data[0], data[0,0], data[0][0], etc. but nothing worked and just breaks out of the function.

Ogundele Olumide
@Lumexralph
May 16 2017 04:14
@Manish-Giri :wave ggm
VaseJS
@VaseJS
May 16 2017 04:18
@Manish-Giri Yo!
Jonathanwam
@Jonathanwam
May 16 2017 04:18
Oh, looks like the data[0] in fact works, I just have a different problem. Nevermind!
VaseJS
@VaseJS
May 16 2017 04:18
I have reappeared
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:32
@Lumexralph gm
Ogundele Olumide
@Lumexralph
May 16 2017 04:34
@HeebieGeeBee Bro!
Good Morning
@HeebieGeeBee Heard of the brutal RansomWare attack?
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:35
yeah
i have a theory it was inside job by microsoft to finally get everyone to upgrade to windows 10
Ogundele Olumide
@Lumexralph
May 16 2017 04:36
@HeebieGeeBee seriously?
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:36
lol nah just kidding
but is suspicious how helpful theyre being
Ogundele Olumide
@Lumexralph
May 16 2017 04:37
though it was windows that was most vulnerable and Russia got hit the most
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:37
yeah and only old versions of windows
Ogundele Olumide
@Lumexralph
May 16 2017 04:37
People refused to abandon XP which plug has been pulled from
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:38
pretty cool that guy figured out the domain where the malware was trying to dump all the data was available
so bought it to capture all the data
Pearl
@Jiaaa1014
May 16 2017 04:39
In the Mutations challenge, why the first for loop can't work
function mutation(arr) {
  arr[0] = arr[0].toLowerCase();
  oneByOne = arr[1].toLowerCase().split('');


  for (i = 0; i < oneByOne.length ; i++){

    if(arr[0].indexOf(oneByOne[i]) >= 0 ) {
      return true;
    }
  }
  return false;
}

mutation(["hello", "ey"]);
function mutation(arr) {
  arr[0] = arr[0].toLowerCase();
  oneByOne = arr[1].toLowerCase().split('');


  for (i = 0; i < oneByOne.length ; i++){

    if(arr[0].indexOf(oneByOne[i]) < 0 ) {
      return false;
    }
  }
  return true;
}

mutation(["hello", "ey"]);
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:40
@Jiaaa1014 because a true return will return true if just one letter is correct
which you dont want you want to make sure all letters are true before returning true
but if you onyl find one letter that is false its fine to return false
becuase just one letter being wrong is enough to fail the test
Ogundele Olumide
@Lumexralph
May 16 2017 04:41
@Jiaaa1014 because the first loop is checking if characters are found in the arr[0] string, once it get's the first true occurrence, it returns stopping the loop and exiting the function immediately
CyberBrick
@CyberBrick
May 16 2017 04:41
A bit stuck on the Stand in Line challenge
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:41
@Lumexralph the nhs in england got hit pretty hard too
Ogundele Olumide
@Lumexralph
May 16 2017 04:42
@HeebieGeeBee yeah..... bad bad
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:42
but i thought it was bizarre they still all used xp on their system
Ogundele Olumide
@Lumexralph
May 16 2017 04:42
@CyberBrick what do you have?
cusbus
@cusbus
May 16 2017 04:42
hey all! i i just finished the factorialize function challenge. it works, but my buddy said it was not clear, so i'm assuming there is a more elegant solution. can anyone provide a push in the right direction without giving me the answer verbatim?
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:42
like 5 years ago i saw they were still using xp
cusbus
@cusbus
May 16 2017 04:42

function factorialize(num) { 
  var product = 1;
  var array = [];
    for (var i = num; i > 0; i--) {
      array.push(i);
        } 
        for (var j=0; j < array.length; j++) {
         product = product * array[j];
        }
  return product;
}

factorialize(5);
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:42
and they still hadnt upgraded
Ogundele Olumide
@Lumexralph
May 16 2017 04:43
@cusbus you can use a loop to make the multiplication without using an array, if you understand recursion you can do that do
Pearl
@Jiaaa1014
May 16 2017 04:43
a lot THX for u two guys :)
Ogundele Olumide
@Lumexralph
May 16 2017 04:43
@HeebieGeeBee hope they'll learn now
Matt Green
@mattxgreen
May 16 2017 04:43
@cusbus nested for Loops for me are kind of hard to read. Take a look at array.map
Ogundele Olumide
@Lumexralph
May 16 2017 04:43
@CyberBrick what have you tried?
cusbus
@cusbus
May 16 2017 04:43
i'll search recursion and array.map... cheers all
CyberBrick
@CyberBrick
May 16 2017 04:44

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

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

Ogundele Olumide
@Lumexralph
May 16 2017 04:44
@CyberBrick testArr => arr
@CyberBrick shift just once
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:45
@cusbus even just in yours theres no need for the nested loop
youre loop is already creating a variable that will provide all the numbers on every iteration
Ogundele Olumide
@Lumexralph
May 16 2017 04:45
@HeebieGeeBee you know the thing about working on canvas?
CyberBrick
@CyberBrick
May 16 2017 04:45
So delete line 6?
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:45
@Lumexralph what about it?
Ogundele Olumide
@Lumexralph
May 16 2017 04:46
@HeebieGeeBee a lot of maths and motion physics are involved
that's what I've noticed so far
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:46
yep
sketch libraries can help
Ogundele Olumide
@Lumexralph
May 16 2017 04:46
@CyberBrick add the suggestions we gave and let's see the updated code
@HeebieGeeBee maybe when I'm moving into JS canvas i'll see helpful modules
CyberBrick
@CyberBrick
May 16 2017 04:47

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

return removedItem; // Change this line
}

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

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

HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:47
matter.js is a good physics library and p5 is a good and easy sketching library
both can work well together
CyberBrick
@CyberBrick
May 16 2017 04:48
Do I have to create a var for removed item
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:48
or theres phasers that is a pretty good game engine that has everything
Ogundele Olumide
@Lumexralph
May 16 2017 04:48
@CyberBrick you can return it without storing
@HeebieGeeBee cool....
CyberBrick
@CyberBrick
May 16 2017 04:49

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

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

Ogundele Olumide
@Lumexralph
May 16 2017 04:49
@CyberBrick check the corrections from above
CyberBrick
@CyberBrick
May 16 2017 04:49
ReferenceError: testArray is not defined
Joseph
@revisualize
May 16 2017 04:50
@CyberBrick testArray is not defined.
Ogundele Olumide
@Lumexralph
May 16 2017 04:50
@CyberBrick testArr should be arr and where did you get the variable removedItem ?
Joseph
@revisualize
May 16 2017 04:50
@CyberBrick You shouldn't be using testArray or even testArr in your function.
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:51
i kinda wish jared leto wasnt in films
Ogundele Olumide
@Lumexralph
May 16 2017 04:51
@HeebieGeeBee why?
Matt Gagne
@justcbdev
May 16 2017 04:51
This -> nextInLine([], 1) should return 1 <- is the ONLY part of "testing" this that makes no sense...
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:51
his face stops me enjoying any character he plays
Joseph
@revisualize
May 16 2017 04:51
@HeebieGeeBee I think he's a good actor. I felt he was good in Suicide Squad.
Matt Gagne
@justcbdev
May 16 2017 04:51
how are we supposed to test that?
CyberBrick
@CyberBrick
May 16 2017 04:52
the challege says to return the item that was removed
Joseph
@revisualize
May 16 2017 04:52
@justcbdev Would you like for me to walk through that?
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:52
yeah he is a good actor
Joseph
@revisualize
May 16 2017 04:52
@CyberBrick Here.
HeebieGeeBee
@HeebieGeeBee
May 16 2017 04:52
thats not the problem
Joseph
@revisualize
May 16 2017 04:52
@CyberBrick @justcbdev I'm going to walk through the function with you.
Ogundele Olumide
@Lumexralph
May 16 2017 04:52
@justcbdev it makes big sense, because you push before shifting
CyberBrick
@CyberBrick
May 16 2017 04:52
ok
Matt Gagne
@justcbdev
May 16 2017 04:52
```js
Joseph
@revisualize
May 16 2017 04:52
Okay folks!

Stand In Line is a CheckPoint where you're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).

function nextInLine(arr, item) { }

That part has been done for you! Yay!

So!
Matt Gagne
@justcbdev
May 16 2017 04:53

Here's what I have : function nextInLine(arr, item) {
// Your code here

var arrItemShifted = arr[0];
arr.push(item);
arr.shift();
return arrItemShifted; // 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));

Joseph
@revisualize
May 16 2017 04:53
With that function declaration you have a function name of nextInLine. You have two parameters arr which represents an array passed into the function and item that represents a number passed to the function.
Matt Gagne
@justcbdev
May 16 2017 04:53
and the console log shows:
Joseph
@revisualize
May 16 2017 04:53

A few example function calls:

nextInLine([4,3,2] , 1) the values passed to arr is [4,3,2] and the value passed to item is 1

nextInLine([2,4,6,8] , 10) ... arr is [2,4,6,8] & item is 10

nextInLine([2,3,5,7,11] , 13) ... arr is [2,3,5,7,11] & item is 13 (first 5 and 6th prime numbers)

nextInLine([] , 0) ... arr is [] & item is 0

var myArr = [1,3,5,7]; nextInLine(myArr , 9) ... arr is [1,3,5,7] a copy of the value of the global variable myArr & item is 9

Matt Gagne
@justcbdev
May 16 2017 04:54
Before: [1,2,3,4,5]
1
Joseph
@revisualize
May 16 2017 04:54
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).
Matt Gagne
@justcbdev
May 16 2017 04:54
After: [2,3,4,5,6]
Joseph
@revisualize
May 16 2017 04:54
Again the two parameters for the nextInLine function are arr & item.

Per the instructions: 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.

You need to add the number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).

Then you need to have your function return the removed element from the array arr.

@justcbdev So, you stated that this didn't make sense nextInLine([] , 0) ... But when you make that function call the value of the parameter arr is [] & item is 0
Damien
@DubbDevs
May 16 2017 04:55

can I get a bit of help please? trying to capitalize the first letter in each word

function titleCase(str) {
 var strLoweredArray;
 var firstCap = [""];


  strLoweredArray = str.toLowerCase().split(" "); // all lowercase into array

   for (var i=0; i < strLoweredArray.length; i++) {
    firstCap = strLoweredArray.substring(0,1).upperCase; //loop thru array select 1st letter in string capitalize return first cap
   }





  return firstCap;
}

titleCase("I'm a liTtle tea pot");

getting a syntax error : expected expression got "{"

Che Cabello
@CheCabello
May 16 2017 04:56
What is wrong here: function caseInSwitch(val) {
var answer = "";
// Only change code below this line
case 1:
answer = 'alpha';
break;
Joseph
@revisualize
May 16 2017 04:56
@justcbdev The problem is that your solution won't work.
Ogundele Olumide
@Lumexralph
May 16 2017 04:56
@CheCabello your switch statement is not well constructed
Joseph
@revisualize
May 16 2017 04:56
@justcbdev Because when you make the function call nextInLine( [] , 1) ... the value of arr[0] is .. undefined
Matt Gagne
@justcbdev
May 16 2017 04:57
@revisualize Right, now I'm seeing how to test that...was all I was missing...Thanks.
CamperBot
@camperbot
May 16 2017 04:57
justcbdev sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3974 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 16 2017 04:57
@justcbdev Or you could just not test for that.
And you could just do things in the correct order.
Ogundele Olumide
@Lumexralph
May 16 2017 04:57
@DubbDevs you need to also concatenate the susbtring of the word after the first character is changed to upper case
Che Cabello
@CheCabello
May 16 2017 04:57
@CheCabello which is the problem? Is telling me that case 1: is wrong
Matt Gagne
@justcbdev
May 16 2017 04:58
@revisualize Lol, except it requires it and the correct result and won't continue until it's correct :P
Joseph
@revisualize
May 16 2017 04:58
@justcbdev How do you add something to the end of an array?
Ogundele Olumide
@Lumexralph
May 16 2017 04:58
Che Cabello
@CheCabello
May 16 2017 04:58
@Lumexralph which is the problem? Is telling me that case 1: is wrong
Mihir Shanishchara
@MihirNS
May 16 2017 04:58
@revisualize arr.push
CyberBrick
@CyberBrick
May 16 2017 04:59
.push() right?
Joseph
@revisualize
May 16 2017 04:59
@CyberBrick Yes.
@CyberBrick But, you have to declare what is "pushed"
Che Cabello
@CheCabello
May 16 2017 04:59
@Lumexralph I have done it
CyberBrick
@CyberBrick
May 16 2017 04:59
@revisualize inside the function?
Joseph
@revisualize
May 16 2017 05:00
@CyberBrick If you do it not inside the function it won't happen when the function is called.
So. Yes. Inside the function.
Matt Gagne
@justcbdev
May 16 2017 05:01
@revisualize --> arr.push(what you want to add);
CyberBrick
@CyberBrick
May 16 2017 05:01
So, .push(item); would be correct?
Joseph
@revisualize
May 16 2017 05:01
@justcbdev How do you remove the first element from an array?
cusbus
@cusbus
May 16 2017 05:01
one more dumb random question... can reduce be used to a find a product instead of a sum?
Joseph
@revisualize
May 16 2017 05:01
@CyberBrick You have to declare the array.
Matt Gagne
@justcbdev
May 16 2017 05:01
@revisualize that's one of the things that IS working :P
@revisualize ---> arr.shift();
Joseph
@revisualize
May 16 2017 05:02
@justcbdev What does .shift() return back to the function caller?
Matt Gagne
@justcbdev
May 16 2017 05:02
@revisualize Ooh, I never thought about that...good one, thanks.
CamperBot
@camperbot
May 16 2017 05:02
justcbdev sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: justcbdev already gave revisualize points
CyberBrick
@CyberBrick
May 16 2017 05:03
the first item in the array
Che Cabello
@CheCabello
May 16 2017 05:04
@Lumexralph thank you
CamperBot
@camperbot
May 16 2017 05:04
checabello sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1761 | @lumexralph |http://www.freecodecamp.com/lumexralph
Joseph
@revisualize
May 16 2017 05:04
@justcbdev So, you can have your function just return what is returned from .shift() no need for a new variable.. No need to get arr[0] when arr[0] is undefined.
Matt Gagne
@justcbdev
May 16 2017 05:04
@revisualize Gotcha.
Ogundele Olumide
@Lumexralph
May 16 2017 05:05
@CheCabello :+1:
CyberBrick
@CyberBrick
May 16 2017 05:05

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

return array.shift; // Change this line
}

// Test Setup
var array = [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));

Ogundele Olumide
@Lumexralph
May 16 2017 05:06
@CyberBrick shift returns the first element in the arr which hold array for your function
Matt Gagne
@justcbdev
May 16 2017 05:06
@revisualize doing a return arr.shift(); did the trick. Thanks for pointing out the option.
CamperBot
@camperbot
May 16 2017 05:06
justcbdev sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: justcbdev already gave revisualize points
Ogundele Olumide
@Lumexralph
May 16 2017 05:06
@CyberBrick your parameter holding the array is arr not array
Joseph
@revisualize
May 16 2017 05:06
@justcbdev :D
@CyberBrick You're not adding anything to the array. And you're doing .shift() twice inside your function so, you're returning two elements from the front of the array.
Matt Gagne
@justcbdev
May 16 2017 05:07
@revisualize :+1: :clap:
CyberBrick
@CyberBrick
May 16 2017 05:08
Im gonna get this
Duong Nguyen
@duongital
May 16 2017 05:09
@Manish-Giri @longnt80 @Netrunner21 thank you guys, I apply arguments object and passed the excercise.
CamperBot
@camperbot
May 16 2017 05:09
ocsenttdd sends brownie points to @manish-giri and @longnt80 and @netrunner21 :sparkles: :thumbsup: :sparkles:
:cookie: 261 | @longnt80 |http://www.freecodecamp.com/longnt80
:cookie: 293 | @netrunner21 |http://www.freecodecamp.com/netrunner21
:star2: 5534 | @manish-giri |http://www.freecodecamp.com/manish-giri
Markus Kiili
@Masd925
May 16 2017 05:10
@revisualize Morning. Where have you been hiding lately?
CyberBrick
@CyberBrick
May 16 2017 05:10

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

return // Change this line
}

// Test Setup
var array = [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));

Ogundele Olumide
@Lumexralph
May 16 2017 05:11
@CyberBrick shift returns the element removed, you need to return that too
@CyberBrick but don't shift twice
CyberBrick
@CyberBrick
May 16 2017 05:12
what do I return I don't think it should be blank should it?
Joseph
@revisualize
May 16 2017 05:12
@Masd925 Been busy.
Ogundele Olumide
@Lumexralph
May 16 2017 05:12
@CyberBrick the first element removed from arr, that's what to be returned
CyberBrick
@CyberBrick
May 16 2017 05:13
What would I put in the return statement though?
Markus Kiili
@Masd925
May 16 2017 05:13
@Lumexralph Morning.
Ogundele Olumide
@Lumexralph
May 16 2017 05:14
@Masd925 Good Morning
dave oh
@david-oh-git
May 16 2017 05:14
hello people. having issues adding request options for the dark sky api. do i just add for example "?unit=si" to the request url
Matt Gagne
@justcbdev
May 16 2017 05:14
@CyberBrick get rid of the first arr.shit and just put that in your return...that's what I did.
CyberBrick
@CyberBrick
May 16 2017 05:14
I think freeCodeCamp is bugging. I still keep getting the error(ReferenceError: testArr is not defined) and that no longer in my code
Ogundele Olumide
@Lumexralph
May 16 2017 05:14
@CyberBrick the first element removed by shift method
Matt Gagne
@justcbdev
May 16 2017 05:15
@CyberBrick lol, You changed the name of the test array to just the word array...somehow
@CyberBrick You just need to slow down a bit and look at each line and check it with the instructions...if you go to fast, change too many things at once you end up causing yourself a trouble shooting nightmare :)
@CyberBrick Does that make sense?
dave oh
@david-oh-git
May 16 2017 05:18
hello people. having issues adding request options for the dark sky api. do i just add for example "?unit=si" to the request url . i use the the crossorigin.me proxy , which works well but when i add an api option it displays "Origin: header is required"
CyberBrick
@CyberBrick
May 16 2017 05:18
@justcbdev yeah that makes sense.
Well Im down to 2 errors.
progress
Matt Gagne
@justcbdev
May 16 2017 05:19
@CyberBrick Awesomne! :) No worries mate, we've all been there before it's all good
@CyberBrick what are they?
CyberBrick
@CyberBrick
May 16 2017 05:20
nextInLine([], 1) should return 1 and After nextInLine(testArr, 10), testArr[4] should be 10
Matt Gagne
@justcbdev
May 16 2017 05:20
@CyberBrick What's your code look like?
CyberBrick
@CyberBrick
May 16 2017 05:20

this is what is returning in the console Before: [1,2,3,4,5]

1

After: [2,3,4,5]

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

return arr.shift(); // 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));

Matt Gagne
@justcbdev
May 16 2017 05:21
@CyberBrick You're not pushing anything onto the array anymore.
@CyberBrick Look CLOSER to your push statement...can you see if there is/isn't anything wrong with it?
@CyberBrick Anything?
CamperBot
@camperbot
May 16 2017 05:25
:bulb: to format code use backticks! ``` more info
Matt Gagne
@justcbdev
May 16 2017 05:25
@camperbot Thanks
CamperBot
@camperbot
May 16 2017 05:25
justcbdev sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 3246 | @camperbot |http://www.freecodecamp.com/camperbot
Ogundele Olumide
@Lumexralph
May 16 2017 05:25
@CyberBrick you need to push item intoarr`
CyberBrick
@CyberBrick
May 16 2017 05:26
@Lumexralph @revisualize @justcbdev I finally got the code to run. Thanks Now Im gonna study it for a bit
CamperBot
@camperbot
May 16 2017 05:26
cyberbrick sends brownie points to @lumexralph and @revisualize and @justcbdev :sparkles: :thumbsup: :sparkles:
:cookie: 184 | @justcbdev |http://www.freecodecamp.com/justcbdev
:star2: 3975 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 1762 | @lumexralph |http://www.freecodecamp.com/lumexralph
Matt Gagne
@justcbdev
May 16 2017 05:27
@Lumexralph GAH! He needed to see that for himself! "teach a man to fish" right? :worried:
CyberBrick
@CyberBrick
May 16 2017 05:28
I dig ya'll method of helping too. I appreciate it
Ogundele Olumide
@Lumexralph
May 16 2017 05:28
@justcbdev he had to do it himself :wink: he didn't get the code
CyberBrick
@CyberBrick
May 16 2017 05:28
I did see I closed my help
Matt Gagne
@justcbdev
May 16 2017 05:29
@CyberBrick I'm glad, we ALL need to learn to see our errors for ourselves. Usually we only need a "nudge" in the right direction. :)
@Lumexralph No worries mate, to each his own :)
CyberBrick
@CyberBrick
May 16 2017 05:29
yeah once I began deleting this and deleting that it was quite a mess
Matt Gagne
@justcbdev
May 16 2017 05:32
@CyberBrick I've found it supremely helpful to sometimes just hit that reset button, getting rid of whatever mess I created and it can often be clearer then :)
CyberBrick
@CyberBrick
May 16 2017 05:32
LOL did that
Matt Gagne
@justcbdev
May 16 2017 05:32
@CyberBrick It does actually work since our brains can keep looking at the same code and not see anything different :P
CyberBrick
@CyberBrick
May 16 2017 05:32
and did it again
yea the wrong code somehow becomes right in our minds
Matt Gagne
@justcbdev
May 16 2017 05:33
@CyberBrick lol...learning can truly be fun but ALWAYS challenging.
CyberBrick
@CyberBrick
May 16 2017 05:33
True.
Matt Gagne
@justcbdev
May 16 2017 05:33
@CyberBrick Or, our mind just doesn't register it.
@CyberBrick It becomes a sort of "blind spot", which was why I cautioned you to look carefully at EACH line and check it against the instructions. You would have caught it then.
Kavindra Nikhurpa
@kavi-nikhurpa
May 16 2017 05:35

Few of the test cases in "Exact Change" challenge doesn't make any sense to me. For e.g.,

checkCashRegister(19.50, 20.00, [["PENNY", 0.50], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]) should return "Closed".

cash = 20.00
price = 19.50
change due = 20.00 - 19.50 = 0.50

cash in drawer = 0.50 * 0.1( because it's penny) = 0.05
So, cash in drawer will always be < change due.
How am I suppose to get "Closed" (i.e., cid === change due)?

CyberBrick
@CyberBrick
May 16 2017 05:35
Sometimes the instructions are a bit vague. Or I'll step away for a sec and lose sight of the previous challenges.
Markus Kiili
@Masd925
May 16 2017 05:40
@kavi-nikhurpa You need to return 0.50 and you have 0.50 in pennies.
Long Nguyen
@longnt80
May 16 2017 05:46

@kavi-nikhurpa

How am I suppose to get "Closed" (i.e., cid === change due)?

So, cash in drawer will always be < change due.

change due is 0.50, cid is 0.50. What are you talking about?

Kavindra Nikhurpa
@kavi-nikhurpa
May 16 2017 05:47
@kavi-nikhurpa I got it. Thanks :)
@longnt80 I thought it was the number of pennies, not the value IN pennies.
CamperBot
@camperbot
May 16 2017 05:47
kavi-nikhurpa sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 263 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
May 16 2017 05:48
:+1:
Elijah White
@elijahwhite97
May 16 2017 05:51
is anyone else taking a ridiculous amount of time to finish the javascript basics course?
some challenges are easy and some are throwing me several hours behind
Markus Kiili
@Masd925
May 16 2017 05:53
@elijahwhite97 It varies a lot. Some people spend days on one challenge.
Matt Green
@mattxgreen
May 16 2017 05:58
@elijahwhite97 just you :p
Long Nguyen
@longnt80
May 16 2017 05:59
@elijahwhite97 depends on what you already know, but the basic are mostly copy and paste, you need to read more outside sources to really grasp the concepts
Matt Gagne
@justcbdev
May 16 2017 06:01
The only challenges I've spent more than 30mins on were the tribute and profile pages. :P
Johnny Meza
@XLpacman805
May 16 2017 06:02
I found myself getting distracted a lot while doing it. Drink lots of water, take breaks, and stay determined.
Long Nguyen
@longnt80
May 16 2017 06:04
it doesn't matter how long, what matter is if you really understand it
Matt Green
@mattxgreen
May 16 2017 06:04
@longnt80 +1
Sulaiman
@suli-g
May 16 2017 06:12
@elijahwhite97 There's not one of these advanced frontend developement projects that I haven't spent less than a day on yet...
Sulaiman
@suli-g
May 16 2017 06:14
@cwborion
for (var i = 0; i < ourArr.length; i++) {
  ourTotal += ourArr[i];
}
jmariomejiap
@jmariomejiap
May 16 2017 06:14
hey guys. could i please get a hand on this challenge "sum all primes" . on the instructions it says with a value 10 it should return 17.... i dont get it.
this is my code.

function sumPrimes(num) {

  var limit = num;
  var total = 2;

  for (var i = 2; total <= limit; i++) {
    if (i % 2 !== 0 && i % 3 !== 0) {
      console.log("total : ", total);
      console.log("prime: ", i);
      total += i;

    }
  }

  return total;
}

console.log(sumPrimes(10));
Caleb Brenner
@cwborion
May 16 2017 06:15
@suli-g I was looking for more of an explanation. I have the code in front of me, but am curious about which part actually compiles that information to add those particular numbers. FCC doesn’t really explain that.
@suli-g or WHY that part of the code compiles it as such
Markus Kiili
@Masd925
May 16 2017 06:17
@jmariomejiap Sum of 2,3,5,7 is 17.
@jmariomejiap You are not checking for primality there.
jmariomejiap
@jmariomejiap
May 16 2017 06:18
@Masd925 I see Im missing some prime numbers... like 3.
Markus Kiili
@Masd925
May 16 2017 06:18
@jmariomejiap Try to first figure out an algorithm for generating prime numbers.
Rebecca Morris
@RebeccaMorris
May 16 2017 06:19
@cwborion When the loop starts, total is set to 0. It then loops through each item in the array adding the current item to total. So 0 + 2 for the first item. Total is now 2. 2 + 3 for the second item. Total is now 5. Then 5 + 4 for the next item. Etc, until every item in the array has been added to total.
jmariomejiap
@jmariomejiap
May 16 2017 06:19
@Masd925 yes, you are right, ill get back to it right away. tell you in a second... or seconds
Caleb Brenner
@cwborion
May 16 2017 06:21
@RebeccaMorris ah thank you! Sometimes the exercises can be vague, and I don’t want to miss what is actually happening and only be able to write it out correctly based off of the examples before moving on.
CamperBot
@camperbot
May 16 2017 06:21
cwborion sends brownie points to @rebeccamorris :sparkles: :thumbsup: :sparkles:
:cookie: 101 | @rebeccamorris |http://www.freecodecamp.com/rebeccamorris
Rebecca Morris
@RebeccaMorris
May 16 2017 06:22
@cwborion No problem! Definitely keep making sure you understand why something works before moving on to the next challenge.
Caleb Brenner
@cwborion
May 16 2017 06:23
@RebeccaMorris haha I learned that the hard way
Matt Gagne
@justcbdev
May 16 2017 06:30
@longnt80 <-- What HE said ;)
Luke Sallmen
@LukeSallmen
May 16 2017 06:51
Is there any sort of resource for the ideal (or very concise and elegant) answers to the Basic JS Algorithm Challenges?
I
finished the first two and want to check my correct answers against better-looking ones
Luke Sallmen
@LukeSallmen
May 16 2017 06:55
What do you mean? It has an array listed for you to work with.
multiplyAll([[1,2],[3,4],[5,6,7]]);
@cwborion
Markus Kiili
@Masd925
May 16 2017 06:56
Luke Sallmen
@LukeSallmen
May 16 2017 06:56
@Masd925 Thanks! I'll opt for the code review, I don't want to peek on future challenges!
CamperBot
@camperbot
May 16 2017 06:56
lukesallmen sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4076 | @masd925 |http://www.freecodecamp.com/masd925
Caleb Brenner
@cwborion
May 16 2017 06:57
@LukeSallmen oh I suppose that it throws me off because in the instructions it specifically refers to “arr” as the one you’re supposed to be using but there is nothing in the code window labeled “arr"
Deb Adeogba
@dadeogba
May 16 2017 06:59

function isLess(a, b) {
// Fix this code
return a === b;
}

// Change these values to test
isLess(10, 15);

Markus Kiili
@Masd925
May 16 2017 06:59
@cwborion arr is the function parameter function multiplyAll(arr) {...}. It will hold the passed array from the function call then the function is executed. By using arr on the function code, you make the function work with whatever array is passed.
Deb Adeogba
@dadeogba
May 16 2017 06:59

can someone please explain this to me?
function isLess(a, b) {
// Fix this code
return a === b;
}

// Change these values to test
isLess(10, 15);

Casey
@zerowacked
May 16 2017 07:00
Hey, Deb! They want you to change the code to show that is a is less than b (or rather to evaluate whether a is less than b).
You'd want to use the operators they have shown. Where ==, you'd use the less than operator.
Deb Adeogba
@dadeogba
May 16 2017 07:01
@zerowacked so I've tried return a < b; because that makes sense to me but that's not correct either
Caleb Brenner
@cwborion
May 16 2017 07:01
@Masd925 alright, well based off of the example, I have my code written as follows, but it isn’t coming out correct. Is this one of those exercises where even though it says “don’t change code above/below this line”, you’re actually supposed to?
Casey
@zerowacked
May 16 2017 07:01
If you've tried <= as well and it doesn't work, could you link me really quick to the lesson? Maybe I'm misinterpreting.
Deb Adeogba
@dadeogba
May 16 2017 07:01
@zerowacked okay nevermind. i had a lag lol it worked
Caleb Brenner
@cwborion
May 16 2017 07:02
@Masd925
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
      console.log(arr[i][j]);
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Casey
@zerowacked
May 16 2017 07:02
Rad! Looks like you had it all along. :D
Deb Adeogba
@dadeogba
May 16 2017 07:02
@zerowacked thank you
CamperBot
@camperbot
May 16 2017 07:02
dadeogba sends brownie points to @zerowacked :sparkles: :thumbsup: :sparkles:
:cookie: 198 | @zerowacked |http://www.freecodecamp.com/zerowacked
Deb Adeogba
@dadeogba
May 16 2017 07:02
@zerowacked thank you
Markus Kiili
@Masd925
May 16 2017 07:02
@cwborion No, you should obey those orders. You need to multiply product inside the loop.
Luke Sallmen
@LukeSallmen
May 16 2017 07:03
@cwborion Yeah, you need some multiplication! Also I really found this challenge difficult and it took me a really long to get it, stay at it!
Caleb Brenner
@cwborion
May 16 2017 07:04
@LukeSallmen from the point I’m at now, I have no idea how I would write that in, as FCC hasn’t covered multiplication in loops at all until right now when it asks you to do it.
Gaurav
@gauravmagan
May 16 2017 07:06
@LukeSallmen where did you find this challenge?
Rebecca Morris
@RebeccaMorris
May 16 2017 07:07
@zerowacked You can return undefined the same way you would any other value.
Luke Sallmen
@LukeSallmen
May 16 2017 07:07
@gauravmagan I meant that it was challenging for me.
Markus Kiili
@Masd925
May 16 2017 07:07
@zerowacked Just using if is simpler. The FCC console has a display bug.
Gaurav
@gauravmagan
May 16 2017 07:08
@LukeSallmen whats the challenge about
Casey
@zerowacked
May 16 2017 07:09
Thanks @RebeccaMorris and @Masd925! I didn't realize I could just return undefined.
CamperBot
@camperbot
May 16 2017 07:09
zerowacked sends brownie points to @rebeccamorris and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 102 | @rebeccamorris |http://www.freecodecamp.com/rebeccamorris
:star2: 4077 | @masd925 |http://www.freecodecamp.com/masd925
Luke Sallmen
@LukeSallmen
May 16 2017 07:10
@cwborion What do you mean, multiplication in loops? FCC covers multiplying things in for loops, I think.
Markus Kiili
@Masd925
May 16 2017 07:10
@zerowacked return; and return undefined; do the same.
Luke Sallmen
@LukeSallmen
May 16 2017 07:10
like the ideal of using a counter (like i or j) and multiplying i or j by another value in a for loop is somewhere in the curriculum I think
otherwise there are certainly examples of using i or j as counters and repeatedly subtracting or adding values
Caleb Brenner
@cwborion
May 16 2017 07:11
@LukeSallmen it hasn’t yet. I reached the first challenge on Loops that FCC has in JavaScript in the past hour so I know for sure that since for loops have been introduced that multiplication has not been covered inside of them so far.
Casey
@zerowacked
May 16 2017 07:11
Ah, okay. So it's not how I'm using return, I'm missing something else. I think it has to do with the fact that an if-else or switch inside of the function would return control back to the function, which ends with a return anyways. I'm not sure how to force the function to return undefined without being able to edit the return code at the bottom.
Carson Hanel
@chingy1510
May 16 2017 07:12
Has anyone done Caesars Cipher?
Casey
@zerowacked
May 16 2017 07:12
... I only used an if. I wonder if I used an if and then just opened an else above the line. >.>
Carson Hanel
@chingy1510
May 16 2017 07:13
Or more specifically, does anyone know the way Caesars Cipher wants us to use String.fromCharCode()?
Markus Kiili
@Masd925
May 16 2017 07:13
@zerowacked You can just make an if that checks if either a or b is negative and then return undefined; on the if block.
bideru
@bideru
May 16 2017 07:13

Hi guys, I'm having some difficulty with the "check for palindromes" basic algorithm scripting challenge. Something seems to be wrong with my use of .replace method since it keeps returning"false" when checking "eye". Any ideas?
function palindrome(str) {
var splitString = str.split("");
var reverseArray = splitString.reverse();
var joinArray = reverseArray.join("");
var lowerCase = joinArray.toLowerCase();
var replacedUnderscore = lowerCase.replace("
","");

if (str == replacedUnderscore) {
return true;
}
}

Chen-Sishi
@Chen-Sishi
May 16 2017 07:13

@zerowacked // Only change code below this line
if(a<0 ||b<0){
return undefined;

}

bideru
@bideru
May 16 2017 07:14
*keeps returning false when checking for "_eye"
jmariomejiap
@jmariomejiap
May 16 2017 07:15
@Masd925 could you please take another look. Im still stuck. :)
function sumPrimes(num) {

  var limit = num;
  var total = 0;

  for (var i = 2; i <= limit; i++) {
    //console.log(total);
    if (i === 2 ) {
      //console.log("Yes, prime: ", i);
      total += i;
    }

    else if (i % 2 === 0 ) {
      //console.log(i, " is not prime")

    }
    else if (i === 3 ) {
      //console.log("Yes, prime: ", i);
      total += i;
    }
    else if (i === 5) {
      //console.log("Yes, prime: ", i);
      total += i;
    }
    else if (i % 3 === 0) {
      //console.log(i, " is not prime");
    }
    else if (i % 5 === 0) {
      //console.log(i, " is not prime");
    }
    else {
      //console.log("total : ", total);
      //console.log("Yes, prime: ", i);
      total += i;
    }
  }

  return total;
}

sumPrimes(10);
ehabmohammedgh
@ehabmohammedgh
May 16 2017 07:15

var remainder;
var a=3;
var b=17;
var remainder=a % b;

var c = 12;
a += 12;
b += 9;
c += 7;

Do not modify the code above the line
Luke Sallmen
@LukeSallmen
May 16 2017 07:15
@cwborion Could you explain a little bit on where you're stuck? Multipying inside for loops is just like x * y, it's really no different than anywhere else
ehabmohammedgh
@ehabmohammedgh
May 16 2017 07:15
a should equal 15
b should equal 26
c should equal 19
You should use the += operator for each variable
Do not modify the code above the line
Casey
@zerowacked
May 16 2017 07:16
@Chen-Sishi Aaahhhh. That was it. I was using && instead ||. Like I said.. very embarrassing. Thank you! And thanks again for your patience, @Masd925!
CamperBot
@camperbot
May 16 2017 07:16
zerowacked sends brownie points to @chen-sishi and @masd925 :sparkles: :thumbsup: :sparkles:
:warning: zerowacked already gave masd925 points
:warning: @chen-sishi's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Markus Kiili
@Masd925
May 16 2017 07:16
@jmariomejiap That looks like hardcoding things. Not an algorithm.
钱方磊
@qianfanglei
May 16 2017 07:16
hey guys anybody known how to deal with it
blob
anyone help please
Markus Kiili
@Masd925
May 16 2017 07:17
@zerowacked :+1: As a sidenote, you can think why this way works too:
function abTest(a, b) {
  // Only change code below this line
  if (a>=0 && b>=0)
  // Only change code above this line
  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
Rebecca Morris
@RebeccaMorris
May 16 2017 07:17
@qianfanglei You have spaces in places you don't need them.
Long Nguyen
@longnt80
May 16 2017 07:18

@chingy1510

Caesars Cipher wants us to use String.fromCharCode()

no, it does not require you to use String.fromCharCode()

钱方磊
@qianfanglei
May 16 2017 07:18
I try to delete the spaces but it doesnt work too
Rebecca Morris
@RebeccaMorris
May 16 2017 07:18
@qianfanglei Link to your challenge?
Caleb Brenner
@cwborion
May 16 2017 07:19
@LukeSallmen … I stumbled upon the solution on accident while searching for hints. Frustrating. But anyways, even with the solution, I don’t see how anyone without any prior experience in JavaScript would think or evenly remotely know to add the product piece at the bottom.
钱方磊
@qianfanglei
May 16 2017 07:19
oh ,that work this time ,thankyou somuch@RebeccaMorris
jmariomejiap
@jmariomejiap
May 16 2017 07:20
@Masd925 ok, it is not really my intention to hardcode it. I was just trying to find a ways to do it. how would an algorithm solution be or work?
Rebecca Morris
@RebeccaMorris
May 16 2017 07:20
@qianfanglei No problem!
Caleb Brenner
@cwborion
May 16 2017 07:20
@LukeSallmen the rest is just mimicking the example, which I pretty much had, but I would never have guessed to write the product line in the way it is based off of everything covered so far, although it doesn’t help that I don’t get to work on these challenges due to my schedule, meaning that the material is never fresh when I sit back down to continue.
Carson Hanel
@chingy1510
May 16 2017 07:20
Can someone help me with Caesar's Cipher?
Markus Kiili
@Masd925
May 16 2017 07:22
@jmariomejiap Brute force way is to check the looped number for divisibility against all the smaller numbers from 2 up. That is really slow, so a better way is to store the found primes and check the looped number for divisibility only against the primes found so far. So another loop of some kind is in order.
Long Nguyen
@longnt80
May 16 2017 07:22
@chingy1510 what have you done?
Luke Sallmen
@LukeSallmen
May 16 2017 07:22
@cwborion I don't remember the answer to that particular challenge, but I'm guessing you mean the part where you have to multiply the product * each item in each array?
Carson Hanel
@chingy1510
May 16 2017 07:22
@longnt80 I think I see my problem
I arbitrarily subtracted 13 from everything except space values.
But I think that characters over halfway on unicode need to be subtracted from
And vice versa, added to.
Caleb Brenner
@cwborion
May 16 2017 07:23
@LukeSallmen yeah, here is the completed code
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
      console.log(arr[i][j]);
      product = product * arr[i][j];
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Carson Hanel
@chingy1510
May 16 2017 07:23
I'mma tinker.
abraham anak agung
@padunk
May 16 2017 07:23
Caleb Brenner
@cwborion
May 16 2017 07:24
@LukeSallmen thank you for helping though
CamperBot
@camperbot
May 16 2017 07:24
cwborion sends brownie points to @lukesallmen :sparkles: :thumbsup: :sparkles:
:cookie: 246 | @lukesallmen |http://www.freecodecamp.com/lukesallmen
Long Nguyen
@longnt80
May 16 2017 07:24

@chingy1510

But I think that characters over halfway on unicode need to be subtracted from
And vice versa, added to.

yeah, you got it

Luke Sallmen
@LukeSallmen
May 16 2017 07:24
@cwborion It's not really syntax you should be unfamiliar with (I don't think), I think it's the mindset that's challenging. You have to think a bit outside the box and multiply product * each sub-array item
Carson Hanel
@chingy1510
May 16 2017 07:24
thanks @longnt80 , dig the username too.
CamperBot
@camperbot
May 16 2017 07:24
chingy1510 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
May 16 2017 07:25
@chingy1510 haha why? it's my real name btw
Luke Sallmen
@LukeSallmen
May 16 2017 07:25
@cwborion Sorry I couldn't be of much help!
Caleb Brenner
@cwborion
May 16 2017 07:26
@LukeSallmen and that makes sense to me. I understood that, but now how it would be written out. And I’m sure I would have had plenty of questions to where you’d have ended up helping me find the solution after long enough haha
Carson Hanel
@chingy1510
May 16 2017 07:26
@longnt80 "long integer" xD
Long Nguyen
@longnt80
May 16 2017 07:26
can someone help explaining the Permutations in the challenge No repeats please?
jmariomejiap
@jmariomejiap
May 16 2017 07:26
@Masd925 oh, I do see your point about being slow. Ill keep working on this. thanks for your help.
CamperBot
@camperbot
May 16 2017 07:26
jmariomejiap sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4078 | @masd925 |http://www.freecodecamp.com/masd925
Carson Hanel
@chingy1510
May 16 2017 07:27
@longnt80 have you taken discrete math?
jmariomejiap
@jmariomejiap
May 16 2017 07:27
@padunk thanks for the link, Im going to check it out
CamperBot
@camperbot
May 16 2017 07:27
jmariomejiap sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @padunk |http://www.freecodecamp.com/padunk
Long Nguyen
@longnt80
May 16 2017 07:27
@chingy1510 what do you mean?
Carson Hanel
@chingy1510
May 16 2017 07:27
@longnt80 if I'm not mistaken it's the either like
abraham anak agung
@padunk
May 16 2017 07:27
@longnt80 what u want to know?
Carson Hanel
@chingy1510
May 16 2017 07:28
If there are 5 unique characters it's either 5! or 5 factorial, I forget.
abraham anak agung
@padunk
May 16 2017 07:29
there is no formula for this permutation i think, so you have to deal with something, like Heap algorithm @longnt80
Long Nguyen
@longnt80
May 16 2017 07:29
@padunk
permAlone("aabb") should return 8. I don't know how they get 8 math wise. I can only manually write down total of 6 (included repeated letters)
@chingy1510 yeah, I saw the link FCC give
Carson Hanel
@chingy1510
May 16 2017 07:30
I haven't done the algorithm yet, just remember from class.
Luke Sallmen
@LukeSallmen
May 16 2017 07:30
@chingy1510 5! and 5 factorial are the same thing, no?
Long Nguyen
@longnt80
May 16 2017 07:31
@LukeSallmen yes
abraham anak agung
@padunk
May 16 2017 07:31
@longnt80 aabb will return 4! which is 24 permutation, but you need you delete the one that have repeated letter
Carson Hanel
@chingy1510
May 16 2017 07:31
You're right. I was thinking binomial theorem, my bad.
2:30 in the morning xD
Long Nguyen
@longnt80
May 16 2017 07:33
@padunk
I'm trying to understand the rule in the challenge here. Please see if I got it right:
aabb can have these permutations:
aabb,abab,abba,bbaa,baab,baba
is that right?
Carson Hanel
@chingy1510
May 16 2017 07:33
Remember that there are 2 sets of every A and B
Think of it like this...
abraham anak agung
@padunk
May 16 2017 07:34
@longnt80 yes and 18 more of it :)
Carson Hanel
@chingy1510
May 16 2017 07:34
AaBb, aABb, AabB, aAbB
abraham anak agung
@padunk
May 16 2017 07:34
a1 a2 b1 b2 , the a and the other a is not the same
Carson Hanel
@chingy1510
May 16 2017 07:34
with the caps being technically the same letter.
Long Nguyen
@longnt80
May 16 2017 07:34
so uppercase letters
Carson Hanel
@chingy1510
May 16 2017 07:34
Nonono
Look at padunk
a_1 and a_2 are both technically 'a'
But they're not, at the same time.
Aimy24
@Aimy24
May 16 2017 07:35
Initialize a to a value of 9
how to solve it
Carson Hanel
@chingy1510
May 16 2017 07:35
Does that make sense?
Gaurav
@gauravmagan
May 16 2017 07:35
function solveMeFirst( a, b) {
  // Hint: Type return a+b below 

    c = a + b ; 
    return c ;


}

function main() {
    // write your code here.
    // call `readLine()` to read a line.
    // use console.log() to write to stdout
    console.log (solveMeFirst(2,3));
}
Carson Hanel
@chingy1510
May 16 2017 07:35
Like, for example, bob and jim are both boys, but they're different.
Gaurav
@gauravmagan
May 16 2017 07:35
this isnt passing the test case
Carson Hanel
@chingy1510
May 16 2017 07:35
Try just return a+b;
forget c
Long Nguyen
@longnt80
May 16 2017 07:36
@padunk @chingy1510
woa, this is really abstract
Carson Hanel
@chingy1510
May 16 2017 07:37
I mean, it is and isn't. Just how permutations work.
abraham anak agung
@padunk
May 16 2017 07:37
@longnt80 aabb will return 24 different permutations, think like this a1 a2 b1b2 is not the same as a2 a1 b1b2
not reaaly abstract try abcd first and you will get the idea
Carson Hanel
@chingy1510
May 16 2017 07:37
You have to think of each character as its own object.
jmariomejiap
@jmariomejiap
May 16 2017 07:38
@padunk thanks for the link. super illustrative, this type of logic has never been my strong suit. it helps
CamperBot
@camperbot
May 16 2017 07:38
jmariomejiap sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:warning: jmariomejiap already gave padunk points
Long Nguyen
@longnt80
May 16 2017 07:38
@padunk if it was a,b,c,d then I could understand
Carson Hanel
@chingy1510
May 16 2017 07:38
@longnt80 think of "a,b" as both a's and "c, d" as both b's
abraham anak agung
@padunk
May 16 2017 07:38
@jmariomejiap that is one of the hardest challenge, no problem
Long Nguyen
@longnt80
May 16 2017 07:43
@padunk @chingy1510
still don't get it :worried:
Markus Kiili
@Masd925
May 16 2017 07:44
@longnt80 There are two parts there. When looking at permutations, all letters are individuals. When you check for repeated consecutive letters, you group those individuals according to the letter.
Long Nguyen
@longnt80
May 16 2017 07:46
@padunk @chingy1510 @Masd925
ok so how can I tell the difference between:
a1 a2 b1 b2 and a2 a1 b1 b2
Markus Kiili
@Masd925
May 16 2017 07:47
@longnt80 You don't need to tell the difference. You just need to generate correct amount of aabb's.
abraham anak agung
@padunk
May 16 2017 07:47

@longnt80 aabb will return

[ 'aabb',
  'aabb',
  'baab',
  'abab',
  'abab',
  'baab',
  'baab',
  'abab',
  'abab',
  'baab',
  'aabb',
  'aabb',
  'abba',
  'baba',
  'baba',
  'abba',
  'bbaa',
  'bbaa',
  'bbaa',
  'bbaa',
  'abba',
  'baba',
  'baba',
  'abba' ]

you don't need to know the different, but you just need to delete the ones that have repeated letter.

Makopa
@makopa
May 16 2017 07:48
Good day campers :fire: i created an object. and i want to print all of this properties at once. what is the best way?
var object = {
        name: 'John',
        lastName: 'Doe',
        age: '26',
        height: "5'9",
        gender: 'male'
      }
Long Nguyen
@longnt80
May 16 2017 07:49
@padunk
so I have to generate the array with all that permutations?
abraham anak agung
@padunk
May 16 2017 07:50
@longnt80 first you have to do that and then delete the one that have repeated consecutive letters
Long Nguyen
@longnt80
May 16 2017 07:51
I see, I'll try that
thanks guys @padunk @Masd925 @chingy1510
CamperBot
@camperbot
May 16 2017 07:51
longnt80 sends brownie points to @padunk and @masd925 and @chingy1510 :sparkles: :thumbsup: :sparkles:
:cookie: 257 | @chingy1510 |http://www.freecodecamp.com/chingy1510
:cookie: 316 | @padunk |http://www.freecodecamp.com/padunk
:star2: 4079 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
May 16 2017 07:52
@makopa You can console.log(object) or loop Object.keys(object) or use the for...in loop.
abraham anak agung
@padunk
May 16 2017 07:52
@makopa console.log(object)
Makopa
@makopa
May 16 2017 07:54
@Masd925 i tried Object.keys(myobject) all print out the keys, how about the properties?
Markus Kiili
@Masd925
May 16 2017 07:54
@makopa You can loop those keys and use object[key] for getting values.
Will Waymel
@willwaymel
May 16 2017 07:55
very simple question... in a while loop, if I have an if statement that I put a "return result;", does it exit the while loop if it hits this "return"?
Markus Kiili
@Masd925
May 16 2017 07:55
@willwaymel Yes.
Exist the function too.
Makopa
@makopa
May 16 2017 07:55
@Masd925 ow thanks man! ill try and get back to you for result
CamperBot
@camperbot
May 16 2017 07:55
makopa sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4080 | @masd925 |http://www.freecodecamp.com/masd925
Will Waymel
@willwaymel
May 16 2017 07:57
@Masd925 thanks... can you look at my simple lookup code and see if this is the optimal (within my skill level) way to do this lookup?
function lookUpProfile(firstName, prop){
// Only change code below this line
var result = "";
var noContactFound = "No such contact";
var noPropertyFound = "No such property";
i = 0;
while(i < contacts.length) {
  if(contacts[i].firstName === firstName) {
    if(contacts[i].hasOwnProperty(prop)) {
         result = contacts[i][prop];
         return result;   
            } else {
              result = noPropertyFound;
              return result;
             }
  }
  i++;
}
return noContactFound;
CamperBot
@camperbot
May 16 2017 07:57
willwaymel sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4081 | @masd925 |http://www.freecodecamp.com/masd925
Will Waymel
@willwaymel
May 16 2017 07:57
(it works, just wondering on the logic etc. if I'm making it harder than it should be)
Markus Kiili
@Masd925
May 16 2017 07:58
@willwaymel You only need the loop and those two nested if's, and the returns at correct spots. No variables needed at all really.
Will Waymel
@willwaymel
May 16 2017 07:58
right, you mean, i could just return "No such contact" vs the variable for it?
Markus Kiili
@Masd925
May 16 2017 07:58
Always use var when you declare variables like i=0
@willwaymel Yes, just return when you know the return value.
Will Waymel
@willwaymel
May 16 2017 07:59
gotcha, yeah i'm trying to remember that. need to get in the habit
MissLisaMN
@MissLisaMN
May 16 2017 07:59

in Golf Code: I can't understand how to write this into my code: Strokes Return
1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"

= par + 3 "Go Home!"
par and strokes will always be numeric and positive.

Blauelf
@Blauelf
May 16 2017 07:59
@willwaymel What's the use in a result variable if you're not going to use it? You could use it (then initialise it to "No such contact" and return it in the end), but if you instantly return, you could return contacts[i][prop]; without that extra step.
MissLisaMN
@MissLisaMN
May 16 2017 07:59

Here is my code : function golfScore(par, strokes) {
// Only change code below this line
if (par , 1) {
return ("Hole-in-one");
}
else if (par , 2) {
return "Eagle";
}
else if (par , 3) {
return "Birdie";
}
else if (par , 4) {
return "Par";
}
else if (par , 5) {
return "Bogey";
}
else if (par , 5) {
return "Double Bogey";
}
else {
return "Go Home!";
}

// Only change code above this line
}

// Change these values to test
golfScore(4, 1);
golfScore(4, 2);
golfScore(5, 2);
golfScore(4, 3);
golfScore(4, 4);
golfScore(1, 1);
golfScore(5, 5);
golfScore(4, 5);
golfScore(4, 6);
golfScore(4, 7);
golfScore(5, 9);

Blauelf
@Blauelf
May 16 2017 08:00
@MissLisaMN Comma operator is not what you want. Maybe use operators like === or <= or similar? Also, "Hole-in-one!" stands for strokes being 1, all other cases require a certain difference of par and strokes.
MissLisaMN
@MissLisaMN
May 16 2017 08:01
@Blauelf ok, i think i know what you mean, thanks!
CamperBot
@camperbot
May 16 2017 08:01
misslisamn sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4143 | @blauelf |http://www.freecodecamp.com/blauelf
Gaurav
@gauravmagan
May 16 2017 08:01
function solveMeFirst( a, b) { 
  // Hint: Type return a+b below 
        return a + b ;   
}

function main() {
    // write your code here.
    // call `readLine()` to read a line.
    // use console.log() to write to stdout
    console.log (solveMeFirst(2,3));
}
test case is failing stil,
Will Waymel
@willwaymel
May 16 2017 08:01
@Blauelf like this ?
function lookUpProfile(firstName, prop){
// Only change code below this line
var noContactFound = "No such contact";
var noPropertyFound = "No such property";
i = 0;
while(i < contacts.length) {
  if(contacts[i].firstName === firstName) {
    if(contacts[i].hasOwnProperty(prop)) {
         return contacts[i][prop];
         } else {
              return noPropertyFound;
              }
  }
  i++;
}
return noContactFound;
Blauelf
@Blauelf
May 16 2017 08:02
@willwaymel Please declare i using var
Will Waymel
@willwaymel
May 16 2017 08:02
haha
just did, thanks
Gaurav
@gauravmagan
May 16 2017 08:02
@chingy1510 the test case is failing still
Will Waymel
@willwaymel
May 16 2017 08:02
saw that right after hitting enter
Gaurav
@gauravmagan
May 16 2017 08:02

```function solveMeFirst( a, b) {
// Hint: Type return a+b below
return a + b ;
}

function main() {
// write your code here.
// call readLine() to read a line.
// use console.log() to write to stdout
console.log (solveMeFirst(2,3));
}
```

Will Waymel
@willwaymel
May 16 2017 08:03
@Blauelf that what you meant though? ... ish
Blauelf
@Blauelf
May 16 2017 08:03
@willwaymel I don't see much benefit in declaring variables for those string constants you use exactly once. But for instant return ("return early"), that's about the way to go.
Will Waymel
@willwaymel
May 16 2017 08:04
yeah, I see what you mean. it's extra typing and not helping, other than my code looking nicer (to me) if the text was really long or something
@Blauelf thanks for the help
CamperBot
@camperbot
May 16 2017 08:04
willwaymel sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4144 | @blauelf |http://www.freecodecamp.com/blauelf
Long Nguyen
@longnt80
May 16 2017 08:06
@padunk @Masd925 @chingy1510
FreeCodeCamp/freecodecamp#1418
apparently, FCC just making it confusing
Blauelf
@Blauelf
May 16 2017 08:06
@willwaymel The alternative with a result variable is more like
function lookUpProfile(firstName, prop){
  // Only change code below this line
  var result = "No such contact";
  var i = 0;
  while (i < contacts.length) {
    if(contacts[i].firstName === firstName) {
      if(contacts[i].hasOwnProperty(prop)) {
        result = contacts[i][prop];
      } else {
        result = "No such property";
      }
      break; // leave loop early if found matching contact
    }
    i++;
  }
  return result;
}
Will Waymel
@willwaymel
May 16 2017 08:08
@Blauelf aha. I could not figure out how to exit the while loop (without using return) if found match... initially i was trying while(i < contacts.length && contacts.firstName !== firstName) ... but it wasn't working for all of the text scripts... couldn't figure out what the problem was. but that break is really what i want I guess
abraham anak agung
@padunk
May 16 2017 08:14
@longnt80 yeah, i bang my head at first too, but if you read the instruction :
Assume that all characters in the provided string are each unique.
maybe you get the idea :)
Long Nguyen
@longnt80
May 16 2017 08:15
@padunk yes I noticed that after your explanation above
abraham anak agung
@padunk
May 16 2017 08:16
:+1: @longnt80 happy coding, that one is hard :)
Long Nguyen
@longnt80
May 16 2017 08:18
@padunk I already having headache from reading articles about permutations lol
Blauelf
@Blauelf
May 16 2017 08:19
The difference is a factor you could easily compute (product of the factorials of the character counts in the string, so for "aabb" it's 2!2!=42!\cdot2!=4)
Gaurav
@gauravmagan
May 16 2017 08:20
hi can anyone explain about readline here

function solveMeFirst( a, b) {
// Hint: Type return a+b below
return a + b ;
}

function main() {
// write your code here.
// call readLine() to read a line.
// use console.log() to write to stdout
console.log (solveMeFirst(2,3));
}

HeebieGeeBee
@HeebieGeeBee
May 16 2017 08:21
yo
abraham anak agung
@padunk
May 16 2017 08:22
@gauravmagan is it a function?
Masaki
@masaki1223
May 16 2017 08:22

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  for(var i=0; i<collection.length; i++){
    if(collection[i].hasOwnProperty(source) === true){
      arr.push(collection[i]);
    }
  }
  return arr;
  // Only change code above this line

}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Hi everyone. I restarted algorithm challenge again, and i forgot how to access to key of object. Can you help me?
HeebieGeeBee
@HeebieGeeBee
May 16 2017 08:23
@masaki1223 what do you mean access the key?
you can use Object.keys to generate an array of all an objects keys
what are you trying to do though?
Masaki
@masaki1223
May 16 2017 08:25
@HeebieGeeBee I want to indexOf('last'), but this doesn't work because this is not array. How do I see if the second argument is matching anything in first argument?
HeebieGeeBee
@HeebieGeeBee
May 16 2017 08:26
for in loop might be useful
@masaki1223 you for put a for in loop nested inside your for loop i guess
HeebieGeeBee
@HeebieGeeBee
May 16 2017 08:31
or you could generate an array of the keys in source
and then use that to compare
lipanyu
@lipanyu
May 16 2017 08:38
Please help me to answer 216
I'm stuck in this problem
Gaurav
@gauravmagan
May 16 2017 08:40
function main() {
    var n = parseInt(readLine(6));
    arr = readLine().split('');
    arr = arr.map();

}
what does the code say
HeebieGeeBee
@HeebieGeeBee
May 16 2017 08:42
@gauravmagan not a lot
abraham anak agung
@padunk
May 16 2017 08:44
@lipanyu where is your code?
Markus Kiili
@Masd925
May 16 2017 08:53
@masaki1223 Yes, you need another nested loop through source's keys. There are also some handy array iterator methods that could be used instead of those two loops.
Masaki
@masaki1223
May 16 2017 08:54
in an object {firstname:"John"}, property is "John". Right?
HeebieGeeBee
@HeebieGeeBee
May 16 2017 08:55
no firstname is
Markus Kiili
@Masd925
May 16 2017 08:55
@masaki1223 Properties are key:value pairs. "firstname" is a property key (or name) and "John" is a property value.
HeebieGeeBee
@HeebieGeeBee
May 16 2017 08:55
fair enough
Shinra Low
@Shinra-Low
May 16 2017 08:55
Hello guys anyone here free for another question?
Masaki
@masaki1223
May 16 2017 08:56
hasOwnProperty iterates through prop key, so which function is for propvalue??
r2d2
@UsamaHameed
May 16 2017 08:57
What is wrong with this javascript?
const routesArray = projectArray.map((project, index) =>
  <Route key={index} path=`/projects/${project.url}` component={project.component} />);
It shows me a syntax error
Markus Kiili
@Masd925
May 16 2017 08:57
@masaki1223 You need to iterate source's keys and access and compare property values of source and looped object. Use bracket notation for accessing property values.
abraham anak agung
@padunk
May 16 2017 09:00
@Shinra-Low what is it?
Shinra Low
@Shinra-Low
May 16 2017 09:00

function findLongestWord(str) {
var a = str.split(" ");
function reo(a){
if (a[0].length >= a[1].length) {
a.splice(1,1); return reo(a);
} else if (a[0].length <= a[1].length) {
a.splice(0,1); return reo(a);
}
}
return a[0].length;}

findLongestWord("The quick brown fox jumped over the lazy dog");
where did i mess up the recursion?

abraham anak agung
@padunk
May 16 2017 09:01
@Shinra-Low put your code with ```
Shinra Low
@Shinra-Low
May 16 2017 09:02
what is ```?
abraham anak agung
@padunk
May 16 2017 09:02
are you doing loop? where is your loop?
Bhavik
@BhavikSheth
May 16 2017 09:02
Hi everyone. I have to build a battleship game using ReactJS and have a REST API that handles all the game logic. I have also been provided with a swagger json file which gives me details about all the api methods, including json schema used for requests and responses. I've worked with apis before in free code camp projects but nothing this technical. Is there any tutorial or anything that can point me in the right direction? Thanks so much.
abraham anak agung
@padunk
May 16 2017 09:02
to put your code so easier to read
function findLongestWord(str) {
var a = str.split(" ");
function reo(a){
if (a[0].length >= a[1].length) {
a.splice(1,1); return reo(a);
} else if (a[0].length <= a[1].length) {
a.splice(0,1); return reo(a);
}
}
return a[0].length;}
findLongestWord("The quick brown fox jumped over the lazy dog");
Markus Kiili
@Masd925
May 16 2017 09:03
@Shinra-Low It is confusing to use a in two meanings there.
I don't see you calling reo anywhere outside reo declaration.
Shinra Low
@Shinra-Low
May 16 2017 09:04
after splicing either one of the element
HeebieGeeBee
@HeebieGeeBee
May 16 2017 09:04
lol variable called a parameter called in a fucntion that recursively calls the function in a return
thats pretty confusing to follow
Shinra Low
@Shinra-Low
May 16 2017 09:04
then i use return reo(a) to rerun the spliced array
HeebieGeeBee
@HeebieGeeBee
May 16 2017 09:05
https://heebiegeebee.github.io/JS_Arkanoid_Clone/ does everyone get a 404 error with this?
Markus Kiili
@Masd925
May 16 2017 09:05
@Shinra-Low You declare reo, but you don't call it:
function findLongestWord(str) {
  var a = str.split(" ");
  function reo(a){
    if (a[0].length >= a[1].length) {
      a.splice(1,1); return reo(a);
    } 
    else if (a[0].length <= a[1].length) {
      a.splice(0,1); return reo(a);
    }
  }
  return a[0].length;
}
HeebieGeeBee
@HeebieGeeBee
May 16 2017 09:06
i put it up over 30 minutes ago and im still getting 404 error
abraham anak agung
@padunk
May 16 2017 09:06
@Shinra-Low this is confusing. if you try to rerun it use for loop
Masaki
@masaki1223
May 16 2017 09:06

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  var value='';
  // Only change code below this line


  for (var key in source) {
    if (collection.hasOwnProperty(key)) {
        arr.push(collection);
    }

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

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Not working.....
Shinra Low
@Shinra-Low
May 16 2017 09:07
alright i'll give it another shot, thanks guys.
Markus Kiili
@Masd925
May 16 2017 09:07
@masaki1223 You need to keep the object only if the property values match for all the sources keys. So some loop logic needed.
HeebieGeeBee
@HeebieGeeBee
May 16 2017 09:07
@masaki1223 collection is a whole array
Markus Kiili
@Masd925
May 16 2017 09:08
@masaki1223 Two nested loops or iterations are needed over collection and source's keys.
abraham anak agung
@padunk
May 16 2017 09:08
@HeebieGeeBee no, it working with black box, a ball and a red line :)
HeebieGeeBee
@HeebieGeeBee
May 16 2017 09:08
why cant i see it then
@padunk if you press enter the ball should fly off
and you can move the paddle left and right
@Masd925 do you remember the game arkanoid?
abraham anak agung
@padunk
May 16 2017 09:09
yes, im playing it right now, but the ball keep bouncing
HeebieGeeBee
@HeebieGeeBee
May 16 2017 09:10
@padunk its not meant to
Markus Kiili
@Masd925
May 16 2017 09:10
@HeebieGeeBee Not familiar game.
HeebieGeeBee
@HeebieGeeBee
May 16 2017 09:10
until it hits the flooe
but like theres still lots to do with the game
SAIDI YASSINE
@Nero00
May 16 2017 09:10
the hard thing in programming is naming variable
abraham anak agung
@padunk
May 16 2017 09:10
@heebiegeebee oh wait, maybe it hit the edge of the line. it working fine
Veronica Tobias
@vekatobias
May 16 2017 09:10
Hi guys I need help.. Can you help me with this challengues?

// Setup
var testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats"
};

// Only change code below this line

var hatValue = testObj; // Change this line
var shirtValue = testObj; // Change this line

these are the instructions :Read in the property values of testObj using dot notation. Set the variable hatValue equal to the object property hat and set the variable shirtValue equal to the object property shirt.
HeebieGeeBee
@HeebieGeeBee
May 16 2017 09:11
@Masd925 i was trying to think of a way to map the hit tiles
but i guess if youve never played the game you dont know what i mean
SAIDI YASSINE
@Nero00
May 16 2017 09:12
@vekatobias whats the name of the challenge ?
Veronica Tobias
@vekatobias
May 16 2017 09:12
@Nero00 is Accessing Objects Properties with the Dot Operator
HeebieGeeBee
@HeebieGeeBee
May 16 2017 09:13
@vekatobias you need to access the objects property values by assigning the value to the variables
Veronica Tobias
@vekatobias
May 16 2017 09:13
I don't know how to add "dot notation"
SAIDI YASSINE
@Nero00
May 16 2017 09:14
@vekatobias
*hatValue = testObj.hat; // Change this line
shirtValue = testObj.shirt; // Change this line
add dot
Nahuel Ovejero
@NahuelOvejero
May 16 2017 09:14
@vekatobias dot notations is accessing an object via the dot
obj[property] = value; // bracket notation
obj.property = value; // dot notation
SAIDI YASSINE
@Nero00
May 16 2017 09:15
Yep
abraham anak agung
@padunk
May 16 2017 09:15
@HeebieGeeBee how you put image of screenshot here?
Veronica Tobias
@vekatobias
May 16 2017 09:15
@Nero00 I dit exactly the same thing but I have to add an string
HeebieGeeBee
@HeebieGeeBee
May 16 2017 09:15
@padunk paste it
abraham anak agung
@padunk
May 16 2017 09:15
Screenshot 2017-05-16 16.11.51.png
SAIDI YASSINE
@Nero00
May 16 2017 09:16
@vekatobias idk you still stuck ?
Emmanuel Akodia
@akodiaemma
May 16 2017 09:16
HELLO WORLD
HeebieGeeBee
@HeebieGeeBee
May 16 2017 09:16
@padunk what happened there it just stopped?
Veronica Tobias
@vekatobias
May 16 2017 09:16
yes @Nero00 The value of hatValue should be "ballcap"
abraham anak agung
@padunk
May 16 2017 09:16
no it bounce back, and i can keep playing ::)
Veronica Tobias
@vekatobias
May 16 2017 09:16
and thevalue of shirtValue should be "jersey"
Masaki
@masaki1223
May 16 2017 09:17

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];

  // Only change code below this line

    for(var i =0; i<collection.length; i++){
      for(var key in source){
      if(collection.hasOwnProperty(key)){
        arr.push(collection[i]);
      }
    }
  }
  // Only change code above this line
    return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
I nested loop in loop but still not working.
HeebieGeeBee
@HeebieGeeBee
May 16 2017 09:17
@padunk yeah if it hits the floor it should return back to the paddle
SAIDI YASSINE
@Nero00
May 16 2017 09:17
@vekatobias ok lemme see
Veronica Tobias
@vekatobias
May 16 2017 09:17
I'll try to resolve that.. Wait few minute guys
HeebieGeeBee
@HeebieGeeBee
May 16 2017 09:18
@padunk ive only realy just started doing it though so its not realy much of a game yet
abraham anak agung
@padunk
May 16 2017 09:18
@HeebieGeeBee yeah, just a little bug i think, but this is cool!