These are chat archives for FreeCodeCamp/HelpJavaScript

24th
Mar 2017
Conor Murphy
@cmurphy580
Mar 24 2017 00:00
the output was coming from the main function. Not the helper function I had. @JLuboff Thanks for the help though
CamperBot
@camperbot
Mar 24 2017 00:00
cmurphy580 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1263 | @jluboff |http://www.freecodecamp.com/jluboff
Donnie
@Donnie-D
Mar 24 2017 00:00
you bunch of msterminds in here
Jacob Horvat
@yummysnacks
Mar 24 2017 00:01
Hey everyone, could someone help me with this challenge?
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup = {
  "alpha": "Adams",
  "bravo": "Boston",
  "charlie": "Chicago",
  "delta": "Denver",
  "echo": "Easy",
  "foxtrot": "Frank",
    };

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

// Change this value to test
phoneticLookup("charlie");
Donnie
@Donnie-D
Mar 24 2017 00:01
sorry fellas im gonna try once more to see what i did to paste the code.
please dont think im spamming in here.
Stephen James
@sjames1958gm
Mar 24 2017 00:02
@yummysnacks Now you have to set result using lookup object and property name in val
Donnie
@Donnie-D
Mar 24 2017 00:02
var a = 3;
var b = 17;
var c = 12;

// Only modify code below this line

a = a + 12;
b = 9 + b;
c = c + 7;
Stephen James
@sjames1958gm
Mar 24 2017 00:02
@Donnie-D :+1:
Donnie
@Donnie-D
Mar 24 2017 00:02
yup ...that works...Respect to you all !!!
Moustapha
@moustaflo
Mar 24 2017 00:04
I was told the problem was the use of splice but I fixed it. Still not seeing the problem.
function mutation(arr) {
  var test = [];
  var firstArr = [];
  var secArr = "";
 var spliced = arr.splice(1, 1);
 firstArr.push(arr[0].toLowerCase());
 secArr = spliced[0].toLowerCase().split("");
  for(x=0; x<secArr.length; x++){
    test.push(secArr[x]);
  }
  return firstArr.indexOf(test, 0) > -1;
}
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);
si
@demon9181
Mar 24 2017 00:09
hi quick question
trying to turn an array of strings into a single string.but the .join(" ") is adding in unwanted commas!
please advise
function titleCase(str) {
  x = str.split(" ");
  for(a = 0;a < x.length;a++){
    x[a] = x[a].toLowerCase();
    x[a] = x[a].split("");
    x[a][0] =  x[a][0].toUpperCase();
    console.log(x);
  }

  x = x.join(" ");
  return x;
}

titleCase("I'M A liTTle tea pot");
CamperBot
@camperbot
Mar 24 2017 00:10
:bulb: to format code use backticks! ``` more info
si
@demon9181
Mar 24 2017 00:10
heres my code
Moustapha
@moustaflo
Mar 24 2017 00:11
@demon9181 the solution is inside your join() parenthases
Alejandro A Barrera
@AlejandroBarrera01
Mar 24 2017 00:12
Hey GUYS! I am multiplying Nest LOOPS I need HELP!

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < arr.length; i++)
{
for ( var j=0; arr[i].length; j++ )
{
product = [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]]);

any suggestions?
si
@demon9181
Mar 24 2017 00:12
@moustaflo still not clicking .give me more
Moustapha
@moustaflo
Mar 24 2017 00:14
@demon9181 there should be no space in between the quotation marks
Ken Haduch
@khaduch
Mar 24 2017 00:15
@demon9181 - you have a lot of sub-arrays with each word split into the individual characters, and when that is being joined, those are having the commas inserted.
si
@demon9181
Mar 24 2017 00:15
@moustaflo but then i get no spaces at all and the commas are STILL there
@khaduch any suggestions how to remove the commas or avoid them altogether?
Ken Haduch
@khaduch
Mar 24 2017 00:20
@demon9181 - yes - after you make x[a][0] uppercase, you have an array at x[a] that will look like this: ["L","i","t","t","l","e"] - you need to use .join('') on that array to make it back into a word.
I could give you the code that will do it, but see what you think should be done first...
si
@demon9181
Mar 24 2017 00:22
@khaduch awesome thanks for the help!
CamperBot
@camperbot
Mar 24 2017 00:22
demon9181 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2673 | @khaduch |http://www.freecodecamp.com/khaduch
si
@demon9181
Mar 24 2017 00:25
@khaduch just curious but why did that work ( i put x[a] = x[a].join(""); into the loop and worked) why did the .join on a single array get the commas out but .join on an array of arrays leave the commas?
or is that just a quirk of javascript
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:27
is anyone else having trouble with profile lookup?
it's driving me insane
Ken Haduch
@khaduch
Mar 24 2017 00:27
@demon9181 - you know, I don't really know how it works with the sub-arrays, but basically, if you do .join(''), it will join the strings without a space between each string (each letter, in this case). If you do .join(), then it will insert a comma between each letter.
@ladystensberg - you wouldn't be the first one, for sure! Many people have difficulty with that one!
Adam
@GoingAllTheWayUp
Mar 24 2017 00:28
@demon9181 you need to go deeper there is a method .isArray()
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:28
@khaduch Any idea what might be happening here? I'm using a for loop to iterate over contacts. then accessing property names like contacts[i].firstName
Ken Haduch
@khaduch
Mar 24 2017 00:29
@ladystensberg - that sounds like you are on the right track, can you post your code?
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:30
for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName !== firstName) {
      return "No such contact";
    } else if (contacts[i].prop !== prop) {
      return "No such property";
    } else if (contacts[i].firstName == firstName && contacts[i].prop == prop) {
      return contacts[i].prop;
    }
  }
CamperBot
@camperbot
Mar 24 2017 00:30
:bulb: to format code use backticks! ``` more info
Ken Haduch
@khaduch
Mar 24 2017 00:30
@demon9181 - so it looks like it flattens the subarrays into the comma-separated string, because this: [['a','p','p','l','e'], ['p','e','a','r']].join('') will return "a,p,p,l,ep,e,a,r". I wonder if the docs describe this?
Manish Giri
@Manish-Giri
Mar 24 2017 00:31
@ladystensberg contacts[i].prop //hint - look here
Ken Haduch
@khaduch
Mar 24 2017 00:31
@ladystensberg - you can edit your post - put the ``` (Note that they should be backticks) on a separate line at the start and end of the code block.
@ladystensberg - you have a couple problems. @Manish mentioned one. The other is that you cannot just jump and return No such contact if the first contact doesn't match your lookup value.
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:33
oh, right - yeah, that needs to be at the bottom
would it be contacts[i][prop]?
Manish Giri
@Manish-Giri
Mar 24 2017 00:34
yeah
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:35
let me show you what I have now
Donnie
@Donnie-D
Mar 24 2017 00:36
var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count+1;
      break;
    case 7:
    case 8:
    case 9:
      count+0;
      break;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count-1;
      break;
  }
  if(count+0) {
    return count + " Hold";
  }
  else if(count+1){
    return count + " Bet";
  }

  else{return count + " Hold";

  }

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
 cc(6);//cc(3);  cc('K'); cc('A');cc(2);
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:36
for (var i = 0; i < contacts.length; i++) {
    if (contacts[i][firstName] == firstName && contacts[i][prop] == prop) {
      return contacts[i][prop];
    } else if (contacts[i][firstName] !== firstName) {
      return "No such contact";
    } else if (contacts[i][prop] !== prop) {
      return "No such property";
    }
  }
Donnie
@Donnie-D
Mar 24 2017 00:36
it returns "0 Bet" for all inputs
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:37
count = count +1
count = count + 0
count = count - 1
Ken Haduch
@khaduch
Mar 24 2017 00:37
@demon9181 - last thing on this - the docs do not specifically say what happens with nested arrays of strings, but I added a couple more levels of nesting and got this: [['a','p','p','l','e',['a','n','d',['o','n','e']]], ['p','e','a','r']].join(' ') yields: "a,p,p,l,e,a,n,d,o,n,e p,e,a,r"
Donnie
@Donnie-D
Mar 24 2017 00:37
@ladystensberg treid that lol didnt work
Manish Giri
@Manish-Giri
Mar 24 2017 00:38
@Donnie-D your if/else conditions aren't right..
Donnie
@Donnie-D
Mar 24 2017 00:39
@Manish-Giri okay?
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:40
oooh!! right!
Manish Giri
@Manish-Giri
Mar 24 2017 00:40
@Donnie-D
if count is greater than 0 - 
  return ->    count + " Bet";
else - 
 return -> count + " Hold";
Ken Haduch
@khaduch
Mar 24 2017 00:40
@ladystensberg - you're getting closer. BUT - you cannot return "No such contact" if your first (or second, or third) entry does not match the firstName value. Also, you cannot do the test for a property match unless you also have a firstName match.
Donnie
@Donnie-D
Mar 24 2017 00:40
@ladystensberg sorry i meant to say above that count=count+1 etc did solve the count bit of the if/else but not the secong part i.e hold/bet
Luke Pighetti
@lukepighetti
Mar 24 2017 00:40
so I want to do something to every ID that is created after the page load
so for example the wikipedia API returns items with class .searchmatch
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:41
@Donnie-D what @Manish-Giri said. check those if statements. they need a proper condition.
Luke Pighetti
@lukepighetti
Mar 24 2017 00:41
whenever this ID is created I want to do something (in this case, take the text and use it to create a link)
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:42
@khaduch okay thanks. I'll keep trying.
CamperBot
@camperbot
Mar 24 2017 00:42
ladystensberg sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2674 | @khaduch |http://www.freecodecamp.com/khaduch
Luke Pighetti
@lukepighetti
Mar 24 2017 00:42
my first inclination is to try to find a way to trigger on creation of an entity with ID .searchmatch
is there a better way of doing this?
the0ffh
@the0ffh
Mar 24 2017 00:42
Hello!
I have another silly question. Why is the code acting as if the type of [3] was number not object?
function addTogether(x) {
  for(var i=0;i<arguments.length;i++){
    if(typeof arguments[i] !=='number'){
      return undefined;
    }
  }
  if(arguments.length==1){
    return function(y){
      return x+ y;
    };
  }
  return arguments[0]+arguments[1];
}

addTogether(2)([3]);
Luke Pighetti
@lukepighetti
Mar 24 2017 00:43
WOOPS! ignore that entire question
just realized i misunderstood what .searchmatch was
Stephen James
@sjames1958gm
Mar 24 2017 00:47
@the0ffh Your code is not checking for the type of ([3]) because that is passed into the returned function not addTogether
Joseph
@revisualize
Mar 24 2017 00:48
@the0ffh look up currying.
Edward John
@eddmecha
Mar 24 2017 00:49
morning guys
Stephen James
@sjames1958gm
Mar 24 2017 00:49
@eddmecha Morning
Edward John
@eddmecha
Mar 24 2017 00:50
i have no idea how to write this
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
odm275
@odm275
Mar 24 2017 00:50

/*
-obj2 can only match subsets in obj1.
-obj2 is a Object.
-obj1 is an object of objects.
-hasOwnProperty("a") checks if property a exists.

  • Summary: If obj2 exists in any object in obj1 at least partially, return that instance.
    -ob1 should have both properties of obj2 to match.
    */

var obj1 = [{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }];
var obj2 = { "a": 1, "b": 2 };

//go into each individual object in the list of objects
for (var key in obj1){

console.log(obj1[key]);

//go inside obj2 to get each individual property
for(var prop in obj2){
    if()
    console.log(obj1[key].hasOwnProperty(prop));
}

}

var obj1 = [{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }];
var obj2 = { "a": 1, "b": 2 };

//go into each individual object in the list of objects
for (var key in obj1){

//go inside obj2 to get each individual property
for(var prop in obj2){

    console.log(obj1[key].hasOwnProperty(prop));

}

}

How can i say something like, if obj1[key].hasOwnProperty(prop) a pair of iterations are true then return that object, otherwise continue

Output:
true
true
true
false
true
true
Stephen James
@sjames1958gm
Mar 24 2017 00:51
@odm275 You can use a boolean outside the loop that is set true then set false if any element does not pass
odm275
@odm275
Mar 24 2017 00:52
@sjames1958gm thank you!!
CamperBot
@camperbot
Mar 24 2017 00:52
odm275 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6312 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Joseph
@revisualize
Mar 24 2017 00:52
hey.
Stephen James
@sjames1958gm
Mar 24 2017 00:52
@eddmecha The function has 4 parameters each will contain one of the words.
the0ffh
@the0ffh
Mar 24 2017 00:52
@revisualize @sjames1958gm Thanks a lot! :]
CamperBot
@camperbot
Mar 24 2017 00:52
the0ffh sends brownie points to @revisualize and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6313 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 3577 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 24 2017 00:52
This message was deleted
Stephen James
@sjames1958gm
Mar 24 2017 00:52
Edward John
@eddmecha
Mar 24 2017 00:53
@sjames1958gm i see but i dont understand how to start. the pre-written code is

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Sarah Stensberg
@ladystensberg
Mar 24 2017 00:53
@khaduch I'm about ready to give up. I've rearranged the if statements into something that should work and the tests still aren't passing.
for (var i = 0; i < contacts.length; i++) {
    if (contacts[i][firstName] == firstName) {
      if (contacts[i][prop] == prop) {
        return contacts[i][prop];
      } else {
        return "No such property";
      }
    } else {
      return "No such contact";
    }
  }
Stephen James
@sjames1958gm
Mar 24 2017 00:54
@eddmecha You should have learned how to concatenate string values (and variables) to make a longer string.
Do that with the 4 parameters assigning to result variable.
Eirik Vattøy
@eirikkv95
Mar 24 2017 00:54
var a = 3;
Stephen James
@sjames1958gm
Mar 24 2017 00:54
@ladystensberg You cannot return no such contact inside the loop
Also, (contacts[i][prop] == prop this is not how you determine if the contact has the property
the0ffh
@the0ffh
Mar 24 2017 00:54
@ladystensberg " I'm about ready to give up" - don't you even dare! :angry:
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:55
OMG...return statements break loops. Don't they? ><
Joseph
@revisualize
Mar 24 2017 00:56
@ladystensberg They do
Stephen James
@sjames1958gm
Mar 24 2017 00:56
@ladystensberg Yes, they exit the function entirely
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:56
I forgot about that. Geez. LOL
Joseph
@revisualize
Mar 24 2017 00:56
@ladystensberg Question.
@ladystensberg Do if's require an else?
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:56
No, I guess they don't.
Joseph
@revisualize
Mar 24 2017 00:56
@ladystensberg Another.
@ladystensberg 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?
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:57
When I got to the end of the stack.
Joseph
@revisualize
Mar 24 2017 00:57
@ladystensberg So, you're saying that after you loop look through all of the contacts cards in your array of object stack. That you'd tell me you don't have one for the individual?
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:57
Once I've looked through every card, yes.
Joseph
@revisualize
Mar 24 2017 00:57
@ladystensberg Hmmm...
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:57
I see where you're going with this. ;)
Joseph
@revisualize
Mar 24 2017 00:57
  // code before a for loop.
for (..........) {
  // Code inside of a for loop.
}
  // code after a for loop.
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:58
hehe thanks @revisualize
CamperBot
@camperbot
Mar 24 2017 00:58
:star2: 3578 | @revisualize |http://www.freecodecamp.com/revisualize
ladystensberg sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:58
this chat is great!
Joseph
@revisualize
Mar 24 2017 00:58
@ladystensberg Also. you're not supposed to compare the prop you're just supposed to see if it has a property.
Sarah Stensberg
@ladystensberg
Mar 24 2017 00:59
got it. thanks!
Joseph
@revisualize
Mar 24 2017 00:59
@ladystensberg Solve it?
@ladystensberg Oh. That advice won't solve it. You're missing one other thing.
@ladystensberg Let me know if you have time for a few more questions.
@ladystensberg you're actually missing an important part.
Sarah Stensberg
@ladystensberg
Mar 24 2017 01:02
working on it now
Joseph
@revisualize
Mar 24 2017 01:02

@ladystensberg Let's say you have an object.

var myFriend = {
        "firstName": "Happy",
        "lastName": "Feet",
        "number": "-i",
        "likes": ["rhythm", "dancing", "soul"]
    }

How do you access the "firstName" of myFriend?

Sarah Stensberg
@ladystensberg
Mar 24 2017 01:03
you can do myFriend.firstName
Joseph
@revisualize
Mar 24 2017 01:03
You can!
Sarah Stensberg
@ladystensberg
Mar 24 2017 01:03
or myFriend["firstName"]
right?
Joseph
@revisualize
Mar 24 2017 01:03
@ladystensberg (contacts[i][firstName] == firstName) ... hmmm
Ken Haduch
@khaduch
Mar 24 2017 01:03
@ladystensberg - yes, you got it!
Joseph
@revisualize
Mar 24 2017 01:03
@ladystensberg Correct.
@ladystensberg I'm also in Seattle. Sitting at GA at 3rd and Uni currently.
Sarah Stensberg
@ladystensberg
Mar 24 2017 01:04
So would I do contacts[i]["firstName"]?
Joseph
@revisualize
Mar 24 2017 01:04
@ladystensberg try it
Sarah Stensberg
@ladystensberg
Mar 24 2017 01:04
nice! I'm @ 24th and 57th in Ballard :)
Luke Pighetti
@lukepighetti
Mar 24 2017 01:04
        $(".result > span").click(function () {
          // foo
        });
is this the correct way to trigger on all <span> children of .result div?
Adam
@GoingAllTheWayUp
Mar 24 2017 01:05
jquery, i belive
Stephen James
@sjames1958gm
Mar 24 2017 01:06
@lukepighetti Yes
Jacob Horvat
@yummysnacks
Mar 24 2017 01:06
Stephen James
@sjames1958gm
Mar 24 2017 01:07
@ladystensberg Recall this challenge
Jacob Horvat
@yummysnacks
Mar 24 2017 01:07
Still not quite sure what I'm doing wrong here

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

  // Only change code below this line
   var lookup = {
  "alpha": "Adams",
  "bravo": "Boston",
  "charlie": "Chicago",
  "delta": "Denver",
  "echo": "Easy",
  "foxtrot": "Frank",
    };  

  result = lookup.alpha;
  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("alpha");
Stephen James
@sjames1958gm
Mar 24 2017 01:07
@yummysnacks You are not using the variable/parameter val for the lookup
Joseph
@revisualize
Mar 24 2017 01:08
@yummysnacks Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
when I try to do $.(".parent > child") in jquery it stops working
with just child it works, but has issues that should be solved with parent >child
Stephen James
@sjames1958gm
Mar 24 2017 01:10
@lukepighetti Where is the element with the class result?
Luke Pighetti
@lukepighetti
Mar 24 2017 01:11
WOOPS.
id vs class, let me fix it
Wow nice, thank you
and good eye
@sjames1958gm thank you
CamperBot
@camperbot
Mar 24 2017 01:11
lukepighetti sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6314 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Mar 24 2017 01:11
@lukepighetti Also, you have to be careful assigning click handlers to multiple elements inside the loop - you might get a lot of extra handlers
Luke Pighetti
@lukepighetti
Mar 24 2017 01:12
OK. thank you for the warning
any thoughts on getting word text when clicking on a word?
Sarah Stensberg
@ladystensberg
Mar 24 2017 01:12
wooohooo!!!
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].hasOwnProperty(prop) && contacts[i].firstName == firstName) {
      return contacts[i][prop];
    } else if (contacts[i].firstName == firstName && !contacts[i].hasOwnProperty(prop)) {
      return "No such property";
    }
  }
  return "No such contact";
Saboor Malik
@MathematicsCoding
Mar 24 2017 01:13
yo
Stephen James
@sjames1958gm
Mar 24 2017 01:13
@ladystensberg :+1: :sparkle:
@lukepighetti $(this).text() should do it
Sarah Stensberg
@ladystensberg
Mar 24 2017 01:13
yay!!!!!! thanks @sjames1958gm and @khaduch and @revisualize
CamperBot
@camperbot
Mar 24 2017 01:13
ladystensberg sends brownie points to @sjames1958gm and @khaduch and @revisualize :sparkles: :thumbsup: :sparkles:
:warning: ladystensberg already gave khaduch points
:star2: 6315 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:warning: ladystensberg already gave revisualize points
Saboor Malik
@MathematicsCoding
Mar 24 2017 01:13
Lol
Luke Pighetti
@lukepighetti
Mar 24 2017 01:14
@sjames1958gm I could be wrong but I think I need a way to trigger on click of word, right now i am putting each word in a span
is that what you were referring to with your warning? perhaps I misunderstand
Joseph
@revisualize
Mar 24 2017 01:15
@ladystensberg Does it all make sense?
Sarah Stensberg
@ladystensberg
Mar 24 2017 01:15
yes it does :)
Stephen James
@sjames1958gm
Mar 24 2017 01:15
@lukepighetti Using a span might be required to click on an individual word
Joseph
@revisualize
Mar 24 2017 01:15
@ladystensberg Do you want alternative solutions to review?
Sarah Stensberg
@ladystensberg
Mar 24 2017 01:18
sure
Joseph
@revisualize
Mar 24 2017 01:18
@ladystensberg I will PM you.
Sarah Stensberg
@ladystensberg
Mar 24 2017 01:18
ok
how do you even PM someone in this? lol
Trying to get the block at line 37 out on its own
Luke Pighetti
@lukepighetti
Mar 24 2017 01:20
but it doesn't work if i move it out (to line 8)
Joseph
@revisualize
Mar 24 2017 01:20
Luke Pighetti
@lukepighetti
Mar 24 2017 01:20
if I move it out, I can call the search function on click of a word
Donnie
@Donnie-D
Mar 24 2017 01:26

Guys someone very decently corrected my mistake with my if/else just a minute ago regarding following code. I wanted to know if I kept this as it is then why does it choose the else if part when I run the code?


var count = 0;

function cc(card) {

  switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count+1;
      break;
    case 7:
    case 8:
    case 9:
      count=count+0;
      break;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count=count-1;
      break;
  }

  if(count+0) {return count + " Hold";}

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

  else{return count + " Hold";  }
}

 cc(7);

excuse me if its a silly question

just want to know how its executed
Sarah Stensberg
@ladystensberg
Mar 24 2017 01:28
case 6 should be count = count +1
and the if statements still look incorrect
should be something like if (count > 0) { do something; }
OK, this is one of the coolest things i've ever made
Click on any word and it will search for it
Sarah Stensberg
@ladystensberg
Mar 24 2017 01:30
wow! that's fantastic @lukepighetti nice work!
Luke Pighetti
@lukepighetti
Mar 24 2017 01:30
it lets you just CRUISE through wikipedia
Saboor Malik
@MathematicsCoding
Mar 24 2017 01:30
@lukepighetti Congrats
Luke Pighetti
@lukepighetti
Mar 24 2017 01:30
to find articles you may have not known about
Saboor Malik
@MathematicsCoding
Mar 24 2017 01:30
You have created a second Google!
Luke Pighetti
@lukepighetti
Mar 24 2017 01:30
Lol!
Saboor Malik
@MathematicsCoding
Mar 24 2017 01:30
Let call it "Gooogle"
Sarah Stensberg
@ladystensberg
Mar 24 2017 01:30
great work, @lukepighetti ! truly1
+1
Saboor Malik
@MathematicsCoding
Mar 24 2017 01:31
Oh well Cant watch a video on it
Donnie
@Donnie-D
Mar 24 2017 01:31
@ladystensberg i just corrected that sarah and in know that if else is wrong i was only wondering that even with this if else being as it is , why does it choose to execute the else if part .
Saboor Malik
@MathematicsCoding
Mar 24 2017 01:31
I guess wiki only?
Sarah Stensberg
@ladystensberg
Mar 24 2017 01:32
@Donnie-D not sure on that
Conor Murphy
@cmurphy580
Mar 24 2017 01:32
let me try that again
I need to pass the parameter "t", the third parameter in the main function to my third, and last, helper function. I don't use the second parameter and what I have going is not working. Any ideas? Here's what I have going ...
function chooseBestSum(t, k, ls) {
    //ls = array of dist
    //t = 174 mi
    //k = distance to each location 

    if (ls.length < k){
      return null; 
    } else {
      return findBestOption(reduceArray(createCombinations(ls, k, t))); 
    }
} 

//Creates all possible combinations of arrays -- 
function createCombinations (array, n) { /////////////////
    var i,
    subI,
    output = [],
    sub,
    next;
    for(i = 0; i < array.length; i++){
        if(n === 1){ //
            output.push( [ array[i] ] );
        }else{
            sub = createCombinations(array.slice(i+1, array.length), n-1); //
            for(subI = 0; subI < sub.length; subI++ ){
                next = sub[subI];
                next.unshift(array[i]);
                output.push(next);
            }
        }
    }
    return output;
}

//totals the subarrays from the above function's output --
function reduceArray(array) {
  var sum = [];  
  for (var j = 0; j < array.length; j++) {
    sum.push(array[j].reduce(function(a,b) {
       return a+b; 
     }));  
  }
  return sum;  
}

//finds best option -- 
function findBestOption(array, n, p) {
   for (var l = 0; l < array.length; l++) {
     var best = -Infinity;
     if (array[l] > best && array[l] <= p) {
        best = array[l]; 
     }
  } 
  return best; 
}
Donnie
@Donnie-D
Mar 24 2017 01:32
@ladystensberg thats ok :)
Jacob Horvat
@yummysnacks
Mar 24 2017 01:34
Finally got it. Thank you @sjames1958gm & @revisualize
CamperBot
@camperbot
Mar 24 2017 01:34
yummysnacks sends brownie points to @sjames1958gm and @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 6316 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 3579 | @revisualize |http://www.freecodecamp.com/revisualize
Saboor Malik
@MathematicsCoding
Mar 24 2017 01:35
Finally got it. Thank you @sjames1958gm & @revisualize @MathematicsCoding
:star2: 6400 | @MathematicsCoding |]
CamperBot
@camperbot
Mar 24 2017 01:35
mathematicscoding sends brownie points to @sjames1958gm and @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3580 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 6317 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Saboor Malik
@MathematicsCoding
Mar 24 2017 01:35
Yeah
Moustapha
@moustaflo
Mar 24 2017 01:38
i'm not sure how to go about this case. The letters are in the search but not the word as a whole.
function mutation(arr) {
  var test = [];
  var firstArr = [];
  var secArr = "";
 var spliced = arr.splice(1, 1);
 firstArr.push(arr[0].toLowerCase());
 secArr = spliced[0].toLowerCase();
   return firstArr[0].indexOf(secArr, 0) > -1;
}
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);
Conor Murphy
@cmurphy580
Mar 24 2017 01:45
@Donnie-D should the first if statement be "fold"?
Donnie
@Donnie-D
Mar 24 2017 01:47
@cmurphy580 i dont know what "fold" is?
Saboor Malik
@MathematicsCoding
Mar 24 2017 01:48
Hey I have a question...
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  var asd = arr.shift();
  return asd;
}
Does it return item, item?
Conor Murphy
@cmurphy580
Mar 24 2017 01:49
@Donnie-D as in "fold" your hand
Saboor Malik
@MathematicsCoding
Mar 24 2017 01:49
@Donnie-D Maybe you should learn how to play poker
Donnie
@Donnie-D
Mar 24 2017 01:49
i wanted to know why when above code is executed, it displays result from else if part. @MathematicsCoding
Conor Murphy
@cmurphy580
Mar 24 2017 01:50
@Donnie-D you have "if" statement and "else if" statement output the same text
Donnie
@Donnie-D
Mar 24 2017 01:50
@cmurphy580 i wanted to know why when above code is executed, it displays result from else if part
Adrian Borcea
@bacpiano
Mar 24 2017 01:50
hi
i have a question
how do i solve 241?
reverse a string
Conor Murphy
@cmurphy580
Mar 24 2017 01:50
@Donnie-D change the first if statement to
  if(count+0) {return count + " Fold";}
Adrian Borcea
@bacpiano
Mar 24 2017 01:51
hello everybody

function reverseString(str) {
var array = str.split("");
var reverseArray = array.reverse();
reverseArray = reverseArray.join("");
return reverseArray;
}

reverseString("hello");

thats what i have - not working yet
Conor Murphy
@cmurphy580
Mar 24 2017 01:51
@bacpiano var string = "241";
string.split("").reverse().join("");
JamieDawson
@JamieDawson
Mar 24 2017 01:51
on the question "Make Unique Objects by Passing Parameters to our Constructor", can someone please explain why the answer had to be var myCar = new Car(3,2,2); ? I had to look up the answer because I don't know why the numbers had to be 3, 2, and 2.
Donnie
@Donnie-D
Mar 24 2017 01:51
@cmurphy580 done. the answer is still "0 bet"
Adrian Borcea
@bacpiano
Mar 24 2017 01:52
no i mean the exercise number is 241
Donnie
@Donnie-D
Mar 24 2017 01:52
thats else if being executed
@cmurphy580
Saboor Malik
@MathematicsCoding
Mar 24 2017 01:54
@bacpiano That is not exercise number
Its cookies you get one cookie when you complete a lesson or get a thank from another person each
Conor Murphy
@cmurphy580
Mar 24 2017 01:56
@Donnie-D you need to change the if else statements around. Your counting cards. So the first cases are going to add 1 to your count variable, second set nothing, and the third set will subtract one. So your if else statements should include the count variable as a part of your conditional. Something like this,
if (count > 0) {
  return (count + " Bet");
} else {
  return (count + " Hold");
}
@bacpiano
return str.split("").reverse().join("");
Edward John
@eddmecha
Mar 24 2017 02:00
@sjames1958gm i have no idea lol
Donnie
@Donnie-D
Mar 24 2017 02:02
@cmurphy580 if(count+0) means if(count+0==true)
am i right? and if i am then it should run the first if, not the else if
Roxroy
@roxroy
Mar 24 2017 02:04
@JamieDawson , you are creating a car and the car needs the features that you are going to pass to it
var Car = function(wheels, steats, engines) that is why you are sending 3, 2, 2 it corresponds to
2 wheels, 2 seats and 2 stroke-engines
Feelthewind
@Feelthewind
Mar 24 2017 02:06

function destroyer(arr) {

return arr.filter(function(value) {
return value !== arguments[1] && value !== arguments[2];
});
}

destroyer(["tree", "hamburger", 53], "tree", 53);

I want t remove "tree" and 53 in the array, but it doesn't work.

isaac820
@isaac820
Mar 24 2017 02:07

error->The variable myData should equal the first value of myArray->CODE->var ourArray = [1,2,3];

var ourData = ourArray[0]; // equals 1

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

Conor Murphy
@cmurphy580
Mar 24 2017 02:08

@Donnie-D your first if statement should be set up as a "greater than" or "less than" conditional. To something like this,

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

In your switch statement above, you are adding one or subtracting one to the variable count, which is equal to the number 0. After adding or subtracting to 0, your count variable will change. The conditionals will then executed of the new value of count.

Stephen James
@sjames1958gm
Mar 24 2017 02:10
@isaac820 Case sensitive myData not mydata - also you are overwriting the variable
Conor Murphy
@cmurphy580
Mar 24 2017 02:10
I need to pass the parameter "t", the third parameter in the main function to my third, and last, helper function. I don't use the second parameter and what I have going is not working. Any ideas? Here's what I have going ...
function chooseBestSum(t, k, ls) {
    //ls = array of dist
    //t = 174 mi
    //k = distance to each location 

    if (ls.length < k){
      return null; 
    } else {
      return findBestOption(reduceArray(createCombinations(ls, k, t))); 
    }
} 

//Creates all possible combinations of arrays -- 
function createCombinations (array, n) { /////////////////
    var i,
    subI,
    output = [],
    sub,
    next;
    for(i = 0; i < array.length; i++){
        if(n === 1){ //
            output.push( [ array[i] ] );
        }else{
            sub = createCombinations(array.slice(i+1, array.length), n-1); //
            for(subI = 0; subI < sub.length; subI++ ){
                next = sub[subI];
                next.unshift(array[i]);
                output.push(next);
            }
        }
    }
    return output;
}

//totals the subarrays from the above function's output --
function reduceArray(array) {
  var sum = [];  
  for (var j = 0; j < array.length; j++) {
    sum.push(array[j].reduce(function(a,b) {
       return a+b; 
     }));  
  }
  return sum;  
}

//finds best option -- 
function findBestOption(array, n, p) {
   for (var l = 0; l < array.length; l++) {
     var best = -Infinity;
     if (array[l] > best && array[l] <= p) {
        best = array[l]; 
     }
  } 
  return best; 
}
David Amanze
@GodKingShogun
Mar 24 2017 02:16
hello everyone :smile:
ManBearPigg
@ManBearPigg
Mar 24 2017 02:16
I am dynamically deleting html elements. Then when user navigates to new page, then hits back button to come back to original page, the html elements that had been dynamically deleted are rendered from cache. This is bad for me! Those elements are links that now link to nonexistent content and cause my app to crash. What do I do?
David Amanze
@GodKingShogun
Mar 24 2017 02:17
@ManBearPigg sounds complicated lol
ManBearPigg
@ManBearPigg
Mar 24 2017 02:18
its not really i dont think
I just need to prevent the cache from rendering and force a get request instead
there has to be a way to force a get request when u click back button
Ahmed Osman
@Noby707
Mar 24 2017 02:18
Hello, everyone
David Amanze
@GodKingShogun
Mar 24 2017 02:19
@Noby707 :wave:
Seth
@sethdcd
Mar 24 2017 02:19
how can i target 'a','b', or 'c' in this array?
var buz = [{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }];
if i try using the keys method i get 0, 1, 2
Ahmed Osman
@Noby707
Mar 24 2017 02:20
Need help in Understanding String Immutability assignment, or what it wants me to do please. Thank you.
David Amanze
@GodKingShogun
Mar 24 2017 02:21
@sethdcd try buz[][a]
Stephen James
@sjames1958gm
Mar 24 2017 02:21
@sethdcd You can only target the objects, then within those you can target the properties
@Noby707 You are supposed to replace the whole string with the correct value because changing a character is not allowed
Seth
@sethdcd
Mar 24 2017 02:21
@GodKingShogun hi god, yes that does work, but if i'm trying to test across multiple values this isn't very dynamic
ManBearPigg
@ManBearPigg
Mar 24 2017 02:22
@sjames1958gm will try and report back thanks
CamperBot
@camperbot
Mar 24 2017 02:22
manbearpigg sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6318 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Seth
@sethdcd
Mar 24 2017 02:22
@sjames1958gm how would i target said properties once i target the object?
Stephen James
@sjames1958gm
Mar 24 2017 02:22
@sethdcd With for .. in or Object.keys
Are you doing wherefore art thou?
ManBearPigg
@ManBearPigg
Mar 24 2017 02:22
onload="document.refresh();" in the body didn't work, I'll try yours now
Seth
@sethdcd
Mar 24 2017 02:23
@sjames1958gm ha yes :D
Stephen James
@sjames1958gm
Mar 24 2017 02:23
@sethdcd You probably want to target the keys in the source object rather.
Seth
@sethdcd
Mar 24 2017 02:24
@sjames1958gm do i want to grab the values from source and test them against collection or the other way around? i was thinking of getting the values from collection and testing each one in the array against the source
ManBearPigg
@ManBearPigg
Mar 24 2017 02:24
@sjames1958gm didn't work mate it still renders the page as it was before dynamic removals. I'll keep looking around. This has been a tough one.
Ahmed Osman
@Noby707
Mar 24 2017 02:24
Thank you @sjames1958gm
CamperBot
@camperbot
Mar 24 2017 02:24
noby707 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6319 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Seth
@sethdcd
Mar 24 2017 02:25
@sjames1958gm i got the first two tests to work in this challenge, but i fell short when there are multiple values in the source parameter
Stephen James
@sjames1958gm
Mar 24 2017 02:27
@sethdcd You'll need to loop over the keys in source, then only push if all the keys validate
Ray Martinez
@rayjrm
Mar 24 2017 02:27
I need help understanding how this defines a min a max:
  return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
David Amanze
@GodKingShogun
Mar 24 2017 02:28
@rayjrm do you know what math.floor and math.random do
Ray Martinez
@rayjrm
Mar 24 2017 02:28
yes, but i dont understand how the eliminates numbers below min
Seth
@sethdcd
Mar 24 2017 02:28
@sjames1958gm ok that sounds good, but that brings me back to how to target the keys in collection :) since i seem to just get 0, 1, 2
David Amanze
@GodKingShogun
Mar 24 2017 02:29
@rayjrm try using 5 as the max and 1 as the min
Ray Martinez
@rayjrm
Mar 24 2017 02:30
it results in 2,3, or 4
bitcoinabdi
@bitcoinabdi
Mar 24 2017 02:31
Good evening guyz
Tiffany
@tiffanymakes
Mar 24 2017 02:31
@rayjrm adding ourMin afterwards ensures the minimum number will always be greater than the min.
bitcoinabdi
@bitcoinabdi
Mar 24 2017 02:31
how you all doing
David Amanze
@GodKingShogun
Mar 24 2017 02:31
@bitcoinabdi hello
bitcoinabdi
@bitcoinabdi
Mar 24 2017 02:32

i need help with the algorithim ''' var str = "hello";
var res = str.split("");
res.reverse();

function reverseString(str) {
return str;

}

reverseString("hello");'''

CamperBot
@camperbot
Mar 24 2017 02:32
:bulb: to format code use backticks! ``` more info
David Amanze
@GodKingShogun
Mar 24 2017 02:33
@bitcoinabdi post your code in between``` for easy readablity
Ray Martinez
@rayjrm
Mar 24 2017 02:33
so its solving for 0 through ourMax before adding ourMin?
bitcoinabdi
@bitcoinabdi
Mar 24 2017 02:33
'''
CamperBot
@camperbot
Mar 24 2017 02:33
:bulb: to format code use backticks! ``` more info
Ray Martinez
@rayjrm
Mar 24 2017 02:33
okay that makes sense
JamieDawson
@JamieDawson
Mar 24 2017 02:35
@roxroy , Thank you for explaining that. It makes more sense now!
CamperBot
@camperbot
Mar 24 2017 02:35
jamiedawson sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 448 | @roxroy |http://www.freecodecamp.com/roxroy
Conor Murphy
@cmurphy580
Mar 24 2017 02:36
@sjames1958gm didn't know if you could help me here. I have three parameters in my main function and I'm trying to pass one, "t", i haven't used yet to my second helper function. Do you know how I can do that, because the way i have it set up doesn't work. Here's what I'm working on.

function chooseBestSum(t, k, ls) {
    //ls = array of dist
    //t = 174 mi
    //k = distance to each location 

    if (ls.length < k){
      return null; 
    } else {
      return findBestOption(reduceArray(createCombinations(ls, k, t))); 
    }
} 

//Creates all possible combinations of arrays -- 
function createCombinations (array, n) { /////////////////
    var i,
    subI,
    output = [],
    sub,
    next;
    for(i = 0; i < array.length; i++){
        if(n === 1){ //
            output.push( [ array[i] ] );
        }else{
            sub = createCombinations(array.slice(i+1, array.length), n-1); //
            for(subI = 0; subI < sub.length; subI++ ){
                next = sub[subI];
                next.unshift(array[i]);
                output.push(next);
            }
        }
    }
    return output;
}

//totals the subarrays from the above function's output --
function reduceArray(array, n, p) {
  var sum = [];  
  for (var j = 0; j < array.length; j++) {
    sum.push(array[j].reduce(function(a,b) {
       return a+b; 
     }));  
  }
  return sum; 
}

//finds best option -- 
function findBestOption(array) {  
  for (var l = 0; l < array.length; l++) {
    var best = 0;
    if (array[l] > best){
       best = array[l]; 
     }
   }
  return best; 
}
Tiffany
@tiffanymakes
Mar 24 2017 02:38
@bitcoinabdi your res is still an array. you need to use join() to turn it back into a string.
And I don't think you need that extra function.
Andrew Shieh
@andrewlikes
Mar 24 2017 02:39
  else if (engine === "on" && gear < 1 || gear > 5) {
    return "Please select a gear";
  }
Hey if I wanted my code to say "if gear does not equal 1 through 5", what would be the best way?
Manish Giri
@Manish-Giri
Mar 24 2017 02:42
@andrewlikes
function testStuff() {
  var numbers = [1,2,3,4,5];
  var gear = 6;
  return numbers.every((number)=>{return number !== gear;});
}
console.log(testStuff()); //true
ManBearPigg
@ManBearPigg
Mar 24 2017 02:44

@sjames1958gm I found a solution to my problem of dynamically deleted html elements being loaded from cache when i navigate away from page and return by hitting back button. I just added this line to my get route for the page.

      res.set('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');

if you were curious. Thanks for the advice!

CamperBot
@camperbot
Mar 24 2017 02:44
manbearpigg sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: manbearpigg already gave sjames1958gm points
juni
@junipberry
Mar 24 2017 02:44
Im in the switch section, am I writing this wrong? function caseInSwitch(val) {
var answer = "";
// Only change code below this line
case (1):
"alpha";
break;
Andrew Shieh
@andrewlikes
Mar 24 2017 02:44
ah the every() method
thx @Manish-Giri
CamperBot
@camperbot
Mar 24 2017 02:44
andrewlikes sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4886 | @manish-giri |http://www.freecodecamp.com/manish-giri
juni
@junipberry
Mar 24 2017 02:44
or is it supposed to be : caseInSwitch (2):
"beta";
break;
Manish Giri
@Manish-Giri
Mar 24 2017 02:44
@junipberry you need to assign the right string to answer in each case
like answer = "alpha";
and so on..
juni
@junipberry
Mar 24 2017 02:45
hmm its still not working @Manish-Giri
am I doing the case line correct though?
Manish Giri
@Manish-Giri
Mar 24 2017 02:46
@junipberry show complete code..
pcfly
@fl6821494
Mar 24 2017 02:46
anyone please help,why the code can't get passed in freeCodeCamp
```
Manish Giri
@Manish-Giri
Mar 24 2017 02:46
well you don't need the ( ) around 1 but looks okay
@junipberry
pcfly
@fl6821494
Mar 24 2017 02:46
var result=[];
function steamroller(arr) {
  // I'm a steamroller, baby
  for(var i=0;i<arr.length;i++){
    if(Array.isArray(arr[i])){
      steamroller(arr[i]);
    }else{
      result.push(arr[i]);
    }
  }
  return result;
}

steamroller([1, [], [3, [[4]]]]);
anyone please help,why the code can't get passed in freeCodeCamp
Manish Giri
@Manish-Giri
Mar 24 2017 02:47
@fl6821494 make result a local variable.
pcfly
@fl6821494
Mar 24 2017 02:47
but the function only has one arg
Jaime Ruelas
@sdjjr3296
Mar 24 2017 02:47
can someone tell me is coding is useful in the jobs market today? because im losing interest in this and i hope im not wasting my time :worried:
juni
@junipberry
Mar 24 2017 02:47

function caseInSwitch(val) {
var answer = "";
// Only change code below this line

case (1):
answer= "alpha";
break;

case (2):
answer= "beta";
break;

case (3):
answer= "gamma";
break;

case (4):
answer="delta";
break;
@Manish-Giri

Manish Giri
@Manish-Giri
Mar 24 2017 02:48
@junipberry and the return?
Ahmed Osman
@Noby707
Mar 24 2017 02:48
Jamie do not give up
Take a break if you want, but coding will soon be a job requirment
or so I heard ^_^
juni
@junipberry
Mar 24 2017 02:49

function caseInSwitch(val) {
var answer = "";
// Only change code below this line

case (1):
answer= "alpha";
break;

case (2):
answer= "beta";
break;

case (3):
answer= "gamma";
break;

case (4):
answer="delta";
break;

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

Manish Giri
@Manish-Giri
Mar 24 2017 02:50
@junipberry where is the switch(val) statement?
pcfly
@fl6821494
Mar 24 2017 02:50
@Manish-Giri the function only has one argument,what should i do
Manish Giri
@Manish-Giri
Mar 24 2017 02:51
@fl6821494 var result=[]; - I meant put this inside your function
Jaime Ruelas
@sdjjr3296
Mar 24 2017 02:52
@Noby707 ik i just feel that we do all this hard work learning all kinds of programming languages and we barely get an average salary when we apply to a job as a web develpoer
juni
@junipberry
Mar 24 2017 02:52
ohh
pcfly
@fl6821494
Mar 24 2017 02:52
@Manish-Giri but during each recursive,the result will be refresh
Jaime Ruelas
@sdjjr3296
Mar 24 2017 02:52
*developer
Ahmed Osman
@Noby707
Mar 24 2017 02:52
That is why I am going full Developer Millionaire style.
Pursue your passion, and you will succede
juni
@junipberry
Mar 24 2017 02:53
right, I just realised I need that again in the beginning. @Manish-Giri I just thought that was redundant w the function statement ..so excluded it
my bad
Ahmed Osman
@Noby707
Mar 24 2017 02:54
I want to build a top education facility , full equipment, free tools to learn through out "undeveloped countries" with the UN.
Jyue0812
@Jyue0812
Mar 24 2017 02:54
var myStr = "<a href='http://www.example.com' target="_blank">Link</a>";
is there anything wrong with my code? I was asked to remove all "\"
Ahmed Osman
@Noby707
Mar 24 2017 02:54
If anyone wants to help ;)
juni
@junipberry
Mar 24 2017 02:55
ty for your help @Manish-Giri
CamperBot
@camperbot
Mar 24 2017 02:55
junipberry sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4887 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Mar 24 2017 02:55
@junipberry welcome
Jaime Ruelas
@sdjjr3296
Mar 24 2017 02:56
@Noby707 sounds good ! i wish i was postive like you with your plans for the future lol
jaime
@jsaucedo1984
Mar 24 2017 02:57
IM stuck converting celsius to fahrenheit

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = celsius;
celsius *= (9/5) += 32;

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

// Change the inputs below to test your code
convertToF(0);

Ahmed Osman
@Noby707
Mar 24 2017 02:59
Jaime R how about you think of a way that uses your current skill level in coding to make a couple of $$$.
Manish Giri
@Manish-Giri
Mar 24 2017 02:59
@jsaucedo1984 celsius is the value you want to convert to fahreneheit
Usman Akram
@usmanakram1996
Mar 24 2017 02:59
what do in this
any hint plz
Ahmed Osman
@Noby707
Mar 24 2017 03:00
That will motivate you for sure.
Andrew Shieh
@andrewlikes
Mar 24 2017 03:00
this repository thing is confusing
Usman Akram
@usmanakram1996
Mar 24 2017 03:00
have done first two but last two are confusing
Andrew Shieh
@andrewlikes
Mar 24 2017 03:00
im just trying to store code into github :(
Usman Akram
@usmanakram1996
Mar 24 2017 03:00

function fearNotLetter(str) {
str =str.toLowerCase();
var alphabets = ['a','b','c','d','e','f','g','h','i','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];

var chars= str.split("");

for(i=0;i<alphabets.length;i++)
{
if((chars.indexOf(alphabets[i]))==-1)
{
return (alphabets[i]);
}
}
}

fearNotLetter("bcd");

KiingRex
@KiingRex
Mar 24 2017 03:00
hello everybody i'm on the golf code challenge, can somebody explain to me how to input the code for par and strokes?
Daniel
@DanJP2016
Mar 24 2017 03:01
is it possible to store an array of objects using localstorage without adding each element individually?
Jaime Ruelas
@sdjjr3296
Mar 24 2017 03:01
@Noby707 that sounds good but im not sure i have any idea how to do that?
Manish Giri
@Manish-Giri
Mar 24 2017 03:01
@KiingRex the value in the left is what strokes should be compared to, in each if/else
like if(strokes === 1)
@DanJP2016 I think yes, you would need to stringify the array.
Conor Murphy
@cmurphy580
Mar 24 2017 03:02

IF I HAVE AN ARRAY LIKE THIS

[161, 162, 163, 163, , , , , , ]

HOW DO I DELETE THE COMMAS AND EMPTY SPACE SO ITS JUST AN ARRAY OF NUMBERS?

Daniel
@DanJP2016
Mar 24 2017 03:02
@Manish-Giri thank you
CamperBot
@camperbot
Mar 24 2017 03:02
danjp2016 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4888 | @manish-giri |http://www.freecodecamp.com/manish-giri
Usman Akram
@usmanakram1996
Mar 24 2017 03:03
@cmurphy580 arrayname.join("") will give you 161162163.....
Conor Murphy
@cmurphy580
Mar 24 2017 03:04
I want to keep the numbers like they are but get rid of the extra commas @usmanakram1996 thanks fro the help though
CamperBot
@camperbot
Mar 24 2017 03:04
cmurphy580 sends brownie points to @usmanakram1996 :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @usmanakram1996 |http://www.freecodecamp.com/usmanakram1996
Ahmed Osman
@Noby707
Mar 24 2017 03:05
Or go to a Hackathon that gets you 3000$ for first place.
Usman Akram
@usmanakram1996
Mar 24 2017 03:07
@cmurphy580 arrayname.join(",") // pass the "," in quotes in arguement u will get the required output
Jaime Ruelas
@sdjjr3296
Mar 24 2017 03:08
whats hackathon exactly? ive heard of it once lol
Vamp
@the-vampiire
Mar 24 2017 03:08
@joker314 just read through your tutorial bro. awesome work really appreciated. you sure know a lot for a 13 year old! you’re going to be a beast of aprogrammer by the time you get my age
Usman Akram
@usmanakram1996
Mar 24 2017 03:08
  • argument
Caijialinxx
@Caijialinxx
Mar 24 2017 03:08
Hello everybody~ I wanna ask for help: i was trying to sign up CodePen and ready to cheak my email, when i click to sign up for CodePen in email, it turned out 404 error and I've tried many times and still the same problem.. Is there anyone willing to help me ?
Usman Akram
@usmanakram1996
Mar 24 2017 03:09
@Caijialinxx welcome can u share the screenshot
Conor Murphy
@cmurphy580
Mar 24 2017 03:09
@usmanakram1996 sweet thanks
CamperBot
@camperbot
Mar 24 2017 03:09
cmurphy580 sends brownie points to @usmanakram1996 :sparkles: :thumbsup: :sparkles:
:warning: cmurphy580 already gave usmanakram1996 points
Caijialinxx
@Caijialinxx
Mar 24 2017 03:10
@usmanakram1996 how to do this?
Usman Akram
@usmanakram1996
Mar 24 2017 03:10
@cmurphy580 np :)
Vamp
@the-vampiire
Mar 24 2017 03:11
@joker314 can you tell me why when I fork and star your tutorial it doesnt show up in my GitHub under forks / stars? I dont really know how github works I just made one for FCC
I want to be able to save it to look at later
Usman Akram
@usmanakram1996
Mar 24 2017 03:11
Press Alt+PrtScr and then paste it in the chat here Ctrl+V
Matthew
@IMDBLM
Mar 24 2017 03:11
Hey everyone, I'm hung up on make object properties private. I'm hung up in the middle of the this.setGear portion.

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

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

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

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

var Bike = function() {

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

  this.setGear = function(){
    gear = myBike();
  };

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

var myCar = new Car();

var myBike = new Bike();
Usman Akram
@usmanakram1996
Mar 24 2017 03:12
Or you may use snipping tool if using windows OS
Jayna B.
@JBrisker
Mar 24 2017 03:12
Hello I am stuck on switch statements. I can only get case 4 to print?
Usman Akram
@usmanakram1996
Mar 24 2017 03:12
and then Ctrl+V @Caijialinxx
Manish Giri
@Manish-Giri
Mar 24 2017 03:12
this bit is wrong
  this.setGear = function(){
    gear = myBike();
  };
@IMDBLM
Ahmed Osman
@Noby707
Mar 24 2017 03:12
@sdjjr3296 It is basically an event in which you or a maximum team of 4 solve a problem related to a topic.
Caijialinxx
@Caijialinxx
Mar 24 2017 03:12
blob
Jayna B.
@JBrisker
Mar 24 2017 03:13

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch(val){

case (1):
answer="alpha";
break;

case (2):
answer="beta";
break;

case (3):
answer="gamma";
break;

case (4):

answer="delta";

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

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

Manish Giri
@Manish-Giri
Mar 24 2017 03:13

@IMDBLM as an example -

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

this is like a setter method, it takes in a value called change and increments the value of speed by that change.

KiingRex
@KiingRex
Mar 24 2017 03:13
@Manish-Giri thank you
CamperBot
@camperbot
Mar 24 2017 03:13
kiingrex sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4889 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Mar 24 2017 03:13
your setGear should be similar..
Caijialinxx
@Caijialinxx
Mar 24 2017 03:13
@usmanakram1996 can u see that pic?
Usman Akram
@usmanakram1996
Mar 24 2017 03:13
@Caijialinxx yeah
Jaime Ruelas
@sdjjr3296
Mar 24 2017 03:14
@Noby707 how do you sign up?
Vamp
@the-vampiire
Mar 24 2017 03:14
@IMDBLM
this.setGear = function(val){
gear = val;
};
Usman Akram
@usmanakram1996
Mar 24 2017 03:14
have you clicked on sign up on top right
?
@Caijialinxx
Caijialinxx
@Caijialinxx
Mar 24 2017 03:15
@usmanakram1996 yeah, I've input my info and clicked "send verification email"
Matthew
@IMDBLM
Mar 24 2017 03:15
@the-vampiire This seems like it's really simple and I don't know why I didn't understand that.
Usman Akram
@usmanakram1996
Mar 24 2017 03:15
@Caijialinxx let me search
Vamp
@the-vampiire
Mar 24 2017 03:16
@IMDBLM where ‘val’ can be any parameter name you want. it is just what you will pass as a value to gear. so if you want gear to be 5 you would be setting val to 5 like this
myBike.setGear(5); 
myBike.getGear(); // will return the value 5
juni
@junipberry
Mar 24 2017 03:16
I have a general question about switches and if/else statements. Are switches easier when you have a lot of variables in separate categories, with several cases within a category?
Caijialinxx
@Caijialinxx
Mar 24 2017 03:16
blob
Matthew
@IMDBLM
Mar 24 2017 03:16
@the-vampiire And because setGear is a method. Right. I understand better. Thanks.
CamperBot
@camperbot
Mar 24 2017 03:16
imdblm sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 244 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
juni
@junipberry
Mar 24 2017 03:17
Trying to understand the diff uses of when to use if/else and switches
Matthew
@IMDBLM
Mar 24 2017 03:17
What tripped me up was the example change
Usman Akram
@usmanakram1996
Mar 24 2017 03:17
@Caijialinxx seems you msut update your Chrome
Vamp
@the-vampiire
Mar 24 2017 03:17
@IMDBLM both are methods. but one is a SETTER method so to set something you have to PASS a parameter into the function. the parameter I used in my example to pass is ‘val’
Usman Akram
@usmanakram1996
Mar 24 2017 03:17
it will resolve the issue
Vamp
@the-vampiire
Mar 24 2017 03:18
@IMDBLM and the other is a GETTER method but of course it won’t have a parameter to be passed because it is simply returning a value to you
Usman Akram
@usmanakram1996
Mar 24 2017 03:18
@Caijialinxx try updating google chrome
Caijialinxx
@Caijialinxx
Mar 24 2017 03:19
blob
Usman Akram
@usmanakram1996
Mar 24 2017 03:19
@Caijialinxx let me know which version of Google Chrome u are using
Caijialinxx
@Caijialinxx
Mar 24 2017 03:19
blob
Vamp
@the-vampiire
Mar 24 2017 03:20
@IMDBLM yes it might be confusing because in their example they were passing ‘change’ but instead of simply setting the speed to that value they were updating the value of speed with ‘+=‘ meaning take whatever speed is currently at and ADD ‘change’ value to it. remember ‘+=‘ is same as speed = speed + change just shorthand. in your case you want to purely set the gear variable to a new value that you pass into it through the function so you say gear = val
Caijialinxx
@Caijialinxx
Mar 24 2017 03:20
@usmanakram1996
Vamp
@the-vampiire
Mar 24 2017 03:21
@IMDBLM any other confusion you want to clear up for this problem or does that suffice as explanation?
Usman Akram
@usmanakram1996
Mar 24 2017 03:21
@Caijialinxx look
blob
Julian Hierro
@julianhierro
Mar 24 2017 03:22
Hello
I'm stuck at the seek and destroy problem
Usman Akram
@usmanakram1996
Mar 24 2017 03:22
mine is this :D @Caijialinxx
download from here
Matthew
@IMDBLM
Mar 24 2017 03:22
@the-vampiire No this is good, thanks. I believe I understand it, but I just want to re-read the notes, etc.
CamperBot
@camperbot
Mar 24 2017 03:22
imdblm sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:warning: imdblm already gave the-vampiire points
Vamp
@the-vampiire
Mar 24 2017 03:23
@julianhierro you can add your code to get help by pasting your code between characters ( before and after your code)
like this
sorry passing between ``` without the backslash
this is the character just below your escape key
@IMDBLM cool man
Julian Hierro
@julianhierro
Mar 24 2017 03:24
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Caijialinxx
@Caijialinxx
Mar 24 2017 03:24
blob
Julian Hierro
@julianhierro
Mar 24 2017 03:24
function destroyer(arr) {
  var args = Array.prototype.slice.call(arguments);
  var args = [].slice.call(arguments);

  for (var i = 1; i < arguments.length; i++) {
    args = args[0].filter(args[i]);
  }
  return args;
}
Caijialinxx
@Caijialinxx
Mar 24 2017 03:24
@usmanakram1996 I can't open the link
Julian Hierro
@julianhierro
Mar 24 2017 03:24
@the-vampiire that's cool thanks
CamperBot
@camperbot
Mar 24 2017 03:24
julianhierro sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 245 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Matthew
@IMDBLM
Mar 24 2017 03:25
@the-vampiire Actually, I do have one more question, and maybe it's irrelevant presently. What's the point of this particular challenge? I'm setting a gear to my own specifications and then having it return to me, the gear I just specified. I can PM you if this is better.
Vamp
@the-vampiire
Mar 24 2017 03:25
@julianhierro no problem. so you just write your question and then paste the relevent part of your code then people can help sort you out
Usman Akram
@usmanakram1996
Mar 24 2017 03:25
@Caijialinxx u having internet issue?
Vamp
@the-vampiire
Mar 24 2017 03:26
@IMDBLM so for this particular example it seems silly. but let’s say you have another function that is going to do something based on whatever gear is set to. well in you could start by setting the gear to a value and then in that other separate function it can use the GETTER function to automatically determine what gear is at and perform an action based on the result
Caijialinxx
@Caijialinxx
Mar 24 2017 03:27
I think maybe china can't download the new version now? @usmanakram1996
Conrad
@conradOU
Mar 24 2017 03:27
function User(){
    var username, password;

    function doLogin(user,pw) {
        username = user;
        password = pw;

        // do the rest of the login work
    }

    var publicAPI = {
        login: doLogin
    };

    return publicAPI;
}

// create a `User` module instance
var fred = User();

fred.login( "fred", "12Battery34!" );
I executed this code and it works.
why doLogin() is equal to login() ? Where can I read more about that? Thanks.
Julian Hierro
@julianhierro
Mar 24 2017 03:27

Ok, I'm supposed to remove all elements from the initial array that are of the same value as the arguments following that array.

Here's my code:
```


function destroyer(arr) {
  var args = Array.prototype.slice.call(arguments);
  var args = [].slice.call(arguments);

  for (var i = 1; i < arguments.length; i++) {
    args = args[0].filter(args[i]);
  }
  return args;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Usman Akram
@usmanakram1996
Mar 24 2017 03:28
right but i thnk u can do it using A VPN @Caijialinxx
Caijialinxx
@Caijialinxx
Mar 24 2017 03:28
blob
Vamp
@the-vampiire
Mar 24 2017 03:28
@IMDBLM you can PM me if you want I can try to write up a sample code to show what I mean if waht I said didn’t make sense
Tiffany
@tiffanymakes
Mar 24 2017 03:28
@julianhierro you accidentally defined args twice. And your filter() method needs a callback function.
Also, you don't need a for loop as filter() loops through an array under the hood.
Conrad
@conradOU
Mar 24 2017 03:29
is it because of publicAPI, which has weird structure btw? I only have some experience with Java and python from uni, so I'm struggling to understand this
Caijialinxx
@Caijialinxx
Mar 24 2017 03:30
@usmanakram1996 without signing up CodePen can I still finish the task http://www.freecodecamp.cn/challenges/build-a-tribute-page ?
Usman Akram
@usmanakram1996
Mar 24 2017 03:30
no i don't think it would be possible @Caijialinxx
@Caijialinxx FreeCodeCamp/FreeCodeCamp#11856
this might help u search here
Julian Hierro
@julianhierro
Mar 24 2017 03:31
Thanks @tiffanymakes so should I just convert the arguments to an array, and then use filter?
CamperBot
@camperbot
Mar 24 2017 03:31
julianhierro sends brownie points to @tiffanymakes :sparkles: :thumbsup: :sparkles:
:cookie: 322 | @tiffanymakes |http://www.freecodecamp.com/tiffanymakes
Usman Akram
@usmanakram1996
Mar 24 2017 03:31
i gotta go :) hope you will resolve it soon :)
Tiffany
@tiffanymakes
Mar 24 2017 03:31
@julianhierro yep!
Julian Hierro
@julianhierro
Mar 24 2017 03:32
@tiffanymakes I'll give that a try! Thanks a bunch!
CamperBot
@camperbot
Mar 24 2017 03:32
julianhierro sends brownie points to @tiffanymakes :sparkles: :thumbsup: :sparkles:
:warning: julianhierro already gave tiffanymakes points
Matthew
@IMDBLM
Mar 24 2017 03:32
@the-vampiire was afk but I'll read and come back if it's unclear. Thanks again :+1:
CamperBot
@camperbot
Mar 24 2017 03:32
imdblm sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:warning: imdblm already gave the-vampiire points
Caijialinxx
@Caijialinxx
Mar 24 2017 03:32
@usmanakram1996 Okay! Thx a lot!
CamperBot
@camperbot
Mar 24 2017 03:32
caijialinxx sends brownie points to @usmanakram1996 :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @usmanakram1996 |http://www.freecodecamp.com/usmanakram1996
Vamp
@the-vampiire
Mar 24 2017 03:33
@IMDBLM no problem. feel free to PM me if you need to. I am working on algorithm problems but I can help when you need because I finished the section you are in already
Matthew
@IMDBLM
Mar 24 2017 03:34
@the-vampiire Your example makes sense. You're saying another function could say Do X if gear = X or whatever.
Vamp
@the-vampiire
Mar 24 2017 03:36
@IMDBLM exactly. getters and setters let you set things and check on them and you can use those object methods anywhere else they are needed. let’s say you have a function go_fast() and in that function you use the getter to find out what gear you are in. then using a conditional statement maybe the gear is too low so you can now use the setter method to change the gear to the appropriate gear needed to go fast
Julian Hierro
@julianhierro
Mar 24 2017 03:36
@tiffanymakes sorry I have one more question, if I'm not using a loop, how do I remove all the elements from the initial array that are equal to the arguments. Assuming there might be a lot of arguments
bitcoinabdi
@bitcoinabdi
Mar 24 2017 03:37
'''
CamperBot
@camperbot
Mar 24 2017 03:37
:bulb: to format code use backticks! ``` more info
bitcoinabdi
@bitcoinabdi
Mar 24 2017 03:38

'''
var str = "hello";
var res = str.split("");
res.reverse();

function reverseString(str) {
return str;

}

reverseString("hello");
'''

CamperBot
@camperbot
Mar 24 2017 03:38
:bulb: to format code use backticks! ``` more info
Tiffany
@tiffanymakes
Mar 24 2017 03:38
Is that what you're asking?
bitcoinabdi
@bitcoinabdi
Mar 24 2017 03:39
```

var str = "hello";
var res = str.split("");
res.reverse();

function reverseString(str) {
return str;

}

reverseString("hello");
```

Julian Hierro
@julianhierro
Mar 24 2017 03:40
so it would be a combination of filter and indexOf? Sorry to ask so many question, trying to learn :-) @tiffanymakes
bitcoinabdi
@bitcoinabdi
Mar 24 2017 03:40

``` var str = "hello";
var res = str.split("");
res.reverse();

function reverseString(str) {
return str;

}

reverseString("hello");
```

Tiffany
@tiffanymakes
Mar 24 2017 03:40
@julianhierro no worries, yes. Here's the documentation for filter(), which might be helpful: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
bitcoinabdi
@bitcoinabdi
Mar 24 2017 03:41
can someone please explain to me why my code is not correct

var str = "hello";
var res = str.split("");
res.reverse();

function reverseString(str) {
return str;

}

reverseString("hello");

Tiffany
@tiffanymakes
Mar 24 2017 03:41
@bitcoinabdi your res variable is still an array. you need to use join() to turn it back into a string. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join
Julian Hierro
@julianhierro
Mar 24 2017 03:41
@tiffanymakes Thanks!!
CamperBot
@camperbot
Mar 24 2017 03:41
julianhierro sends brownie points to @tiffanymakes :sparkles: :thumbsup: :sparkles:
:warning: julianhierro already gave tiffanymakes points
Tiffany
@tiffanymakes
Mar 24 2017 03:42
@julianhierro :thumbsup:
@bitcoinabdi And you shouldn't be returning str, which hasn't been altered in this case.
Vamp
@the-vampiire
Mar 24 2017 03:43
@bitcoinabdi the way is written all you are doing is passing ‘str’ into the function then returning it back
function reverseString(str){
    var res = str.split('');
    return res.reverse().join('');
}
bitcoinabdi
@bitcoinabdi
Mar 24 2017 03:47
@the-vampiire @tiffanymakes so it should look like so --> var res = str.join();
Vamp
@the-vampiire
Mar 24 2017 03:48
or to make it cleaner
function reverseString(str){
    return str.split('').reverse().join('');
}
bitcoinabdi
@bitcoinabdi
Mar 24 2017 03:48
@the-vampiire so all my changes goes inside the function..?
@the-vampiire ..wooow that makes lots of sense
@tiffanymakes @the-vampiire thank you very much guyz
CamperBot
@camperbot
Mar 24 2017 03:49
bitcoinabdi sends brownie points to @tiffanymakes and @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 323 | @tiffanymakes |http://www.freecodecamp.com/tiffanymakes
:cookie: 246 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Vamp
@the-vampiire
Mar 24 2017 03:49

because you do not need this res unless it is used for something else. you can chain the methods into one line. break down this return line I just sent you

take string (str) split it for each letter (split(‘’)) into an array now reverse elements in this array (reverse()) now join these reversed elements back into a string (join(‘’))

yes it must all be inside the function otherwise what is the function doing for you? any actions you want the function to perform must take place within the function brackets then any result you want to come out of the function must be placed in the return line
bitcoinabdi
@bitcoinabdi
Mar 24 2017 03:52
@the-vampiire ...OMG that makes soo much sense !
thank you very much @the-vampiire
CamperBot
@camperbot
Mar 24 2017 03:52
bitcoinabdi sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:warning: bitcoinabdi already gave the-vampiire points
keanusuasuasuasuasuas
@keanusuasuasuasuasuas
Mar 24 2017 03:53
var myList =
[[["Milk", 2],
["Skim", 1],
["Light", 1]],
[["Cereal", 4],
["Flakes", 2],
["Cheerios", 2]],
[["Juice", 2],
["Cherry", 1],
["Apple", 1]],
[["Vegetables", 4],
["Corn", 2],
["Beans", 2]],
[["Water", 10],
["Water", 10]]];
why is it not passing?
Vamp
@the-vampiire
Mar 24 2017 03:54

@bitcoinabdi no problem. so why do you return this result back? well maybe you want to use this function you made…in another function!

I wrote this for you now try it out

function reverseString(str){
    return str.split('').reverse().join('');
}

function is_Palindrome(str){
    if(str == reverseString(str)){
        return true
    }
    return false
}

but wait. why do we have this if statement? we are checking if a boolean is true or false…and returning true or false. can this be shortened?

function is_Palindrome(str){
    return str === reverseString(str);
}

now if it is true it will return true, if it is false it will return false!

so is_Palindrome is taking a str and then it is checking if that str is equal to the reverse of str by using the reverseString function you made before.
then telling you true if it is a palindrome (same forward and reverse) or false if it is not.
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:01
@the-vampiire thank you now i understand
CamperBot
@camperbot
Mar 24 2017 04:01
bitcoinabdi sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:warning: bitcoinabdi already gave the-vampiire points
Tiffany
@tiffanymakes
Mar 24 2017 04:01
@the-vampiire nice explanation. I like that you gave an example as well.
@keanusuasuasuasuasuas what are you trying to do?
juni
@junipberry
Mar 24 2017 04:03
In the “Return early pattern” lesson. What am I missing? function abTest(a, b) {
// Only change code below this line
if (a<0 || (b<0);
return undefined;
Duy Nguyen
@dtn9797
Mar 24 2017 04:03
can someone help me to explain why
var array = [2, 9, 9];
array.indexOf(2, -1); // return -1
link : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
Doni Yafi
@yafiwebdev
Mar 24 2017 04:03
guys, can someone help with the stand in line challenge ?
Manish Giri
@Manish-Giri
Mar 24 2017 04:05
@yafiwebdev what's the problem?
Doni Yafi
@yafiwebdev
Mar 24 2017 04:06
I can only solve half of it
the instructions are confusing
juni
@junipberry
Mar 24 2017 04:06
post your code @yafiwebdev
Doni Yafi
@yafiwebdev
Mar 24 2017 04:06
I cleared my code
I added this
testArr.push(item);
arr = testArr.shift();
inside the nextInLine function
S7eve
@S7eve
Mar 24 2017 04:07
<@s.link  beanclass=actionBean.class class="light-box-link waves-effect waves-light" event="ticketAndServiceLists">
                                    <@s.param name="serviceCategory" value="totalServices"  />
                                    <@s.param name="ticketCategory" value="I want to put javascript function here!"/>
Hello guys, does anyone know how to put javascript function to populate a value of "param"??
Doni Yafi
@yafiwebdev
Mar 24 2017 04:07
I probably replaced testArr with arr
Manish Giri
@Manish-Giri
Mar 24 2017 04:08
@yafiwebdev use the array passed in to your function.
Doni Yafi
@yafiwebdev
Mar 24 2017 04:08
yeah I did
Manish Giri
@Manish-Giri
Mar 24 2017 04:08
then show that code.
Doni Yafi
@yafiwebdev
Mar 24 2017 04:08
that's a code I copied earlier
arr.push(item);
arr = arr.shift();
juni
@junipberry
Mar 24 2017 04:08
isnt it .unshift?
Doni Yafi
@yafiwebdev
Mar 24 2017 04:09
also, I return arr
Manish Giri
@Manish-Giri
Mar 24 2017 04:09
can you show the complete code?
Doni Yafi
@yafiwebdev
Mar 24 2017 04:09
I solved it
LOL
dunno why it didn't work before
Vamp
@the-vampiire
Mar 24 2017 04:10
@tiffanymakes thank you I help with what I understand while I am stuck on these algorithm problems lol
CamperBot
@camperbot
Mar 24 2017 04:10
the-vampiire sends brownie points to @tiffanymakes :sparkles: :thumbsup: :sparkles:
:cookie: 324 | @tiffanymakes |http://www.freecodecamp.com/tiffanymakes
Doni Yafi
@yafiwebdev
Mar 24 2017 04:10
thanks though
Vamp
@the-vampiire
Mar 24 2017 04:11
how can I return just a part of a string or array element? in python I could say str[1:] and it would give me the string starting at the second character until the end. not working here in javascript
Joel
@MMK123
Mar 24 2017 04:11
var myList = ["apples", 5],["carrots", 3],["pears", 5],["snickers", 34],["peaches", 21];
i dont see anything wrong here
juni
@junipberry
Mar 24 2017 04:11
arr.push(item); return arr.shift(); @yafiwebdev
Joel
@MMK123
Mar 24 2017 04:11
can someone help?
Vamp
@the-vampiire
Mar 24 2017 04:11
@MMK123 what is the question asking
juni
@junipberry
Mar 24 2017 04:12
bc the previous function is in the latter
Joel
@MMK123
Mar 24 2017 04:12
@the-vampiire Create a shopping list in the variable myList. The list should be a multi-dimensional array containing several sub-arrays.
Vamp
@the-vampiire
Mar 24 2017 04:13
put extra [ ] around your list
var myList = [["apples", 5],["carrots", 3],["pears", 5],["snickers", 34],["peaches", 21]];
Joel
@MMK123
Mar 24 2017 04:14
@the-vampiire yep that was it
not sure i understand why i need it though...
Vamp
@the-vampiire
Mar 24 2017 04:14
now you have an array [] with several sub arrays [‘apples’, 5] inside
because this is what it asked for
Joel
@MMK123
Mar 24 2017 04:14
ok thanks
I guess i do see. one large array with several inside.
Osa
@AkhatorEnosa
Mar 24 2017 04:15

someone help me with Nesting Loop challenge

This below is my code

  for (i =0; i < arr[i].length; i++){
   for (j = 0; j < arr[j].length; j++){
     console.log(arr[i][j]);
   }
  }
Vamp
@the-vampiire
Mar 24 2017 04:15
the way ou had it written originally was just several arrays, it asked for a multi-dimensional array meaning array with several sub-arrays inside of it
Joel
@MMK123
Mar 24 2017 04:15
gotcha
Vamp
@the-vampiire
Mar 24 2017 04:16
@AkhatorEnosa use return not console log
Tiffany
@tiffanymakes
Mar 24 2017 04:17
@the-vampiire I know what you mean. I'm procrastinating on the projects haha. And thanks for the unintentional brownies!
CamperBot
@camperbot
Mar 24 2017 04:17
tiffanymakes sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 247 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Osa
@AkhatorEnosa
Mar 24 2017 04:21
@the-vampiire Not working either
Vamp
@the-vampiire
Mar 24 2017 04:22
@AkhatorEnosa please cop paste what the question is asking so I can help
@AkhatorEnosa or tell me the section and title of lesson and I will find it in my map
S7eve
@S7eve
Mar 24 2017 04:23
<@s.link  beanclass=actionBean.class class="light-box-link waves-effect waves-light" event="ticketAndServiceLists">
                                    <@s.param name="serviceCategory" value="totalServices"  />
                                    <@s.param name="ticketCategory" value="I want to put javascript function here!"/>
Hello guys, does anyone know how to put javascript function to populate a value of "param"?? (does it even possible?)
Vamp
@the-vampiire
Mar 24 2017 04:24
in case anyone was wondering I will answer my own question. in python you can take a part of a string like this str[1:] will give you the str from position 1 to the end. to do the same in javascript you use str.slice(1); and it will do the same
Osa
@AkhatorEnosa
Mar 24 2017 04:24
@the-vampiire The title is Nesting For Loops
Vamp
@the-vampiire
Mar 24 2017 04:24
@AkhatorEnosa in what section
@AkhatorEnosa what is the main section title called
found it
@AkhatorEnosa you have nested the for loops correctly. but you have not performed the proper action within the nested loops. reread the question
Matthew
@IMDBLM
Mar 24 2017 04:29
Hey folks could someone please explain something in the condense array challenge? Why does the function have to declare singleVal , array? If the vars already exist, why can't it just be function(){return singleVal + array;} and what is the purpose of that trailing 0?
juni
@junipberry
Mar 24 2017 04:31
// Setup
function abTest(a, b) {
// Only change code below this line
if (a>0);
console.log("alpha");
if (b>0);
console.log("beta");
else if (a<0 || b<0);
return undefined;
}
Hey guys, can you help me find out what Im doing wrong? Cant get undefined to show
Osa
@AkhatorEnosa
Mar 24 2017 04:32
@the-vampiire Still not getting it
Manish Giri
@Manish-Giri
Mar 24 2017 04:33
@junipberry you need just one if condition
that checks if a or b is less than 0
if it is, return undefined
@junipberry
Traek Wells
@TraekWells
Mar 24 2017 04:34
can anyone help me out with this? not sure what I’m doing wrong.
function multiplyArguments() {
    //use the arguments keyword to multiply all of the arguments together and return the product
    //if no arguments are passed in return 0
    //if one argument is passed in just return it
    if (arguments.length === 0) {
        return 0;
    }
    if (arguments.length === 1) {
        return arguments;
    }
    var total = 0;
    for(var i = 0; i < arguments.length; i++) {
        total *= arguments[i];
    }
    return total;
}
juni
@junipberry
Mar 24 2017 04:35

// Setup
function abTest(a, b) {
// Only change code below this line
if (a<0 || b<0);
return undefined;
}

but this does not work either.. @Manish-Giri

Manish Giri
@Manish-Giri
Mar 24 2017 04:36
@junipberry why the ; at the end?
if (a<0 || b<0);
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:37
anyone help me please Factorialize a Number
juni
@junipberry
Mar 24 2017 04:37
I thought && was for AND and || was for OR
Manish Giri
@Manish-Giri
Mar 24 2017 04:37
it is.
juni
@junipberry
Mar 24 2017 04:38
ok..not seeing the problem
Osa
@AkhatorEnosa
Mar 24 2017 04:38
@the-vampiire for (i =0; i < arr[i].length; i++){
for (j = 0; j > arr[j].length; j++){
var variable = arr[i][j];
console.log(variable);
}
}
Manish Giri
@Manish-Giri
Mar 24 2017 04:38
the ;
juni
@junipberry
Mar 24 2017 04:38
got rid of the ; but didnt make a difference
Manish Giri
@Manish-Giri
Mar 24 2017 04:38
if (a<0 || b<0);
@junipberry why the ; at the end?
juni
@junipberry
Mar 24 2017 04:38
got rid of it. doesnt make a difference.
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:39
@Manish-Giri please help
Manish Giri
@Manish-Giri
Mar 24 2017 04:39
enclose the return undefined; in a set of {}
juni
@junipberry
Mar 24 2017 04:39
now its saying its an illegal statement
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:39
Factorialize a Number @Manish-Giri
Chris Cullen
@123xylem
Mar 24 2017 04:39

Can you see why req.flash is being called not a function?
I have included and required it on my app.js main page but its acting like its not there...

 var flash          =require("connect-flash");

app.use(flash());

//In my Middleware page i call it 

obj.isLoggedIn=function (req,res,next){
    if(req.isAuthenticated()){                        
       return next()}
        else{
            req.flash("error", "Please Login First")            //HERE and it says req.flash is not a function
            res.redirect("/login")}
                    }                    
//further details : im getting a lot of messages that reference router. (im using an express router that has given me problems)::

 at next (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:275:10)
    at Function.handle (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:174:3)
    at router (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:47:12)

Any idea why my req.flash isnt recognised or how to check for why these files seem not to link to eachother?

Manish Giri
@Manish-Giri
Mar 24 2017 04:39
@bitcoinabdi what's the problem?
juni
@junipberry
Mar 24 2017 04:39
ah
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:40
@Manish-Giri -->Return the factorial of the provided integer.
Jasdeep Singh
@jay-dee7
Mar 24 2017 04:40
please help me with the problem "Diff two Arrays"
Manish Giri
@Manish-Giri
Mar 24 2017 04:40
@bitcoinabdi show your code..
Jasdeep Singh
@jay-dee7
Mar 24 2017 04:40

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

  for (var i=0; i<arr1.length; i++){
    if(arr2.indexOf(arr1[i]===-1)){
      newArr.push(arr1[i]);
    }
  }
  for (var j=0; j<arr2.length; j++){
    if(arr1.indexOf(arr2[j])===-1){
      newArr.push(arr2[j]);
    }
  }
  return newArr;
}
juni
@junipberry
Mar 24 2017 04:40
ty @Manish-Giri
CamperBot
@camperbot
Mar 24 2017 04:40
junipberry sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4891 | @manish-giri |http://www.freecodecamp.com/manish-giri
Jasdeep Singh
@jay-dee7
Mar 24 2017 04:41
i have to return an array which conatins unique elements from either array
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:41
function factorialize(num) {
  return num(x*y);
}

factorialize(5);
Manish Giri
@Manish-Giri
Mar 24 2017 04:42
@bitcoinabdi what is x and y?
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:43
thats the perator syntax @Manish-Giri
I could not find out how to write the code
Manish Giri
@Manish-Giri
Mar 24 2017 04:43
@bitcoinabdi do you know what a factorial of a number is?
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:44
yes.5! = 1 2 3 4 5 = 120
Jasdeep Singh
@jay-dee7
Mar 24 2017 04:44
5!=12345=120
Manish Giri
@Manish-Giri
Mar 24 2017 04:45
@bitcoinabdi 5! = 5 x 4 x 3 x 2 x 1
Jasdeep Singh
@jay-dee7
Mar 24 2017 04:45
:worried:
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:45
yes
Manish Giri
@Manish-Giri
Mar 24 2017 04:45
given a number, you multiply that number with all the numbers from that number down till 1.
@bitcoinabdi
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:45
yes
Manish Giri
@Manish-Giri
Mar 24 2017 04:45
try writing the code for it.
because this - return num(x*y);
is wrong..
Tiffany
@tiffanymakes
Mar 24 2017 04:46
@jay-dee7 you have a typo. if(arr2.indexOf(arr1[i]===-1)) should be if(arr2.indexOf(arr1[i])===-1)
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:46
do you use the (var i = 0; i <=5; i++)
Manish Giri
@Manish-Giri
Mar 24 2017 04:47
try doing it backwards
from 5
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:47
(var i = 0; i <=5; i--)
Jasdeep Singh
@jay-dee7
Mar 24 2017 04:48
omg i've sitting here for an hour my god thank you very much @tiffanymakes you're awesome
CamperBot
@camperbot
Mar 24 2017 04:48
jay-dee7 sends brownie points to @tiffanymakes :sparkles: :thumbsup: :sparkles:
:cookie: 325 | @tiffanymakes |http://www.freecodecamp.com/tiffanymakes
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:48
@Manish-Giri is that right ?
Manish Giri
@Manish-Giri
Mar 24 2017 04:49
(var i = 0; i <=5; i--)
@bitcoinabdi first iteration - i is 0, condition i <= 5 is true, so the body of the loop executes, then terminating condition is i--, so i will be -1.
Is that what you want?
Tiffany
@tiffanymakes
Mar 24 2017 04:50
@jay-dee7 :thumbsup: no problem! It happens to all of us.
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:50
no @Manish-Giri
Vamp
@the-vampiire
Mar 24 2017 04:51

@bitcoinabdi it does not matter if you go forward or backwards (for this problem) as long as you state it properly

forward

for(var i = 0; i < num; i++);

backward

for(var i = num; i > 0; i—);
Manish Giri
@Manish-Giri
Mar 24 2017 04:51
@the-vampiire for(var i = 0; i < num; i++);
is this right?
multiplication with 0?
Vamp
@the-vampiire
Mar 24 2017 04:51
oh sorry
no not for factorial
start 1
mpochiro
@mpochiro
Mar 24 2017 04:52
hey for remainder quotients im really confused on how this is working
var remainder; 11 % 3= 2;
how is this not right?
Vamp
@the-vampiire
Mar 24 2017 04:53
@mpochiro that is correct
mpochiro
@mpochiro
Mar 24 2017 04:54
then why isn't it going?
Vamp
@the-vampiire
Mar 24 2017 04:54
11/3 = 3 with remainder 11-9 = 2
Manish Giri
@Manish-Giri
Mar 24 2017 04:54
is not correct.
Vamp
@the-vampiire
Mar 24 2017 04:54
oh
the way you have it written is wrong
but 11%3 = 2
this is correct
mpochiro
@mpochiro
Mar 24 2017 04:55
yeah it's till not going even when i do that
step 135
Manish Giri
@Manish-Giri
Mar 24 2017 04:55
@mpochiro you've got to assign the result to remainder
Vamp
@the-vampiire
Mar 24 2017 04:55
var remainder;
this means you are creating a variable named remainder and are assigning nothing to it
11%3 = 2; is not a valid expression in javascript. you can not assign a mathematical operation to a value
now what if you set your variable to be equal to a mathemaical operation? that is valid
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:57

``` function factorialize(num) {
for(var i = 0; i < num; i++);

return num ;
}

factorialize(5);

```

whats wround with my code ?
mpochiro
@mpochiro
Mar 24 2017 04:57
@the-vampiire still not getting it
Vamp
@the-vampiire
Mar 24 2017 04:57

var remainder = 11%3;

this is valid. you are saying create variable named remainder and assign it to the result of the operation 11%3…which is 2

mpochiro
@mpochiro
Mar 24 2017 04:57
like I understand setting the variable to something but how would I write that?
Vamp
@the-vampiire
Mar 24 2017 04:58
now if you return remainder it will return the value of the operation which is 2
bitcoinabdi
@bitcoinabdi
Mar 24 2017 04:58

``` function factorialize(num) {
for(var i = 0; i < num; i++);

return num ;
}

factorialize(5);
```

Vamp
@the-vampiire
Mar 24 2017 04:58
var remainder = 11%3;
return remainder // returns 2
Manish Giri
@Manish-Giri
Mar 24 2017 04:58
@bitcoinabdi do you know what's happening in the for loop?
Manish Giri
@Manish-Giri
Mar 24 2017 04:59
actually your for loop isn't complete either..
Vamp
@the-vampiire
Mar 24 2017 04:59
@bitcoinabdi this for loop is invalid
mpochiro
@mpochiro
Mar 24 2017 04:59
i think youre thinking too far ahead of me
Vamp
@the-vampiire
Mar 24 2017 04:59
return will stop the loop after a single iteration
and return 0 (your start)
Manish Giri
@Manish-Giri
Mar 24 2017 05:00
@mpochiro how do you assign a value to a variable?
like how would you assign 5 to the variable a?
Vamp
@the-vampiire
Mar 24 2017 05:00
@mpochiro no I am not. reread what I have said
@mpochiro okay maybe I was sorry. you do not need return in this problem. it is jsut asking you to assign a variable to the operation. however in the future you would want to know what that value is otherwise it’s meaningless to you. so you would use return variable_name;
mpochiro
@mpochiro
Mar 24 2017 05:03
right i understand that and I have put in var remainder;11%3; and it's still not taking it
Vamp
@the-vampiire
Mar 24 2017 05:03
dude
mpochiro
@mpochiro
Mar 24 2017 05:03
I'm not sure what it's wantingT.T
Manish Giri
@Manish-Giri
Mar 24 2017 05:03
@mpochiro how do you assign a value to a variable?
bitcoinabdi
@bitcoinabdi
Mar 24 2017 05:03
@the-vampiire @Manish-Giri am lost/stuck
Manish Giri
@Manish-Giri
Mar 24 2017 05:03
you didn't answer my question..
mpochiro
@mpochiro
Mar 24 2017 05:04
var a;5;
Manish Giri
@Manish-Giri
Mar 24 2017 05:04
@bitcoinabdi I think you should do the JS lessons in codeacademy first..
mpochiro
@mpochiro
Mar 24 2017 05:04
right manish?
Manish Giri
@Manish-Giri
Mar 24 2017 05:04
then you could come back to this..it'll help you
Vamp
@the-vampiire
Mar 24 2017 05:04
var remainder; is creating a variable but not assigning it to anything. 11%3; is not a valid expression on its own. listen to @Manish-Giri
Manish Giri
@Manish-Giri
Mar 24 2017 05:04
@mpochiro you use the = to assign something to something else.
Vamp
@the-vampiire
Mar 24 2017 05:04
‘=‘ is an assignment operator
Manish Giri
@Manish-Giri
Mar 24 2017 05:04
like userName = mpochiro
Vamp
@the-vampiire
Mar 24 2017 05:04
you use it to assign a variable to something else
Manish Giri
@Manish-Giri
Mar 24 2017 05:04
a = 5
mpochiro
@mpochiro
Mar 24 2017 05:05
yall it's not clicking what do i physically type out
Vamp
@the-vampiire
Mar 24 2017 05:05
‘;’ is how you end a line in javascript. so you want to
create a variable:
var remainder
assign something to this variable with assignment operator ‘='
var remainder =
something in this case is 11%3
var remainder = 11%3
end this line in javascript with ‘;’
var remainder = 11%3;
I get it now
thank you ahahha
now how do you send brownie points?
Vamp
@the-vampiire
Mar 24 2017 05:07
@mpochiro I am not trying to make fun at all but you need to redo the lessons if you can not understand assignment. this is one of the most critical aspects of javascript and coding in general
just remember ‘;’ is only used at the END of a line in javascript. nowhere else. ‘=‘ only used for assignment nowhere else.
you just say thank you with a tag of Manish name to give brownie points
mpochiro
@mpochiro
Mar 24 2017 05:08
@the-vampiire @Manish-Giri thank you
CamperBot
@camperbot
Mar 24 2017 05:08
mpochiro sends brownie points to @the-vampiire and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 250 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
:star2: 4892 | @manish-giri |http://www.freecodecamp.com/manish-giri
mpochiro
@mpochiro
Mar 24 2017 05:08
yall must be like...super irritated haha I would be
Manish Giri
@Manish-Giri
Mar 24 2017 05:09
nope, we're here to help..
Vamp
@the-vampiire
Mar 24 2017 05:09
a little bit but only because you weren’t listening!
Manish Giri
@Manish-Giri
Mar 24 2017 05:09
good luck :sparkles:
Vamp
@the-vampiire
Mar 24 2017 05:09
you will be okay just remember the basics and it will keep building on itself
@bitcoinabdi write out in words what you want to accomplish with your code for this problem. start with this
Ogundele Olumide
@Lumexralph
Mar 24 2017 05:15
@Manish-Giri Hey Buddy :smile:
Manish Giri
@Manish-Giri
Mar 24 2017 05:15
@Lumexralph :wave:
Jyue0812
@Jyue0812
Mar 24 2017 05:16

what's wrong with my code? I cannot pass the challenge! Help~~~function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result = myNoun + myAdjective + myVerb + myAdverb;

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Ogundele Olumide
@Lumexralph
Mar 24 2017 05:18
@Jyue0812 you need to separate them with spaces " " else your strings will be joined together
Jyue0812
@Jyue0812
Mar 24 2017 05:19
@Lumexralph It works!!!Thanks a lot!
Makopa
@makopa
Mar 24 2017 05:20
Goodday everyone! i read and watched alot of tutorial about callbacks, but still im confused why we need it and whats its general purpose. especially in node.js
Ogundele Olumide
@Lumexralph
Mar 24 2017 05:22
@makopa when an event occurs due to time or user interaction with the app, server response etc...they are all events and you want your program to do some stuffs when those events happens......that's the reason for callbacks, your program carrys out an action or some when the event occurs, that's where callback comes in
Makopa
@makopa
Mar 24 2017 05:29
@Lumexralph so callback is just like a function waiting to be triggered?
Ogundele Olumide
@Lumexralph
Mar 24 2017 05:29
@makopa right
@makopa it's a function
Makopa
@makopa
Mar 24 2017 05:30
@Lumexralph thanks man for responsing! and last one. callback function always has a parent function?
CamperBot
@camperbot
Mar 24 2017 05:30
makopa sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1364 | @lumexralph |http://www.freecodecamp.com/lumexralph
Makopa
@makopa
Mar 24 2017 05:31
@Lumexralph it making a lot of sense now. also in jquery when click event occur. thats why it has anonymous function to carry out the action
Ogundele Olumide
@Lumexralph
Mar 24 2017 05:31
@makopa depends on what you mean by that, I know of parent class, parent object and a function defined in another function, i don't understand what you meant parent function
@makopa yes.... that's the reason
Makopa
@makopa
Mar 24 2017 05:32
@Lumexralph o imean that a callback always be inside another function
Ogundele Olumide
@Lumexralph
Mar 24 2017 05:33
@makopa no, not necessarily... you can define a callback on it's own without being in another function
Makopa
@makopa
Mar 24 2017 05:33
@Lumexralph alright ill check into that examples. :+1:
nabheetmadan
@nabheetmadan
Mar 24 2017 05:37
@makopa parent function concept is normally to demonstrate closures and then to call back
Chris Cullen
@123xylem
Mar 24 2017 06:02

Can someone help me with adding flash messages.
I require express-flash in my app.js and get my app to use it like the docs say

var flash              =require("express-flash")
app.use(flash())

and then I use req.flash in my routes that are connected to my app.js file

//NEW CAMP FORM
router.get("/new",obj.isLoggedIn, function(req, res) {
        req.flash("info","welcome");

    res.render("campgrounds/new");
})

but i get: type error req.flash is not a function
Any Ideas?!?

bitcoinabdi
@bitcoinabdi
Mar 24 2017 06:04
 function factorialize(num) {
   for(var i = 0; i < num; i++);{


   }

    return num++ ;
}

factorialize(10);
杨海雄
@yanghx1014
Mar 24 2017 06:10

// Initialize these three variables
var a;
var b;
var c;

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

Greusa Marite
@greusa10
Mar 24 2017 06:24

hi huys, i´m having problem with Selecting frommany options with Switch statements, this is what :
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch(val){case===1: console.log("1===alpha");break;}

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

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

can someone please pin point me to the right place

Manish Giri
@Manish-Giri
Mar 24 2017 06:26
@greusa10 to begin with, case===1 is wrong
Markus Kiili
@Masd925
Mar 24 2017 06:26
@bitcoinabdi You need a variable initialized to 1 that you multiply inside the loop.
Manish Giri
@Manish-Giri
Mar 24 2017 06:26
you just write the corresponding values beside each case
Markus Kiili
@Masd925
Mar 24 2017 06:27
Also loop from 2 to <=num
Manish Giri
@Manish-Giri
Mar 24 2017 06:27
like case 1
then, inside each case, you would assign the right string to answer, because answer is being returned eventually - return answer;
bitcoinabdi
@bitcoinabdi
Mar 24 2017 06:33
@Masd925 how?
Markus Kiili
@Masd925
Mar 24 2017 06:34
@bitcoinabdi Like var result = 1; and then multiply it by i inside the loop block.
Greusa Marite
@greusa10
Mar 24 2017 06:34
hi @Manish-Giri but I cannot use if, so how would I assign the correct string to answer?
tylerccarson
@tylerccarson
Mar 24 2017 06:34
Why do the users display as “undefined” rather than their actual names?
http://codepen.io/tylerccarson/pen/jBzmpO?editors=1011
devpaaji
@devpaaji
Mar 24 2017 06:34
@Masd925 are you doing hacker Rank cgallenges as well
oh sorry @Manish-Giri
for you
Markus Kiili
@Masd925
Mar 24 2017 06:35
@devpaaji No.
Osa
@AkhatorEnosa
Mar 24 2017 06:36
Someone should help me with the Stand in Line challenge
bitcoinabdi
@bitcoinabdi
Mar 24 2017 06:37
Raghav Mundra
@Raghav17
Mar 24 2017 06:37

Can anyone please tell me what is wrong with my code?
function titleCase(str) {
var split = str.split(" ");
var newArr;
for (i = 0; i < split.length; i++)
{

  var newStr = split[i];
  var first = newStr.charAt(0).toUpperCase();

  newArr.push(first);

}

var join = newArr.join(" ");
return join;
}

bitcoinabdi
@bitcoinabdi
Mar 24 2017 06:37

function factorialize(num) {
for(var i = num; i > 0; i--);{
var result = 1;
}
return (result * i );
}

factorialize(5);

Manish Giri
@Manish-Giri
Mar 24 2017 06:37
@greusa10
case 1: answer = "..."; break;
Raghav Mundra
@Raghav17
Mar 24 2017 06:37
I need to make the first letter of every word capital.
Manish Giri
@Manish-Giri
Mar 24 2017 06:38
@devpaaji yeah
bitcoinabdi
@bitcoinabdi
Mar 24 2017 06:38
function factorialize(num) {
  for(var i = num; i > 0; i--);{
   var result = 1;
  }
  return (result * i );
}

factorialize(5);
@Masd925
Markus Kiili
@Masd925
Mar 24 2017 06:38
@bitcoinabdi Declaration before the loop.
result = result * i; inside the loop.
bitcoinabdi
@bitcoinabdi
Mar 24 2017 06:41

@Masd925 --->function factorialize(num) {

for(var i = num; i > 0; i--);{
result = result * i;
}

return num;
}

factorialize(5);

Greusa Marite
@greusa10
Mar 24 2017 06:41
@Manish-Giri so I only use one = sign, I was using 3 equal signs, because it said that case values are tested with strict equality(===)
Osa
@AkhatorEnosa
Mar 24 2017 06:42

PLease someone shoul help me with this code

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

return item; // Change this line
}

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

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

WHat should i do?

Greusa Marite
@greusa10
Mar 24 2017 06:42
thanks @Manish-Giri for the help
CamperBot
@camperbot
Mar 24 2017 06:42
greusa10 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4895 | @manish-giri |http://www.freecodecamp.com/manish-giri
Edward John
@eddmecha
Mar 24 2017 06:42
hi guys
need help here
Markus Kiili
@Masd925
Mar 24 2017 06:42
@bitcoinabdi Where is the result declaration?
Edward John
@eddmecha
Mar 24 2017 06:42
Add a local variable to myOutfit to override the value of outerWear with "sweater".
and i wrote

// Setup
var outerWear = "T-Shirt";

function myOutfit() {
// Only change code below this line

var outerWear = "Sweater";

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

myOutfit();

Manish Giri
@Manish-Giri
Mar 24 2017 06:43
@greusa10 actually, = is used for assignment, like you assign alpha to the variable answer.
== or === is used when you want to compare two things like
2 === 3; //false
bitcoinabdi
@bitcoinabdi
Mar 24 2017 06:43
@Masd925 am lost
Markus Kiili
@Masd925
Mar 24 2017 06:43
@bitcoinabdi First declare a result variable and initialize it to 1.
bitcoinabdi
@bitcoinabdi
Mar 24 2017 06:51

@Masd925
function factorialize(num) {

for(var i = num; i > 0; i--);{
var result = 1;
result = result * i;
}

return num;
}

factorialize(5);

Markus Kiili
@Masd925
Mar 24 2017 06:51
@bitcoinabdi Declare result before the for loop.
and return result after the loop block.
Use i>=2 condition of for loop.
bitcoinabdi
@bitcoinabdi
Mar 24 2017 06:53

function factorialize(num) {
var result = 1;
for(var i = num; i > 0; i--);{

result = result * i;
}

return num;
}

factorialize(5);

h1tag
@h1tag
Mar 24 2017 06:58
@AkhatorEnosa you didn't try anything
Osa
@AkhatorEnosa
Mar 24 2017 06:59
i have been trying out different things but its not been working
h1tag
@h1tag
Mar 24 2017 06:59
@AkhatorEnosa show me your last try
Sampea
@Sampea
Mar 24 2017 07:01
Hi there, I've been working on this JS challenge for a while, finding a remainder in JS. Does anyone have any feedback?

// Only change code below this line

var remainder; 11 % 3 = 2;

Manish Giri
@Manish-Giri
Mar 24 2017 07:01
@Sampea you don't compute the 2 yourself..js does that.
drinkwaterman
@drinkwaterman
Mar 24 2017 07:02

Hello guys
I didn't understand this exercise called: Arguments Optional

and more specifically The function that should be returned:

Calling this returned function with a single argument will then return the sum:

var sumTwoAnd = addTogether(2);

sumTwoAnd(3) returns 5.

Arguments Optional

Create a function that sums two arguments together. If only one argument is provided, then return a function that expects one argument and returns the sum.

For example, addTogether(2, 3) should return 5, and addTogether(2) should return a function.

Calling this returned function with a single argument will then return the sum:

var sumTwoAnd = addTogether(2);

sumTwoAnd(3) returns 5.

If either argument isn't a valid number, return undefined.
Osa
@AkhatorEnosa
Mar 24 2017 07:08
@fortMaximus // Your code here
var puah = arr.push(item);
arr.shift(gitterhq/gitter#1638);
return item; // Change this line
Edward John
@eddmecha
Mar 24 2017 07:08
@Sampea replace the ; with = and delete the =2
h1tag
@h1tag
Mar 24 2017 07:09
@AkhatorEnosa what's is "(gitterhq/gitter#1638)" here?
and shift() doesn't take arguemnts
Osa
@AkhatorEnosa
Mar 24 2017 07:10
@fortMaximus It is supposed to be puah
h1tag
@h1tag
Mar 24 2017 07:10
shift() doesn't take arguemnts
Osa
@AkhatorEnosa
Mar 24 2017 07:12
@fortMaximus I have removed it
h1tag
@h1tag
Mar 24 2017 07:12

@AkhatorEnosa

The nextInLine function should then return the element that was removed.

do you know what shift() returns?
Edward John
@eddmecha
Mar 24 2017 07:14

guys is there anything wrong with my code? because i cant get pass the challange.
// Setup
var outerWear = "T-Shirt";

function myOutfit() {
// Only change code below this line

var outerWear = "Sweater";

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

myOutfit();

the instruction is myOutfit should return "sweater"
stuck
h1tag
@h1tag
Mar 24 2017 07:16
@eddmecha you don't need to declare outWear twice
Edward John
@eddmecha
Mar 24 2017 07:16
@ninjacatdev you should write like this
var myStr = 'FirstLine\n\SecondLine\\rThirdLine';
Doni Yafi
@yafiwebdev
Mar 24 2017 07:17
@ninjacatdev you missed the back slashes
you need to put them and escape too
"FirstLine\n\SecondLine\\rThirdLine"
damn
Edward John
@eddmecha
Mar 24 2017 07:17
@ninjacatdev
var myStr = 'FirstLine\n\SecondLine\\rThirdLine';
Doni Yafi
@yafiwebdev
Mar 24 2017 07:17
the message is removing the backslashes
"FirstLine\n\\SecondLine\\\rThirdLine"
here you go
Edward John
@eddmecha
Mar 24 2017 07:18
lol
@fortMaximus which means?i just ignore it?
Intars Broks
@ninjacatdev
Mar 24 2017 07:19
@yafiwebdev Thank you! Yep missed one backslash.
CamperBot
@camperbot
Mar 24 2017 07:19
ninjacatdev sends brownie points to @yafiwebdev :sparkles: :thumbsup: :sparkles:
:cookie: 209 | @yafiwebdev |http://www.freecodecamp.com/yafiwebdev
h1tag
@h1tag
Mar 24 2017 07:19
var outerWear = "T-Shirt";
var var outerWear = "Sweater";
@eddmecha
you're declaring it twice
what's the challenge name btw?
bitcoinabdi
@bitcoinabdi
Mar 24 2017 07:21
'''
someone explain this
function factorialize(num) {
if (num === 0 || num === 1)
return 1;
for (var i = num - 1; i >= 1; i--) {
num *= i;
}
return num;
}
factorialize(5);
'''
CamperBot