These are chat archives for FreeCodeCamp/HelpJavaScript

13th
Apr 2017
Joseph
@revisualize
Apr 13 2017 00:00
@BrianWilliams28 One sec.
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:00
You and the one I know live in California
Rudy Hernandez
@rudolphh
Apr 13 2017 00:00
is she cute?
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:00
lol
Rudy Hernandez
@rudolphh
Apr 13 2017 00:00
then i might know her ;)
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:00
What if she is actually your relatives?
Joseph
@revisualize
Apr 13 2017 00:00
@BrianWilliams28
The function declaration was set up as... function phoneticLookup(val) giving the function name as phoneticLookup and with the parameter of val. There is more that I could go into (if you want I can) but, I'll sum it up with: Parameters are variable-like objects that represent the values that get passed into your function from the function call (arguments). (You basically treat them like variables.)
So, as we learned in: Accessing Objects Properties with Variables you have to use bracket notation to access an object property with a variable. Example: var num = 42; myObj[num];
You need to re-assign the variable result the the object property value of the object that you created lookup. (As per the instructions)
With this code: function phoneticLookup(val) { } you have a function declaration with a function name of phoneticLookup and a parameter val.
When you make the function call: phoneticLookup("charlie"); You are calling the function by name and passing the argument of "charlie" to the function parameter of val as a value.
You'll need to use bracket notation to access your object (lookup) property value. Note: Parameters are used inside of your function just like variables.
You need to assign the value of the object property to the variable result.
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:00
She is english teacher
Rudy Hernandez
@rudolphh
Apr 13 2017 00:01
no i know my close relatives, if she's some 6th cousin its fair game imo
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:01
lol
Rudy Hernandez
@rudolphh
Apr 13 2017 00:01
my sister lisa is a professor in austin
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:01
I see
So you said you have a sister then Rachel might be your cousin...
That person doesnt have a bother
brother*
Rudy Hernandez
@rudolphh
Apr 13 2017 00:02
you do know we're all related right?
Joseph
@revisualize
Apr 13 2017 00:02
@BrianWilliams28 That's a lot of text. I can break it down for you if you'd like.
Rudy Hernandez
@rudolphh
Apr 13 2017 00:02
so if she's far down the chain i could care less
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:02
Hm
Are you Jews?
Rudy Hernandez
@rudolphh
Apr 13 2017 00:03
not jewish, but some fam is
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:03
Oh
I wonder why I didnt even realized your last name..
limbu
@limbu
Apr 13 2017 00:03
i just figured this task out can someone please proof read and see if this solution is ok???
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:03
Did you change names or something?
limbu
@limbu
Apr 13 2017 00:03

function titleCase(str) {

  var splitChar = str.toLowerCase().split(" ");

  var strHolder = [];

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

    str = splitChar[i].charAt(0).toUpperCase() + splitChar[i].slice(1);

    str = strHolder.push(str);

    str = strHolder.join(" ");

  }

  return str;

}

titleCase("I'm a little tea pot");
Trakra
@trgme
Apr 13 2017 00:04
I’ve tried to solve it this way:
<script>
  document.addEventListener('DOMContentLoaded',function(){
    document.getElementById('getMessage').onclick=function(){
      req=new XMLHttpRequest();
      req.open("GET",'/json/cats.json',true);
      req.send();
      req.onload=function(){
        json=JSON.parse(req.responseText);
        document.getElementsByClassName('message')[0].innerHTML=JSON.stringify(json);
        // Add your code below this line
        console.log(id.altText.imageLink.codeNames[2]);

        // Add your code above this line
      };
    };
  });
</script>
Rudy Hernandez
@rudolphh
Apr 13 2017 00:04
this is mine, yours might look better
function titleCase(str) {
  let myArr = str.split(" ");
  let newWord = "";

  for(let i = 0; i < myArr.length; i++){
    newWord = myArr[i][0].toUpperCase();
    newWord += myArr[i].substring(1,myArr[i].length).toLowerCase();
    myArr[i] = newWord;
    newWord = "";
  }
  return myArr.join(" ");
}
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:04
@trgme What challenge?
Trakra
@trgme
Apr 13 2017 00:04
but it’s not working.
thx...
it’s in beta and called 'JSON APIs and Ajax: Access the JSON Data from an API'
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:05
oh
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 00:05
im getting that same error message on heroku that @Manish-Giri was getting now
Trakra
@trgme
Apr 13 2017 00:05
how do i find challenge/lesson number?
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:05
You know once beta is completed it will reset your progresses..
You would have to redo
limbu
@limbu
Apr 13 2017 00:05
@rudolphh you're using es6 which is awesome... don't know mine works and passes the test
Rudy Hernandez
@rudolphh
Apr 13 2017 00:06
switch let with var and its fine @limbu
limbu
@limbu
Apr 13 2017 00:06
@rudolphh yours looks more difficult to write than mine...
@rudolphh i know let is flexible and const is not
Rudy Hernandez
@rudolphh
Apr 13 2017 00:06
i guess it looks like but think its the same :)
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:07
Well copy and paste...
limbu
@limbu
Apr 13 2017 00:07
@rudolphh was just using what the tutorial taught me for the time being
Trakra
@trgme
Apr 13 2017 00:07
I didn’t know.. i thought plan was to replace entirely.. i can go and re-do on ‘regular’ site
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:07
Im not sure if this site will be removed or stay
IF it was removed and I would be pissed off..
Rudy Hernandez
@rudolphh
Apr 13 2017 00:08
i only use beta
just save the challenges locally or github with asterisk (*) and you're good
Trakra
@trgme
Apr 13 2017 00:10
I’ve been saving most of mine locally… either way initially i kinda just started so did beta..
jeffreynasca
@jeffreynasca
Apr 13 2017 00:10
complete noob to java and im confused by this task "a should be assigned to b with =" how does one do this?
JonathanMKPT
@JonathanMKPT
Apr 13 2017 00:10
still stumped on the Nesting For Loop can someone better explain it to me
code follows:

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length;i++){
    for (var j = 0; j < arr.length;j++){
      console.log(arr[i][j] *= product);
    }

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Joseph
@revisualize
Apr 13 2017 00:11
@JonathanMKPT YOu're getting closer. console.log(arr[i][j] *= product); you don't want to console.log. You have your variables backwards.
Saboor Malik
@MathematicsCoding
Apr 13 2017 00:11
@jeffreynasca Javascript not java
They are not same thing
Rudy Hernandez
@rudolphh
Apr 13 2017 00:11
beta is far from done so still moving along. d3 is a cinch, looking forward to getting to the contributions
jeffreynasca
@jeffreynasca
Apr 13 2017 00:12
@MathematicsCoding my bad =(
turbit-smart
@turbit-smart
Apr 13 2017 00:13
Thanks @Rafase282 @sabahang @aganita @Hallaathrad for your help with Algorithm: Pig Latin
CamperBot
@camperbot
Apr 13 2017 00:13
turbit-smart sends brownie points to @rafase282 and @sabahang and @aganita and @hallaathrad :sparkles: :thumbsup: :sparkles:
:cookie: 178 | @aganita |http://www.freecodecamp.com/aganita
:cookie: 308 | @sabahang |http://www.freecodecamp.com/sabahang
:cookie: 544 | @hallaathrad |http://www.freecodecamp.com/hallaathrad
:star2: 1525 | @rafase282 |http://www.freecodecamp.com/rafase282
Trakra
@trgme
Apr 13 2017 00:14
so, it’s on the normal path.. any idea? I think I’m just lost in the arrays??
Rudy Hernandez
@rudolphh
Apr 13 2017 00:15
what about arrays @trgme ?
Trakra
@trgme
Apr 13 2017 00:16
so, for cat with id “id” of 2 , console.log the 2nd value in codeNames array.
[
    {"id":0,"imageLink":"https://s3.amazonaws.com/freecodecamp/funny-cat.jpg","altText":"A white cat wearing a green, helmet shaped melon on it's head. ","codeNames":
        ["Juggernaut","Mrs. Wallace","Buttercup"]},
    {"id":1,"imageLink":"https://s3.amazonaws.com/freecodecamp/grumpy-cat.jpg","altText":"A white cat with blue eyes, looking very grumpy. ","codeNames":["Oscar","Scrooge","Tyrion"]},
    {"id":2,"imageLink":"https://s3.amazonaws.com/freecodecamp/mischievous-cat.jpg","altText":"A ginger cat with one eye closed and mouth in a grin-like expression. Looking very mischievous. ","codeNames":
        ["The Doctor","Loki","Joker"]
    }
]
argh… i was taking apart to be easier. … it scrolls!
JonathanMKPT
@JonathanMKPT
Apr 13 2017 00:19
@revisualize I'm still stumped
Joseph
@revisualize
Apr 13 2017 00:19
@JonathanMKPT Okay. How can I help?
JonathanMKPT
@JonathanMKPT
Apr 13 2017 00:20
@revisualize you said that my variables were reversed
Joseph
@revisualize
Apr 13 2017 00:21
@JonathanMKPT This: console.log(arr[i][j] *= product); you shouldn't be console.logging and then the variables are reversed.
@JonathanMKPT I just noticed that you aren't doing for (var j = 0; j < arr.length;j++) correctly either.
@JonathanMKPT You should be getting the .length of the sub array.
Trakra
@trgme
Apr 13 2017 00:22
got it figured out.
JonathanMKPT
@JonathanMKPT
Apr 13 2017 00:22
@revisualize ah, let me try again
Matt Barron
@mbarronj
Apr 13 2017 00:24
Soooo, my function for titleCase returns a string, that looks correct. Why would it be failing the test?
Joseph
@revisualize
Apr 13 2017 00:25
@mbarronj Have you tried visualizing your code on www.pythontutor.com/javascript.html
Rudy Hernandez
@rudolphh
Apr 13 2017 00:26
or revisualizing your code? lol
Matt Barron
@mbarronj
Apr 13 2017 00:26
I have a codepen instance with the code
Joseph
@revisualize
Apr 13 2017 00:26
@mbarronj I'd try to help more but, I'm actually running late for an event. I'd suggest taking a few of the failing and walking through the code execution on that site I just linked.
@mbarronj That site actually let's you walk through your code line by line.
Matt Barron
@mbarronj
Apr 13 2017 00:27
hmm
ok
Joseph
@revisualize
Apr 13 2017 00:27
@mbarronj I'd say give it a shot. I'm certain someone else may be able to assist you further.
JonathanMKPT
@JonathanMKPT
Apr 13 2017 00:27
@revisualize hey finally figured it out, thanks for the tips :)
CamperBot
@camperbot
Apr 13 2017 00:27
jonathanmkpt sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3726 | @revisualize |http://www.freecodecamp.com/revisualize
Rudy Hernandez
@rudolphh
Apr 13 2017 00:27
post the codepen @mbarronj
Matt Barron
@mbarronj
Apr 13 2017 00:29
not sure if pens need to be set to public, but here: https://codepen.io/mbarronj/pen/zwYZmZ
Neat integration
Rudy Hernandez
@rudolphh
Apr 13 2017 00:30
yeah it works @mbarronj now what code do you have in the challenge?
maybe you just aren't returning the result correctly
Matt Barron
@mbarronj
Apr 13 2017 00:31
same thing, but with the input and return codes changed.
Yeah, that's what im thinking. "I'm A Little Tea Pot" is not === "I'm A Little Tea Pot"
wait - I think I'm somehow adding a space at the end
Rudy Hernandez
@rudolphh
Apr 13 2017 00:32
gotta love when that happens
Matt Barron
@mbarronj
Apr 13 2017 00:34
double wait. I'm somehow returning an array of length 5, not a string of length 20, somehow the result still looks like a string
Johnny
@JohnnyBizzel
Apr 13 2017 00:35
@JLuboff @Manish-Giri Alternative to Heroku? It was called Gomix but now it's called https://glitch.com/.
Joseph
@revisualize
Apr 13 2017 00:36
@mbarronj is that site helping? ... Im on my phone.
Matt Barron
@mbarronj
Apr 13 2017 00:38
@revisualize a bit - showed me an extra space problem
@revisualize and that it's supposed to be returning a string
Joseph
@revisualize
Apr 13 2017 00:39
You should be returning a string.
Rudy Hernandez
@rudolphh
Apr 13 2017 00:39
can you post your challenge code @mbarronj ?
@revisualize is going for free food and drinks lets not bother him
Matt Barron
@mbarronj
Apr 13 2017 00:41
function titleCase(str) {
  var words = str;
  var re = /./i;
  var newword = "";
  var awords = words.split(" "); 
  var curword;

  for(var entry in awords){
    curword =awords[entry].toLowerCase();
    curword = curword.replace(re,replaceUpper);
    newword = newword.concat(curword," ");
  }
    //= words.replace(re,replaceUpper);
  if(newword === "I'm A Little Tea Pot"){
    newword = "true";
  }
  return(newword);
}

function replaceUpper(match, p1, p2, p3, offset, string) {
  var res = "";
  res = match.toUpperCase();
  return(res);
}

titleCase("I'm a little tea pot");
CamperBot
@camperbot
Apr 13 2017 00:41
:bulb: to format code use backticks! ``` more info
Rudy Hernandez
@rudolphh
Apr 13 2017 00:42
function titleCase(str) {
  let myArr = str.split(" ");
  let newWord = "";

  for(let i = 0; i < myArr.length; i++){
    newWord = myArr[i][0].toUpperCase();
    newWord += myArr[i].substring(1,myArr[i].length).toLowerCase();
    myArr[i] = newWord;
    newWord = "";
  }
  return myArr.join(" ");
}
Stephen James
@sjames1958gm
Apr 13 2017 00:45
@mbarronj if you put curword back into awords - then only need to join after loop
Rudy Hernandez
@rudolphh
Apr 13 2017 00:45
@sjames1958gm to the rescue
Matt Barron
@mbarronj
Apr 13 2017 00:45
ah lovely, yeah the array join works
Stephen James
@sjames1958gm
Apr 13 2017 00:45
@rudolphh :)
Rudy Hernandez
@rudolphh
Apr 13 2017 00:46
every time i see you i want a beer lol :)
Stephen James
@sjames1958gm
Apr 13 2017 00:46
lol
Rudy Hernandez
@rudolphh
Apr 13 2017 00:46
i'm not even joking lmao
how's it going man?
i follow you because i do aspire to your career heights believe it or not
Matt Barron
@mbarronj
Apr 13 2017 00:48
@rudolphh thanks!
CamperBot
@camperbot
Apr 13 2017 00:48
mbarronj sends brownie points to @rudolphh :sparkles: :thumbsup: :sparkles:
:cookie: 201 | @rudolphh |http://www.freecodecamp.com/rudolphh
Stephen James
@sjames1958gm
Apr 13 2017 00:48
@rudolphh Thanks
Rudy Hernandez
@rudolphh
Apr 13 2017 00:48
i got 201 brownies? nice
300 and i retire i swear
Christopher Hall
@ChristopherBHall
Apr 13 2017 00:49

function cleaner(clean){
var args = Array.prototype.slice.call(arguments).slice(1,9);
return clean !== args[0];
}
function destroyer(arr) {
arr = arr.filter(cleaner);
return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Stephen James
@sjames1958gm
Apr 13 2017 00:49
@rudolphh going good - got home from work - had to help with the physics project for our exchange student.
then I found out that it was our turn for my daughters softball team dinner - a lot of noisy teenage girls
Christopher Hall
@ChristopherBHall
Apr 13 2017 00:49
Anyone with any idea why that doesnt work? If I replace args[0] with 2 it works, but args[0] doesnt even though it IS 2
Moisés Man
@moigithub
Apr 13 2017 00:50
@ChristopherBHall why slice 1,9 ?
what IF have more than 9 elements ?
u can ommit that ,9 then slice will take everything else till the end
Christopher Hall
@ChristopherBHall
Apr 13 2017 00:50
args[0] is just the array, Didn't really need that
Stephen James
@sjames1958gm
Apr 13 2017 00:50
@ChristopherBHall arguments in cleaner has no relationship to the arguments of destroyer
Rudy Hernandez
@rudolphh
Apr 13 2017 00:50
lol, cant wait for that, i got 3 girls myself. only the 9 year old plays, but i'm grooming the 3 year-old. i played from 3 all the way through high-school
Stephen James
@sjames1958gm
Apr 13 2017 00:50
@rudolphh nice -
Rudy Hernandez
@rudolphh
Apr 13 2017 00:51
really cool you got an exchange student.
Stephen James
@sjames1958gm
Apr 13 2017 00:52
@rudolphh Yeah, she is from Madrid been with us from August and is here until june
Joseph
@revisualize
Apr 13 2017 00:52
I dont drink beer.
Moisés Man
@moigithub
Apr 13 2017 00:52
@ChristopherBHall every function have its own arguments object
soo calling inside filter callback is NOT the same as using it insode destroyer as @sjames1958gm said
u can console.log(arguments) in both functions to check
Rudy Hernandez
@rudolphh
Apr 13 2017 00:53
oh man i had the longest exchange with a madrid girl back in the day, i forget the site, it was for long distance letter stuff. would love to visit
and who was talking to you about beer @revisualize ?
Stephen James
@sjames1958gm
Apr 13 2017 00:53
@rudolphh Same here - I am a big soccer fan would love to see a game in Madrid
Rudy Hernandez
@rudolphh
Apr 13 2017 00:53
yeah i also love the team too!
Stephen James
@sjames1958gm
Apr 13 2017 00:53
@revisualize :wine_glass:
Rudy Hernandez
@rudolphh
Apr 13 2017 00:54
stick to martinis @revisualize
sour apple
you prob smoke a lotta weed tho up there in seattle
not that its bad, i'm game for that once in awhile
Joseph
@revisualize
Apr 13 2017 00:57
@sjames1958gm I really dont like the taste of wine. Oddly enough, I actaully dont drink a lot. When I do, it is on the weekends out playing pool. Or in the rare occasion I drink at home it is after 7pm and only 1 shot.
Stephen James
@sjames1958gm
Apr 13 2017 00:58
@revisualize I like playing pool
Joseph
@revisualize
Apr 13 2017 00:58
Then it is Crown Royal, a good potato vodka or Captain.
Rudy Hernandez
@rudolphh
Apr 13 2017 01:00
you know i really like? jameson on ice
pretty much the only thing i can drink straight and not feel like shit while doing it
Phuong Nguyen
@neunygph
Apr 13 2017 01:01
Is it possible to retrieve browser cache with pure JavaScript?
Rudy Hernandez
@rudolphh
Apr 13 2017 01:01
i have a pool table but the girls don't like to play with me
Stephen James
@sjames1958gm
Apr 13 2017 01:01
@rudolphh You probably hustle them for my little ponies
Rudy Hernandez
@rudolphh
Apr 13 2017 01:01
lmao, how did you know?
more like hustle them for less allowance
Joseph
@revisualize
Apr 13 2017 01:02
@sjames1958gm I dont play enough these days. I really need to get out more.
Rudy Hernandez
@rudolphh
Apr 13 2017 01:02
yeah you look pale
Joseph
@revisualize
Apr 13 2017 01:03
I'm trying to improve my JavaScript skills, learn Python and Docker.
Stephen James
@sjames1958gm
Apr 13 2017 01:03
@revisualize I used to play a lot in college. My best friend and I would play all night, then he would go to bed and I would go to class
Rudy Hernandez
@rudolphh
Apr 13 2017 01:03
docker is cool, highly recommend
my dad used to hustle pool with his friends in the 60's, good stories
Joseph
@revisualize
Apr 13 2017 01:04
@sjames1958gm I used to play a lot when I was homeless.
Stephen James
@sjames1958gm
Apr 13 2017 01:04
@rudolphh Yeah, I upgraded my desktop to 16.04 ubuntu and then I couldn't build one of my projects, had to create a docker image to be able to build
Rudy Hernandez
@rudolphh
Apr 13 2017 01:04
really? strange
Stephen James
@sjames1958gm
Apr 13 2017 01:04
@revisualize Those places are open 24 hours?
Joseph
@revisualize
Apr 13 2017 01:06
@sjames1958gm nope. But, when it was raining. It was better than sitting outside. Also, I was able to save money for the 24hrs Dennys with free coffee refills all night.
canoid
@canoid
Apr 13 2017 01:07
hi I'm having a problem wih the "Escape Sequences in Strings" challenge it doesn't works
Joshua
@jfc246
Apr 13 2017 01:07
Just finished Main JavaScript! :)
Joseph
@revisualize
Apr 13 2017 01:07
What do you have?
@jfc246 congrats.
Joshua
@jfc246
Apr 13 2017 01:08
that took me forever to complete @revisualize
Rudy Hernandez
@rudolphh
Apr 13 2017 01:08
congrats to you too @revisualize, i didn't know your story like i do now.
canoid
@canoid
Apr 13 2017 01:08
```var myStr= "FirstLine\n\SecondLine\r\ThirdLine"; // Change this line
Rudy Hernandez
@rudolphh
Apr 13 2017 01:09
hate me if you must :\
Joshua
@jfc246
Apr 13 2017 01:09
@canoid can you send me your code?
ohh sry @canoid
canoid
@canoid
Apr 13 2017 01:09
var myStr= "FirstLine\n\\SecondLine\r\\ThirdLine"; // Change this line
Rudy Hernandez
@rudolphh
Apr 13 2017 01:09
good work @jfc246
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 01:10
anyone used node and express to make an api?
Rudy Hernandez
@rudolphh
Apr 13 2017 01:10
uggh no, i'd use lumen
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 01:11
@canoid \\\r
canoid
@canoid
Apr 13 2017 01:12
it works!! thank you!!
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 01:12
youre welcome
Joshua
@jfc246
Apr 13 2017 01:13
@HeebieGeeBee man i was just about to say that :angry: LOL
canoid
@canoid
Apr 13 2017 01:13
lol
thanks anyways :)
Gene
@bginop
Apr 13 2017 01:14

hey guys i am working on challenge 198 "count cards" and for some reason i can't seem to solve the following challenges: Cards Sequence 2, J, 9, 2, 7 should return "1 Bet", Cards Sequence 2, 2, 10 should return "1 Bet". Could someone give me an idea of what i am missing. 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;
  return count + " Bet" ;   

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

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

}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(7);cc(8);cc(9);

my program seems to work if i put in the sequences that the challenge is asking (2,2,10) but for some reason the challenge isn't passed
i gotta be missing something real finicky
Joshua
@jfc246
Apr 13 2017 01:16
@bginop the first count should be
count = count +1;
instead of
count +=1;
Gene
@bginop
Apr 13 2017 01:17
i tried that. no dice
Joshua
@jfc246
Apr 13 2017 01:17
and the bottom shoud be the same like this
count = count -1;
Rudy Hernandez
@rudolphh
Apr 13 2017 01:17
do you need to make an api with node an express @HeebieGeeBee ?
Gene
@bginop
Apr 13 2017 01:18
@jfc246 i tried that too. no dice
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 01:18
i dont need to, but i am anyway
Rudy Hernandez
@rudolphh
Apr 13 2017 01:18
oh okay. cool. no experience with php?
Diego Mayer
@Chrono79
Apr 13 2017 01:18
@jfc246 count = count +1;and count +=1;do the same thing
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 01:18
@rudolphh not really
im just working through node stuff, im not looking for the best way to make an api or anything
Joshua
@jfc246
Apr 13 2017 01:19
@bginop the holds should be at the bottom like this
if(count > 0) {

        return count + " Bet";
      }else {

        return count + " Hold";
      }
Rudy Hernandez
@rudolphh
Apr 13 2017 01:19
okay then, yeah do what you gotta do. lumen is php-based and so easy to make an api
Diego Mayer
@Chrono79
Apr 13 2017 01:19
@bginop separate card evaluation (don't return there!) from count evaluation
Gene
@bginop
Apr 13 2017 01:19
ohh snap it just got real
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 01:20
was just wondering if anyone knew how to get data about the ip or any special id of someone requesting data within the express module
Joshua
@jfc246
Apr 13 2017 01:20
@bginop were you able to solve it?
Gene
@bginop
Apr 13 2017 01:20
I'm thinking about where the if statement goes.
so dont have any returns until the end?
Joshua
@jfc246
Apr 13 2017 01:21
rigth at on top of only change code above this line line @bginop
Diego Mayer
@Chrono79
Apr 13 2017 01:24
count++;
count += 1;
count = count + 1;
The three do the same, increasing count in 1
Gene
@bginop
Apr 13 2017 01:24
@jfc246 ohh my god you sir are a genius. I would o f never though of doing that
Joshua
@jfc246
Apr 13 2017 01:24
@bginop i got hung at that as well when i was at that challenge.............
Gene
@bginop
Apr 13 2017 01:25
what a doozie
Joshua i appreciate your help. You're the man
or women?
i dont know
Joshua
@jfc246
Apr 13 2017 01:25
@Chrono79 i know just sometimes the code area wont let you do it any other way
Gene
@bginop
Apr 13 2017 01:25
dont need to know either
Joshua
@jfc246
Apr 13 2017 01:26
@bginop i am a boy
and i am 11
@bginop
Rudy Hernandez
@rudolphh
Apr 13 2017 01:30
okay gotta go hack reactor meeting yay
si
@demon9181
Apr 13 2017 01:31
trying to figure out how to write a .filter function to filter out an argument please advise
function destroyer(arr) {
function args(val){
  return val != arguments[a];
  }
  for(a = 1;a < arguments.length;a++){
    return arr.filter(args);
  }
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
this is what i have so far and it doesnt work :(
Diego Mayer
@Chrono79
Apr 13 2017 01:33
@demon9181 each function has its own arguments object
si
@demon9181
Apr 13 2017 01:34
so how would i refer to the main functions arguments?
Diego Mayer
@Chrono79
Apr 13 2017 01:34
also a return like that, inside a loop, will end your loop at the first run
Joseph
@revisualize
Apr 13 2017 01:36
These events are rough.
20170412_181913.jpg
20170412_182432.jpg
20170412_182127.jpg
@awb715 Where you at!?
@awb715 You're missing out. It's going to be a great series of talks tonight.
Hashtag-if you live in / near a major city and you don't attend tech meetup events.
You're missing out.
@sperrye Ping!?
She won't respond.
Maybe those pictures weren't needed for this chat. .. Should I delete them?
seanrhee
@seanrhee
Apr 13 2017 01:40
Hey guys, me again! I'm stuck on the Mutations exercise, this is what I have so far...

function mutation(arr) {
  var oStr = arr[0].toLowerCase();
  var checkStr = arr[1].toLowerCase();
  var count = 0;
  for (var i = 0; i < checkStr.length; i++){
    if (oStr.indexOf(checkStr)){
      count++;
    }
  }
  if (count < checkStr.length){
    return false;  
  }
  return true;
}
mutation(["hello", "hey"]);
Neal
@njordan9
Apr 13 2017 01:40

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

if (a < 0 || b < 0); {
return ;
}
// Only change code above this line

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

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

Joseph
@revisualize
Apr 13 2017 01:41
@njordan9 you need to return undefined
It's a javascript keyword.
@njordan9 OH!
Wait, you have another issue.
Joseph
@revisualize
Apr 13 2017 01:41
@njordan9 The ; is a statement terminator.
seanrhee
@seanrhee
Apr 13 2017 01:41
This code actually returns better test results:

function mutation(arr) {
  var oStr = arr[0].toLowerCase();
  var checkStr = arr[1].toLowerCase();
  var count = 0;
  for (var i = 0; i < checkStr.length; i++){
    if (oStr.indexOf(checkStr[i])){
      count++;
    }
  }
  if (count < checkStr.length){
    return true;  
  }
  return false;
}
mutation(["hello", "hey"]);
Carter4502
@Carter4502
Apr 13 2017 01:41
im tring to recreate the instagram login page
can you show me how i can make it so itt says username on the tetbox but when they click it it is empty
Joseph
@revisualize
Apr 13 2017 01:42
@njordan9 You have a ; in here: if (a < 0 || b < 0); { it is terminating the if statement before it reaches the statement block.
Neal
@njordan9
Apr 13 2017 01:42
@revisualize omg thank you!
CamperBot
@camperbot
Apr 13 2017 01:42
njordan9 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3727 | @revisualize |http://www.freecodecamp.com/revisualize
Neal
@njordan9
Apr 13 2017 01:42
That was driving me crazy
Joseph
@revisualize
Apr 13 2017 01:42
@njordan9 That's a hard one to catch sometimes.
seanrhee
@seanrhee
Apr 13 2017 01:42
@Carter4502 you put placeholder="Username" in your input element
i'm fairly sure
Joseph
@revisualize
Apr 13 2017 01:43
Okay, I need to get back to this event hosted by Facebook.
Carter4502
@Carter4502
Apr 13 2017 01:45
yup that was it. Thanks @seanrhee
CamperBot
@camperbot
Apr 13 2017 01:45
carter4502 sends brownie points to @seanrhee :sparkles: :thumbsup: :sparkles:
:cookie: 250 | @seanrhee |http://www.freecodecamp.com/seanrhee
Marco
@heyitscino
Apr 13 2017 01:50
having some trouble with "check for palindromes" challenge.
Stephen James
@sjames1958gm
Apr 13 2017 01:51
@heyitscino post what you have
Marco
@heyitscino
Apr 13 2017 01:51

function palindrome(str) {

result = str.split("").reverse().join("").toLowerCase().replace(/\W+/g, "").replace(/[_-]/g, "");
if (result === str){
return true;
} else {
return false;
}

}

palindrome("eye");

Lance
@texas2010
Apr 13 2017 01:52
@revisualize bye, they will miss you. :trollface:
Stephen James
@sjames1958gm
Apr 13 2017 01:52
@heyitscino You are comparing to the original string which hasn't been modified
@heyitscino .toLowerCase().replace(/\W+/g, "").replace(/[_-]/g, ""); do this to the original string.
then reverse it and compare the two
Marco
@heyitscino
Apr 13 2017 01:54
@sjames1958gm so I am! Thanks a lot for pointing that out . I'll see how I go
CamperBot
@camperbot
Apr 13 2017 01:54
heyitscino sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6671 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Aaron Bell
@awb715
Apr 13 2017 01:54
shouldve went @revisualize
@revisualize iam working on tic tac toe
Stephen James
@sjames1958gm
Apr 13 2017 01:54
@heyitscino yw
Aaron Bell
@awb715
Apr 13 2017 01:54
@JLuboff apparently for the good tic tac toe AI theres a algorithim
@JLuboff i def donthave the skills to even think something like that. I think in the form of if statements
Marco
@heyitscino
Apr 13 2017 01:55
@sjames1958gm all working now. such a simple mistake after all of that. Cheers again.
Stephen James
@sjames1958gm
Apr 13 2017 01:56
@awb715 I developed my own AI - it is not perfect, but it is a challenge to win
@heyitscino You had the right pieces just not all in the right places ;)
Aaron Bell
@awb715
Apr 13 2017 01:57
@sjames1958gm right now im focusing on just getting the 2 player version to determine ifthere is a winner. my computer generate code will come next
Stephen James
@sjames1958gm
Apr 13 2017 01:57
@awb715 :+1:
Aaron Bell
@awb715
Apr 13 2017 01:58
i met a dude who didnt write his first line of code until he was 30 last week so it made me feel better cusim 22 hhaha
Paul Rail
@PolarisTLX
Apr 13 2017 02:03
In the Find Longest Word in a Strong problem. I believe I have it figured out. but for some reason my variable becomes "undefined" instead of being a number:
function findLongestWord(str) {
  var array = str.split(' ');
  var longest = 0;
  for (i=0; i < array.length; i++) {

    if (array[i].length > longest) {
      longest = array[i].lentgh;
    }

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

findLongestWord("quick brown fox");
the var I called "longest" starts off as 0 then becomes "undefined" when it should become 5.
Aaron Bell
@awb715
Apr 13 2017 02:05
anyoneelseup to tic tac toe?
Moisés Man
@moigithub
Apr 13 2017 02:05
array[i].lentgh; @PolarisTLX typo
Paul Rail
@PolarisTLX
Apr 13 2017 02:06
oh thanks @moigithub
CamperBot
@camperbot
Apr 13 2017 02:06
polaristlx sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3078 | @moigithub |http://www.freecodecamp.com/moigithub
Paul Rail
@PolarisTLX
Apr 13 2017 02:06
gahh typos
JonathanMKPT
@JonathanMKPT
Apr 13 2017 02:06
on the Profile-Lookup challenge, believe I'm close but not close enough yet
code is:
function lookUpProfile(firstName, prop){
// Only change code below this line
  if(contacts.hasOwnProperty(firstName,prop) === true){
    return contacts(firstName,prop);
  }else if(contacts.hasOwnProperty(prop.likes || prop.number) !== true){
    return "No such property";
  }else if(contacts.hasOwnProperty(firstName || prop.lastName ) !== true){
    return "No such contact";
  }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Moisés Man
@moigithub
Apr 13 2017 02:07
@JonathanMKPT u need a loop to iterate all contacts array
and check its object elements properties
JonathanMKPT
@JonathanMKPT
Apr 13 2017 02:07
@moigithub I'll try that, thank you
CamperBot
@camperbot
Apr 13 2017 02:07
jonathanmkpt sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3079 | @moigithub |http://www.freecodecamp.com/moigithub
Alejandro A Barrera
@AlejandroBarrera01
Apr 13 2017 02:09

function truncateString(str, num) {
// Clear out that junk in your trunk

if (str.length > num)
return str.substring(0,num)+'...';
else
return str;

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);

HELLO GUYS! I need help. With
I need to return "Peter Piper ... "
Anything that i am doing wrong?
Moisés Man
@moigithub
Apr 13 2017 02:11
for that exercise there are 3 possible cases u only handling 2 @AlejandroBarrera01
Alejandro A Barrera
@AlejandroBarrera01
Apr 13 2017 02:12
Yeah, i cant figured out the other one
Moisés Man
@moigithub
Apr 13 2017 02:13
  1. when dont have enough letters .. num > str.length
  2. when have enough letters str.length > num AND num > 3
  3. when have enough letters str.length > num AND num <= 3
Wing Ng
@citrusapple
Apr 13 2017 02:14
trying to get a space before capitalized letters in a string, googled it and identifying with regex seems like the solution, but it's not working, am I just confused? It seems to be jquery since it has "$". Perhaps there's something basic that i'm missing?
 var answer = array.replace(/(\A-Z)/g, " $1");
WillSmithTE
@WillSmithTE
Apr 13 2017 02:15
hey guys, im in one of the intermediate algorithm exercises. just made an infinite loop accidentally, and now can't even open the page to edit my code. it's like it automatically runs the code when I open the page. any ideas?
Wing Ng
@citrusapple
Apr 13 2017 02:15
oh and btw, array isn't an array... just a variable for a single string
WillSmithTE
@WillSmithTE
Apr 13 2017 02:15
nevermind think i got it
Moisés Man
@moigithub
Apr 13 2017 02:17
@citrusapple ur regex saying.. check for \A-Z literally
probably u wanna say.. find ANY uppercase letters then it shoudl be [A-Z]
Wing Ng
@citrusapple
Apr 13 2017 02:20
@moigithub
like this?
 var answer = array.replace(/[\A-Z]/g, " $1");
Moisés Man
@moigithub
Apr 13 2017 02:21
IF u gonna use $1 (group selectors) then u need to include () on ur regex expression too
/([A-Z])/g, ' $1'
Wing Ng
@citrusapple
Apr 13 2017 02:21
but my result is simply taking " $1" literally and replacing my capitalized letters
Milo Hartsoe
@MiloATH
Apr 13 2017 02:22
help format
Wing Ng
@citrusapple
Apr 13 2017 02:22
so (/([\A-Z]])/g, " $1")?
Rudy Hernandez
@rudolphh
Apr 13 2017 02:22
you working on any fcc projects @sjames1958gm ?
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:23
just thought id pass this on, found a nice little youtube series thats being made at the moment which is like a basic introduction to computer science https://www.youtube.com/watch?v=tpIctyqH29Q&list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo
Wing Ng
@citrusapple
Apr 13 2017 02:23
@MiloATH anyways, I got to go afk, thanks for the help
CamperBot
@camperbot
Apr 13 2017 02:23
citrusapple sends brownie points to @miloath :sparkles: :thumbsup: :sparkles:
:cookie: 341 | @miloath |http://www.freecodecamp.com/miloath
Paul Rail
@PolarisTLX
Apr 13 2017 02:24
Trying to make the first letter of a string be uppercase. I feel like my code should work but toUpperCase does not impact the letter:
function titleCase(str) {

  var array = str.split(' ');

  for (i = 0; i < array.length; i++){
        array[i][0].toUpperCase();
  }
  console.log(array.join(' '));
  return array.join(' ');  
}

titleCase("I'm a little tea pot");
Moisés Man
@moigithub
Apr 13 2017 02:24
strings are immutable.. soo u cant change part of it
u need to rebuild/reassign the whole string
Paul Rail
@PolarisTLX
Apr 13 2017 02:25
ohhhhhh
thanks @moigithub do I then need to break down each work into their own array then?
CamperBot
@camperbot
Apr 13 2017 02:25
polaristlx sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: polaristlx already gave moigithub points
juni
@junipberry
Apr 13 2017 02:30
guys, what am I doing wrong here
function titleCase(str) {
  var lowered = str.toLowerCase('');
  var array = lowered.split(' ');

for (var i = array[0][0]; i < array.length; i++) {
    console.log = (array.toUpperCase[i]);
    console.log = (array.slice[1]);
   return array.toUpperCase[i] + array.slice(1);
}

var joined = array.join(' ');                
  return joined;
}
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:31
@junipberry you cant make a return in side the loop like that
it will stop the function on the first iteration
juni
@junipberry
Apr 13 2017 02:31
oh..do i just place it outside?
Gilbert
@gilbertp97
Apr 13 2017 02:32
hello coders
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:32
@junipberry no
Gilbert
@gilbertp97
Apr 13 2017 02:32
quick question
juni
@junipberry
Apr 13 2017 02:32
thought it'd be okay bc I closed the }
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:32
@junipberry anytime a function hits a return it will stop the function operation
Gilbert
@gilbertp97
Apr 13 2017 02:32
var strSplit = str.split(' ')
what does the (' ') do with my string if i use that?
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:33
@junipberry you need to assign it to array[i] also you have other problems
toUpperCase() should just have empty parenthesis
not [i]
Milo Hartsoe
@MiloATH
Apr 13 2017 02:33
@gilbertp97 I think it splits every character
Paul Rail
@PolarisTLX
Apr 13 2017 02:34
@gilbertp97 the ' ' splits your string at each space
Gilbert
@gilbertp97
Apr 13 2017 02:34
ohh
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:34
@junipberry and just initialise your loop variable with 0
Paul Rail
@PolarisTLX
Apr 13 2017 02:34
@gilbertp97 you could also put '3' an it would split it at each 3
Gilbert
@gilbertp97
Apr 13 2017 02:34
thanks u both @MiloATH @PolarisTLX
CamperBot
@camperbot
Apr 13 2017 02:34
gilbertp97 sends brownie points to @miloath and @polaristlx :sparkles: :thumbsup: :sparkles:
:cookie: 342 | @miloath |http://www.freecodecamp.com/miloath
:cookie: 243 | @polaristlx |http://www.freecodecamp.com/polaristlx
Milo Hartsoe
@MiloATH
Apr 13 2017 02:34
you're welcome
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:35
@junipberry and you dont want be saying the whole array to upper case and trying to spice from the whole array
Paul Rail
@PolarisTLX
Apr 13 2017 02:35
oh my first brownie points! :smile: :smile: :sparkles: I helped someone else!
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:36
you're meant to just be changing the first letter of each word and adding the rest of the word
@junipberry so yeah lots of problems need sorting
juni
@junipberry
Apr 13 2017 02:36
@HeebieGeeBee
for (var i = array[i][0]; i < array.length; i++) {
    console.log = (array.toUpperCase());
    console.log = (array.slice[1]);
  array.toUpperCase[i] + array.slice(1);
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:36
no not like that @junipberry
do you understand what youre doing the for loop for?
juni
@junipberry
Apr 13 2017 02:37
yea to iterate the first letter of each word
I just dont get why its not doing it
Paul Rail
@PolarisTLX
Apr 13 2017 02:37
looks like we are on similar problem
juni
@junipberry
Apr 13 2017 02:38
closest I got was only to the first word
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:38
@junipberry no youre creating a loop so youre able to iterate over every word in the array
juni
@junipberry
Apr 13 2017 02:38
right, the first letter of every word
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:39
no on every iteration you'll have a value stored in the variable i that is that can be used for the index of a word in the array
juni
@junipberry
Apr 13 2017 02:39
so why wouldn't var i = array[i][0] target that?
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:40
thats your loop variable
you want to initialise that with var i = 0
you cant use the variable i in the value when youre declaring the i variable
how would it know what array[i][0] is
@junipberry i think you may need to review what loops do and how they work
they come up a lot in coding
Jeremy Ford
@mightypupil
Apr 13 2017 02:43
im stuck on making object properties private, any advice?
juni
@junipberry
Apr 13 2017 02:43
so var i=0; var i = array [i][0]; i<array.length; i++
I have been reviewing them and it makes sense in those simple lessons but these algorithms seem to complicate my basic understanding of those simple tasks
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:44
no just for(var i = 0; i < array.length; i++)
juni
@junipberry
Apr 13 2017 02:44
and it somehow ends up all convoluted
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:45
you have three parts to a for loop
you have your variable initialisation var i = 0 in this case, which means we're starting with a varibale declared as i with the value of 0
then you have the conditional which is i < array,length, which means that as long as i is less than the length of the array another loop will be performed
Vicky Lai
@vickylai
Apr 13 2017 02:47
Hey yall. How can I get the red divs to slide in without jumping up and down like that when user clicks buttons? http://codepen.io/vickylaixy/pen/jBXgeR
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:48
and then you have the final expression which is i++, meaning that the last thing the loop will do on its iteration will add 1 to the i variable
@junipberry
so that means no the we have a variable that we can use as the index to access each element of the array, cus on the first iteration i is 0 so we can use it to access the first element of the array by using array[i]
so therefore we can perform tasks in the loop statement using the i variable that will effect that particular element in the array
JonathanMKPT
@JonathanMKPT
Apr 13 2017 02:51
thinking I have the wrong loop on the profile lookup challenge. Any thoughts:
function lookUpProfile(firstName, prop){
// Only change code below this line

  for (var i = 0; i < contacts.length; i++){
    for (var j = 0; j < contacts[i].length; j++){
      if (contacts.hasOwnProperty(firstName) === true && contacts.hasOwnProperty(prop) === true){
        return contacts(firstName,prop);
      }else if (contacts.hasOwnProperty(firstName) !== true){
        return "No such contact";
      }else if (contacts.hasOwnProperty(prop.likes) !== true || contacts.hasOwnPropety(prop.numbers) !== true){
        return "No such property";
      }
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
juni
@junipberry
Apr 13 2017 02:53
okay, ty for that explanation @HeebieGeeBee
I used that initially but changed it up bc thought I wasnt setting the index correctly. Earlier on I was able to capitalize the first letter of the first word but not iterate through later words. But I guess that wasnt the problem..smtg else was.
CamperBot
@camperbot
Apr 13 2017 02:53
junipberry sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1288 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
juni
@junipberry
Apr 13 2017 02:53
would you advise I use console.log in a for loop?
also, every since I put () after .toUpperCase, its saying its not a function
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:55
@junipberry it was probably becuase you were returning in the loop
Aaron Bell
@awb715
Apr 13 2017 02:55
@junipberry if you want to visualize the loop sure, i have 3 loops within eachother and ni use console log to make sure its iterating how i want
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:55
@junipberry you can if you want, do you use the console?
@JonathanMKPT why are you using a nested loop?
Aaron Bell
@awb715
Apr 13 2017 02:56
test: function(player) {
      combos.map(function(array) {
        console.log(array + ' array tested');

        for (z = 0; z < player.length; z++) {
          console.log(player[z] + "player box tested");
          for (i = 0; i < array.length; i++) {
            console.log(array[i] + "winning box requirement");

          }

        }
      });
    } //
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:56
@JonathanMKPT and i cant see anywhere you using the loop variable
Aaron Bell
@awb715
Apr 13 2017 02:56
thats part of my coderight now haha
juni
@junipberry
Apr 13 2017 02:56
only when I get warnings..not much
just got into the habit of writing that in bc of the examples ..but then someone sent a link about the dangers of using console.log too much..
David Amanze
@GodKingShogun
Apr 13 2017 02:57
@junipberry you've been on here a long time :smile:
juni
@junipberry
Apr 13 2017 02:58
yea bc I cant figure it out
David Amanze
@GodKingShogun
Apr 13 2017 02:58
@junipberry im with you on that :worried:
@junipberry what is it you cant figure out
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 02:58
@junipberry so do you understand what your looping for and what you want to do on each iteration?
JonathanMKPT
@JonathanMKPT
Apr 13 2017 03:00
@HeebieGeeBee I removed the nested loop and now I have one block checked off, this is what I have now and not sure where to go next:
function lookUpProfile(firstName, prop){
// Only change code below this line

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

      if (contacts.hasOwnProperty(firstName) === true && contacts.hasOwnProperty(prop) === true){
        return contacts(firstName,prop);
      }else if (contacts.hasOwnProperty(firstName) !== true){
        return "No such contact";
      }else if (contacts.hasOwnProperty(prop.likes) !== true || contacts.hasOwnPropety(prop.numbers) !== true){
        return "No such property";
      }
    }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
juni
@junipberry
Apr 13 2017 03:00
Yes, I've understood what I'm supposed to do but I need some guidance doing it! People just say so and so is wrong but Im in the dark about how to go about it differently from what I have @HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:00
@JonathanMKPT you want to be accessing each contact on every iteration using your loop variable
and performing the checks
@junipberry so write your loop and show me the code
dont put anything inside it yet
Henry
@GitHub-Henry
Apr 13 2017 03:02
@junipberry I've found writing pseudo code helps me, then I translate to real code
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:02
@JonathanMKPT and i dont really have any idea what return contacts(firstName,prop); would return anyway?
David Amanze
@GodKingShogun
Apr 13 2017 03:03
@JonathanMKPT i think you mean contacts[firstName][prop]
Henry
@GitHub-Henry
Apr 13 2017 03:03
@junipberry if you are having trouble visualizing what your code is doing this may help http://www.pythontutor.com/
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:03
@GodKingShogun even that wrong
David Amanze
@GodKingShogun
Apr 13 2017 03:04
@junipberry you can always try watching a video if you dont fully understand how it is being explained here
JonathanMKPT
@JonathanMKPT
Apr 13 2017 03:04
@HeebieGeeBee it's part of challenge
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:04
@JonathanMKPT you also want to be just making a straight comparison to the contacts first name to the first name parameter
David Amanze
@GodKingShogun
Apr 13 2017 03:04
@HeebieGeeBee im not sure how the object looks like so i just wrote down pseudocod
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:05
@JonathanMKPT but thats not how you access object properties
you use dot or bracket notation?
@junipberry did you write the loop?
David Amanze
@GodKingShogun
Apr 13 2017 03:06
@HeebieGeeBee i know you haven't done the simon challenge yet but i have this block of code that should create an increasing number of sequence to the dom
function colorToClick(){
 for (var j=0; j<sequence.length; j++){
   sequenceEvent=sequenceEvent.concat(sequence[j]);
for (var k=0; k<sequenceEvent.length; k++) { 
   if (sequenceEvent[k]===1){  
  setTimeout(function(){
    $("#display").html(counter++);
 $("#red").animate({opacity:".5"},1000).animate({opacity:"1"},1000);
  redSound.play(2000);
  },2000*k);
      } else if(sequenceEvent[k]===2){
   setTimeout(function(){
     $ ("#display").html(counter++);
 $("#blue").animate({opacity:".5"},1000).animate({opacity:"1"},1000);
    blueSound.play(2000);
   },2000*k);
      } else if (sequenceEvent[k]===3){
 setTimeout(function(){
 $("#display").html(counter++);
 $("#yellow").animate({opacity:".5"},1000).animate({opacity:"1"},1000);
   yellowSound.play(2000);
  },2000*k);
  } else if(sequenceEvent[k]===4){
   setTimeout(function(){
$("#display").html(counter++);
 $("#green").animate({opacity:".5"},1000).animate({opacity:"1"},1000);
 greenSound.play(2000);
   },2000*k);
  }
 }
   clearTimeout();
    }
};
DrKlahn33
@DrKlahn33
Apr 13 2017 03:06
I have a couple questions. First, I would like to know how to easily paste my code into chat so that it has the black background and color coded text.
David Amanze
@GodKingShogun
Apr 13 2017 03:06
@DrKlahn33 post it in between ```
juni
@junipberry
Apr 13 2017 03:07
@HeebieGeeBee Im just figuring out what to change..
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:07
@junipberry lets just start fresh
David Amanze
@GodKingShogun
Apr 13 2017 03:07
@HeebieGeeBee it always stops at the first sequence though
DrKlahn33
@DrKlahn33
Apr 13 2017 03:07
'''
CamperBot
@camperbot
Apr 13 2017 03:07
:bulb: to format code use backticks! ``` more info
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:07
@GodKingShogun sorry thats a bit too much to delve into for me at the moment
DrKlahn33
@DrKlahn33
Apr 13 2017 03:07

function titleCase(str) {
var newString = str.toLowerCase();
var strArray = newString.split(' ');
var i = 0;
var finalString;
var capArray;
var capStrArray = strArray;
for(i; i< strArray.length;i++){
strArray[i][0] = strArray[i][0].toUpperCase();
}
finalString = strArray.join(' ');

return finalString;

}
titleCase("I'm a little tea pot");
'''

CamperBot
@camperbot
Apr 13 2017 03:07
:bulb: to format code use backticks! ``` more info
David Amanze
@GodKingShogun
Apr 13 2017 03:07
@HeebieGeeBee okay i understand
DrKlahn33
@DrKlahn33
Apr 13 2017 03:08
' ' '
juni
@junipberry
Apr 13 2017 03:08
okay
DrKlahn33
@DrKlahn33
Apr 13 2017 03:08

' ' '
function titleCase(str) {
var newString = str.toLowerCase();
var strArray = newString.split(' ');
var i = 0;
var finalString;
var capArray;
var capStrArray = strArray;
for(i; i< strArray.length;i++){
strArray[i][0] = strArray[i][0].toUpperCase();
}
finalString = strArray.join(' ');

return finalString;

}
titleCase("I'm a little tea pot");
' ' '

JonathanMKPT
@JonathanMKPT
Apr 13 2017 03:08
@HeebieGeeBee i'll try using that instead of the .hasOwnProperty method
David Amanze
@GodKingShogun
Apr 13 2017 03:08
@DrKlahn33 the key to the left of your one key at the top bar
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:08
@junipberry lets work through this together ok, first off do this for me, split the string
DrKlahn33
@DrKlahn33
Apr 13 2017 03:08
Sorry guys.
function titleCase(str) {
  var newString = str.toLowerCase();
  var strArray  = newString.split(' ');
  var i = 0;
  var finalString; 
  var capArray;
  var capStrArray = strArray;
  for(i; i< strArray.length;i++){
  strArray[i][0] = strArray[i][0].toUpperCase();
  }
  finalString = strArray.join(' ');


  return finalString;

}
titleCase("I'm a little tea pot");
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:09
@DrKlahn33 strings are immutable
David Amanze
@GodKingShogun
Apr 13 2017 03:09
@DrKlahn33 what is strArray[i][0]
DrKlahn33
@DrKlahn33
Apr 13 2017 03:10
Awesome. I think I can figure out how to make this code work just fine, but I am trying to decipher the error message. "Cannot assign to read only property '0' of string 'i'm'.
juni
@junipberry
Apr 13 2017 03:10
okay, ty~~ @HeebieGeeBee
I would set a `var array = titleCase.split('');
CamperBot
@camperbot
Apr 13 2017 03:10
:warning: junipberry already gave heebiegeebee points
junipberry sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:10
titleCase isnt the string str is i think and you need to split the string by spaces
David Amanze
@GodKingShogun
Apr 13 2017 03:10
@DrKlahn33 because you only have a one dimensional array when you split
DrKlahn33
@DrKlahn33
Apr 13 2017 03:10
I was hoping strArray[i][0] would be the first letter in the ith array element.
juni
@junipberry
Apr 13 2017 03:11
oh right, okay then it would make it
var array = str.split(' '); @HeebieGeeBee
David Amanze
@GodKingShogun
Apr 13 2017 03:11
@DrKlahn33 when you split it is going to look like this ["im","a","little", "teapot"]
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:12
@junipberry correct
now you have an array full of the words without spaces, now can you write a for loop so we can iterate over each of the words
DrKlahn33
@DrKlahn33
Apr 13 2017 03:12
what does immutable mean?
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:13
@junipberry
David Amanze
@GodKingShogun
Apr 13 2017 03:13
@DrKlahn33 it means it cant be changed
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:13
well mutated is more apt
Darth Skywalker
@adityaparab
Apr 13 2017 03:13

well mutated is more apt

+1

DrKlahn33
@DrKlahn33
Apr 13 2017 03:13
if I just return strArray[0][0], I get 'i'. or strArray[1][0], I get 'a'
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:15
@DrKlahn33 youre just accessing the value
DrKlahn33
@DrKlahn33
Apr 13 2017 03:15
or strArray[2][2] I get 't' So I figured you could single out letters that way.
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:16
when you try and change that value is the problem
DrKlahn33
@DrKlahn33
Apr 13 2017 03:16
So that is not a method I can use to change the value and that is what the error message means>
?
ok.Thanks.
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:17
@DrKlahn33 that value is part of a string, which is immutable, so you have to change the whole string, not just try and mutate part of it
Miftahul Awali Rizkina
@miftahulawali
Apr 13 2017 03:17
blob
juni
@junipberry
Apr 13 2017 03:17
okay, so I would do
```
for (var=0; i<array.length; i++) {
console.log( array[i][0].toUpperCase());
@HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:18
@junipberry var i = 0
juni
@junipberry
Apr 13 2017 03:18
oops..sorry
*var i = 0
DrKlahn33
@DrKlahn33
Apr 13 2017 03:18
@HeebieGeeBee That makes sense. I'll see if I can tackle it another way.
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:18
ok so you now you have a loop with a variable you can use to access each element of the array
@junipberry do you understand that?
juni
@junipberry
Apr 13 2017 03:19
yes, I do
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:19
right so how would you access the ith element of the array
juni
@junipberry
Apr 13 2017 03:20
array[i]
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:20
yes
so we want to re assign the value of array[i] on each iteration
Darth Skywalker
@adityaparab
Apr 13 2017 03:21
@junipberry Just a note, if you're planning to do something like array[i][0] = array[i][0].toUpperCase() and expecting the array[i] to become title cased, it doesn't work that way. Since strings are immutable, you can't update part of it. You will have to reassign value to the string.
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:21
just as example how would you re assign the value of array[i] to the same value just in uppercase
@junipberry
juni
@junipberry
Apr 13 2017 03:22
I would do array[i] = array[i].toUpperCase();
Ken Haduch
@khaduch
Apr 13 2017 03:22
@miftahulawali - I don't know if you got any help - the instructions say "playerNumber should be a number". Actually the first test result says "playerNumber should be a number"
Darth Skywalker
@adityaparab
Apr 13 2017 03:23
@junipberry do array[i] = array[i][0].toUpperCase() + array[i].slice(1); and you're good
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:23
@junipberry right, so we dont want to assign in that we...
or yeah just paste that
you'll need to chain .toLowerCase() to the slice though
cus we didnt change it before
Darth Skywalker
@adityaparab
Apr 13 2017 03:26
Just do .toLowerCase() before you .split(' ') and you don't need to worry about it later on.
juni
@junipberry
Apr 13 2017 03:27
okay I'll do that now @HeebieGeeBee
btw ty to everyone else trying to help w this, but if its okay I'll just stick with one person for this. I've been getting a surplus of input from many people over the past few days and its just put me in a bigger mess/confusion. The way heebie explains things just make a lot of sense to me ..so I'm just fine rn ty everyone.
Heathercoraje
@Heathercoraje
Apr 13 2017 03:29
Others can help me out then ;)
I am doing Accessing Nested Object.
Darth Skywalker
@adityaparab
Apr 13 2017 03:29
Post your code.
Heathercoraje
@Heathercoraje
Apr 13 2017 03:29
var gloveBoxContents = myStorage.car["glove box"];
It says, gloveBoxContents is not defined.
Darth Skywalker
@adityaparab
Apr 13 2017 03:30
Share your full code.
Heathercoraje
@Heathercoraje
Apr 13 2017 03:31

// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

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

juni
@junipberry
Apr 13 2017 03:32
would I do `{array[i][1] = array[i][1].toLowerCase();}
@HeebieGeeBee
Darth Skywalker
@adityaparab
Apr 13 2017 03:32
@Heathercoraje The glove box property is inside your inside object. Which is inside car object.
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:32
@junipberry no
you cant jsut change parts of a string
juni
@junipberry
Apr 13 2017 03:32
wait..I know what i did wrong..
Darth Skywalker
@adityaparab
Apr 13 2017 03:32
@Heathercoraje : So it should be var gloveBoxContents = myStorage.car.inside["glove box"];
Heathercoraje
@Heathercoraje
Apr 13 2017 03:32
@adityaparab
juni
@junipberry
Apr 13 2017 03:32
okay one sec
Heathercoraje
@Heathercoraje
Apr 13 2017 03:33
(embarrassed)
haha
thank you.
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:33
@junipberry you should be re assigning the value of array[i] all in one expression
@adityaparab ty
CamperBot
@camperbot
Apr 13 2017 03:33
heebiegeebee sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 987 | @adityaparab |http://www.freecodecamp.com/adityaparab
Darth Skywalker
@adityaparab
Apr 13 2017 03:34
@Heathercoraje Just a note, make it a habit to indent your code properly so you don't run into any such small issues.
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
    },
    "outside": {
      "trunk": "jack"
    }
  }
};
Now it's pretty obvious what is the nesting.
DrKlahn33
@DrKlahn33
Apr 13 2017 03:37

So, I changed my code to ```
function titleCase(str) {
var newString = str.toLowerCase();
var strArray = newString.split(' ');
var i = 0;
var finalString;
var capArray;
var tempString;
var capStrArray = strArray;

var test = strArray[2].split('');
for(i; i< strArray.length;i++){
tempString = strArray[i].split('');
tempString[0] = tempString[0].toUpperCase();
tempString = tempString.join('');
strArray[i] = tempString;

}
return strArray.join(' ');

}
titleCase("I'm a little tea pot");
```

It works, but is that a bit of a complicated way to solve the task?
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:37
@DrKlahn33 make sure the backticks are on their own lines
DrKlahn33
@DrKlahn33
Apr 13 2017 03:38
function titleCase(str) {
  var newString = str.toLowerCase();
  var strArray  = newString.split(' ');
  var i = 0;
  var finalString; 
  var capArray;
  var tempString;
  var capStrArray = strArray;

  var test = strArray[2].split('');
  for(i; i< strArray.length;i++){
   tempString =  strArray[i].split('');
    tempString[0] = tempString[0].toUpperCase();
    tempString = tempString.join('');
    strArray[i] = tempString;


  }
  return strArray.join(' ');

}
titleCase("I'm a little tea pot");
juni
@junipberry
Apr 13 2017 03:38
array[i][1]= array.slice(1).toLowerCase();
@HeebieGeeBee
Heathercoraje
@Heathercoraje
Apr 13 2017 03:39
@adityaparab Got ya. Thank you!
CamperBot
@camperbot
Apr 13 2017 03:39
heathercoraje sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 988 | @adityaparab |http://www.freecodecamp.com/adityaparab
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:40
@junipberry no, but closish, youre expression in the loop should be array[i] re assigned the value of the first letter of array[i] to upper case plus a slice of array[i] from index 1 in lowercase
if that makes sense
without jsut giving you the code
Darth Skywalker
@adityaparab
Apr 13 2017 03:40
@DrKlahn33 : You could easily improve this code multiple folds :)
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:41
This message was deleted
lol wait its not
array[i].slice(1).toLowerCase() remember the i
juni
@junipberry
Apr 13 2017 03:41
okay, that makes sense..so you're saying I can concatenate the two parts while slicing? @HeebieGeeBee
DrKlahn33
@DrKlahn33
Apr 13 2017 03:42
@adityaparab Yeah, thats what I figured. Any advice to get me thinking about it in another simpler way?
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:42
@junipberry well you can concat the first letter and the slice
but just use the +
dont need to use the concat method
Jeff Lung YK
@jefflung
Apr 13 2017 03:43
hiya
juni
@junipberry
Apr 13 2017 03:44
right, got it ..one sec
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:44
@animatist hola
Darth Skywalker
@adityaparab
Apr 13 2017 03:44
@DrKlahn33 You could use .slice method. Let me show you an example.
function titleCase(str) {
  // same as storing results in two separate variables. You can just "chain" these two methods
  var array = str.toLowerCase().split(' ');

  for(var i=0; i<array.length;i++){
    array[i] = array[i][0].toUpperCase() + array[i].slice(1);
  }

  return array.join(' ');

}
titleCase("I'm a little tea pot");
This might not be intuitive to you but you can also get it done as one liner.
function titleCase(str) {
  return str.toLowerCase()
            .split(' ')
            .map(w => w[0].toUpperCase() + w.slice(1))
            .join(' ');
}
titleCase("I'm a little tea pot");
Abe
@abealto
Apr 13 2017 03:47
Hello! Can someone assist me with JS please?
Darth Skywalker
@adityaparab
Apr 13 2017 03:47
@abealto shoot
Abe
@abealto
Apr 13 2017 03:48
I'm having some trouble understanding "Returning Boolean Values from Functions" in the JS section.
Darth Skywalker
@adityaparab
Apr 13 2017 03:48
@abealto show your code
Abe
@abealto
Apr 13 2017 03:48

function isLess(a, b) {
// Fix this code
if (a < b) {
return true;
} else {
return false;
}
}

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

DrKlahn33
@DrKlahn33
Apr 13 2017 03:48
@adityaparab Thanks, I have only been coding for about two weeks, so honestly your solution does not make much sense to me, but it gives me something to dissect and figure out.
CamperBot
@camperbot
Apr 13 2017 03:48
drklahn33 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 989 | @adityaparab |http://www.freecodecamp.com/adityaparab
Abe
@abealto
Apr 13 2017 03:49
The instructions state to replace the if else with ===
Darth Skywalker
@adityaparab
Apr 13 2017 03:50
@abealto I think all you need to do is return a < b;
so your code looks like
function isLess(a, b) {
  return a < b;
}

// Change these values to test
isLess(10, 15);
Abe
@abealto
Apr 13 2017 03:50
I see.
Darth Skywalker
@adityaparab
Apr 13 2017 03:51
because the comparison operator result in a boolean value
so you don't need to explicitly return true or false based on the result of comparison.
Abe
@abealto
Apr 13 2017 03:51
hmmm...
Darth Skywalker
@adityaparab
Apr 13 2017 03:51
just return the result of comparison as it is
Abe
@abealto
Apr 13 2017 03:51
ohhh i see now.
Chris Cullen
@123xylem
Apr 13 2017 03:52
var date=function(){
    return date.now();}

var postSchema= new mongoose.Schema({
    name:String,
    image:String,
    author:{
        id:{
            type:mongoose.Schema.Types.ObjectId,
        ref:"user"},
        username:String
    },
    date:date
});
Im trying to return the date of creation from a made post... Its saying this is undefined .. is there a way to do this with date.now?
Abe
@abealto
Apr 13 2017 03:52
Thanks Darth Skywalker!
Darth Skywalker
@adityaparab
Apr 13 2017 03:52
@abealto :+1:
@123xylem I think you need to set date : Date (Date being the native JS Date object)
juni
@junipberry
Apr 13 2017 03:53
array[i][0] = array[i][0].toUpperCase();
 array[i][1] = array[i].slice(1).toLowerCase();
    }
@HeebieGeeBee
then do I join then return it?
Benjamin
@XenoCoding
Apr 13 2017 03:54
I'm having trouble with "Testing Objects for Properties." Here is my code.

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

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

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

HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:54
@junipberry no you cant just change parts of the strings like that
Chris Cullen
@123xylem
Apr 13 2017 03:54
@adityaparab ah an inbuilt object that tells the time of creation?
Darth Skywalker
@adityaparab
Apr 13 2017 03:54
@XenoCoding return myObj.checkProp; should be return myObj[checkProp];
checkProp is a variable that contains key name
Benjamin
@XenoCoding
Apr 13 2017 03:55
ah, I see. Thanks!
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:55
array[i] = array[i][0].toUpperCase() + array[i].slice(1).toLowerCase();
@junipberry
do you see why you have to do it like that?
youre re assigning the complete word
juni
@junipberry
Apr 13 2017 03:56
ohhh
Darth Skywalker
@adityaparab
Apr 13 2017 03:56
@123xylem : The schema that you have specifies the type of value...
what value should go at that property is defined at the time you do schema.save
juni
@junipberry
Apr 13 2017 03:56
yes, I understand why
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:56
@junipberry but yeah after the loop you will have to return the joined array
Chris Cullen
@123xylem
Apr 13 2017 03:57
@adityaparab i assume js Date object will give the date once saved?
Darth Skywalker
@adityaparab
Apr 13 2017 03:57
@123xylem can you show me how you're saving the value?
Gulsvi
@gulsvi
Apr 13 2017 03:57

@123xylem

var date = () => Date.now();

var postSchema = new mongoose.Schema({
  name: String,
  image: String,
  author: {
    id: {
      type: mongoose.Schema.Types.ObjectId,
      ref: "user"
    },
    username: String
  },
  date: date()
});

or just use Date.now() instead of making a function out of it.

Darth Skywalker
@adityaparab
Apr 13 2017 03:57
because they way you have right now means your date property will have a value of type [Object Function] I believe that is not what you want...
juni
@junipberry
Apr 13 2017 03:58
got it, thank you so much @HeebieGeeBee !!
CamperBot
@camperbot
Apr 13 2017 03:58
junipberry sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1289 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Darth Skywalker
@adityaparab
Apr 13 2017 03:58
or you can just date:date()
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 03:58
yw
Chris Cullen
@123xylem
Apr 13 2017 03:58
@adityaparab @SkyCoder01 thanks sky thats what i wanted... Thanks skywalker aswell for clarifying
CamperBot
@camperbot
Apr 13 2017 03:58
123xylem sends brownie points to @adityaparab and @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 990 | @adityaparab |http://www.freecodecamp.com/adityaparab
:star2: 1023 | @skycoder01 |http://www.freecodecamp.com/skycoder01
juni
@junipberry
Apr 13 2017 03:59
I really appreciate it~~
Darth Skywalker
@adityaparab
Apr 13 2017 03:59
@123xylem : Just to clarify it once again... Although date:date() seems to work, it is not the right way.
Heathercoraje
@Heathercoraje
Apr 13 2017 03:59
I am lost why is var ourArray = [];
for (var i = 0; i < 5; i++) {
ourArray.push(i);
} returns [0,1,2,3,4]? I feel like the final-expression of loop (i++) should make the array [0.1,2,3,4,5] because it is supposed to +1?
Wing Ng
@citrusapple
Apr 13 2017 03:59
@HeebieGeeBee thanks for the crash course series link. Sad that PBS is getting funding cut... bye elmo
CamperBot
@camperbot
Apr 13 2017 03:59
citrusapple sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1290 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Chris Cullen
@123xylem
Apr 13 2017 04:00
@adityaparab because i give a value under type?
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 04:00
@citrusapple lol
yw
Gulsvi
@gulsvi
Apr 13 2017 04:00
@Heathercoraje Because the loop goes until i < 5, if it was i <= 5, it would include 5 in the array
Darth Skywalker
@adityaparab
Apr 13 2017 04:00

@Heathercoraje : That's because your loop condition is i < 5 when your i is 4 and you do i++, i becomes 5.

And 5<5 is false.

becase 5 is equal to 5 and not <5. So your loop exits
Gulsvi
@gulsvi
Apr 13 2017 04:01
:)
Darth Skywalker
@adityaparab
Apr 13 2017 04:01
@123xylem Yes. It should be type. It will later result in surprising issues when you begin scaling ;)
So if it's type, set type. Separate value concern from type concern
always
Aaron Bell
@awb715
Apr 13 2017 04:02
anyone sitting at a computer with 2 peope?
Heathercoraje
@Heathercoraje
Apr 13 2017 04:02
@adityaparab Understood. thank you. I did pass the challenge but I just didnt want to move on with this confusion.
CamperBot
@camperbot
Apr 13 2017 04:02
heathercoraje sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:warning: heathercoraje already gave adityaparab points
Chris Cullen
@123xylem
Apr 13 2017 04:02
@adityaparab ok.. well the code above doesnt work anyway with type.. i guess they wont let me do it like that
Darth Skywalker
@adityaparab
Apr 13 2017 04:02
@123xylem Show your full code
Gulsvi
@gulsvi
Apr 13 2017 04:03
@awb715 2 people in front of 2 computers, same desk
Wing Ng
@citrusapple
Apr 13 2017 04:03
@awb715 nice, coding budies
Chris Cullen
@123xylem
Apr 13 2017 04:03
@adityaparab
var mongoose=require("mongoose")


var date = () => Date.now();

var postSchema= new mongoose.Schema({
    name:String,
    image:String,
    text:String,
    author:{
        id:{
            type:mongoose.Schema.Types.ObjectId,
        ref:"user"},
        username:String
    },
    date:date()
});

module.exports=  mongoose.model("post",postSchema);
Havent got to the saving part yet
Darth Skywalker
@adityaparab
Apr 13 2017 04:04
@123xylem : Try this
var mongoose=require("mongoose")


var date = () => Date.now();

var postSchema= new mongoose.Schema({
    name:String,
    image:String,
    text:String,
    author:{
        id:{
            type:mongoose.Schema.Types.ObjectId,
            ref:"user"
        },
        username:String
    },
    date:{ type : Date, default: Date.now }
});

module.exports=  mongoose.model("post",postSchema);
and get rid of that var date = () => Date.now();
Chris Cullen
@123xylem
Apr 13 2017 04:05
@adityaparab :) :) :) :thumbsup:
Darth Skywalker
@adityaparab
Apr 13 2017 04:06
@123xylem :+1:
Aaron Bell
@awb715
Apr 13 2017 04:07
@SkyCoder01 @citrusapple 2 player version is approaching completion
letme know what you think
Gulsvi
@gulsvi
Apr 13 2017 04:12
@awb715 I like it, but that's because it's easy to beat my gf :p
Would be nice to have a reset button of course, but I'm guessing you're working on that
Didn't notice any problems
Aaron Bell
@awb715
Apr 13 2017 04:13
yes, reset coming
the hard part will bethe AI for the computer
juni
@junipberry
Apr 13 2017 04:15
I have a general question, if I need an attribute like return but don't want to use it just yet bc it will close my loop..what else can I use other then console.log?
Manish Giri
@Manish-Giri
Apr 13 2017 04:17
@junipberry why not console log?
Gulsvi
@gulsvi
Apr 13 2017 04:18
If you need to store the data to return it later, you can save it to a variable or push() it to an array and then return that variable or array after the for loop is finished @junipberry
Sandesh Shrestha
@UnovaXan
Apr 13 2017 04:19

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

I don't understand what I need to do here
Wing Ng
@citrusapple
Apr 13 2017 04:22
@awb715 worked just fine for me, I am far from tic tac toe, but does it require that you say who wins at the end?
Aaron Bell
@awb715
Apr 13 2017 04:23
im still working on that @citrusapple
you can see the beginning of that being implemented now if you make someone win
juni
@junipberry
Apr 13 2017 04:24
@SkyCoder01 what happens if the variable I save it to has a return
like for example I need to sort within a loop
Wing Ng
@citrusapple
Apr 13 2017 04:25
@awb715 good luck!
juni
@junipberry
Apr 13 2017 04:25
but a sort requires a return after it, doesnt it
Wing Ng
@citrusapple
Apr 13 2017 04:25
@UnovaXan if I remember correctly, you're supposed to define variables
juni
@junipberry
Apr 13 2017 04:26
like myArray[i].sort(function(b,a) {
return b-a}); @SkyCoder01 @Manish-Giri
Gulsvi
@gulsvi
Apr 13 2017 04:27
@junipberry That should be fine because the return will be used to define that variable and not exit the loop. Though, I can't think of a time that you would have to sort on every iteration of a for loop.
There is probably a more efficient way to do it, I mean. Usually it's not a good practice to run a function inside a for() loop, but there are exceptions.
juni
@junipberry
Apr 13 2017 04:28
I have an array of strings I want to sort from greatest to least
Manish Giri
@Manish-Giri
Apr 13 2017 04:28
I'm not sure what we were discussing
juni
@junipberry
Apr 13 2017 04:28
then return the first number of each
Manish Giri
@Manish-Giri
Apr 13 2017 04:28
@junipberry you don't want a return?
Wing Ng
@citrusapple
Apr 13 2017 04:28
@UnovaXan nvm I think it's concatenating?
Sandesh Shrestha
@UnovaXan
Apr 13 2017 04:28
@citrusapple Figured it out. I was supposed to create a sentence out of those variables with extra words of my own.
juni
@junipberry
Apr 13 2017 04:29
hmm..so I shouldnt use a sort inside a loop?
yes, I dont want a return bc it would close my loop @Manish-Giri
Sandesh Shrestha
@UnovaXan
Apr 13 2017 04:29
there are several sorting algorithms out there
you can sort them and then take out the first no. of the array
juni
@junipberry
Apr 13 2017 04:30
I need to be inside the loop still to console.log later to get the array[i][0]
Manish Giri
@Manish-Giri
Apr 13 2017 04:30
@junipberry a return inside a callback to sort won't terminate your loop
Sandesh Shrestha
@UnovaXan
Apr 13 2017 04:30
that would be either the least or the greatest
juni
@junipberry
Apr 13 2017 04:30
ahh
rugano
@rugano
Apr 13 2017 04:32
Hello campers
juni
@junipberry
Apr 13 2017 04:33
ok ty @Manish-Giri ty @SkyCoder01
Ill try what I have here
CamperBot
@camperbot
Apr 13 2017 04:33
junipberry sends brownie points to @manish-giri and @skycoder01 :sparkles: :thumbsup: :sparkles:
:star2: 1024 | @skycoder01 |http://www.freecodecamp.com/skycoder01
:star2: 5139 | @manish-giri |http://www.freecodecamp.com/manish-giri
DJToners
@DJToners
Apr 13 2017 04:34

// Declare your variable here

var myGlobal =10 ;
function fun1(oopsGlobal) {
  // Assign 5 to oopsGlobal Here
    oopsGlobal = 5;
}

// Only change code above this line
function fun2() {
  var output = "";
  if (typeof myGlobal != "undefined") {
    output += "myGlobal: " + myGlobal;
  }
  if (typeof oopsGlobal != "undefined") {
    output += " oopsGlobal: " + oopsGlobal;
  }
  console.log(output);
}
what am i doing wrong?
Gulsvi
@gulsvi
Apr 13 2017 04:34
@junipberry Is this for "Return Largest Numbers in Arrays?" (I have to be careful not to give away the answer lol)
Duy khanh
@buiduykhanh
Apr 13 2017 04:34
hi i dont know what im wrong any one can help ?
juni
@junipberry
Apr 13 2017 04:34
lol yes it is @SkyCoder01
Duy khanh
@buiduykhanh
Apr 13 2017 04:34

function palindrome(str) {
// Good luck!
var a =str.replace(/\W/g, '').toLowerCase().split("");
var b = a.reverse();
if(a==b){
return true;
}
else{
return false;
}
}

palindrome("eye");

Darth Skywalker
@adityaparab
Apr 13 2017 04:37
@hackedWifi You're returning too early.
Manish Giri
@Manish-Giri
Apr 13 2017 04:38
@buiduykhanh it would be better if you compare two strings instead of two arrays
James Long
@KingJames101
Apr 13 2017 04:38
Hey guys, I'm on the Word blanks challenge, and I'm not quite sure what it wants from me. I get stringing for the most part, but its more of me not knowing the wordplay situation. This is what I have:

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "The dog was big and ran very quickly";
// 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");

Augusto
@hackedWifi
Apr 13 2017 04:38
I just need to know why is this code not working.
juni
@junipberry
Apr 13 2017 04:38
this is what I have for return largest number
Augusto
@hackedWifi
Apr 13 2017 04:39

function largestOfFour(arr) {
// You can do this!

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

    }
  }

return max;

}

} `

juni
@junipberry
Apr 13 2017 04:39
function largestOfFour(str) {
  // You can do this!
var myArray = str.split('],');  
  for (var i=0; i<arr.length; i++) {
   myArray[i] = myArray[i].sort(function(b,a) {
   return (b-a);});
    console.log([i][0]);
}
var joined = myArray.join(' , ');

    return joined;}
@Manish-Giri @SkyCoder01
can you tell me why its not working
James Long
@KingJames101
Apr 13 2017 04:39

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.

And this is the precise instructions
Manish Giri
@Manish-Giri
Apr 13 2017 04:39
@junipberry why do you have .sort() in a loop?
James Long
@KingJames101
Apr 13 2017 04:39
*these
rugano
@rugano
Apr 13 2017 04:39
I am making a Madlibs style word blank game . why is my result wrong? code: function wordBlanks(myNoun,myAdjective,myVerb,myAdverb){var result = ""; result = 'dog\"is a\"big\"animal and\"ran\"people\"quickly\"sometimes\".'; return result;}
Wing Ng
@citrusapple
Apr 13 2017 04:39

Hey all, I'm at Title Case a Sentence and my code is returning what it demands but it's not passing me.... why? bug?

function titleCase(str) {//[i gOt tHIs]
  var string = str.toLowerCase(); // [i got this]
  var stringLow = string.replace(/\s\w/gi,function (x){
    return x[1].toUpperCase() ;
  });//(iGotThis)
var newString = stringLow.charAt(0).toUpperCase() + stringLow.slice(1);//(IGotThis)
newString = newString.replace(/([A-Z])/g,' $1');
  return newString;
}


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

the code returns "I'm A Little Tea Pot" when argument is "I'm a little tea pot" but I still have a big red X next to it

juni
@junipberry
Apr 13 2017 04:40
bc I want to sort from greatest to least @Manish-Giri
Manish Giri
@Manish-Giri
Apr 13 2017 04:40
@junipberry the callback you pass to .sort() takes care of sorting from greatest to lowest
you don't need a loop to put .sort() in.
Gulsvi
@gulsvi
Apr 13 2017 04:41
@junipberry An array is not a string and .split() only works on strings
Duy khanh
@buiduykhanh
Apr 13 2017 04:41
@Manish-Giri thanks u i done that :D im wrong :D
CamperBot
@camperbot
Apr 13 2017 04:41
buiduykhanh sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5140 | @manish-giri |http://www.freecodecamp.com/manish-giri
juni
@junipberry
Apr 13 2017 04:42
ahh good point @SkyCoder01 okay Ill rid that now.
ok got it @Manish-Giri Ill fix that too
ty guys
CamperBot
@camperbot
Apr 13 2017 04:42
junipberry sends brownie points to @skycoder01 and @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: junipberry already gave skycoder01 points
:warning: junipberry already gave manish-giri points
h1tag
@h1tag
Apr 13 2017 04:43
@KingJames101
var result = "The dog was big and ran very quickly";
You're not using the variables here, you're using their literal value (keep in mind that these variables will change from a call to call to the function)
Augusto
@hackedWifi
Apr 13 2017 04:43
can anyone help me on here about this code not returning the proper answer

function largestOfFour(arr) {
// You can do this!

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

    }

  }

return max;

}
//return max;
}

Darth Skywalker
@adityaparab
Apr 13 2017 04:44
@hackedWifi You're returning way too early...
Augusto
@hackedWifi
Apr 13 2017 04:44
@adityaparab why do you mean
Darth Skywalker
@adityaparab
Apr 13 2017 04:45

you can maintain a separate array and push max to that array instead of returning max.

When both loops are over, just return the new array that contains all the max values

@hackedWifi
juni
@junipberry
Apr 13 2017 04:47
@Manish-Giri I need sort within the function bc I dont just want to sort the arrays inside the array. I want to sort the within each individual array
Manish Giri
@Manish-Giri
Apr 13 2017 04:51
@junipberry okay I see
Augusto
@hackedWifi
Apr 13 2017 04:55
@adityaparab I got it to work I just had to create an empy array of items and push it
Darth Skywalker
@adityaparab
Apr 13 2017 04:55
@hackedWifi :+1:
juni
@junipberry
Apr 13 2017 04:55
@Manish-Giri can you check out why this is not displaying in the console
function largestOfFour(arr) {
  // You can do this!
  for (var i=0; i<arr.length; i++) {
  var sorted = arr.sort(function(b,a) {
    return (b-a);});
    console.log([i][0]);
}
}
Darth Skywalker
@adityaparab
Apr 13 2017 04:55
You understood what you were doing wrong, correct?
Manish Giri
@Manish-Giri
Apr 13 2017 04:56
@junipberry I just redid that challenge, with .forEach and sort()..
Darth Skywalker
@adityaparab
Apr 13 2017 04:56
@junipberry : arr.sort(function(b,a) { should be arr[i].sort(function(b,a) {
and then console.log(sorted[0])
Manish Giri
@Manish-Giri
Apr 13 2017 04:57
@junipberry arr is the outermost array, so you need arr[i] to refer to individual sub arrays in arr
juni
@junipberry
Apr 13 2017 04:57
ahh~~ right. ty @adityaparab
CamperBot
@camperbot
Apr 13 2017 04:57
junipberry sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 991 | @adityaparab |http://www.freecodecamp.com/adityaparab
Manish Giri
@Manish-Giri
Apr 13 2017 04:58
oh, also you could use .map() for the last step
@junipberry
juni
@junipberry
Apr 13 2017 04:58
yea I could. But Im not, Im using a simple loop.
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 04:58
@Manish-Giri yo, do you know i have a json file on heroku that gets updated by client side, but when i restart the server the data is no longer stored in the json file
juni
@junipberry
Apr 13 2017 04:58
thinking of using it for everything..
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 04:58
any ideas why that might be?
Gulsvi
@gulsvi
Apr 13 2017 04:59
@junipberry Your code is really close as you have it now
juni
@junipberry
Apr 13 2017 04:59
or is this a bad idea.
ok ty brb in a few mins..Ill try to fix it
Darth Skywalker
@adityaparab
Apr 13 2017 04:59
@junipberry Your sorting logic is also reverse. You're sorting in ascending order, For your largest element to be first, you need to sort in descending order. From your sort callback return a-b instead of b-a
Gulsvi
@gulsvi
Apr 13 2017 05:00
@junipberry Be sure to sort the subarray, not the original array as you go through the loop. And keep in mind the difference between a-b and b-a
Manish Giri
@Manish-Giri
Apr 13 2017 05:00
@HeebieGeeBee um, hold on
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:00
@Manish-Giri by the way i had the same error message on jeroku earlier and i jsut did the same thing coped the repository and tries to deply again and it worked
@Manish-Giri another new picture?
not sure i can handle all this
Manish Giri
@Manish-Giri
Apr 13 2017 05:00
@HeebieGeeBee :see_no_evil: :stuck_out_tongue:
Joseph
@revisualize
Apr 13 2017 05:01
Hey
Manish Giri
@Manish-Giri
Apr 13 2017 05:01
she's amazing in the thor trailer
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:01
fair enough
i havent watched any of those super hero films
juni
@junipberry
Apr 13 2017 05:01
I just watched the trailer for ragnarok today
w cate blanchett as hela?
Manish Giri
@Manish-Giri
Apr 13 2017 05:02
yiss
she's amazing
juni
@junipberry
Apr 13 2017 05:02
she looked right for the part from what little I saw lol
Manish Giri
@Manish-Giri
Apr 13 2017 05:03
@HeebieGeeBee are you using something like persist?
James Long
@KingJames101
Apr 13 2017 05:03
Alright guys, here is what I have, and I'm still missing something. I'm trying to create a 'fill in the blank' sentence.

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result = 'The "dog"\ was \"big"\ and \"ran"\ very \"quickly"';
// Your code above this line
return result;
}

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

HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:03
no, is that a function i need to use or summin ? @Manish-Giri
James Long
@KingJames101
Apr 13 2017 05:04
Please help! -_-
Been on this one for 2 days now..
Gulsvi
@gulsvi
Apr 13 2017 05:04
@KingJames101 That returns this string: "The 'dog' was 'big' and 'ran' very 'quickly'"
Bryan Reed
@Bronsky91
Apr 13 2017 05:05
Can anyone tell why this doesn't return anything?
function getMax(arr) {
  return Math.max.apply(arr);
}

function largestOfFour(arr) {
  var largest;
  for (i=0 ; i > 5 ; i++) {
   largest = getMax(arr[i]);

  }
  return largest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Manish Giri
@Manish-Giri
Apr 13 2017 05:05
@HeebieGeeBee https://www.npmjs.com/package/persist
I used it once for making a password app
it persists things even after restarts
Coy Sanders
@coymeetsworld
Apr 13 2017 05:05
@Bronsky91 for loop never runs
largest stays undefined
juni
@junipberry
Apr 13 2017 05:06
any btw guys, Im not getting what youre saying .. b-a IS descending..is it not
*and
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:06
@Manish-Giri im using fs write file
Gulsvi
@gulsvi
Apr 13 2017 05:06
@junipberry b-a is descending if your arguments are a,b
James Long
@KingJames101
Apr 13 2017 05:06
Yes. I'm trying to figure out how to set up the fill in the blank. result = 'The was and very';?
juni
@junipberry
Apr 13 2017 05:06
it is
Manish Giri
@Manish-Giri
Apr 13 2017 05:06
@junipberry
arr.sort(function(b,a) {
    return (b-a);}
juni
@junipberry
Apr 13 2017 05:06
thats what I have
Manish Giri
@Manish-Giri
Apr 13 2017 05:06
change the arguments to a and b
instead of b and a
Bryan Reed
@Bronsky91
Apr 13 2017 05:06
@coymeetsworld What is preventing it from running?
Manish Giri
@Manish-Giri
Apr 13 2017 05:06
then it is descending
@junipberry
juni
@junipberry
Apr 13 2017 05:07
ohh my bad
Coy Sanders
@coymeetsworld
Apr 13 2017 05:07
the conditional statement in your for loop
Darth Skywalker
@adityaparab
Apr 13 2017 05:07
@Bronsky91 Your loop condition is wrong. i=0 and i > 5 (0 is alwats less than 5 so your loop never runs)
juni
@junipberry
Apr 13 2017 05:07
ok ty @Manish-Giri
CamperBot
@camperbot
Apr 13 2017 05:07
junipberry sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: junipberry already gave manish-giri points
juni
@junipberry
Apr 13 2017 05:07
ty @adityaparab
CamperBot
@camperbot
Apr 13 2017 05:07
junipberry sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:warning: junipberry already gave adityaparab points
Coy Sanders
@coymeetsworld
Apr 13 2017 05:07
your loop is saying, initialize i to 0, when i is greater than 5 run the statement
Bryan Reed
@Bronsky91
Apr 13 2017 05:07
LOL
Thanks XD
Manish Giri
@Manish-Giri
Apr 13 2017 05:07
@HeebieGeeBee oh kay, tagging @Marmiz pretty sure he'd know
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:09
@Manish-Giri it was working for another project earlier fine like running local
Bryan Reed
@Bronsky91
Apr 13 2017 05:09
@coymeetsworld When it change it to start the for loop until it's at i < 5 it gives me null
James Long
@KingJames101
Apr 13 2017 05:09
Please some one help. It's killing me that I can't figure this out
Darth Skywalker
@adityaparab
Apr 13 2017 05:09
@Bronsky91
function getMax(arr) {
  return Math.max.apply(null, arr); // first argument needs to be null, since you want to spread contents of arr as parameters to Math.max
}

function largestOfFour(arr) {
  var largest = []; // this needs to be an array that holds the largest number from each sub array
  for (i=0 ; i < arr.length ; i++) { // run loop till arr.length
   largest.push(getMax(arr[i]));
  }
  return largest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
see comments inline
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:10
but i dont know how the heroku handles the server side files between restarts
Manish Giri
@Manish-Giri
Apr 13 2017 05:10
heroku is so crappy
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:10
im guessing it just restarts from the original repo
Bryan Reed
@Bronsky91
Apr 13 2017 05:10
@adityaparab Thank you!!!
Darth Skywalker
@adityaparab
Apr 13 2017 05:10
@HeebieGeeBee : It will checkout code from your registered git repo
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:11
yeah so how would i get it to store the json file that have all the changes made on it
wrote all the code for him @adityaparab ? :)
Bryan Reed
@Bronsky91
Apr 13 2017 05:12
that's definitely what I was missing
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:13
hmm reading and looks like i need to write to an external database or summin
Darth Skywalker
@adityaparab
Apr 13 2017 05:14
@coymeetsworld I just filled in the blanks... Since he had it all sorted out with logic and code flow.. So don't think much explanation was needed in that department. :)
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:14
geuss thats fair enough
Darth Skywalker
@adityaparab
Apr 13 2017 05:15
@HeebieGeeBee DB should be a good options. As a rule of thumb never maintain static files.
to store data, specifically
juni
@junipberry
Apr 13 2017 05:16
wait, @SkyCoder01 why would I console.log(sort[0]); instead of sort[i]?
Coy Sanders
@coymeetsworld
Apr 13 2017 05:16
depends on how much data to store, but yeah not that many good reasons to use text files to store data
juni
@junipberry
Apr 13 2017 05:16
isnt that just sorting the outer array?
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:16
@adityaparab yeah
juni
@junipberry
Apr 13 2017 05:16
I want to sort the inner array
Darth Skywalker
@adityaparab
Apr 13 2017 05:16
@junipberry Show your updated code.
Gulsvi
@gulsvi
Apr 13 2017 05:16
@junipberry If you want the largest element of the array, after it is sorted, it will be [0]
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:16
and heroku resets every 24 hours or summin too
Darth Skywalker
@adityaparab
Apr 13 2017 05:17
@HeebieGeeBee Welcome to the free world ;)
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:17
something called an ephemeral file system
Gulsvi
@gulsvi
Apr 13 2017 05:17
Assuming you're sorting descending
juni
@junipberry
Apr 13 2017 05:17
but I am still within the loop..after just having had sorted it
Manish Giri
@Manish-Giri
Apr 13 2017 05:17
@junipberry check your pm
juni
@junipberry
Apr 13 2017 05:17
dont I need something like [0][i]
ok
Gulsvi
@gulsvi
Apr 13 2017 05:18
Sounds like Manish is going to help you finish this one :) it's bedtime for me, good luck getting everything sorted
juni
@junipberry
Apr 13 2017 05:18
ohh okay
Manish Giri
@Manish-Giri
Apr 13 2017 05:18
nope nope
Gulsvi
@gulsvi
Apr 13 2017 05:19
(pun intended)
Manish Giri
@Manish-Giri
Apr 13 2017 05:19
@SkyCoder01 gnight
juni
@junipberry
Apr 13 2017 05:19
ty @Manish-Giri ty @SkyCoder01
CamperBot
@camperbot
Apr 13 2017 05:19
junipberry sends brownie points to @manish-giri and @skycoder01 :sparkles: :thumbsup: :sparkles:
:warning: junipberry already gave skycoder01 points
:warning: junipberry already gave manish-giri points
Manish Giri
@Manish-Giri
Apr 13 2017 05:19
:wave:
Gulsvi
@gulsvi
Apr 13 2017 05:19
:wave:
juni
@junipberry
Apr 13 2017 05:19
*clap clap
Heathercoraje
@Heathercoraje
Apr 13 2017 05:20
product = product * arr[i][j];
what does this arr[i][j] means?
multiply product by arr[i] and arr[j]?
Darth Skywalker
@adityaparab
Apr 13 2017 05:21
@Heathercoraje it means multiply product by jth element in ith array inside arr
Conor Murphy
@cmurphy580
Apr 13 2017 05:22
does anyone know how to override the native Function.prototype.bind method by a new one that will allow you to rebind context multiple times?
juni
@junipberry
Apr 13 2017 05:22
ok ty@manish but I want to try solving this w a simple loop instead of w foreach and map..
I want to figure out what Im doing wrong here
Darth Skywalker
@adityaparab
Apr 13 2017 05:23
the same way @cmurphy580 :
Function.prototype.bind = function () { 
  // your new bind definition
}
Manish Giri
@Manish-Giri
Apr 13 2017 05:23
@junipberry cool, you're done with the first step I think
for the last one, you can create an array and push to it from within the loop
juni
@junipberry
Apr 13 2017 05:25
hmm..would it be wrong to just console.log the [0] to each array
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:25
@Heathercoraje arr[i][j] just accesses a value
James Long
@KingJames101
Apr 13 2017 05:25

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result+= "My "+dog+" was "+big+" and "+ran+" very "+quickly+".";
// Your code above this line
return result;
}

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

Okay... Now what am I missing?

Manish Giri
@Manish-Giri
Apr 13 2017 05:25
@junipberry console.log to each array doesn't make sense
Coy Sanders
@coymeetsworld
Apr 13 2017 05:26
@KingJames101 your variable names aren't right
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:26
@KingJames101 youre meant to be using the function parameters
Manish Giri
@Manish-Giri
Apr 13 2017 05:26
console.log simply prints to the console
Coy Sanders
@coymeetsworld
Apr 13 2017 05:26
instead of variables like dog, you want to use the parameters you're passing into the function (myNoun)
Manish Giri
@Manish-Giri
Apr 13 2017 05:26
nothing to do with arrays
@junipberry
Conor Murphy
@cmurphy580
Apr 13 2017 05:27
@adityaparab i have no idea what to do on this. I would want to reset the what the function is attached to. How would I go about doing that
James Long
@KingJames101
Apr 13 2017 05:27
What should my variable names be?
juni
@junipberry
Apr 13 2017 05:27
well, if I want to console.log the [0] of each array, doesnt that make sense?
James Long
@KingJames101
Apr 13 2017 05:28
And function in the place of result?
Manish Giri
@Manish-Giri
Apr 13 2017 05:28
if I want to console.log the [0] of each array,
if to test things then yes
Coy Sanders
@coymeetsworld
Apr 13 2017 05:28
@KingJames101 the ones defined in wordBlanks
HeebieGeeBee
@HeebieGeeBee
Apr 13 2017 05:29
@junipberry conslole.logging is just to help with debugging and stuff
Coy Sanders
@coymeetsworld
Apr 13 2017 05:29
myNoun, myAdjective, myVerb, myAdverb
Heathercoraje
@Heathercoraje
Apr 13 2017 05:29
@adityaparab I don't understand..
Manish Giri
@Manish-Giri
Apr 13 2017 05:29
@junipberry eventually you need to return an array with the largest number from each sub array
Coy Sanders
@coymeetsworld
Apr 13 2017 05:29
when you call wordBlanks("dog", "big", "ran", "quickly");, myNoun is "dog", myAdjective is "big", etc
juni
@junipberry
Apr 13 2017 05:30
ok, I get that..cant I do that inside the loop?
James Long
@KingJames101
Apr 13 2017 05:30
Oh shit! Aha, thanks! @coymeetsworld
CamperBot
@camperbot
Apr 13 2017 05:30
kingjames101 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2453 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Apr 13 2017 05:30
yw @KingJames101
James Long
@KingJames101
Apr 13 2017 05:30
@HeebieGeeBee Thanks!
CamperBot
@camperbot
Apr 13 2017 05:30
kingjames101 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1291 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Manish Giri
@Manish-Giri
Apr 13 2017 05:30
@junipberry which bit
you cant return from inside for
juni
@junipberry
Apr 13 2017 05:31
oh why not
Manish Giri
@Manish-Giri
Apr 13 2017 05:31
because it will terminate the function itself
juni
@junipberry
Apr 13 2017 05:32
thats fine though..bc Ill be done after returning it ..wouldnt i
Manish Giri
@Manish-Giri
Apr 13 2017 05:32
can you show the code you mean
juni
@junipberry
Apr 13 2017 05:35
ok one sec
jaime
@jsaucedo1984
Apr 13 2017 05:35
I need help with "Understand String Immutability"
Darth Skywalker
@adityaparab
Apr 13 2017 05:36
@cmurphy580 : Can you explain it a bit more.. I'm not able to understand what you're trying to achieve exactly
jaime
@jsaucedo1984
Apr 13 2017 05:36

'''
// Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me '''

CamperBot
@camperbot
Apr 13 2017 05:36
:bulb: to format code use backticks! ``` more info
juni
@junipberry
Apr 13 2017 05:37
function largestOfFour(arr) {
  // You can do this!
  for (var i=0; i<arr.length; i++) {
  var sorted = arr[i].sort(function(a,b) {
    return (b-a);});
return sorted[0][i];
  }

}
Darth Skywalker
@adityaparab
Apr 13 2017 05:37
@Heathercoraje : Can you post your code?

@junipberry :

First, return a-b instead of b-a

Sencond, get rid of last return return sorted[0][i];

Heathercoraje
@Heathercoraje
Apr 13 2017 05:38
@adityaparab Actually I have passed the challenge itself but I didn't understand fully.
Augusto
@hackedWifi
Apr 13 2017 05:38
I really don't know if I am not understanding this exercise. But why this should return false confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification"
Heathercoraje
@Heathercoraje
Apr 13 2017 05:38

function multiplyAll(arr) {
var product = 1;

for (var i = 0; i < arr.length; i++) {
for (var j = 0; j <arr[i].length; j++) {
product = product * arr[i][j];
}
}

return product;

juni
@junipberry
Apr 13 2017 05:38
why @adityaparab I want descending order