These are chat archives for FreeCodeCamp/Help

30th
Jun 2015
jlin14
@jlin14
Jun 30 2015 00:56
anyone have a more elegant solution to html entities than chaining replace()?
gravesr1993
@gravesr1993
Jun 30 2015 01:05
I am confused, is this not the correct .event CSS declaration I needed to go to? http://puu.sh/iHFAk/b23a81d77e.png
Robert Ozimek
@robertozimek
Jun 30 2015 01:25
@gravesr1993 these devtools challenges are very buggy
try refreshing if that doesn’t work, then just skip it
Suzanne Atkinson
@AdventureBear
Jun 30 2015 01:27
hey does anyone know offhand the easiest way to start incorporating time values? I'm writing a script to help people determine their qualifying times for the Boston Marathon. Here's the qualifying times, I have already modified the times to be in H:MM:SS format. How to best represent this in JS? Not too experiecned workign with time/date objects. Basically if I need to do a lot of manipulation I'd rather manipulate these standard times before I encode them in a JS file.
AGE GROUP    MEN    WOMEN
18-34    3:05:00    3:35:00
35-39    3:10:00    3:40:00
40-44    3:15:00    3:45:00
45-49    3:25:00    3:55:00
50-54    3:30:00    4:00:00
55-59    3:40:00    4:10:00
60-64    3:55:00    4:25:00
65-69    4:10:00    4:40:00
70-74    4:25:00    4:55:00
75-79    4:40:00    5:10:00
80-115    4:55:00    5:25:00
And since they are alreayd in that format, if I DO need to encode them, would I need to parse them out? Can I do it in excel?
here's the (lame as of now) marathon training plan wizard...basically if their PR is within 30 minutes of BQ time, they will be recommended the advanced training plan.
http://codepen.io/AdventureBear/pen/WvdLBq?editors=100
Robert Ozimek
@robertozimek
Jun 30 2015 01:36
@AdventureBear I would say in JSON would be easiest if you could get in into that format
Suzanne Atkinson
@AdventureBear
Jun 30 2015 01:37
OK, please check again...that doesn't help me (yet)...once it's in JSON...trying to figure out how to manipulate the actual string re taking their input time & comparing to to the table.
Robert Ozimek
@robertozimek
Jun 30 2015 01:38
well JSON has specific formats for dates/times, so you would get date objects
or you can always use integers in your JSON and manipulate them
Cristián Berríos
@crisberrios
Jun 30 2015 01:42
hi Suzanne
Suzanne Atkinson
@AdventureBear
Jun 30 2015 01:42
Json has different formats than Javascript date/time objects? I'm not sure I follow. It looks like I can use strings in a specific format and convert to ms. Then I guess my 30 min difference can just be converted to ms also.
Robert Ozimek
@robertozimek
Jun 30 2015 01:43
@AdventureBear as for taking the input, you create an object that matches the format of your JSON
Suzanne Atkinson
@AdventureBear
Jun 30 2015 01:43
Hey @crisberrios !
Cristián Berríos
@crisberrios
Jun 30 2015 01:43
time right now = moment.js
don't leave home without it!
Robert Ozimek
@robertozimek
Jun 30 2015 01:43
well JSON = (JavaScript Object Notation)
so it’s made for javascript, so the formats can me turned into the ones neccessary for javascript
Cristián Berríos
@crisberrios
Jun 30 2015 01:45
but for very simple things you could go on with regex for input matching and converting to milliseconds or something like that
if you want to improve the input part, you could go on with a popup balloon that shows the actual time that's being entered
so if you input 12:36 it would show "12 minutes 36 seconds" in real-time
something like that, to improve feedback when multiple input formats are accepted, or input format can lead to errors
Suzanne Atkinson
@AdventureBear
Jun 30 2015 01:49
Ok good things to think about! My computer battery died so im on my mobile now and will just have to think about for now!
Thanks @robertozimek and Cris
Also this sounds lame, but instead best way to line up the labels and the input fields to put them in tables? I hope not! Nested divs? I'm Feeling out of practice!
Cristián Berríos
@crisberrios
Jun 30 2015 01:52
display: table... table-cell, etc... using css
unless in some specific cases where you are sure it's always going to be a table even in responsive mode
Suzanne Atkinson
@AdventureBear
Jun 30 2015 01:57
Right
Clay Holt
@tarwater
Jun 30 2015 02:27
can someone explain why "1" % 1 === 0; evaluates to true?
it's a string
Lightwaves
@Lightwaves
Jun 30 2015 02:28
lol and your using triple equals wow that is weird javascript is so quirky
Adam Rehard
@adamrehard
Jun 30 2015 02:28
I think It's implicit type. conversion.
Mike Semko
@MadOgre
Jun 30 2015 02:28
@tarwater because "1" autoconverts to 1 according to operator % autoconvert rules
Clay Holt
@tarwater
Jun 30 2015 02:29
i need my program to be able to tell the difference between 1 and '1'
Mike Semko
@MadOgre
Jun 30 2015 02:30
@tarwater you could use typeOf
if (typeOf x == "string") {
}
Clay Holt
@tarwater
Jun 30 2015 02:32
ah, I didn't know that was a thing, thank you
Logan Tegman
@ltegman
Jun 30 2015 02:32
@tarwater Can you do ’1’ === 1? It won't type convert if you’re directly using them in your triple equals comparison.
Clay Holt
@tarwater
Jun 30 2015 02:32
well it could be any number
Mike Semko
@MadOgre
Jun 30 2015 02:33
@ltegman yes that would actually work, what's important is the operator being used % autoconverts === doesn't
but I think typeOf is the most approved method
Tom DeFrank
@TomDeFrank
Jun 30 2015 02:45
yeah I agree with MadOgre
a = 2
b = "2"
console.log(a % b === 0 && typeof b === "number")
been quite few times that i wish js was more explicit
Mike Semko
@MadOgre
Jun 30 2015 02:53
@TomDeFrank I think it would be better to swap the conditions because of short circuit evaluation on the &&
a = 2
b = "2"
console.log(typeof b === "number" && a % b === 0 )
Tommy Izen
@TommyIzen
Jun 30 2015 02:53
Maybe I'm just tired but not sure what I'm doing wrong here.

Write an if / else statement inside the isEven function. It should return true; if the number it receives is evenly divisible by 2. Otherwise (else), it should return false;.

Make sure to return - don't use console.log()!

var isEven = function(number) {
if (number % 2)
{
return true;
}
else
{
return false;
}

};

Mike Semko
@MadOgre
Jun 30 2015 02:54
@TomDeFrank Although in this specific case it would work either way
Going AFK for 1 hour
Tommy Izen
@TommyIzen
Jun 30 2015 02:55
var isEven = function(number) {
  if (number % 2)
  {
    return true;
  }
  else
  {
    return false;
  }

};
ugh sorry for messing up the markup
Mike Semko
@MadOgre
Jun 30 2015 02:56
@TommyIzen You know you can edit your posts right ?
Tommy Izen
@TommyIzen
Jun 30 2015 02:56
ah i see
thanks
anyone see anything wrong with the above code?
Lightwaves
@Lightwaves
Jun 30 2015 02:59
@TommyIzen a number that divides evenly has a remainder of what
Tommy Izen
@TommyIzen
Jun 30 2015 02:59
0
Lightwaves
@Lightwaves
Jun 30 2015 03:00
look at your if statement
Tommy Izen
@TommyIzen
Jun 30 2015 03:01
if number is divisible by 2, return true, else false?
would it be false since number would be zero?
Lightwaves
@Lightwaves
Jun 30 2015 03:02
% returns the remainder
Tommy Izen
@TommyIzen
Jun 30 2015 03:02
right
so the remainder is zero
so the code should be
var isEven = function(number) {
  if (number % 2)
  {
    return false;
  }
  else
  {
    return true;
  }

};
Lightwaves
@Lightwaves
Jun 30 2015 03:03
not quite we need to check against what number % 2 returns if that is 0 then it's an even number
Tommy Izen
@TommyIzen
Jun 30 2015 03:04
ha
Code Academy thinks that's right
lol
Lightwaves
@Lightwaves
Jun 30 2015 03:04
seriously haha
actually that might just work
if number % 2 returns 0 it evaluates to false and skips to the else
wow that is terrible lol
Tommy Izen
@TommyIzen
Jun 30 2015 03:05
yeah
Lightwaves
@Lightwaves
Jun 30 2015 03:05
I guess that works haha
Tommy Izen
@TommyIzen
Jun 30 2015 03:05
well, it's boolean logic
0 is false
Lightwaves
@Lightwaves
Jun 30 2015 03:06
I tend to be explicit
with these things
Tommy Izen
@TommyIzen
Jun 30 2015 03:07
Explicit rather than imp;icit ftw!
implicit
thanks for the input @Lightwaves :)
How would you write it?
Lightwaves
@Lightwaves
Jun 30 2015 03:08
The Zen of Python
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
LOL that reminded me of that so I had too
Tommy Izen
@TommyIzen
Jun 30 2015 03:09
lol
Should this work?
Lightwaves
@Lightwaves
Jun 30 2015 03:09
Randomness and personal preference aside
Tommy Izen
@TommyIzen
Jun 30 2015 03:09
var isEven = function(number) {
  if (number % 2 === 0)
  {
    return false;
  }
  else
  {
    return true;
  }

};
ugh
nm
i just answered my own question
Lightwaves
@Lightwaves
Jun 30 2015 03:10
almost just needed to flip the logic so have it return true else false
Tommy Izen
@TommyIzen
Jun 30 2015 03:10
yep exactly
:)
thx man
Lightwaves
@Lightwaves
Jun 30 2015 03:10
honestly the way you did it wasn't bad I was just like wahh until I thought about it
Tommy Izen
@TommyIzen
Jun 30 2015 03:11
lol
they need to add some sort of social networking features in FCC so you can add people as friends, partners etc
that could be a project
Lightwaves
@Lightwaves
Jun 30 2015 03:14
would be a cool feature
Tommy Izen
@TommyIzen
Jun 30 2015 03:14
Def
Man the thing I hate about Code Academy is they teach you all these things in bits and pieces and you never wind up building anything useful with it
Lightwaves
@Lightwaves
Jun 30 2015 03:15
Honestly it's more a stepping stone/introduction.
Tommy Izen
@TommyIzen
Jun 30 2015 03:15
Yeah
Cristián Berríos
@crisberrios
Jun 30 2015 03:15
^
Tommy Izen
@TommyIzen
Jun 30 2015 03:16
Im just going through the waypoints
Tommy Izen
@TommyIzen
Jun 30 2015 03:22
So how am I supposed to use Screenhero if I don't have a Slack email?
Lightwaves
@Lightwaves
Jun 30 2015 03:23
you shouldn't need one but I could be wrong
Suzanne Atkinson
@AdventureBear
Jun 30 2015 03:45
@crisberrios moment.js looks pretty great!
@TommyIzen since switchgn to gitter there are a handful of outstanding things needing updated. You could submit an issue on github for that if its not already reported
Mike Semko
@MadOgre
Jun 30 2015 04:02
Back
So has anyone started on the intermediate bonfires ?
ramireznoe01
@ramireznoe01
Jun 30 2015 04:06
@MadOgre yup
Suzanne Atkinson
@AdventureBear
Jun 30 2015 04:11
@crisberrios I've made some progress...may seem simple, but i cleaned things up with bootstrap.
Can anyone tell me why my "submit" button isn't on it's own line?
Also how do I get form inputs to only fill 2 or 3 grid columns and not have the next row jump up the to that same line? Seems like I have to have every item wrapped in it's own div with many calssses.
jrandallhansen
@jrandallhansen
Jun 30 2015 04:17
Screen Shot 2015-06-29 at 8.58.07 PM.png
Did anyone encounter an issue on any of the bonfires in which they wrote working code that satisfies each test condition but the system didn't count as a 'correct' answer?
Rex Schrader
@SaintPeter
Jun 30 2015 04:18
@AdventureBear Ok . . problem #1 - you can't have a submit button in its own form.
Suzanne Atkinson
@AdventureBear
Jun 30 2015 04:18
I only did that b/c I was troubleshooting the line before...let me take that out.
Rex Schrader
@SaintPeter
Jun 30 2015 04:18
@AdventureBear Well . . I suppose you could, but you're not going to submit anything.
Teejay Parker
@TeejayParker
Jun 30 2015 04:20
Waypoint: Center Text with Bootstrap issue. in my h2 element, i typed { text-align: Center; } and gave me the outcome i wanted, but didn't give me credit.. i can only assume that though this gave the same end result, it wants me to do it a certain way?
Mike Semko
@MadOgre
Jun 30 2015 04:20
@ramireznoe01 I have completed the Create a Person one, but my test underneath the function returns underfined, does yours do that as well ?
Troy Leonard
@taleon
Jun 30 2015 04:20
@Majeye I believe you're supposed to use a bootstrap class
Suzanne Atkinson
@AdventureBear
Jun 30 2015 04:20
since i'm using jquery I wasn't sure if it mattered, like may be I don't need the form except to get the bootstrap responsiveness? Anyway I did take out all but one pair of <form> tags for the whole thing
Teejay Parker
@TeejayParker
Jun 30 2015 04:21
I suppose, but it seemed easier (and more efficient to do it this way.
Suzanne Atkinson
@AdventureBear
Jun 30 2015 04:21
@Majeye probabaly looking for "center" not "Center"?
oh take that back...yeah, it's a bootstrap lesson
Troy Leonard
@taleon
Jun 30 2015 04:21
putting style on element tags is discouraged generally
Teejay Parker
@TeejayParker
Jun 30 2015 04:21
nah, capitalization shouldn't matter for that specific class type. it wants the bootstrap, i get that, just saying there are 2 ways to accomplish this goal
Troy Leonard
@taleon
Jun 30 2015 04:21
better to separate style into css and apply classes
Teejay Parker
@TeejayParker
Jun 30 2015 04:21
i suppose
Thank you for the feedback, i'll keep it in mind :)
Suzanne Atkinson
@AdventureBear
Jun 30 2015 04:24
right, well...it's a lesson teaching bootstrap. If you know it then don't worry abou tit.
I know the caps shouldn't matter for the effect, but you were asking about the test
Teejay Parker
@TeejayParker
Jun 30 2015 04:24
true :)
Suzanne Atkinson
@AdventureBear
Jun 30 2015 04:24
so I was offering some ideas !
Teejay Parker
@TeejayParker
Jun 30 2015 04:24
thanks again haha <3
Rex Schrader
@SaintPeter
Jun 30 2015 04:24
Man, I'm looking at it but not making much progress
I've solved a similar situation in the past by mixing regular and inline forms
Troy Leonard
@taleon
Jun 30 2015 04:27
@AdventureBear you could use the btn-block class to move it to it's own line and resize as you'd like
and float to whichever side you want it on
would also need to do a clear: both; though
Suzanne Atkinson
@AdventureBear
Jun 30 2015 04:28
Is there a way to "end" an inline form? even with the inline form I had to use the sizing class to get them to be smaller. @taleon I'll try that
Troy Leonard
@taleon
Jun 30 2015 04:29
so you're just trying to shrink the inputs so they don't take up the full width?
Rex Schrader
@SaintPeter
Jun 30 2015 04:30
@AdventureBear HEre is a solution I used on some production code: http://codepen.io/SaintPeter/pen/bdYdJW
Cristián Berríos
@crisberrios
Jun 30 2015 04:31
@AdventureBear bootstrap requires a lot of divs with a lot of classes :( I'm using react-bootstrap no a small project so the jsx syntax looks more clean
Rex Schrader
@SaintPeter
Jun 30 2015 04:31
@AdventureBear I think that I modified the .form-group .col-md-6 to remove the margin.
Suzanne Atkinson
@AdventureBear
Jun 30 2015 04:31
thanks gys, I'll check it out again in the AM after some sleep...looking better though!
@crisberrios is that just a css library or do I need to also be using react with it? So much to learn!!
@taleon yes... the inputs are just 2 digit numbers and it seems hard to read to me when they take up the full width
Cristián Berríos
@crisberrios
Jun 30 2015 04:32
it's for react but mostly a bootstrap wrapper
it won't help you learn bootstrap
I think I'll be doing the course that's on edx
or something in Pluralsight or tutsplus
Suzanne Atkinson
@AdventureBear
Jun 30 2015 04:33
lol. And People say they don't like angular b/c it injects so much stuff into the HTML.
Cristián Berríos
@crisberrios
Jun 30 2015 04:33
as it's used a lot on the job
Suzanne Atkinson
@AdventureBear
Jun 30 2015 04:33
Right.
Ok, time for bed. thanks everyone, goodnight for now!!
Troy Leonard
@taleon
Jun 30 2015 04:34
@AdventureBear you can give .form-group a set width (fixed or %)
then margin: 0 auto to center
Suzanne Atkinson
@AdventureBear
Jun 30 2015 04:34
OK, cool, I'll try that.
Troy Leonard
@taleon
Jun 30 2015 04:34
but g'night!
Rob Colella
@robcolella
Jun 30 2015 04:52
Hey, has anyone done the Where art though bonfire? I am having trouble with really starting on this. I understand you can use Object.keys to break down each element of the array into a number. I am guessing you can use these to compare the first to the second. But not sure how to pull the actual string values to compare.
Rex Schrader
@SaintPeter
Jun 30 2015 04:53
@robcolella Do you have any code to share?
Mario Mitchell
@undergroundfx
Jun 30 2015 04:54
Does know how to produce the following code in a for loop? I'm trying to create 9
$('#8').click(function() { addtogame('#8'); });
Rex Schrader
@SaintPeter
Jun 30 2015 04:55
@undergroundfx You mean How do you generate all 9 of those progrematically?
Mario Mitchell
@undergroundfx
Jun 30 2015 04:55
yes
numbered 0-9
trying to refactor my tic-tac-toe game theres alot of non DRY
Rex Schrader
@SaintPeter
Jun 30 2015 04:57
for(i=0; i < 10; i++) {
     $('#' + i).click(function() { addtogame('#' + i); });
}
They're going to be numbered 0-8
The + operator in a string context concatenates
Mario Mitchell
@undergroundfx
Jun 30 2015 04:57
thats what I thought, I thought I tried that but must have had something wrong
Rob Colella
@robcolella
Jun 30 2015 04:57
Nothing beyond a console.log of the keys. I can loop through each value to break it up, but still dont know how to get the string values associated with it. I know it says to use object.hasOwnProperty but with that you have to specify a specific string it looks like
Mario Mitchell
@undergroundfx
Jun 30 2015 04:58
also I got a warning not to create a function in a loop.. what that all about?
Rob Colella
@robcolella
Jun 30 2015 04:58
function where(collection, source) {
  var first = Object.keys(collection);
  var second = Object.keys(source);
  for(var i = 0; i < first.length; i ++) {
      console.log(first);
      console.log(second);
  }
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Mario Mitchell
@undergroundfx
Jun 30 2015 04:58
thanks @SaintPeter
Rex Schrader
@SaintPeter
Jun 30 2015 04:59
@robcolella You can access the key like this: collection[first[i]]
@robcolella In general there are two ways to access a key for an object:
obj.keyname or obj['keyname']
Mario Mitchell
@undergroundfx
Jun 30 2015 05:01
@SaintPeter its not working because I need i to be a string. I need the selector to be $('#1') ?
Rob Colella
@robcolella
Jun 30 2015 05:03
omg... @SaintPeter You are the man. I didnt see that on the mdn page. I must of missed it
Rex Schrader
@SaintPeter
Jun 30 2015 05:03
@undergroundfx The selector is a string - $('#' + i) should generate 9 unique strings
@robcolella No problem :) - they talk about it a lot in the videos, I thought
@undergroundfx Alternate solution: Assign a class to all of your spaces. Like ".space" or whatver. Write your functions (the one that addtogame uses) to reference $(this)
Since clicking on a button will have this defined
Mario Mitchell
@undergroundfx
Jun 30 2015 05:05
but doesnt a jquery selector need a ' ' around it to work? this would produce '#'4
below is the could I'm trying to create programattically
$('#9').click(function() {
  addtogame('#9');
});

$('#8').click(function() {
  addtogame('#8');
});

$('#7').click(function() {
  addtogame('#7');
});

$('#6').click(function() {
  addtogame('#6');
});

$('#5').click(function() {
  addtogame('#5');
});

$('#4').click(function() {
  addtogame('#4');
});

$('#3').click(function() {
  addtogame('#3');
});

$('#2').click(function() {
  addtogame('#2');
});

$('#1').click(function() {
  addtogame('#1');
});
Rex Schrader
@SaintPeter
Jun 30 2015 05:07
No, the + operator concatenates
Ok, what does addtogame do?
my code could use refactoring and I need to remove the alerts, but it works
Not quite working, but I made the basic change
Mario Mitchell
@undergroundfx
Jun 30 2015 05:14
yeah I couldnt get this to work like it should for some reason, so that's why I did it the other way
Suzanne Atkinson
@AdventureBear
Jun 30 2015 05:18
@robcolella I think I used arguments for that bonfire
(Can't sleep)
Rex Schrader
@SaintPeter
Jun 30 2015 05:20
@undergroundfx All I can say is that that's how you're "supposed" to do it. Trying to loop through is probably not the best solution.
Rob Colella
@robcolella
Jun 30 2015 05:22
I think I am getting closer, just need to do the compare now, I think indexof might work?
function where(collection, source) {
  var first = Object.keys(collection);
  var second = Object.keys(source);
  for(var i = 0; i < first.length; i ++) {
      console.log(collection[first[i]]);
      for(var x = 0; x < second.length; x++) {
          console.log(source[second[x]]);
      }

  }
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Rex Schrader
@SaintPeter
Jun 30 2015 05:30
@robcolella You need to compare the contents of each object. Just do an === on the 'same key', assuming that key exists in both.
@robcolella Well, not the key, but the object[key]
Suzanne Atkinson
@AdventureBear
Jun 30 2015 05:33
It doesn't use Keys but it solves the problem fine
I don't think a double loop is really needed, that seems more complex than it needs to be. Use a foreach to loop through arg 1 and then just compare to what you known of arg 2
Rob Colella
@robcolella
Jun 30 2015 05:34
yea was trying that @SaintPeter but no dice. I think I am making it more complicated then it needs to be, like @AdventureBear said
function where(collection, source) {
  var first = Object.keys(collection);
  var second = Object.keys(source);
  for(var i = 0; i < first.length; i ++) {
      console.log(collection[first[i]]);
      for(var x = 0; x < second.length; x++) {
          console.log(source[second[x]]);
          if(source[second[x]] == collection[first[i]]) {
              console.log(true);
          }
          else {
              console.log(false);
          }
      }

  }
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Rex Schrader
@SaintPeter
Jun 30 2015 05:35
@robcolella I'm looking at my solution and I have two loops. one to loop through each collection and one to loop through the keys
Anyway, I'm gonna call it a night - good luck
Rob Colella
@robcolella
Jun 30 2015 05:35
Take care @SaintPeter thanks for the help!
Mike Semko
@MadOgre
Jun 30 2015 05:51
@robcolella why not simply use a for in loop ??
There is no need for 2 loops
no reason to go through all the keys either
Rob Colella
@robcolella
Jun 30 2015 05:54
@MadOgre Yea thought about a for loop right off the bat, but just trying to utilize what is recommend on the bonfire page.
It was talking about the keys, so figured I would give it a go
Mike Semko
@MadOgre
Jun 30 2015 05:55
I know I looked at that too but the solution with for - in is so much shorter and simpler it didn't seem necessary at all
But even with your method there is no need for 2 loops
Rob Colella
@robcolella
Jun 30 2015 05:57
Agreed, refactoring it now. Still trying to get the compare
Kwame
@pearcraft
Jun 30 2015 05:58
Ok folks, this is my first time asking for help, so forgive me if I err!
I'm on the Waypoint: Build Rock Paper Scissors on CodeAcademy:
I'm on step 7 of 9 and I can't get my first nested if/else to work without an "SyntaxError: Unexpected token {" error. I've looked and looked and i can't find out where I went wrong & the CodeAcademy forums and Googling have failed me for the first time! :worried:
my code follows:
var compare = function(choice1, choice2) {
if (choice1 === choice2) {
return "The result is a tie!";
} else if (choice1 === "rock") {
if (choice2 === "scissors") {
return "rock wins";
} else {
return "paper wins";
}
} else if (choice1 === "paper") {
if (choice2 === "rock" {
return "paper wins";
} else {
return "scissors wins";
}
}
};
hmmm, how do I properly format my js code in chat?
Rob Colella
@robcolella
Jun 30 2015 05:59
@pearcraft its if (choice2 === "rock" {
You are missing a )
Mike Semko
@MadOgre
Jun 30 2015 05:59
@pearcraft Put ``` before and after code
@pearcraft backquotes
Kwame
@pearcraft
Jun 30 2015 06:00
:headdesk:
Rob Colella
@robcolella
Jun 30 2015 06:00
if(choice2 ==="rock" {

}
To get code use three ``` symbols
then hit shift enter and type your code in
You can use something like www.jshint.com
I found the error quickly with that
Kwame
@pearcraft
Jun 30 2015 06:01
var compare = function(choice1, choice2) {
        if (choice1 === choice2) {
            return "The result is a tie!";
        } else if (choice1 === "rock") {
            if (choice2 === "scissors") {
                return "rock wins";
            } else {
                return "paper wins";
            }
        } else if (choice1 === "paper") {
            if (choice2 === "rock" {
                    return "paper wins";
                } else {
                    return "scissors wins";
                }
            }
        };
Thanks sooo much! :smile:
bookmarking jshint now!
Mike Semko
@MadOgre
Jun 30 2015 06:03
@robcolella BTW this assignment (Where art thou) is simply crying out for a filter function
Kwame
@pearcraft
Jun 30 2015 06:03
How do I archive this chat for posterity?
Mario Mitchell
@undergroundfx
Jun 30 2015 06:03
Working on an interactive map using Google maps API.. anyone know how to change the default zoom level
Mike Semko
@MadOgre
Jun 30 2015 06:04
@pearcraft you don't have to, the site saves all chats forever
@pearcraft just remember the date and time
@robcolella hint: my entire where() function is 5 lines long not counting closing braces
Vos
@KrisVos130
Jun 30 2015 12:05
Could someone explain to me why at the bonfire No repeats please aab has to return 2, aabb has to return 8, abcdefa has to return 3600 and the others ones as well because I just don't get the logic behind it
Paul Soper
@pdsoper
Jun 30 2015 12:28
@KrisVos130 abc has the permutations abc acb bac bca cab cba. For aab - since the two a's are "different", they are aab aba aab aba baa baa. Of these only aba & aba have no adjacent letters that are the same - two combinations.
Vos
@KrisVos130
Jun 30 2015 12:33
@pdsoper So you basically just have to make all permutations and then get all permutations that don't have the same letter to the right/left
Paul Soper
@pdsoper
Jun 30 2015 12:33
That's the way I tackled it.
Vos
@KrisVos130
Jun 30 2015 12:34
@pdsoper But when you have abcdefa do you also have to make permutations like afc or does it have to have all characters that are provided
Paul Soper
@pdsoper
Jun 30 2015 12:45
You need to use all of the characters. Each permutation is the same length.
For N characters, the number of such permutations is N! (N factorial).
Vos
@KrisVos130
Jun 30 2015 12:57
Aah okay, thank you. Time to break my head on this one then I guess
David Wilbanks
@dwilbank68
Jun 30 2015 15:16
Any cloud9 users here?
jrtmns
@jrtmns
Jun 30 2015 15:23
I'm confused by Seek and Destroy
only one argument is passed to the function
yet there's two digits present in the function call besides the array
ah, the arguments object
David Wilbanks
@dwilbank68
Jun 30 2015 15:26
yep - start looking for extra goodies at arguments1, cuz arguments[0] will always be the array
kefzy
@kefzy
Jun 30 2015 15:41
@robertozimek thanks for your help yesterday
Robert Ozimek
@robertozimek
Jun 30 2015 15:42
@kefzy np
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:45
@taleon , @crisberrios @SaintPeter some progress! Still need some breathing room below the submit button. http://codepen.io/AdventureBear/full/WvdLBq/
Rex Schrader
@SaintPeter
Jun 30 2015 15:46
@AdventureBear All right, looking good! Although the font renders as comic sans on my machine for some reason.
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:46
Also breathing space on the edge as the screen width decreases, and eventually have them stack on top of each other for narrow widths. Not sure hwo to do that yet.
ewww
comic sans? Lol
supposed to be "walter turncoat". I wanted oen that might look like a coach's handwriting
Rex Schrader
@SaintPeter
Jun 30 2015 15:47
I think - it doesn't look like it's using the Walter Runcoat on my mahcine
is that a web font?
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:48
but it's good enough for now to actuall DO the Wizardry functions
yes it's a google font
Rex Schrader
@SaintPeter
Jun 30 2015 15:48
I think that it's not a standard font and so since I don't have it installed it goes to "cursive", my machine downgrades to comic sans
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:48
maybe it just looks real similar to comic sans?
Rex Schrader
@SaintPeter
Jun 30 2015 15:48
Is it linked?
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:48
you don't need to have it onstalled though do you? I thought that was the beauty of google fonts
well...hmmm
Rex Schrader
@SaintPeter
Jun 30 2015 15:49
No, but you DO need to link it in the CSS
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:49
is this correct?
Rex Schrader
@SaintPeter
Jun 30 2015 15:49
Find the URL for it and add that to your 'css' settings for Codepen
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:49
<link href='http://fonts.googleapis.com/css?family=Libre+Baskerville:400,700|Walter+Turncoat' rel='stylesheet' type='text/css'>
Rex Schrader
@SaintPeter
Jun 30 2015 15:49
Yeah, just add the href part (the url) to your settings in codepen
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:49
I have 2 fonts in there
Rex Schrader
@SaintPeter
Jun 30 2015 15:49
As a 'css'
I don't see them
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:50
It should also work by pasting the link into the HTML...it does for me. Myabe it's browser specific behavior.
Rex Schrader
@SaintPeter
Jun 30 2015 15:50
Maybe so - but the "proper" thing to do is put the url in the settings in the codepen - that'll ensure it's in the header of the html
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:51
OK, well that's icing anyway but I see you're point, and the header is where it belongs
Rex Schrader
@SaintPeter
Jun 30 2015 15:51
blob
Here:
Well, comic sans is a horrible failure mode ;)
Anyway, nitpicking, it looks great otherwise
Tony Keovongphet
@TSKeo
Jun 30 2015 15:52

I have a question about hosting and domain names.

So buying a domain name is a one time purchase, while hosting you can pay either monthly or annually?

Rex Schrader
@SaintPeter
Jun 30 2015 15:52
No, a Domain Name is a yearly purchase
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:52
OK, try it again if you like
lol..I agree...mabye you should delete it from your machine. :)
Rex Schrader
@SaintPeter
Jun 30 2015 15:52
Although you can buy domain names for longer
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:52
thanks!
Rex Schrader
@SaintPeter
Jun 30 2015 15:52
:D
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:53
ok, now to get it workign
Tony Keovongphet
@TSKeo
Jun 30 2015 15:53
So, you go buy a domain name from a hosting service.
Rex Schrader
@SaintPeter
Jun 30 2015 15:53
You can, but you don't have to
You buy a Domain Name from a registrar. Most hosting services offer domain name registration as well, but then you're kinda (but not fully) stuck with them.
But they're just reselling from a registrar
The only advantage is that they do all the setup for you
Whereas if you get it from a registrar you have to change some records
it's not rocket science, though, and there are generally good guides
Related: for the love of GOD do not use GoDaddy
For anything.
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:55
agree with no GoDaddy
Tony Keovongphet
@TSKeo
Jun 30 2015 15:55
My plan is to build a portfolio. I was offered a free 1 year. Though, I am from the US this company is in the UK.
Why is GoDaddy not so great? lol
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:55
i usually use namecheap for domains and for hosting hostgator or sitepoint or lunarpages
expensive hosting
difficult to use admin & control anels
Rex Schrader
@SaintPeter
Jun 30 2015 15:56
They're . . . umm . . very slow, force you to use their tools (which stink), their support is terrible and slow
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:56
panels
Rex Schrader
@SaintPeter
Jun 30 2015 15:56
and, expensive
Tony Keovongphet
@TSKeo
Jun 30 2015 15:56
I see.
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:56
and hard to get out of once you're in
Rex Schrader
@SaintPeter
Jun 30 2015 15:56
Their control panel was written by a drunk monkey on crack.
I loath them.
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:56
is that domain available?
drunkmonkeyoncrack.io
Rex Schrader
@SaintPeter
Jun 30 2015 15:56
LOL
My new host!
It is yes
Rex Schrader
@SaintPeter
Jun 30 2015 15:57
I can see the cartoon logo right now - an out of it monkey with a crack pipe
Suzanne Atkinson
@AdventureBear
Jun 30 2015 15:57
sweet! Only $59
SaintPeter @SaintPeter laughs out loud!
case in point...$32 her
here
Rex Schrader
@SaintPeter
Jun 30 2015 15:58
For a smallish host who really knows their crap, I've used http://a2hosting.com for 10+ years and for multiple clients. They're awesome.
I wonder if we can get a .ck domain
drunkmonkeyoncra.ck
Oh, wow, they want $300/year for the .ck domain
Suzanne Atkinson
@AdventureBear
Jun 30 2015 16:08
lol
could be worth it!!
Rex Schrader
@SaintPeter
Jun 30 2015 16:10
Priorities . . . humm . . new tablet or awesome domain name . . .
Ryan Malm
@Rybar
Jun 30 2015 16:21
Wouldn't alcohol and cocaine cancel each other out? Sorta like comatosemonkeyonmeth
Rex Schrader
@SaintPeter
Jun 30 2015 16:21
LOL
Grace
@dogbot101
Jun 30 2015 16:22
Poor monkey!
Lightwaves
@Lightwaves
Jun 30 2015 16:22
LOL is there a .th domain that would be awesome
comatosemonkeyonme.th
Rex Schrader
@SaintPeter
Jun 30 2015 16:23
Well, either way, one of them could have written the GoDaddy control panel. That, kids, is why you don't do drugs - you might end up working for GoDaddy
Charlene
@ck1ldn
Jun 30 2015 16:24
wow! was just about to go to godaddy for domain and hosting phew! seemed an easy option but will look around a bit
any suggestions.
did anyone have problems with waypoint exercise 88 or is it just me
Rex Schrader
@SaintPeter
Jun 30 2015 16:25
I like http://www.a2hosting.com - they're great.
Charlene
@ck1ldn
Jun 30 2015 16:26
@SaintPeter cheers will check them out
Charlene
@ck1ldn
Jun 30 2015 16:49
Can you review your work. I have a lovely green tick against my work, on the map. but when i wish to go back and review, it expects me to redoo
Rex Schrader
@SaintPeter
Jun 30 2015 16:51
Only the Bonfires are saved
You can view them in your profile
Arthur Zhuk
@ug02fast
Jun 30 2015 17:00
Anyone have a moment to help with Bonfire: title Case a Sentence? I’ve been stuck on this for a while now and am not sure how to get it to do what I want
function titleCase(str) {
  var arrayOfWords = str.split(" ");
  var word;
  var capitalized = [];
  var restLowerCased = [];

  arrayOfWords.forEach(function(word){
    capitalized.push(word.charAt(0).toUpperCase() + word.substring(1));
  });


  arrayOfWords.forEach(function(word){
    for(var i = 1; i <= word.length; i++) {
        restLowerCased.push(word.charAt(i).toLowerCase() + word.substring(i));
    }
    console.log(restLowerCased);
  });


  //var lowerCasedWords = restLowerCased.join(" ");
  //var upperCasedWords = capitalized.join(" ");
  //console.log(upperCasedWords);
  //console.log(lowerCasedWords);
  //return upperCasedWords;
}

titleCase("I'm A LITTLE TEA POT");
Maybe there’s a better way to approach this problem? Idk D:
Lightwaves
@Lightwaves
Jun 30 2015 17:03
since the point of title casing is to have the first letter uppercase and the rest lowercase one thing you can do is lowercase the whole thing
before splitting then do the capitalized push portion
it allows you to remove the rest after that
Arthur Zhuk
@ug02fast
Jun 30 2015 17:09
Oh dang
I didn’t think about that thanks
ramireznoe01
@ramireznoe01
Jun 30 2015 17:32
when pair programming, does the person who sends the invite host their screen?
drd13
@drd13
Jun 30 2015 17:34
Hello I am a bit unsure as to how to have my code run var bob = new Person('Bob Ross'); am I doing what is expected?
the challenge is http://www.freecodecamp.com/challenges/bonfire-make-a-person could anybody guide me in the good direction?
var Person = function(firstAndLast) {
    this.getFirstName=function(){
      return this.firstName;
    };
    this.getLastName=function(){
      return this.lastName;
    };
    this.getFullName=function(){
      return this.firstName + ' ' + this.lastName;
    };
    this.setFirstName=function(first){
      this.firstName=first;
    };
    this.setLastName=function(last){
      this.lastName=last;
    };
    this.setFullName=function(firstAndLast){
      this.firstName=firstAndLast.split(' ')[0];    
      this.lastName=firstAndLast.split(' ')[1];  
    };

};

var bob = new Person('Bob Ross');
bob.getFullName();
Rex Schrader
@SaintPeter
Jun 30 2015 17:40
You can copy and paste your code into http://repl.it and test there
You can add console.log statements to see the outputs of stuff
IE: console.log(bob.getFullName());
drd13
@drd13
Jun 30 2015 17:48
Yes my issue is just that I could add conditions to pass this but not while keeping 6 keys (A requirement for the exercise).
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:02
Hey folks, does anyone know why when I submit this form, the pen refreshes? I am outputing to a #results div for testing but I can't see before the screen flashes & reloads. This makes actual logic programming difficult! Same pen as before...
Rex Schrader
@SaintPeter
Jun 30 2015 18:03
A form submission is a POST operation (or maybe a GET operation) - submitting means that you're going to a new URL
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:04
thats what I was afraid of...so instead of submitting, I just need a click event?
I hate forms
Mario Mitchell
@undergroundfx
Jun 30 2015 18:04
just disable the submit for testing use prevent default
gravesr1993
@gravesr1993
Jun 30 2015 18:04
why is localArr considered undefined? It should be in scope of findLongestWord function, and be accessible in the for loop and i'm very confused again haha http://puu.sh/iIt5c/27b459bb86.png
Rex Schrader
@SaintPeter
Jun 30 2015 18:04
Either that or you need to capture the submit event with JS
Makeing it a 'button' is probably the way to go
Rather than type="submit"
Mario Mitchell
@undergroundfx
Jun 30 2015 18:05
theres a vanilla and jquery version
or prevent default for testing
Eko Julianto Salim
@ekojsalim
Jun 30 2015 18:05
@AdventureBear you can also do preventDefault()
Rex Schrader
@SaintPeter
Jun 30 2015 18:05
You can intercept the 'onsubmit' event and "preventDefault" on it
Haha - we all said at once
Eko Julianto Salim
@ekojsalim
Jun 30 2015 18:05
:)
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:06
lol
Grace
@dogbot101
Jun 30 2015 18:06
@gravesr1993 for loop, the first part is the start, the second is the end, and the third is how you want it to change
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:06
@SaintPeter I'm trying to use jquery to get the click event right now.
Rex Schrader
@SaintPeter
Jun 30 2015 18:06
@gravesr1993 What does the .match function return?
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:06
you guys are smart!
gravesr1993
@gravesr1993
Jun 30 2015 18:06
the .match function turns it into an array of the words @SaintPeter , you can see the array in the console log above 9
Rex Schrader
@SaintPeter
Jun 30 2015 18:07
@AdventureBear Note: if it is a type='submit' button, capturing the click will not be enough - you'll need to do a preventDefault
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:07
OK, thanks, I removed the type submit and just gave it an ID, and updated the jquery to a click event (if it's workign properly...testing now)
gravesr1993
@gravesr1993
Jun 30 2015 18:07
i'm just confused because the length property returns properly before the for loop, but it becomes undefined once inside for some reason, and the object seems to become undefined
Grace
@dogbot101
Jun 30 2015 18:08
maybe i< the length? or i<= length?
Eko Julianto Salim
@ekojsalim
Jun 30 2015 18:08
@gravesr1993 there is a difference between arr.length and arr.Length
Rex Schrader
@SaintPeter
Jun 30 2015 18:08
Yeah. arr.Length is not defined
lowercase l for the win
gravesr1993
@gravesr1993
Jun 30 2015 18:09
they're both undefined though
Mario Mitchell
@undergroundfx
Jun 30 2015 18:10
@gravesr1993 post your code please
Eko Julianto Salim
@ekojsalim
Jun 30 2015 18:10
arr.length isn't supposed to be undefined, are you sure that you have tried the lowercase l?
Grace
@dogbot101
Jun 30 2015 18:11
I thought the second condition in the for loop had to be a condition?
gravesr1993
@gravesr1993
Jun 30 2015 18:11
function findLongestWord(str) {

  var localArr=str.toLowerCase().match(/[a-z]+/g);
  var largest=0;

  console.log(localArr);
  console.log(localArr.length);

  for(i=0;localArr.length;i++)
  {
    console.log(localArr.Length);
    if(localArr[i].length>largest)
    {
      largest=localArr[i].length;
    }
    else
      {
        //wasn't big enough
      }
  }


  return largest;
}

findLongestWord('The quick brown fox jumped over the lazy dog');
yeah, that's what was wrong, i'm too tired for this haha
forgot i<
Grace
@dogbot101
Jun 30 2015 18:12
;)
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:13
@ekojsalim I removed the form method and changed the submit to just a button, but it's still doign the same behavior. Where do I put the preventDefault() method? chain it to the click event?
Eko Julianto Salim
@ekojsalim
Jun 30 2015 18:14
@AdventureBear
  $('#calculate').on('click', function(e) {
   e.preventDefault();
that should be it
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:15
OK, cool...trying one more thing which is taking the button out of the form tags altogether. I'm using the form tages only for styling.
that ended up working. Do you think preventDeafault is better or is what I did OK? It's a bit hacky
Eko Julianto Salim
@ekojsalim
Jun 30 2015 18:17
hmm, either way works fine, but I suppose adding type="button" to your button is shorter
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:20
This message was deleted
Tony Keovongphet
@TSKeo
Jun 30 2015 18:22
Can anyone help with Search and Destroy?
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:36
OK, if anyone wants to play with my training plan wizard go ahead and fill out out but you have to choose 0 prior marathons right now!
Arthur Zhuk
@ug02fast
Jun 30 2015 18:37
function largestOfFour(arr) {
  // You can do this!
  var value;
  arr.forEach(function(value) {
    console.log(value);
    if (value[0] > value[1] && value[0] > value[2] && value[0] > value[3]) {
      console.log(value[0]);
      arr.push(value[0]);
      return value[0];
    }
    else if(value[1] > value[0] && value[1] > value[2] && value[1] > value[3]) {
      console.log(value[1]);
      arr.push(value[1]);      
      return value[1];

    }
    else if(value[2] > value[0] && value[2] > value[1] && value[2] > value[3]) {
      console.log(value[2]);
      arr.push(value[2]);
      return value[2];
    }
    else {
      console.log(value[3]);
      arr.push(value[3]);
      return value[3];
    } 
    console.log(arr);
    console.log(value);
  });
  arr.splice(0,4);
  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
This is the solution I came up with and it was accepted but I feel like it’s not acceptable. Is this acceptable? ayylmao
*I feel like it’s not morally acceptable.
Mario Mitchell
@undergroundfx
Jun 30 2015 18:38
@TSKeo I can help you
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:40
@ug02fast yeah, it works, but the idea is to learn about array traversals & sorts so that you can apply the concepts more generally to other problems. The brute force method you have only applies to arrays of four numbers.
Mario Mitchell
@undergroundfx
Jun 30 2015 18:41
@ug02fast I did similar but like this, it can accept more numbers
function largestOfFour(arr) {
  var nums = arr;
  var largest = [];
  var bigone = nums[0][0];
    if(nums[0][1] > bigone) {
        bigone = nums[0][1];
    }
    if(nums[0][2] > bigone) {
        bigone = nums[0][2];
    }
    if(nums[0][3] > bigone) {
        bigone = nums[0][3];
    }
    largest[0] = bigone;

    bigone = nums[1][0];
    if(nums[1][1] > bigone) {
        bigone = nums[1][1];
    }
    if(nums[1][2] > bigone) {
        bigone = nums[1][2];
    }
    if(nums[1][3] > bigone) {
        bigone = nums[1][3];
    }
    largest[1] = bigone;   

        bigone = nums[2][0];
    if(nums[2][1] > bigone) {
        bigone = nums[2][1];
    }
    if(nums[2][2] > bigone) {
        bigone = nums[2][2];
    }
    if(nums[2][3] > bigone) {
        bigone = nums[2][3];
    }
    largest[2] = bigone; 

        bigone = nums[3][0];
    if(nums[3][1] > bigone) {
        bigone = nums[3][1];
    }
    if(nums[3][2] > bigone) {
        bigone = nums[3][2];
    }
    if(nums[3][3] > bigone) {
        bigone = nums[3][3];
    }
    largest[3] = bigone; 

  return largest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Arthur Zhuk
@ug02fast
Jun 30 2015 18:42
@undergroundfx @AdventureBear Yeah I don’t too much about array methods even arrays in general :(
Lightwaves
@Lightwaves
Jun 30 2015 18:43
@AdventureBear you ever try swimming the butterfly?
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:43
@undergroundfx , @ug02fast can you see any patterns in your algorithm that you can generalize, specifically with how you are checking each array? You'll have a lot of trouble with other bonfires and with real life problems if you don't start to work on array methods.
@Lightwaves yes I'm a member of the butternuts club 500yd continuous legal butterfly
Lightwaves
@Lightwaves
Jun 30 2015 18:44
oh god 500 yard butterfly I think a 50 yard fly would kill me at this point bleh need to get back in shape
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:44
lol
before the day I actually did it the furthest I had gone is 75m
Mario Mitchell
@undergroundfx
Jun 30 2015 18:44
@AdventureBear yeah but I did different on the others. I've completed almost all the Bonfires and completed 3 ziplines yesterday. Im ok
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:44
I was inspired that day, and did it in a lake on a 200m buoy line.
Mario Mitchell
@undergroundfx
Jun 30 2015 18:45
@AdventureBear can we see your solution?
Lightwaves
@Lightwaves
Jun 30 2015 18:45
the longer distances are more about extending the glide portion of the stroke
Suzanne Atkinson
@AdventureBear
Jun 30 2015 18:45
that's good! For "Fun" you could work on redoing that one if for no other reason to have a solution you can share with others.
@Lightwaves yes exactly!
@undergroundfx you can see everyones solutions like this...only up to the ones youve completed i believe
i think mine coudl be more elegant but you can see what I did
Mario Mitchell
@undergroundfx
Jun 30 2015 18:46
thx
Arthur Zhuk
@ug02fast
Jun 30 2015 18:50
@AdventureBear Yeah ik but I really think the freeCodeCamp team should have added more tests with different amounts of arrays if they wanted brand new learners to come up with a smarter approach of getting the solution.
gravesr1993
@gravesr1993
Jun 30 2015 18:58
This message was deleted
how do I put it in the code thing :(
function largestOfFour(arr) {
  var arrConstr=[];

  for(var i=0;i<arr.length;i++)
    {
      var curMax=0;
      for(y=0;y<arr[i].length;y++)
        {
            if(curMax<arr[i][y])
              {
                curMax=arr[i][y];
              }
        }
          arrConstr.push(curMax);
          console.log(curMax);
          console.log(arrConstr);
    }
  // You can do this!
  return arrConstr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
that's the solution I came up with
it'll work with arrays of any size that are 2D to provide the correct answer as far as I know
Arthur Zhuk
@ug02fast
Jun 30 2015 19:18
Thanks @gravesr1993 I didn’t even know about the arr[i][y] thing. I’m going to go over the codecademy javascript course for arrays again. It’s been over a month since I did that and haven’t used it since.
Miguel Correa
@miguelc1221
Jun 30 2015 19:41
anyone finish smallest common multiple?
Chirag Khatri
@ckhatri
Jun 30 2015 19:45
hey can anyone help me with the bonfire: arguments optional, how exactly do you return a function?
Miguel Correa
@miguelc1221
Jun 30 2015 19:45
@Ckhatri closure
Lightwaves
@Lightwaves
Jun 30 2015 19:48
@gravesr1993 nice solution
Chirag Khatri
@ckhatri
Jun 30 2015 19:55
okay thank you very much @miguelc1221
cblupodev
@cblupodev
Jun 30 2015 20:04
Can someone just tell me where I'm supposed to round in Map the Debris? http://www.freecodecamp.com/challenges/bonfire-map-the-debris. I'm spending too much time copy pasting Math.round() around everywhere
Paul Soper
@pdsoper
Jun 30 2015 20:18
@cblupodev - I believe you should only need to round the final result.
Miguel Correa
@miguelc1221
Jun 30 2015 20:34
anyone finish smallest common multiples
EstherJaikeo
@EstherJaikeo
Jun 30 2015 20:36
Did anyone finish seek and destroy? I have been stuck for awhile.
function destroyer(arr){
  for (var i = 0; i < arr.length; i++){
    if (arr[i] === arguments[1] || arr[i] === arguments[2]){
      arr.pop(i);
    }
  }
  return arr;
}

destroyer([1, 2, 3 ,1, 2, 3], 2, 3);
Grace
@dogbot101
Jun 30 2015 20:38
Anyone can help with HTML entities? I'm still learning objects and regex....
function convert(str) {

  // replace regular expression with html entity 
  //created object as HTML Entity dictionary 
  var listhtml = {
    "&": "&amp;",
    "<": "&lt;",
    ">": "&gt;",
    "\"": "&quot;",
    "\'": "&apos;"
  };

  // regular expression, & or < or > or ' or " g modifier to find all matches
   // created function to access object property 
  //objectname is listHTML
 return str.replace(/&|<|>|\'|\"/g, function(char){
      return console.log(listhtml[char]);
  }); 


  }




convert('Hamburgers < Pizza < Tacos');
Ariel
@ArielLeslie
Jun 30 2015 20:39
@dogbot101 this is a great regex tester https://regex101.com/#javascript
Grace
@dogbot101
Jun 30 2015 20:41
Thank you @arielleslie . Hmm...
Robert Ozimek
@robertozimek
Jun 30 2015 20:44
@dogbot101 from what I see if you just return listhtml[char]; inside your function(char) that should work just find
fine*
Grace
@dogbot101
Jun 30 2015 20:45
Oh dear... haha.. Thank you @robertozimek
Robert Ozimek
@robertozimek
Jun 30 2015 20:45
hahaha no problem
@EstherJaikeo then .pop() removes the last element of the array
Robert Ozimek
@robertozimek
Jun 30 2015 20:51
what your looking for is .splice(i, 1)
jrtmns
@jrtmns
Jun 30 2015 20:56
In "sum all numbers in a range", what does the test case mean by the second line in its output:
Robert Ozimek
@robertozimek
Jun 30 2015 20:56
and actually it would be easier to just make a new array rather than manipulating the existing one because when you remove things from the array the position of the elements is shifted but your for loop is moving forward
jrtmns
@jrtmns
Jun 30 2015 20:56
expected 20 to equal 10
oh, wait
Robert Ozimek
@robertozimek
Jun 30 2015 20:57
@jrtmns are you doing the smallest common multiple bonfire?
jrtmns
@jrtmns
Jun 30 2015 20:58
not sure you mean by smallest common multiple
Grace
@dogbot101
Jun 30 2015 20:58
Title of the challenge?
jrtmns
@jrtmns
Jun 30 2015 20:59
err
Robert Ozimek
@robertozimek
Jun 30 2015 20:59
ahh I see
the sum all number in range
jrtmns
@jrtmns
Jun 30 2015 20:59
no, not there yet sorry
Robert Ozimek
@robertozimek
Jun 30 2015 21:00
that one wants you to add up the numbers in the range so 1 to 4 would be 1+2+3+4
jrtmns
@jrtmns
Jun 30 2015 21:00
yes sorry for confusing, my chat was lagged showing only posts from two hours ago so i though i'd just put it out there
yup
Robert Ozimek
@robertozimek
Jun 30 2015 21:00
oh ok
jrtmns
@jrtmns
Jun 30 2015 21:07
hmm
expect(sumAll([1, 4])).to.equal(10); gives the expected result each time
but the expected 20 to equal 10 line fails
and I have no idea what it means by that
Robert Ozimek
@robertozimek
Jun 30 2015 21:09
well your outputing 20 but it expected to get 10
so for some reason your result is 20 when it should be 10 since 1+2+3+4 = 10
jrtmns
@jrtmns
Jun 30 2015 21:11
oh somehow I thought it was some kind of a second test case
sumAll([1, 4]) returns 10
Robert Ozimek
@robertozimek
Jun 30 2015 21:13
are you sure?
jrtmns
@jrtmns
Jun 30 2015 21:13
if I console.log in jsfiddle it returns everything as expected
Robert Ozimek
@robertozimek
Jun 30 2015 21:14
can you post your code
jrtmns
@jrtmns
Jun 30 2015 21:14
oh wait lol no it doesn't
haha
ta for pointing out what that message meant though
Robert Ozimek
@robertozimek
Jun 30 2015 21:15
no problem :smile:
jrtmns
@jrtmns
Jun 30 2015 21:16
I'm confused
Stephen Wanhella
@1hella
Jun 30 2015 21:17
Has anyone here done 'Bonfire: No repeats please'?
I'm totally stumped.
// factorialize a number
function factorialize(num) {
  if (num === 0) {
    return 1;
  }

  return num * factorialize(num - 1);
}

function permAlone(str) {
  var n = str.length;
  var totalPermutations = factorialize(n);
  var arr = str.split('');

  // Find the repeated letters

  // Count the permutations with repeated letters
}

permAlone('aab');
Robert Ozimek
@robertozimek
Jun 30 2015 21:19
@1hella that one was tough, you need to find the permutations of all the strings, then using regexp find the one with consective letters
Stephen Wanhella
@1hella
Jun 30 2015 21:20
Ok so something like store every single permutation in an array and filter out the ones without consecutive letters?
Robert Ozimek
@robertozimek
Jun 30 2015 21:20
yeah
Stephen Wanhella
@1hella
Jun 30 2015 21:21
Ok thanks @robertozimek. That's a good start at least.
Robert Ozimek
@robertozimek
Jun 30 2015 21:21
then just return the length of the array
Jonathan
@jonathantimm
Jun 30 2015 21:21
Hey guys, can anybody help with the rock paper scissors lesson? I'm trying to wrap my head around the nested if/else concept..
Stephen Wanhella
@1hella
Jun 30 2015 21:21
This is the only bonfire I have left
@jonathantimm Sure, what do you need help with?
Jonathan
@jonathantimm
Jun 30 2015 21:21
var compare = function(choice1,choice2) {
    if (choice1 === choice2) {
        return "The result is a tie!"
    } else if(choice1 === "rock")
        if (choice2 === "scissors") {
            return "rock wins"
        } 

        else {
            return "paper wins"
        } else if (choice1 === "paper") {
            if (choice2 ==="rock") {
                return "scissors wins"
            };        
};
i'm getting an error there - unexpected end of input
Robert Ozimek
@robertozimek
Jun 30 2015 21:22
@jonathantimm your else if statement should be between the if and the else
so ```
Stephen Wanhella
@1hella
Jun 30 2015 21:22
Yeah you have if... else... else if
Robert Ozimek
@robertozimek
Jun 30 2015 21:23
if() {
}
elseif() {
}
else {
}
yeah sorry about that
Jonathan
@jonathantimm
Jun 30 2015 21:23
ohh so it has to go in order
Robert Ozimek
@robertozimek
Jun 30 2015 21:23
your if statement is alwys the first then your else if statement and then finally your else
Stephen Wanhella
@1hella
Jun 30 2015 21:23
Yeah, else is the default if it doesn't match the if or else if
Jonathan
@jonathantimm
Jun 30 2015 21:24
thanks guys
Stephen Wanhella
@1hella
Jun 30 2015 21:25
No worries. Let us know if you need some more help @jonathantimm
Jonathan
@jonathantimm
Jun 30 2015 21:27
Thanks, I will. This is definitely taking it up a notch from the html/css/bootstrap/jquery/cs101. the code is just getting more intricate
Stephen Wanhella
@1hella
Jun 30 2015 21:28
For sure. It’s a lot to take in at once if you’ve never done any programming before.
Don’t be afraid to go back and do previous steps again if you need refreshers. Codecademy goes pretty fast sometimes.
Jonathan
@jonathantimm
Jun 30 2015 21:30
good idea. thanks @1hella
Stephen Wanhella
@1hella
Jun 30 2015 21:30
:)
Lightwaves
@Lightwaves
Jun 30 2015 21:38
Need a bit of help with Roman Numerial I almost have my solution just need a bit of help wrapping it up.
Robert Ozimek
@robertozimek
Jun 30 2015 21:40
@Lightwaves what exactly do you need help with?
Lightwaves
@Lightwaves
Jun 30 2015 21:40
oh I just having some issues building the string.
I have two parallel arrays telling one for the letters
and the other how many times to repeat that letter
so I was expecting the code to do this
Robert Ozimek
@robertozimek
Jun 30 2015 21:42
I guess you can use an nested for loop
Lightwaves
@Lightwaves
Jun 30 2015 21:42
Haha I was trying to avoid doing that!
hmm I thought of something
Robert Ozimek
@robertozimek
Jun 30 2015 21:47
what do you have in mind? I’m trying to think what another way you could do it but can’t think of one
Lightwaves
@Lightwaves
Jun 30 2015 21:50
hold on.
ciper99
@ciper99
Jun 30 2015 21:51
hi all
Ariel
@ArielLeslie
Jun 30 2015 21:52
I just used a sequence of while loops. I also only used one array
mine wasn't very elegant, but I find the roman numerals thing irritating in general and didn't feel like cleaning it up.
ciper99
@ciper99
Jun 30 2015 21:55
lol, I'm afraid ot the roman numeral one myself
it seems weird
Ariel
@ArielLeslie
Jun 30 2015 21:56
It's not scary. Roman numerals are just irritating because you have to explicitly check for the 4,9, etc
ciper99
@ciper99
Jun 30 2015 21:57
hmm, they are weird
Robert Ozimek
@robertozimek
Jun 30 2015 21:57
yeah that’s a pain, don’t even remember how I did it
ciper99
@ciper99
Jun 30 2015 21:57
because you have to put lots of if statements
I think
I think
Ariel
@ArielLeslie
Jun 30 2015 21:59
yeah. I didn't bother doing the full roman numeral system. Didn't go as high as 50 because those numbers weren't checked for and it's the same logic, just extended
Lightwaves
@Lightwaves
Jun 30 2015 21:59
Ok I got something
I'll check if it passes
Robert Ozimek
@robertozimek
Jun 30 2015 21:59
well I think I made an object that had the symbols for 1, 4, 5, 9, 10 etc. then just used the actual numbers as keys to get those values
Ariel
@ArielLeslie
Jun 30 2015 22:00
you still have to have a ton of ifs
Lightwaves
@Lightwaves
Jun 30 2015 22:00
it passed
Robert Ozimek
@robertozimek
Jun 30 2015 22:00
I don’t think I had many, just used the % for the 4s and 9s and thats it
Lightwaves
@Lightwaves
Jun 30 2015 22:00
I'll show you guys my solution
function convert(num) {
 var romanNumerials = ["X", "IX", "V", "VI", "I"];
 var numbers = [10, 9, 5, 4, 1];
 var divis = [];
 var romanNum;
 for(var i = 0; i<numbers.length; i++){
   if (Math.trunc(num / numbers[i]) > 0){
     divis.push(Math.trunc(num/numbers[i]));
     num%=numbers[i];

   }
   else{
     divis.push(0);





   }





   }
   romanNum = romanNumerials.map(function(ele, idx, arr){

        if (divis[idx] > 0){
            return ele.repeat(divis[idx]);
        }
        else{
            return "";
        }



   }).join("");



    return romanNum;

   }
I couldn't get repeat to work with += I'd get XXXXVIIIIIXXX
or weird combinations like that
Ariel
@ArielLeslie
Jun 30 2015 22:02
var arr = [];
  while(num>=10){
    arr.push('X');
    num -= 10;
  }
... etc
is how I did it
Lightwaves
@Lightwaves
Jun 30 2015 22:03
I did a similar problem well sorta similar validating credit card numbers and having to extract digits with %10 and move past the digit with /10
ciper99
@ciper99
Jun 30 2015 22:33
hey y'all
I need some help
I gotta ask you about this idea of mine for the roman numeral thingy
I decided I should maybe do it with the help of recursion
like, deciding how it works for some
and then calling the function for specific numbers
for example, say it is 12
my function would, using an if statement automatically concatenate the string I want to return with "X" because the num is bigger than 8
then, I would call string += convert(num1)
PS: I have turned the num into a string, which allows me to do comparison operators with it and access the smaller integers like the 1 and the 2 of 12 like in an array
what do you think? is this stupid'
Briana Swift
@brianamarie
Jun 30 2015 22:39
@ciper99 looks like a solid strategy, you should draft it out into smaller steps in comments and start coding! I'm not as familliar with the convert method, but other than that, it looks pretty similar to what I did
ciper99
@ciper99
Jun 30 2015 22:41
!
the convert is the name of the function we have to write
like, roman numerals are like arrays
if it is bigger than 8 and smaller than 40, it will have an X
which is the 10
then, if it is smaller than 10
I will call string += convert(10-num) + string to finish it off
in this case, if it was 9, it would be convert(10-num), which will give the I and then + string, which is X
and it will be IX
Briana Swift
@brianamarie
Jun 30 2015 22:50
Awesome. sounds like a great solution :)
ciper99
@ciper99
Jun 30 2015 22:51
it is so boring to write
like, it feels too manual
this whole bonfire feels very manual
Briana Swift
@brianamarie
Jun 30 2015 22:52
Interesting. It was added after I finished up the first bunch so I was so happy to have a new one lol. They were frustrating when I was trying to hammer them out but I didn't realize how fun they are
ciper99
@ciper99
Jun 30 2015 22:56
This was the one I disliked the most
Sean Haverstick
@Valenten
Jun 30 2015 23:06
Hey im having trouble completing the waypoint STyle Text Inputs as Form Controls I swear ive done everything it has said just doesnt seem to be recognising half of it :/
sarvagya3943
@sarvagya3943
Jun 30 2015 23:06
hey can anyone here help me in figuring out whats wrong with my zipline solution?
Sean Haverstick
@Valenten
Jun 30 2015 23:07

so far ive done

 <input type='text' class='form-control' placeholder='cat photo URL' required>
  <button type='sumbit'; class='btn btn-primary'><i class='fa fa-paper-plane'></i>Submit</button>

and all it asks for us to do is Give the submit button in your form the classes "btn btn-primary".

and Add a <i class="fa fa-paper-plane"></i> within your submit button element.
Give the text input in your form the class "form-control".
Make sure each of your i elements has a closing tag
Sam Crowe
@crowesam
Jun 30 2015 23:08
@Valenten you might try quotes around the 'Lobster' in your css
nevermind
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:09
can anyone help in css?
Sam Crowe
@crowesam
Jun 30 2015 23:09
yes
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:10
im really struggling how to shorten the height of the right border.
Sam Crowe
@crowesam
Jun 30 2015 23:10
which excercise is it?
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:10
its not from freecodecamp
Sam Crowe
@crowesam
Jun 30 2015 23:12
you want to adjust the height of a right border or the width
thickness
sarvagya3943
@sarvagya3943
Jun 30 2015 23:12
anyone help me with the zipline please..
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:12
height,
heres the html code
<div id="headcontent">

<ul>
<li>England</li>
<li>N.Ireland</li>
<li>Scotland</li>
<li>Alba</li>
<li>Wales</li>
<li>Cymru</li>
</ul>
</div>
heres the style
#headcontent ul{
padding:2px 0 2px 2px;
color:black;
}

#headcontent li {
border-right:1px solid grey;
float:left;
list-style:none;
padding: 10px 25px 2px 17px;
position:relative;
top:-17px;
font-size:0.8em;
height:50%;
}
Robert Ozimek
@robertozimek
Jun 30 2015 23:13
@Valenten your type=‘sumbit’ should be type=submit
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:13
i just added the height, it didnt work,
sarvagya3943
@sarvagya3943
Jun 30 2015 23:13
Sam Crowe
@crowesam
Jun 30 2015 23:14
the height would be determined by the line height
Sean Haverstick
@Valenten
Jun 30 2015 23:14
well i changed it to that but it didnt really do much in the way of recognising to 2 goals im missing :/
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:14
so what do i have to do?
Sean Haverstick
@Valenten
Jun 30 2015 23:15
it isnt recognising the "Give the submit button in your form the classes "btn btn-primary" and "Add a <i class="fa fa-paper-plane"></i> within your submit button element."
Sam Crowe
@crowesam
Jun 30 2015 23:15
What do you want to accomplish have a short border
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:15
have a shorter height of the border,
like centred short,
Sam Crowe
@crowesam
Jun 30 2015 23:16
I think you might have to use z-index and absolute positionnig to stack another element on top or behind another one to use border and accomplish that.
seems like you might do better to use an image
background image pushed to the right maybe
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:18
yeah thats away, but a very long one, because i have like 8 lists.
cheers thou,
Sam Crowe
@crowesam
Jun 30 2015 23:19
you can assign class to each one
and just reuse the class
Robert Ozimek
@robertozimek
Jun 30 2015 23:19
@Valenten I guess there is a bug try refreshing the page and doing it again
Sam Crowe
@crowesam
Jun 30 2015 23:21
@Valenten which excercise is it
Waypoint
Sean Haverstick
@Valenten
Jun 30 2015 23:22
it was just a bug
i refreshed it and did it again
is fine now
but it was the Waypoint: Style Text Inputs as Form Controls
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:42
one question,
i made a h2, and gave it a class, and i am trying to call that class in style sheet, it doesnt work?
like what ever i assign in that class style it doesnt apply it?
anyone on?
Ben McMahon
@benmcmahon100
Jun 30 2015 23:46
@CodeAmateur7 make sure it's like
<style>
.classname {

}
</style>
the full stop at the start is important for css classes
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:47
it is
thats why i dont get it why it dont work
Ben McMahon
@benmcmahon100
Jun 30 2015 23:48
so

<style>
.big{
font-size: 50px;
}
</style>

<h2 class = "big">
This is big
</h2>
like that?
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:49
yep,
exact same thing,
Ben McMahon
@benmcmahon100
Jun 30 2015 23:49
@CodeAmateur7 can you paste what you have for a second?
Sam Crowe
@crowesam
Jun 30 2015 23:49
@Valenten Glad you got it
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:49
<h1 id="headerline" style="color:grey;">Greece misses IMF payment deadline</h1>
Ben McMahon
@benmcmahon100
Jun 30 2015 23:49
@CodeAmateur7 also is this in the FCC editor or somewhere else?
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:50
i used the style here abit cuz it didnt work in style sheet
note++
#headerline {
padding-left:20px;

}
it was class i did change it to id to try if it work,
i added many tags in this idd/class nothing worked
hy i got it, i was being stupid, i added lots of dashes between my codes in style sheet to make it easier to set them apart,
Ben McMahon
@benmcmahon100
Jun 30 2015 23:53
yeah what you had was perfect so it had to be something wierd
This message was deleted
if you want to seperate things
Sam Crowe
@crowesam
Jun 30 2015 23:54
@CodeAmateur7 with regards to your border question check out this js fiddle. I think this might do what you want.
CodeAmateur7
@CodeAmateur7
Jun 30 2015 23:55
@benmcmahon100 thanks, and sorry for the confusion
@crowesam on it, lmc
wow damn it, thank you,!!! it worked
@crowesam cheers!
Sam Crowe
@crowesam
Jun 30 2015 23:56
Haha
Glad to help
Is anybody here working on learning Angular?
Ben McMahon
@benmcmahon100
Jun 30 2015 23:59
@crowesam Did a bit and then moved to react at @terakilobyte 's reccomendation