These are chat archives for FreeCodeCamp/Help

27th
Sep 2015
Mateja Trifunovski
@Matko95
Sep 27 2015 00:00
aand it's the width :D Just gotta see why
Star Cherrix
@Sparklepaws
Sep 27 2015 00:01
Interesting, it also works when I specifically delete all of the .horbar CSS o.o
AH FIXED IT
Mateja Trifunovski
@Matko95
Sep 27 2015 00:02
@Sparklepaws add this to your header z-index:2;
it fixes it
Star Cherrix
@Sparklepaws
Sep 27 2015 00:02
Yep, did z-index: 1 xD
Haha
Mateja Trifunovski
@Matko95
Sep 27 2015 00:02
:D
Star Cherrix
@Sparklepaws
Sep 27 2015 00:02
@Matko95 Thanks, Mat!
CamperBot
@camperbot
Sep 27 2015 00:02
sparklepaws sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 382 | @matko95 | http://www.freecodecamp.com/matko95
Mateja Trifunovski
@Matko95
Sep 27 2015 00:02
np, still strange though :D
Star Cherrix
@Sparklepaws
Sep 27 2015 00:03
Yeah I'm still not sure what caused that, it may have something to do with collapsing margins and positions.
I'll see if I can replicate it again by changing the z-index of something to 1 as well
peopleblazin
@peopleblazin
Sep 27 2015 00:04
<html>

<head>
<title>Hutner's_blog</title>
<link href="style.css" type="text/css" rel="stylesheet">
<body>
    <!DOCTYPE html>
    <html>
    <body>
        <div>
    <h2>Coding is difficult only if you don't put your mind to it.</h2>
    <img src"coding_pic" style="width:1600px;height:864px;">
        </div>
   <div id="main">

        <h1>My experiences with coding in HTML</h1>
    <p>        Coding for me, when I had just started learning the basics, was a lot harder than it seemed!
    Coding is a good way to know how the internet works:</p>
<li>Be able to understand HTML</li>
   </div>
</body>

</html>
I am preoccupied with making my own webpage through notepad++ and i am trying to get a picture to show up but it just is a huge outline of a picture and wont show the picture . Can anyone possibly help?
Star Cherrix
@Sparklepaws
Sep 27 2015 00:05
Your <img src> lacks an = before "coding_pic"
It should be img src="coding pic"
peopleblazin
@peopleblazin
Sep 27 2015 00:05

lol

Thank you
@Sparklepaws

CamperBot
@camperbot
Sep 27 2015 00:05
peopleblazin sends brownie points to @sparklepaws :sparkles: :thumbsup: :sparkles:
:star: 189 | @sparklepaws | http://www.freecodecamp.com/sparklepaws
Star Cherrix
@Sparklepaws
Sep 27 2015 00:06
No worries :D
peopleblazin
@peopleblazin
Sep 27 2015 00:07

But now it has an outline and that small paper showed up in the corner

should i put the alt="" back?

Star Cherrix
@Sparklepaws
Sep 27 2015 00:07
Also @Matko95 , putting the z-index of .horbar at the same .z-index as .header broke it again, so it has something to do with .horbar
Are you putting a link in the src area or are you hosting the picture on an FTP server, @peopleblazin ?
peopleblazin
@peopleblazin
Sep 27 2015 00:09
FTP server
Star Cherrix
@Sparklepaws
Sep 27 2015 00:09
Is the picture located in the same folder as your code?
peopleblazin
@peopleblazin
Sep 27 2015 00:09

i opened up the file on chrome through notepad++

no
its not

should it be
?
Star Cherrix
@Sparklepaws
Sep 27 2015 00:11
Well if you just give it the name it should look in the same folder as the code, otherwise you'll need to show it the path. So let's say you have a folder inside your code folder called "images", then you would need to write something like: `<img src="images/coding_pic.jpg">
It's been a while since I did anything public on an FTP server so I could be incorrect.
peopleblazin
@peopleblazin
Sep 27 2015 00:11
okay let me work with it @Sparklepaws I will let you know if i get anything
Ted Patterson
@tedjpatterson
Sep 27 2015 00:18
Hello @all ! Unfortunately, I'm back again and completely stuck on Waypoint: Make Object Properties Private.
Mateja Trifunovski
@Matko95
Sep 27 2015 00:18
@tedjpatterson feel free to post the code
Ted Patterson
@tedjpatterson
Sep 27 2015 00:19
var Bike = function() {
  // Only change code below this line.
  this.speed = 100;
  function addUnit(valueMe) {
    return value + "KM/H";
  }

  getSpeed = function () {
    return addUnit(myBike.speed);
  };
I still have no clue what to add into this thing to complete the task...
Mateja Trifunovski
@Matko95
Sep 27 2015 00:21
@tedjpatterson
this.speed=100; //public
speed=100;//private
Ted Patterson
@tedjpatterson
Sep 27 2015 00:22
I've done this, but I'm still not cleared.
Mateja Trifunovski
@Matko95
Sep 27 2015 00:23
@tedjpatterson what did you do exactly?
Paul Snider
@snipaw26
Sep 27 2015 00:23
Help ... I need help removing special characters from a string.
CamperBot
@camperbot
Sep 27 2015 00:23
no wiki entry for: i need help removing special characters from a string
:pencil: click here to create one now!after creating your page type update to reload it here
Star Cherrix
@Sparklepaws
Sep 27 2015 00:23
Is there a way to use CSS selectors to select a child element within a parent container? So for example, if I wanted to effect all paragraphs that were children of .randomName. In my head it looks something like this: .randomName p {};
Ted Patterson
@tedjpatterson
Sep 27 2015 00:24
var Bike = function() {
  speed = 100;
  function addUnit(valueMe) {
    return value + "KM/H";
  }

  getSpeed = function () {
    return addUnit(myBike.speed);
  };
Paul Snider
@snipaw26
Sep 27 2015 00:24
Help ... I need help removing special characters from a string.
CamperBot
@camperbot
Sep 27 2015 00:24
no wiki entry for: i need help removing special characters from a string
:pencil: click here to create one now!after creating your page type update to reload it here
Star Cherrix
@Sparklepaws
Sep 27 2015 00:24
The parent element HAS to be called by it's class
Mateja Trifunovski
@Matko95
Sep 27 2015 00:25
@tedjpatterson getSpeed must be public
peopleblazin
@peopleblazin
Sep 27 2015 00:25
@Sparklepaws still didnt work you still helped me get more organized THumbs up
I am going to be doing a brand new web site
Paul Snider
@snipaw26
Sep 27 2015 00:26
Help
CamperBot
@camperbot
Sep 27 2015 00:26

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. ex: find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • bonfire BONFIRENAME info on a bonfire

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Star Cherrix
@Sparklepaws
Sep 27 2015 00:26
@peopleblazin No worries, but if it's not working feel free to ask more questions, I'm sure it's something very simple to fix.
Ted Patterson
@tedjpatterson
Sep 27 2015 00:26
@Matko95 So it should be this.getSpeed , correct?
Mateja Trifunovski
@Matko95
Sep 27 2015 00:27
@tedjpatterson exactly
peopleblazin
@peopleblazin
Sep 27 2015 00:27
yes i am too
Ted Patterson
@tedjpatterson
Sep 27 2015 00:28
Interesting. This is still not clearing....
Star Cherrix
@Sparklepaws
Sep 27 2015 00:28
@snipaw26 Try studying .split() and .filter(). Both will help you to remove things from a string.
Walter Cavalcante Junior
@WalterCJ
Sep 27 2015 00:29
Someone plz help me with this one: Sum All Odd Fibonacci Numbers
function sumFibs(num) {
  var numFibs = [], sum = 2;
  numFibs[0] = 1;
  numFibs[1] = 1;
  for(var i=2; i < num ; i++){
    numFibs[i] = numFibs[i-1] + numFibs[i-2];
    if(numFibs[i] % 2 !== 0){
      sum += numFibs[i];
    }
  }
  console.log(sum);
  return sum ;
}

sumFibs(10);
Paul Snider
@snipaw26
Sep 27 2015 00:29
Why doesn't this command work? : noSpace = str.replaceAll("[-+.^:,]","");
Mateja Trifunovski
@Matko95
Sep 27 2015 00:30
@tedjpatterson could you compare to this?
//Let's create an object with a two functions. One attached as a property and one not.
var Car = function() {
  this.gear = 1;
  function addStyle(styleMe){
    return 'The Current Gear Is: ' + styleMe;
  }
  this.getGear = function() {
    return addStyle(this.gear);
  };
};

var Bike = function() {
  // Only change code below this line.
  speed = 100;
  function addUnit(value) {
    return value + "KM/H";
  }

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

};

// Only change code above this line.
var myCar = new Car();
var myBike = new Bike();

if(myBike.hasOwnProperty('getSpeed')){(function() {return JSON.stringify(myBike.getSpeed());})();};
KnittingInCode
@infoalisaa
Sep 27 2015 00:30
hello! has anyone done the ziplines before?
Paul Snider
@snipaw26
Sep 27 2015 00:30

function palindrome(str) {

var lower, noSpace, reverse = "";
var strLeng = 0;

lower = str.toLowerCase();
noSpace = str.replaceAll("[-+.^:,]","");
strLeng = noSpace.length;

for (strLeng-1; strLeng >=0; strLeng--) reverse = reverse+noSpace.charAt(strLeng);
if (reverse==noSpace) {return true;} else {return false;}

}

palindrome("A man, a plan, a canal. Panama");

I keep getting errors when trying to remove special characters.
Kenneth Black
@LawlietBlack
Sep 27 2015 00:31
@infoalisaa yeah, I've done them
KnittingInCode
@infoalisaa
Sep 27 2015 00:31
@LawlietBlack have you had any issues getting links to work in CodePen?
Kenneth Black
@LawlietBlack
Sep 27 2015 00:32
@infoalisaa yeah, it has some issues. Which one are you working on?
Paul Snider
@snipaw26
Sep 27 2015 00:32
Bonfire: Check for Palindromes
CamperBot
@camperbot
Sep 27 2015 00:32

:fire:Bonfire: Check for Palindromes :link:

function palindrome(str) {
  // Good luck!
  return true;
}



palindrome("eye");

Return true if the given string is a palindrome. Otherwise, return false.

more info:  bf details | bf links | hint

KnittingInCode
@infoalisaa
Sep 27 2015 00:32
@LawlietBlack I'm working on the first one that is to create a profile page. I've put in my LinkedIn link, and it doesn't open a new window at all.
Kenneth Black
@LawlietBlack
Sep 27 2015 00:33
alright, post your code and I'll take a look
Star Cherrix
@Sparklepaws
Sep 27 2015 00:33
@snipaw26 Strings are immutable if I'm remembered correctly, meaning you can't just "edit" them and get a result. You need to turn them into an array, change what you want, and then .join() them back together to form a string once more.
John Oksasoglu
@oksas
Sep 27 2015 00:33
@infoalisaa does it work if you try to open the link in a new tab (mouse3 clicking) ?
KnittingInCode
@infoalisaa
Sep 27 2015 00:34
@LawlietBlack here is my code:<div class='container'>
<div class="row">
<div class="col-md-12">
<nav class="navbar navbar-default" role="navigation">
<div class='col-md-12'>
<div class="navbar-header">
</button> <a class="navbar-brand" href="#">My Portfolio</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#">Link</a>
</li>
<li>
<a href="#">Link</a>
</li>
<li>
<a href="http://www.msn.com">Contact</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="jumbotron">
<h2>My name </h2>
<p>
I'm a <a href='http://freecodecamp.com/' target='_blank'>coder</a>.
</p>
</div>
<div class="row">
<div class="col-md-4">
<h2> Heading </h2>
<img class='img-responsive' src='http://i.imgur.com/jESF2.jpg'>
<p>
Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.
</p>
</div>
<div class="col-md-4">
<h2> Heading </h2>
<img class='img-responsive' src='http://i.imgur.com/jESF2.jpg'>
<p>
Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.
</p>
</div>
<div class="col-md-4">
<h2> Heading </h2>
<img class='img-responsive' src='http://i.imgur.com/jESF2.jpg'>
<p>
Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.
</p>
</div>
</div>
<div class='jumbotron'>
<h2 class='text-center'>Contact me</h2>
<div class='row'>
<div class='col-md-3'>
<button class='btn btn-block' href='#' target='_blank'>Twitter</button>
</div>
<div class='col-md-3'>
<button class='btn btn-block' href='https://linkedin.com/in/alisaarnold ' target='_blank'>LinkedIn</button>
</div>
<div class='col-md-3'>
<button class='btn btn-block' href='#' target='_blank'>GitHub</button>
</div>
<div class='col-md-3'>
<button class='btn btn-block' href='#' target='_self'>Free Code Camp</button>
</div>
</div>
</div>
</div>
Star Cherrix
@Sparklepaws
Sep 27 2015 00:34
@snipaw26 .split() and .filter() are your friends, along with .replace
John Oksasoglu
@oksas
Sep 27 2015 00:34
also, I'm a little confused on the exact change bonfire. one of the tests says this:
assert.deepEqual(drawer(3.26, 100.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]), [['TWENTY', 60.00], ['TEN', 20.00], ['FIVE', 15], ['ONE', 1], ['QUARTER', 0.50], ['DIME', 0.20], ['PENNY', 0.04] ], 'return correct change with multiple coins and bills');
Mateja Trifunovski
@Matko95
Sep 27 2015 00:34
@infoalisaa are you doing it on codepen?
KnittingInCode
@infoalisaa
Sep 27 2015 00:34
@oksas No, it doesn't unfortunately. :(
Star Cherrix
@Sparklepaws
Sep 27 2015 00:35
@infoalisaa You may want to use GIST in the future, it makes sharing large chunks of code easier and keeps the chat clean: https://gist.github.com/
:3
KnittingInCode
@infoalisaa
Sep 27 2015 00:35
@Matko95 Yeah, I'm doing it on CodePen.
John Oksasoglu
@oksas
Sep 27 2015 00:35
@infoalisaa hmm okay :( not what I thought then
Mateja Trifunovski
@Matko95
Sep 27 2015 00:35
@infoalisaa copy the codepen link, not the code :)
KnittingInCode
@infoalisaa
Sep 27 2015 00:35
oh, whoops! :D
Kenneth Black
@LawlietBlack
Sep 27 2015 00:35
@snipaw26 looks like replaceall is a jquery method, I'm not sure those work with strings
@infoalisaa also, if you're going to post code, wrap it in ``` on the top and bottom
KnittingInCode
@infoalisaa
Sep 27 2015 00:36
@Matko95 i think this is the link:http://codepen.io/fluentincoding/pen/jbVypR
DTing
@dting
Sep 27 2015 00:36
@oksas i think you have a floating point inaccuracy error
Risle
@Risle
Sep 27 2015 00:36
@snipaw26 Also using the global flag (g) in your regex expression would help: /[...]/g
Mateja Trifunovski
@Matko95
Sep 27 2015 00:36
@infoalisaa so which link doesn't work? in the navbar?
Paul Snider
@snipaw26
Sep 27 2015 00:37
.replace works once but if I change it to .replaceall I get an error.
DTing
@dting
Sep 27 2015 00:37
@oksas you can either deal with cents instead of dollars or used toFixed
KnittingInCode
@infoalisaa
Sep 27 2015 00:37
@Matko95 My LinkedIn link in the contact section.
John Oksasoglu
@oksas
Sep 27 2015 00:37
@dting I'm confused why it looks like the test is suggesting I should have $60 in twenties, and then $20 in tens, and not $80 in twenties and $10 in tens though
maybe I'm missing something here
DTing
@dting
Sep 27 2015 00:38
@oksas your drawer only starts with $60 in 20's
Kenneth Black
@LawlietBlack
Sep 27 2015 00:38
@infoalisaa not sure buttons with hrefs automatically act as links
DTing
@dting
Sep 27 2015 00:38
you cant have give $80 if you only have $60 in 20's
Mateja Trifunovski
@Matko95
Sep 27 2015 00:38
@infoalisaa you can't add a href value to a button
KnittingInCode
@infoalisaa
Sep 27 2015 00:38
@Matko95 Ah, so what do I do then?
Kenneth Black
@LawlietBlack
Sep 27 2015 00:38
@infoalisaa make it an anchor tag and give it the classes "btn" and "btn-block" and it will look the same - and work
John Oksasoglu
@oksas
Sep 27 2015 00:39
@dting loooool. ok. hadn't even considered that. awesome. thank you very much :D
CamperBot
@camperbot
Sep 27 2015 00:39
oksas sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1260 | @dting | http://www.freecodecamp.com/dting
Star Cherrix
@Sparklepaws
Sep 27 2015 00:39
@snipaw26 Don't use replaceAll, just use .replace(). As for your regex, make sure you use the opening tag / and close it again when you're done /. Putting the "g" after your closing tag will help you pass that particular Waypoint. So it should look something like this: /\s+/g
Mateja Trifunovski
@Matko95
Sep 27 2015 00:39
@infoalisaa if you are using bootstrap you can do <a href="#" class="btn btn-info" role="button"></a>
KnittingInCode
@infoalisaa
Sep 27 2015 00:39
@LawlietBlack but it already has those classes: <button class='btn btn-block' href='https://linkedin.com/in/alisaarnold ' target='_blank'>LinkedIn</button>
DJ
@qualitymanifest
Sep 27 2015 00:40
@Matko95 do you even have to do role="button" though? when i added role="button" i didn't notice a difference. it already worked fine FWIW
Kenneth Black
@LawlietBlack
Sep 27 2015 00:40
@infoalisaa yeah, but make it an < a> instead of <button>
DJ
@qualitymanifest
Sep 27 2015 00:40
@infoalisaa change it from button to a
Ted Patterson
@tedjpatterson
Sep 27 2015 00:40
@Matko95 Thanks for the help! I'm really not getting this JavaScript business :/
CamperBot
@camperbot
Sep 27 2015 00:40
tedjpatterson sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 386 | @matko95 | http://www.freecodecamp.com/matko95
Mateja Trifunovski
@Matko95
Sep 27 2015 00:40
@qualitymanifest well bootstrap documentation uses that, I guess not.. but maybe in jquery it can be called with the $("button") selector or something
Star Cherrix
@Sparklepaws
Sep 27 2015 00:40
Also can anyone tell me if there's a way to select child elements with CSS using class names? For example: .className p to select all paragraphs of .className
KnittingInCode
@infoalisaa
Sep 27 2015 00:41
@Matko95 and @LawlietBlack Thank you! Thank you! That worked!!!:D
CamperBot
@camperbot
Sep 27 2015 00:41
infoalisaa sends brownie points to @matko95 and @lawlietblack :sparkles: :thumbsup: :sparkles:
:star: 279 | @lawlietblack | http://www.freecodecamp.com/lawlietblack
:star: 387 | @matko95 | http://www.freecodecamp.com/matko95
Aaron Markle
@aaronmarkle
Sep 27 2015 00:41

why am i getting the error 'false is not a function' here

var newArray = arr.filter(Boolean());

shouldn't the above code run the Boolean() function on each array value, and then create a new array with only the values that returned true?

DJ
@qualitymanifest
Sep 27 2015 00:41
@Matko95 got it, can't hurt to include it
Kenneth Black
@LawlietBlack
Sep 27 2015 00:41
@Sparklepaws $('parent-thing').children('.class-name')
Mateja Trifunovski
@Matko95
Sep 27 2015 00:41
@Sparklepaws yep that works
@LawlietBlack that's jquery :)
Star Cherrix
@Sparklepaws
Sep 27 2015 00:42
@Matko95 Thanks Mat! And thank you for the effort too, @LawlietBlack
CamperBot
@camperbot
Sep 27 2015 00:42
sparklepaws sends brownie points to @matko95 and @lawlietblack :sparkles: :thumbsup: :sparkles:
:warning: sparklepaws already gave matko95 points
:star: 280 | @lawlietblack | http://www.freecodecamp.com/lawlietblack
John Oksasoglu
@oksas
Sep 27 2015 00:42
@aaronmarkle if I'm understanding correctly, you're passing filter another method
Kenneth Black
@LawlietBlack
Sep 27 2015 00:42
@Matko95 ah, you're right, that's sloppy, lol
John Oksasoglu
@oksas
Sep 27 2015 00:42
rather than passing it a function
one sec
DTing
@dting
Sep 27 2015 00:42
@aaronmarkle you should pass the function
return arr.filter(Boolean);
you are passing the result of calling the Boolean function with no arguments
Kenneth Black
@LawlietBlack
Sep 27 2015 00:43
@Sparklepaws .className p.otherclassname
Star Cherrix
@Sparklepaws
Sep 27 2015 00:43
@LawlietBlack So the paragraphs have to have a class name?
Aaron Markle
@aaronmarkle
Sep 27 2015 00:43
@dting aaaaaah, just needed to get rid of those pesky () after boolean, gotcha
i get that, pass the function, don't pass the result of the function
for .filter
Kenneth Black
@LawlietBlack
Sep 27 2015 00:44
@Sparklepaws oh no, if you want all the p elements of the .classname parent, what you had works fine
DTing
@dting
Sep 27 2015 00:44
the Boolean argument with no arguments evaluates to false. Then the array filter tries to call false with each element, false isnt a function so it throws that error
Star Cherrix
@Sparklepaws
Sep 27 2015 00:44
@LawlietBlack Yeah that's what I was shooting for, perfect!
Kenneth Black
@LawlietBlack
Sep 27 2015 00:44
@Sparklepaws my reading comprehension is really bad today, lol
DTing
@dting
Sep 27 2015 00:44
ya
Aaron Markle
@aaronmarkle
Sep 27 2015 00:45
thanks @dting @oksas i was scrambling my head on that one for a while lol
CamperBot
@camperbot
Sep 27 2015 00:45
aaronmarkle sends brownie points to @dting and @oksas :sparkles: :thumbsup: :sparkles:
:star: 210 | @oksas | http://www.freecodecamp.com/oksas
:star: 1261 | @dting | http://www.freecodecamp.com/dting
peopleblazin
@peopleblazin
Sep 27 2015 00:46
How do I make a word underlined in HTML
Mateja Trifunovski
@Matko95
Sep 27 2015 00:46
@peopleblazin text-decoration: underline;
peopleblazin
@peopleblazin
Sep 27 2015 00:49
okay thanks
@Matko95
CamperBot
@camperbot
Sep 27 2015 00:49
peopleblazin sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 388 | @matko95 | http://www.freecodecamp.com/matko95
Devon Jones
@jones-codes
Sep 27 2015 00:58
hey how do you view the suggested answer of a bonfire after you complete it?
DJ
@qualitymanifest
Sep 27 2015 01:00
@jones-codes you can type something like "bonfire name of bonfire"
then "hint"
in the chat here
which one are you looking for
Devon Jones
@jones-codes
Sep 27 2015 01:03
Thanks @qualitymanifest
CamperBot
@camperbot
Sep 27 2015 01:03
jones-codes sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 230 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Devon Jones
@jones-codes
Sep 27 2015 01:03
It's Find the Longest Word in a String
Wasn't too bad, just want to tighten up my code
DJ
@qualitymanifest
Sep 27 2015 01:04
bonfire find longest word
CamperBot
@camperbot
Sep 27 2015 01:04

:fire:Bonfire: Find the Longest Word in a String :link:

function findLongestWord(str) {
  return str.length;
}

findLongestWord('The quick brown fox jumped over the lazy dog');

Return the length of the longest word in the provided sentence.

more info:  bf details | bf links | hint

Devon Jones
@jones-codes
Sep 27 2015 01:04
hint
CamperBot
@camperbot
Sep 27 2015 01:04
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Jason
@Jauble
Sep 27 2015 01:04
That would be a good idea to show the suggested answer when you complete so you can compare them
DJ
@qualitymanifest
Sep 27 2015 01:05
and then yeah just click the link to the custom room. you can share your code on here too and ask how it could be optimized. i've done that a few times and gotten good responses
Jason
@Jauble
Sep 27 2015 01:07
@qualitymanifest I was thinking about doing that. Do you just post 'code' before and after your code?
Devon Jones
@jones-codes
Sep 27 2015 01:07
is there a fancy way to do that?
DJ
@qualitymanifest
Sep 27 2015 01:07
@Jauble i can kinda relate but sometimes the "best practice" answer involves methods that really haven't been taught that far along yet
help format
CamperBot
@camperbot
Sep 27 2015 01:08

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks, then type js or html and then press [shift + enter ⏎]

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

DJ
@qualitymanifest
Sep 27 2015 01:08
the part that really trips people up is you have to use backticks ` not single quotes '. and you have to do them on separate lines above, and below, your code
Devon Jones
@jones-codes
Sep 27 2015 01:09
Well I don't see a backtick, nor do I even understand where I place my code in there lol
DJ
@qualitymanifest
Sep 27 2015 01:09
backticks are upper left of the keyboard, same key as ~
so you would do
your code here
whoops it formatted it even with ~'s haha
Devon Jones
@jones-codes
Sep 27 2015 01:11
function findLongestWord(str) {
  var array = str.split(' ');
  var high_length = 0;
  array = array.map(function(word){
  var word_length = word.length;
  if (word_length > high_length)
    high_length = word_length;
});
  return high_length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Thanks @qualitymanifest
CamperBot
@camperbot
Sep 27 2015 01:11
jones-codes sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:warning: jones-codes already gave qualitymanifest points
DJ
@qualitymanifest
Sep 27 2015 01:11
This message was deleted
Devon Jones
@jones-codes
Sep 27 2015 01:12
I'm just interested if there's an advantage/disadvantage in using the array map method vs. a for loop
DJ
@qualitymanifest
Sep 27 2015 01:14
i can't say for sure. i still haven't used .map and i solved that one with for loops. i will say it's good to learn new methods like that rather than trying to use loops for everything
Devon Jones
@jones-codes
Sep 27 2015 01:15
I believe they recently added the .map waypoint, which I just did today. So I used a for loop first, then figured I might as well try to apply .map
random but learned that setting up for loops like this may be a good habit to get into to save processing time on larger loops:
DJ
@qualitymanifest
Sep 27 2015 01:16
turns out i did that waypoint and forgot what i learned!
Devon Jones
@jones-codes
Sep 27 2015 01:18
for (var i=0, max = string.length; i < max; i++){ };
Haha it was a short one, easy to forget
DJ
@qualitymanifest
Sep 27 2015 01:19
@jones-codes huh, how does that end up being faster than just i < string.length?
because it doesn't have to keep referring to string.length, since it already has max?
Devon Jones
@jones-codes
Sep 27 2015 01:20
indeed, max becomes a static number once it is assigned that first time
so it doesn't have to run .length every time through
@jones-codes thanks
CamperBot
@camperbot
Sep 27 2015 01:21
qualitymanifest sends brownie points to @jones-codes :sparkles: :thumbsup: :sparkles:
:star: 175 | @jones-codes | http://www.freecodecamp.com/jones-codes
Jason
@Jauble
Sep 27 2015 01:22
Can anyone read this?
DJ
@qualitymanifest
Sep 27 2015 01:22
@Jauble yes?
Devon Jones
@jones-codes
Sep 27 2015 01:23
No worries
Awesome, I'll read that, someone just showed me a short quote from a book to explain, could use some detail
Jason
@Jauble
Sep 27 2015 01:27
anyone know how to paste code? I've tried using the 3 back-ticks and using code but can't get anything to work.
DJ
@qualitymanifest
Sep 27 2015 01:29
3 backticks
paste your code here
3 more backticks
Jason
@Jauble
Sep 27 2015 01:30
ohhhh I'm an idiot, i thought it was 3 backticks and then the characters "js" then your code lol
I thought you had to tell it what type of code you were posting
function reverseString(str) {
  var array = [];
  for (var i = 0; i < str.length; i++) {
    array[i] = str[i];
  }
  str = array.reverse().toString();
  var comma = /,/g
  return str.replace(comma, "");
}

reverseString("hello", "");
Anyone know how I could make this more efficient?
And also why they have the extra quotes after "hello" in the function call
Since there
Since there's only one parameter, is the second argument just ignored?
DJ
@qualitymanifest
Sep 27 2015 01:37
i believe the extra quotes are where they put the string you produce to compare, for their own testing to see if you passed
Jason
@Jauble
Sep 27 2015 01:37
Oh ok
DTing
@dting
Sep 27 2015 01:38
@Jauble you can use str.split('') instead of a for loop
doesnt make it more efficient but makes it more consice
also you shouldnt toString your array
Aaron Markle
@aaronmarkle
Sep 27 2015 01:38
i have a feeling im gonna be on seek and destroy bonfire all night :/
DTing
@dting
Sep 27 2015 01:38
use Array.join('')
then you dont need to do the str.replace(coma, '')
Jason
@Jauble
Sep 27 2015 01:39
so .join("") omits the commas?
DTing
@dting
Sep 27 2015 01:39
bf reverse
CamperBot
@camperbot
Sep 27 2015 01:39

:fire:Bonfire: Reverse a String :link:

function reverseString(str) {
  return str;
}

reverseString('hello');

Reverse the provided string.

more info:  bf details | bf links | hint

Jose E. Pimentel
@jedpimentel
Sep 27 2015 01:39
there aren't any cmmas in the string to begin with
DTing
@dting
Sep 27 2015 01:39
bf links
DTing
@dting
Sep 27 2015 01:40
@jedpimentel if you toString an array
it inserts commas
DJ
@qualitymanifest
Sep 27 2015 01:40
whoops i was wrong here
Jose E. Pimentel
@jedpimentel
Sep 27 2015 01:40
whoa, I didn't know about that, I'll need to practice toString a bit,
DTing
@dting
Sep 27 2015 01:41
var a = "hello";
a.split('').toString();
"h,e,l,l,o"
DJ
@qualitymanifest
Sep 27 2015 01:42
huh. the more you know.
Moisés Man
@moigithub
Sep 27 2015 01:43
function reverseString(str) {
  var desrever= "";
  for (var i = 0; i < str.length; i++) {
//      desrever = desrever + str[i];
      desrever =  str[i] +   desrever;
  }
  return desrever;
}
DJ
@qualitymanifest
Sep 27 2015 01:44
oh yeah i just looked up that bonfire again, you can solve that in one line...
if you utilize what's contained in the "helpful links"
Yashaswi Yogeshwara
@yashaswiyogeshwara
Sep 27 2015 01:46
@all how can i can get feedback on the Zipline i completed
Jose E. Pimentel
@jedpimentel
Sep 27 2015 01:46
@yashaswiyogeshwara just share it in the chat, :p
Kory J. Campbell
@KoryJCampbell
Sep 27 2015 01:46
@moigithub how did you share you code in here?
@moigithub the screenshot of your code?
Jason
@Jauble
Sep 27 2015 01:47

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

reverseString("hello", "");```

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

reverseString("hello", "");
How's that?
@KoryJCampbell is that you or Tupac?
Kory J. Campbell
@KoryJCampbell
Sep 27 2015 01:50
@jauble it's me
Jose E. Pimentel
@jedpimentel
Sep 27 2015 01:50
It's possible to squeeze it a bit more (into a single "return _"),
Karolis
@Luomint
Sep 27 2015 01:52
maybe someone has an idea why nothing works with the "api1" but ok with api2... https://gist.github.com/Luomint/5d7dbf12271539c2e237
Will Stufflebeam
@stufflebeam
Sep 27 2015 01:52
function reverseString(str) {
  return str.split('').reverse().join('');
}
Jason
@Jauble
Sep 27 2015 01:53
@stufflebeam wow, didn't think of that, that's awesome
Will Stufflebeam
@stufflebeam
Sep 27 2015 01:56
:smile:
Jason
@Jauble
Sep 27 2015 02:05
@jedpimentel just noticed your comment, thanks
CamperBot
@camperbot
Sep 27 2015 02:05
jauble sends brownie points to @jedpimentel :sparkles: :thumbsup: :sparkles:
:star: 317 | @jedpimentel | http://www.freecodecamp.com/jedpimentel
Kory J. Campbell
@KoryJCampbell
Sep 27 2015 02:13
What am i doing wrong here?

var array = [4,5,6,7,8];
var singleVal = 0;
// Only change code below this line.

var singleVal =
array.reduce(function(previousVal, currentVal) {
return
previousVal+currentVal;
});

// Only change code above this line.
(function() {return singleVal;})();

{singleVal should have been set to the result of you reduce operation}
Jason
@Jauble
Sep 27 2015 02:15
I've learned/am learning: HTML, CSS, JavaScript, jQuery & Bootstrap. What do you guys think would be the most logical next step? PHP, Python, SQL? (I'm not much of a fan of Ruby).
@KoryJCampbell I had a problem with that one too, that looks like what I passed with though. Try typing three backtaps ``` (below the esc key usually) then enter, then post your code, then type three more backtaps and enter. It will format your code correctly.
Jason
@Jauble
Sep 27 2015 02:21
try putting previousVal+currentVal on the same line as return
@KoryJCampbell try putting previousVal+currentVal on the same line as return
OverTheNeptune
@OverTheNeptune
Sep 27 2015 02:22
@KoryJCampbell what Jauble just said. Playing around with it, the line break there seems to be the problem.
return previousVal+currentVal;
Kory J. Campbell
@KoryJCampbell
Sep 27 2015 02:23
@OverTheNeptune @Jauble dope got it. thanks
CamperBot
@camperbot
Sep 27 2015 02:23
koryjcampbell sends brownie points to @overtheneptune and @jauble :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for jauble
:star: 207 | @overtheneptune | http://www.freecodecamp.com/overtheneptune
OverTheNeptune
@OverTheNeptune
Sep 27 2015 02:24
No problem. Glad to help. :)
Jason
@Jauble
Sep 27 2015 02:24
no prob
Yashaswi Yogeshwara
@yashaswiyogeshwara
Sep 27 2015 02:29
thanks @jedpimentel
CamperBot
@camperbot
Sep 27 2015 02:29
yashaswiyogeshwara sends brownie points to @jedpimentel :sparkles: :thumbsup: :sparkles:
:star: 319 | @jedpimentel | http://www.freecodecamp.com/jedpimentel
JeremyWBean
@JeremyWBean
Sep 27 2015 02:33
Hey, folks. I think I am finished with my Simon game and am excited about moving on to GIT and dealing with databases! If you don't mind, check it out to make sure there are not ridiculous flaws! http://codepen.io/JeremyWBean/full/vOqwgG
Yashaswi Yogeshwara
@yashaswiyogeshwara
Sep 27 2015 02:33
Hey guys this is below is my code pen to my first ZipLine. Please give me your feedback. I've used JSONP requests to get the data from the http://forismatic.com/en/api/
Application : http://codepen.io/theMeticulist/full/vNyGZE/
Code : http://codepen.io/theMeticulist/pen/vNyGZE
Mateja Trifunovski
@Matko95
Sep 27 2015 02:37
@JeremyWBean nice
JeremyWBean
@JeremyWBean
Sep 27 2015 02:38
@Matko95 Thanks!
CamperBot
@camperbot
Sep 27 2015 02:38
jeremywbean sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 389 | @matko95 | http://www.freecodecamp.com/matko95
Sebastian Hewelt
@sebhewelt
Sep 27 2015 02:52
Hey, struggling with random background for my zip. While randomquote() works, randomcover() doesn't and hell no, i have no clue why. Any ideas? http://codepen.io/RycerzPegaza/pen/YypZza
JeremyWBean
@JeremyWBean
Sep 27 2015 03:06
Are you wanting it to be a random background-image every time you load the page?
Farhad ali
@alifarhad
Sep 27 2015 03:08
can someone pls help me with a tiny jquery problem?
JeremyWBean
@JeremyWBean
Sep 27 2015 03:09
@alifarhad I'll give it a shot.
Farhad ali
@alifarhad
Sep 27 2015 03:09
im grabbing a value from an iput filed and appending the value inside a div once the button is clicked using jqery with this code
$(document).ready(function() {
  $("#btn").click(function() {
var user = $("#icon_prefix").val();
 $(".holder").append("<p> id is " + user );
    return false;





  });

});
but I want to remove that appended p once the user input another value
how do i do that?
ok it should be
 $(".holder").append("<p> id is " + user  + "</p>");
but how do i remove this <p> once the button is clicked again with another value?
JeremyWBean
@JeremyWBean
Sep 27 2015 03:12
Is it putting your output on a new line of code every time?
Farhad ali
@alifarhad
Sep 27 2015 03:13
yeah
JeremyWBean
@JeremyWBean
Sep 27 2015 03:14
have you thought about just using .html()?
Farhad ali
@alifarhad
Sep 27 2015 03:14
I want it to remove the last value first and then append the new value once the button is clicked again
nope what about that?
JeremyWBean
@JeremyWBean
Sep 27 2015 03:16
Try this:
$('.holder').html('<p> id is " + user + '</p>');
Farhad ali
@alifarhad
Sep 27 2015 03:18
how it's going to help me remove a <p> once the button is clicked again?
JeremyWBean
@JeremyWBean
Sep 27 2015 03:20
It just updates the element each time the button is clicked. You don't have to append, it just takes the full user var along with the tags and places in the element, clearing the previous information.
Farhad ali
@alifarhad
Sep 27 2015 03:20
ok let me try
sorry doesn't seem to be working @JeremyWBean
it doesn't even append the new <p> in the first place
JeremyWBean
@JeremyWBean
Sep 27 2015 03:22
Can I see your full code?
Farhad ali
@alifarhad
Sep 27 2015 03:23
sure
$(document).ready(function() {
  $("#btn").onclick(function() {
var user = $("#icon_prefix").val();
$('.holder').html('<p> id is' + user + '</p>');





  });


});
JeremyWBean
@JeremyWBean
Sep 27 2015 03:24
I meant in the context of the application you are creating. I was just wanting to see exactly what you were doing.
If I could see the html and the rest of the js, it would be helpful in figuring it out.
Farhad ali
@alifarhad
Sep 27 2015 03:25
let me put it on my codepen
JeremyWBean
@JeremyWBean
Sep 27 2015 03:28
Okay.
Paul Calabrese
@pacalabre
Sep 27 2015 03:28
so here is my quote generator http://codepen.io/pacalabre/pen/xwVYWV i did it a bit differently than the example, which I know is okay since it works... but is the way I did it not as good or efficient? should I try to restructure this?
Farhad ali
@alifarhad
Sep 27 2015 03:28
JeremyWBean
@JeremyWBean
Sep 27 2015 03:31
In your jquery, change onClick to click on line 2.
Farhad ali
@alifarhad
Sep 27 2015 03:31
right. it was click initially
it works ok with click. does append a new <p>
but my issue is when you give it another value and click sumbit
it adds the new value below the first one which is not what i want
i want it to remove the last one first and then go on to adding the new ones
x34passenger
@x34passenger
Sep 27 2015 03:33
how do you test for if it is a function or not?
JeremyWBean
@JeremyWBean
Sep 27 2015 03:34
So, if I type Jeremy and click submit, you want it to say id is Jeremy.. And when I type a new name and click submit, you want it to only say the new username?
Farhad ali
@alifarhad
Sep 27 2015 03:34
exaclty @JeremyWBean
JeremyWBean
@JeremyWBean
Sep 27 2015 03:35
$('.holder').html('');
Farhad ali
@alifarhad
Sep 27 2015 03:35
if i get it working then I can go ahead and do something else much better. this one is just for test
JeremyWBean
@JeremyWBean
Sep 27 2015 03:35
add that on the line before the append method. It will clear the element before posting your new username.
Farhad ali
@alifarhad
Sep 27 2015 03:35
where should I put that?
JeremyWBean
@JeremyWBean
Sep 27 2015 03:35
G2G
Farhad ali
@alifarhad
Sep 27 2015 03:36
it worked ! thank you !!! @JeremyWBean
CamperBot
@camperbot
Sep 27 2015 03:36
alifarhad sends brownie points to @jeremywbean :sparkles: :thumbsup: :sparkles:
:star: 296 | @jeremywbean | http://www.freecodecamp.com/jeremywbean
Farhad ali
@alifarhad
Sep 27 2015 03:36
you are a live saver!
x34passenger
@x34passenger
Sep 27 2015 03:38
how do you test for if it is a function or not?
Farhad ali
@alifarhad
Sep 27 2015 03:39
you mean in javascript? @x34passenger
x34passenger
@x34passenger
Sep 27 2015 03:39
@alifarhad yes
Farhad ali
@alifarhad
Sep 27 2015 03:39
there's a method called "typeof()" in javascript @x34passenger
it lets you know about the type of something
like this code here produces "string"
var s = "farhad";
alert(typeof(s));
and this one results into an alert reading "function" :
var s = function() {
  alert(s);
}
alert(typeof(s));
x34passenger
@x34passenger
Sep 27 2015 03:42
@alifarhad typeof(s) == Function ?
@alifarhad typeof(s) === Function ?
Mateja Trifunovski
@Matko95
Sep 27 2015 03:42
@x34passenger yep
Farhad ali
@alifarhad
Sep 27 2015 03:42
yeah @x34passenger
Aaron Markle
@aaronmarkle
Sep 27 2015 04:08
is there a certain reason in particular this doesn't work for the seek and destroy bonfire?
function destroyer(arr) {  
  for (var j=1; j<arguments.length; j++){ //loop through arguments
    for (var k=0; k<arr.length; k++){ //loop through elements of first array
      if (arguments[j] === arr[k]){ //if array element matches an argument, delete it
        arr.splice(k, 1);
        k = 0;                      //i think splicing was affecting indexes, so this was added
      }
    }
  }  

  return arr;
}
it works across all cases but 1, where it should produce an empty array, but it leaves one element in there (even though it got rid of the other element of the same value)
DJ
@qualitymanifest
Sep 27 2015 04:21
@aaronmarkle i'm looking into it now. i will say, it's valuable to learn .filter
Aaron Markle
@aaronmarkle
Sep 27 2015 04:25
ya, i knew i was doing this in the wrong fashion, i kept going back and forth. i did eventually break down and check the solution for this one (been struggling all day with this one) and i understand what i was doing wrong before
Boris
@boris-in-london
Sep 27 2015 04:29
Love that you all are working and helping on a Saturday night.
I came across a problem I've been working on today. If anyone has a min, i'd appreciate some help. big time.
function palindrome(str) {
  // Good luck!
//debugger;
  var lowerCase = str.toLowerCase();
  var strOne = lowerCase.replace(/[,!@#.$%^&*() ]/g, '').split("");

  for (var i = 0; i < strOne.length; i++) {
    if (strOne[i] != strOne[(strOne.length - 1) - i]) {
      return false;
      }
    }  
  return true;

}



palindrome("0_0 (: /-\\ :) 0-0");
So this is suppose to return true but i'm getting false with my code. I have no idea why... banging my head against a wall right now.
Alexander
@teichopsia-
Sep 27 2015 04:33
@boris-in-london That's actually the next one I'm supposed to work on... I believe I have a version of that in python if you want to take a look at it... tough, it doesn't use regex
Boris
@boris-in-london
Sep 27 2015 04:33
@teichopsia- sure, i could check my logic against it. thanks
CamperBot
@camperbot
Sep 27 2015 04:33
boris-in-london sends brownie points to @teichopsia- :sparkles: :thumbsup: :sparkles:
:star: 177 | @teichopsia- | http://www.freecodecamp.com/teichopsia-
Boris
@boris-in-london
Sep 27 2015 04:34
@teichopsia- it would be a huge help if you could run my code and see why it's doing that though...
HUGE!
i can't make sense of it
Alexander
@teichopsia-
Sep 27 2015 04:35
pali = 'Able was I ere I saw Elba'

def isPalindrome(word):
    '''
    Returns True if a word or a phrase is a palindrome
    '''

    word = word.lower().replace(' ', '')

    if len(word) <= 1:
        return True
    return word[0] == word[-1] and isPalindrome(word[1:-1])

the last line uses recursion...

Sure thing, give me a while to check it out....

CamperBot
@camperbot
Sep 27 2015 04:35
:bulb: to format code use backticks! ``` more info
Boris
@boris-in-london
Sep 27 2015 04:36
How does your python code iterate over the code without a loop?
Alexander
@teichopsia-
Sep 27 2015 04:37

@boris-in-london do you use anything besides freecodecamps in browser interpreter for js? Just curious cause I would like to use something besides that.

It uses recursion.... the last line after the and..... it slices the string each time through the loop..... and I'm not quite sure how that boolean works..... let me see if I have a different version.

Boris
@boris-in-london
Sep 27 2015 04:38
i'm sorry, i'm a noob. my lingo maybe off.. what i mean is. how does your program keep going after the first word
yes i use atom as a text editor and google dev tools as console and debugger.
it's a great combo recommended to me by a regular here. i want to that him again, i forgot his name but i would recognize his profile pic.
Alexander
@teichopsia-
Sep 27 2015 04:40

ah... my machine is too old for atom.

recursion is a function that calls itself..... this conversation would go on for quite a while since there are quite a few concepts I would need to explain......

Boris
@boris-in-london
Sep 27 2015 04:40
no problem. i'll google recursions
Hans van Riet
@hansinla
Sep 27 2015 04:42
@boris-in-london What you want to do in JS is strip out all punctuation, then reverse the string and compare that with then original string minus all non standard characters.
Boris
@boris-in-london
Sep 27 2015 04:44
so stip "-" and "_"
strip*
so that argument will be empty.
Aaron Markle
@aaronmarkle
Sep 27 2015 04:45
the 0's will remain
Hans van Riet
@hansinla
Sep 27 2015 04:45
@boris-in-london No, strip anything that’s not a-z
Boris
@boris-in-london
Sep 27 2015 04:45
AY!!!! you two are good guys, i appreciate that help. let me go give it a try. Thanks @hansinla and @aaronmarkle
CamperBot
@camperbot
Sep 27 2015 04:45
boris-in-london sends brownie points to @hansinla and @aaronmarkle :sparkles: :thumbsup: :sparkles:
:star: 399 | @hansinla | http://www.freecodecamp.com/hansinla
:star: 187 | @aaronmarkle | http://www.freecodecamp.com/aaronmarkle
Alexander
@teichopsia-
Sep 27 2015 05:06
folks.... I set up a basic repo for pair programming... If it's a good idea or not, I don't know... could I get some feed back? The idea is to make it a group collaboration.... maybe add a skeleton so other people can fork it and use a clean slate.....
https://github.com/teichopsia-/freeCodeCamp
x34passenger
@x34passenger
Sep 27 2015 05:17
how do you return that something is not a function
Aayush Kapoor
@xeoneux
Sep 27 2015 05:18
@x34passenger What?
x34passenger
@x34passenger
Sep 27 2015 05:19
@xeoneux Bonfire: Arguments Optional
Aayush Kapoor
@xeoneux
Sep 27 2015 05:21
@x34passenger What is your question?
x34passenger
@x34passenger
Sep 27 2015 05:21
@xeoneux expect(add(2)(3)).to.equal(5);add(...) is not a function <- I don't know how to return is not a function
Aayush Kapoor
@xeoneux
Sep 27 2015 05:22
@x34passenger You return 5
@x34passenger 5 is not a function
@x34passenger 5 is a number
x34passenger
@x34passenger
Sep 27 2015 05:23
@xeoneux ok, will try it
Arooj
@aroojahmad
Sep 27 2015 05:30
function largestOfFour(arr) {
  for (i = 0; i < arr.length; i++) {
    for (j=0; j<arr[j].length; j++) {
      if the number at j is greater than the other numbers in the array, then store that number in a new array
    }
  }
  return arr;
}
Arooj
@aroojahmad
Sep 27 2015 05:37
Any ideas?
Jason
@Jauble
Sep 27 2015 05:46
Sorry, not that far along yet. That's recursion right?
Devon Jones
@jones-codes
Sep 27 2015 05:47
@aroojahmad working on that now
I think what I'm trying will work, it seems way too long though
Jason
@Jauble
Sep 27 2015 05:52
Anyone know a better way to do this? ```
function factorialize(num) {
  var newNum = num;
  if (num > 0) {
    for (var i = num-1; i > 1; i--) {
      newNum *= i;
      num--;
    }
  }
  else {
    newNum = 1;
  }
  return newNum;
}

factorialize(5, '');
Alexander
@teichopsia-
Sep 27 2015 05:53
@Jauble
function factorialize(num) {
  if (num <= 1) {
    return 1;
  }
else {
    // uses recursion to solve the problem
  return num * factorialize(num -1);
    }
}
factorialize(5, '');
Jason
@Jauble
Sep 27 2015 05:57
I thought I remembered using a factorialize method at one point. Other than using factorialize, do you know of any way mine could be better?
Devon Jones
@jones-codes
Sep 27 2015 05:57
@aroojahmad I had my code the same way, you have to declare your i and j variables
Arooj
@aroojahmad
Sep 27 2015 05:59
@jones-codes they are declared in the for loops, right?
Devon Jones
@jones-codes
Sep 27 2015 05:59
yes by placing var in front of them
Jason
@Jauble
Sep 27 2015 05:59
Oh, and thanks @teichopsia-
CamperBot
@camperbot
Sep 27 2015 05:59
jauble sends brownie points to @teichopsia- :sparkles: :thumbsup: :sparkles:
:star: 179 | @teichopsia- | http://www.freecodecamp.com/teichopsia-
Alexander
@teichopsia-
Sep 27 2015 06:01
not at all @Jauble, thank @jones-codes
CamperBot
@camperbot
Sep 27 2015 06:01
teichopsia- sends brownie points to @jauble and @jones-codes :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for jauble
:star: 179 | @jones-codes | http://www.freecodecamp.com/jones-codes
Devon Jones
@jones-codes
Sep 27 2015 06:02
lol how did I help??
Jason
@Jauble
Sep 27 2015 06:03
@jones-codes I dunno, thanks though lol. We're neighbors btw. I'm in SJ
CamperBot
@camperbot
Sep 27 2015 06:03
jauble sends brownie points to @jones-codes :sparkles: :thumbsup: :sparkles:
:star: 180 | @jones-codes | http://www.freecodecamp.com/jones-codes
Devon Jones
@jones-codes
Sep 27 2015 06:03
Oh really??
Jason
@Jauble
Sep 27 2015 06:04
Yep
Devon Jones
@jones-codes
Sep 27 2015 06:04
I'm meeting up with some folks for bonfires in Berkeley tomorrow if you wanna join, I know it's a trek
Jason
@Jauble
Sep 27 2015 06:05
I would, but that's kinda far
Do you guys meet up regularly?
Devon Jones
@jones-codes
Sep 27 2015 06:06
We will see, tomorrow is our first attempt. We have next Sunday scheduled too
Jason
@Jauble
Sep 27 2015 06:06
I see
Devon Jones
@jones-codes
Sep 27 2015 06:06
From a Newbie Coder FB group, but everyone is doing FCC I think
Alexander
@teichopsia-
Sep 27 2015 06:08
@jones-codes :smile: because you noticed that he had to declare the variables.... I'm still struggling with javascript...... damn it's semi colons....
Jason
@Jauble
Sep 27 2015 06:08
I see. Is it a bay area group?
Devon Jones
@jones-codes
Sep 27 2015 06:09
Not even, someone just posted asking if anyone was in the bay
Honestly really random lol
Jason
@Jauble
Sep 27 2015 06:10
lol
Devon Jones
@jones-codes
Sep 27 2015 06:10
Ahh gotcha @teichopsia- I am struggling too
Jason
@Jauble
Sep 27 2015 06:11
Do you have a link? I'd like to check it out if that's cool
Devon Jones
@jones-codes
Sep 27 2015 06:11
The Title Case bonfire had me pulling hairs
For sure
Jason
@Jauble
Sep 27 2015 06:12
Awesome thanks
CamperBot
@camperbot
Sep 27 2015 06:12
if you want to thank someone, put an @ before their name!
Devon Jones
@jones-codes
Sep 27 2015 06:15
@aroojahmad How's it coming along??
I think I'm close if you want to see what I hve
Jason
@Jauble
Sep 27 2015 06:15
It says it's closed. Gotta wait and see if I'm approved I guess
Devon Jones
@jones-codes
Sep 27 2015 06:16
Ahh yeah, the admins are quick I think. It's late though
Luis Felipe López G.
@luishendrix92
Sep 27 2015 06:20
@teichopsia- Why don't you use Coffescript? I'll put one of my bonfires as an example in both js and coffescript:

Bonfire: Steamroller in CoffeeScript

steamroller = (arr) ->
  flattenedArray = []

  flatten = (list) ->
    list.forEach (element) ->
      if Array.isArray element
        flatten element
      else
        flattenedArray.push element
      return
    return

  flatten arr
  return flattenedArray

steamroller [1, [2], [3, [[4]]]]

Now in JS

function steamroller(arr) {
  var flattenedArray = [];

  function flatten(list) {
    list.forEach(function(element) {
      if ( Array.isArray(element) )
        flatten(element);
      else
        flattenedArray.push(element);
    });
  }

  flatten(arr);
  return flattenedArray;
}

steamroller([1, [2], [3, [[4]]]]);
Jason
@Jauble
Sep 27 2015 06:20
Cool. Ya, I doubt it would be approved tonight.
Devon Jones
@jones-codes
Sep 27 2015 06:21
Got it @aroojahmad if you need any help
Alexander
@teichopsia-
Sep 27 2015 06:21

guys, I'm trying to work out the palindromes.... do you know if this regular expression is correct?

var re = /\s\./gi;

@luishendrix92 it would be something new to learn..... I actually know a bit of python and am planning on using that...

Luis Felipe López G.
@luishendrix92
Sep 27 2015 06:22
Coffeescript is a JS preprocessor, it's not actually a separate language, well, IDK how to call it :P, it compiles into JS
Devon Jones
@jones-codes
Sep 27 2015 06:23
@teichopsia- That stuff gave me a headache
here's what i decided was the east reg exp to use, I remember looking at a bunch
easiest*
/\W/ig
Yours may be the same though, don't recall was s does
Alexander
@teichopsia-
Sep 27 2015 06:26
s strips whitespace...... I'm assuming what mine means is:
\s = find whitespace
. = find dots
not sure what gi stand for :smile:
missed a slash there
. = find dots
Devon Jones
@jones-codes
Sep 27 2015 06:26
i is ignore case
g is to make it global, instead of just checking the first character
Luis Felipe López G.
@luishendrix92
Sep 27 2015 06:26
@teichopsia- Hmm nope, that's not the RegExp, for what I see you're trying to replace both whitespace characters and literal dots, so you're basically saying this:
Match any occurence of SPACE. instead of . OR SPACE
You'd want to use: var re = /[\s\.]/g;
Alexander
@teichopsia-
Sep 27 2015 06:28
@luishendrix92 I hate regex, thanks!
CamperBot
@camperbot
Sep 27 2015 06:28
teichopsia- sends brownie points to @luishendrix92 :sparkles: :thumbsup: :sparkles:
:star: 385 | @luishendrix92 | http://www.freecodecamp.com/luishendrix92
Devon Jones
@jones-codes
Sep 27 2015 06:28
\W refers to everything not a number or letter, including space and dots ;)
Alexander
@teichopsia-
Sep 27 2015 06:29
@jones-codes thanks... i'll test both out
var re = /[\s\s]/g;
var er = /\W/ig;
CamperBot
@camperbot
Sep 27 2015 06:29
teichopsia- sends brownie points to @jones-codes :sparkles: :thumbsup: :sparkles:
:warning: teichopsia- already gave jones-codes points
Luis Felipe López G.
@luishendrix92
Sep 27 2015 06:29
The downside is that it considers underscores _
Alexander
@teichopsia-
Sep 27 2015 06:29
var re = /[\s\.]/g;
var er = /\W/ig;
Luis Felipe López G.
@luishendrix92
Sep 27 2015 06:30
But tbh who in their reight minds would write a prhase with underscores
I used /\W/g as well, seems more appropriate
the i flag isn't necessary since alphanumeric characters also include uppercase letters
Devon Jones
@jones-codes
Sep 27 2015 06:32
ahh thanks @luishendrix92
CamperBot
@camperbot
Sep 27 2015 06:32
jones-codes sends brownie points to @luishendrix92 :sparkles: :thumbsup: :sparkles:
:star: 386 | @luishendrix92 | http://www.freecodecamp.com/luishendrix92
Don Price
@KingHippo
Sep 27 2015 06:34
I'm working on the Bonfire: Mutations. Wondering if someone can tell me if I'm headed in the right direction?
function mutation(arr) {
  var letter = arr[1][0].toLowerCase();
  var string = arr[0].toLowerCase().split("");
  return arr.indexOf(letter, string);
}

mutation(["Hello", "Hey"], "");
Abhisek Pattnaik
@abhisekp
Sep 27 2015 06:39
explain regex
CamperBot
@camperbot
Sep 27 2015 06:39

:point_right: js regex [wiki]

Links to useful RegEx resources.

See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software

:pencil: read more about js regex on the FCC Wiki

Abhisek Pattnaik
@abhisekp
Sep 27 2015 06:39
@teichopsia- pls read about regex. It's powerful :point_up: September 27, 2015 12:09 PM
Alexander
@teichopsia-
Sep 27 2015 06:43
@abhisekp if only you could see how many windows and tabs within each window I have of pending stuff to read :smile:
Abhisek Pattnaik
@abhisekp
Sep 27 2015 06:43
@teichopsia- you write periods after English sentences to mark the ending. Similarly, semi-colons mark the ending of JS statements. If you write the English sentences in separate lines, the you might not need the semi-colons bcoz you can recognize sentence ending and start from the whitespace.
Similarly, in JS statements, semi-colon is optional.
@teichopsia- if only you could see how many nights I've stayed up to read all those stuffs.
Alexander
@teichopsia-
Sep 27 2015 06:45
@abhisekp I did not know that.
I have no idea what I'm doing
var re = /[\s\.]/g;
var er = /\W/ig;


function palindrome(str) {
    var new_string = str.toLowercase().replace(re, str, '');
    if (new_string.length == "") {
        return str;
    }
    else {
        return 
        }
    return true;

    }

palindrome("eye");
Abhisek Pattnaik
@abhisekp
Sep 27 2015 06:48
@teichopsia- so you need to read about Regex. Pls do read it. It's not so difficult once you know what the characters do in a Regex.
that replace invocation is not correct, btw. You can read about String.prototype.replace method in http://devdocs.io/#q=js+String+replace
Devon Jones
@jones-codes
Sep 27 2015 06:50
why is your str variable a paramater in your method??
you are still modifying it from the beginning of that statement
in your replace method*
Alexander
@teichopsia-
Sep 27 2015 06:50
where it says return str;? that's a mistake... it should be new_string
Devon Jones
@jones-codes
Sep 27 2015 06:51
no in your initial variable declaration of new_string
Abhisek Pattnaik
@abhisekp
Sep 27 2015 06:51
@teichopsia- if you learn how to read the docs, then that will increase your productivity to gr8 heights.
Alexander
@teichopsia-
Sep 27 2015 06:51
ah...in replace(re, str, ''); ? no idea :smile:
Abhisek Pattnaik
@abhisekp
Sep 27 2015 06:51
pls read the docs
atleast try to... :|
Alexander
@teichopsia-
Sep 27 2015 06:52
I did read the docs :smile:
Devon Jones
@jones-codes
Sep 27 2015 06:52
Yea you only need your condition and what to actually replace it with there
re and the empty string
You only need one line of code after that
Abhisek Pattnaik
@abhisekp
Sep 27 2015 06:53
@teichopsia- the replace method already works on the String str from which you've invoked it. So you don't need to pass it as param.
the toLowerCase method returns a lower-cased string.
....on whc the replace method is invoked.
Alexander
@teichopsia-
Sep 27 2015 06:55
str.toLowercase().replace(re, '');
I thought it didn't return a new string. The original variable keeping it's original value. It would only output the string without storing it in str.....
That's what I understood
Abhisek Pattnaik
@abhisekp
Sep 27 2015 06:56
@teichopsia- if it didn't return a new string, then why did you chain the methods one after the other?
@teichopsia- yes. The original string keeps the original value bcoz strings are immutable
explain immutable
CamperBot
@camperbot
Sep 27 2015 06:56

:point_right: js immutable [wiki]

Immutable means unchangeable i.e. you can't change.

Javascript has lots of immutable types e.g. string primitive type. Try this in your console.

s = "red";
console.log(s[1]); //→ "e"
s[1] = "x";
console.log(s) //→ "red"

the s didn't change! WAT!

:pencil: read more about js immutable on the FCC Wiki

Abhisek Pattnaik
@abhisekp
Sep 27 2015 06:57
@teichopsia- but it does return a lower-cased string on which you're invoking the replace method.
Read about String.prototype.toLowerCase at http://devdocs.io/#q=js+String+toLowerCase
Devon Jones
@jones-codes
Sep 27 2015 06:58
That sounds right, you're modifying the str variable for storage in the new_string variable, not str itself
Alexander
@teichopsia-
Sep 27 2015 06:58

@jones-codes I don't see how it will be only one line after that (but don't give me the solution)

@abhisekp give me a few minutes to read....

Abhisek Pattnaik
@abhisekp
Sep 27 2015 06:59
@teichopsia- btw, the toLowerCase is written like this not toLowercase (see the capitalization of C)
Alexander
@teichopsia-
Sep 27 2015 07:00
thanks guys @abhisekp @jones-codes
let me do the reading and I'll come back.
CamperBot
@camperbot
Sep 27 2015 07:00
teichopsia- sends brownie points to @abhisekp and @jones-codes :sparkles: :thumbsup: :sparkles:
:warning: teichopsia- already gave jones-codes points
:star: 490 | @abhisekp | http://www.freecodecamp.com/abhisekp
Abhisek Pattnaik
@abhisekp
Sep 27 2015 07:02
@Jauble Hope you like this
function factorialize(num) {
  var fact = 1;
  while(num) { fact *= num--; }
  return fact;
}
Alexander
@teichopsia-
Sep 27 2015 07:04
that looks sweet. What does the num-- do? substracts num by one each time?
Abhisek Pattnaik
@abhisekp
Sep 27 2015 07:05
@teichopsia- yes. :+1:
Jason
@Jauble
Sep 27 2015 07:05
Awesome, thanks @abhisekp
CamperBot
@camperbot
Sep 27 2015 07:05
jauble sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star: 491 | @abhisekp | http://www.freecodecamp.com/abhisekp
Abhisek Pattnaik
@abhisekp
Sep 27 2015 07:07
@Jauble have you completed all the bonfires?
Jason
@Jauble
Sep 27 2015 07:07
Nope, just started
Abhisek Pattnaik
@abhisekp
Sep 27 2015 07:08
gr8.
@Jauble after completing the bonfires, ask for other's solns. to see how others have done.
@teichopsia- ^
Jason
@Jauble
Sep 27 2015 07:10
@abhisekp Ya, I've been asking how I can improve on what has passed for me so far
Saulo Melo
@saulojmc
Sep 27 2015 07:14

Help me!!
@EhondaGod

<div class='row'>
<div class='col-xs-4'>
<button class='btn btn-block btn-primary'><i class='fa fa-thumbs-up'></i> Like</button>
</div>
<div class='col-xs-4'>
<button class='btn btn-block btn-info'><i class='fa fa-info-circle'></i> Info</button>
</div>
<div class='col-xs-4'>
<button class='btn btn-block btn-danger'><i class='fa fa-trash'></i> Delete</button>
</div>
</div>
Wrap all of your radio buttons within a <div class='row'> element. Then wrap each of them within a <div class='col-xs-6'> element.
super stuck can anyone help?

CamperBot
@camperbot
Sep 27 2015 07:14
no wiki entry for: me@ehondagoddiv classrow div classcol-xs-4 button classbtn btn-block btn-primaryi classfa fa-thumbs-upi likebutton div div classcol-xs-4 button classbtn btn-block btn-infoi classfa fa-info-circlei infobutton div div classcol-xs-4 button classbtn btn-block btn-dangeri classfa fa-trashi deletebutton divdivwrap all of your radio buttons within a div classrow element then wrap each of them within a div classcol-xs-6 elementsuper stuck can anyone help
:pencil: click here to create one now!after creating your page type update to reload it here
Abhisek Pattnaik
@abhisekp
Sep 27 2015 07:14
explain format
CamperBot
@camperbot
Sep 27 2015 07:14

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks, then type js or html and then press [shift + enter ⏎]

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Abhisek Pattnaik
@abhisekp
Sep 27 2015 07:14
@saulojmc :point_up: September 27, 2015 12:44 PM
Trevor Old
@Frogz1
Sep 27 2015 07:18
Can anyone help me understand how top get this to scroll backwards using the nav bar and why on my "debug" http://s.codepen.io/Frogz1/debug/ZbYywP? there is no white area under my navbar but on this , there is a visible white space? these are the final parts and i'm ready to start my next waypoint
Arooj
@aroojahmad
Sep 27 2015 07:19
@jones-codes Still didn’t get it.
Devon Jones
@jones-codes
Sep 27 2015 07:19
Show me what you have
Saulo Melo
@saulojmc
Sep 27 2015 07:22
Can anyone help me for the exercise:
Alexander
@teichopsia-
Sep 27 2015 07:22
I'm gonna need a hint afterall... or maybe I should just go to sleep....
function palindrome(str) {
    var re = /[\s\.]/g;
    str.toLowerCase().replace(re, '');
    return true;

    }
I don't see how I can get it done with one line of code.
going to take a cig break
Devon Jones
@jones-codes
Sep 27 2015 07:23
so you need to assign that line of code to a variable
Arooj
@aroojahmad
Sep 27 2015 07:23
function largestOfFour(arr) {
  for (i = 0; i < arr.length; i++) {
    for (j=0; j<arr[j].length; j++) {
      if the number at j is greater than the other numbers in the array, then store that number in a new array
    }
  }
  return arr;
}
Devon Jones
@jones-codes
Sep 27 2015 07:23
str = str.toLowerCase().blahblahblah
Saulo Melo
@saulojmc
Sep 27 2015 07:24
<div class="row">
<div class="col-xs-6">
<button class="btn btn-block btn-primary"><i class="fa fa-thumbs-up"></i> Like</button>
</div>
<div class="col-xs-6">
<button class="btn btn-block btn-info"><i class="fa fa-info-circle"></i> Info</button>
</div>
<div class="col-xs-6">
<button class="btn btn-block btn-danger"><i class="fa fa-trash"></i> Delete</button>
</div>
</div>
Chocobowings
@chocobowings
Sep 27 2015 07:24
@saulojmc What is that you are looking to accomplish ?
Saulo Melo
@saulojmc
Sep 27 2015 07:26
@chocobowings , please. I don't understand how to proceed on Waypoint: Responsively Style Radio Buttons.
Chocobowings
@chocobowings
Sep 27 2015 07:26
@saulojmc let me check
Devon Jones
@jones-codes
Sep 27 2015 07:27
In your 2nd for loop, arr[j] won't work, you're trying to reference the individual variables of the arrays without telling it which array
you need to reference the arrays themselves individually
which is arr[i]
Saulo Melo
@saulojmc
Sep 27 2015 07:28
Thanks @chocobowings
CamperBot
@camperbot
Sep 27 2015 07:28
saulojmc sends brownie points to @chocobowings :sparkles: :thumbsup: :sparkles:
:star: 293 | @chocobowings | http://www.freecodecamp.com/chocobowings
Devon Jones
@jones-codes
Sep 27 2015 07:28
@aroojahmad
Chocobowings
@chocobowings
Sep 27 2015 07:29
@saulojmc
Nest all of your radio buttons within a <div class="row"> element. Then nest each of them within a <div class="col-xs-6"> element.
<div class="row">
<div class="col-xs-6>
radio buttons here
</div>
</div>
@saulojmc so what you need to do is create a div element with the class row that surrounds all your radio buttons.
Also each radio button needs it's own div element with the class col-xs-6
Saulo Melo
@saulojmc
Sep 27 2015 07:33
@chocobowings Ok. I'll try.
Devon Jones
@jones-codes
Sep 27 2015 07:34
anyone have a better solution for Confirm the Ending?
I know I butchered it
function end(str, target) {

  var sub_str = "";
  var arr = str.split(" ");
  if (arr.length < 2 )
    sub_str = str.substr(str.length-1);
  else
  sub_str = arr[arr.length-1];
  return sub_str === target;
}

end("Bastian", "n", "");
Chocobowings
@chocobowings
Sep 27 2015 07:35
@saulojmc
Just look at each div element as a container
You need a big container for all your radio buttons and each button is going to have it's own container :) . It's like putting small boxes inside a big box
Alexander
@teichopsia-
Sep 27 2015 07:45
I'm making progress.... I think.... :smile:
function palindrome(str) {

    var re = /[\s\.]/g;
    str = str.toLowerCase().replace(re, '');

    var i = 0;

    while (i < str.length) {
        if (str[i] == str[str.length -i]) {
            return true;
        }
        else {
            return false;
            }
        i++;
    }
}
Saulo Melo
@saulojmc
Sep 27 2015 07:47
@chocobowings nothing, no progress. I'll try tomorrow. Thanks
CamperBot
@camperbot
Sep 27 2015 07:47
saulojmc sends brownie points to @chocobowings :sparkles: :thumbsup: :sparkles:
:warning: saulojmc already gave chocobowings points
Devon Jones
@jones-codes
Sep 27 2015 07:50
in the first iteration of your while loop, you are comparing the first letter to nothing
Mateja Trifunovski
@Matko95
Sep 27 2015 07:50
@jones-codes
function end(str, target) {
  return str.substr(-target.length)==target ? true : false;
}

end('Bastian', 'n');
Devon Jones
@jones-codes
Sep 27 2015 07:50
it will throw off the rest of your comparisons, the 2nd letter will be compared to the last, etc.
Alexander
@teichopsia-
Sep 27 2015 07:51
true..... but so far do I have the right idea?
Devon Jones
@jones-codes
Sep 27 2015 07:51
Oh my that looks rough. thanks @Matko95
CamperBot
@camperbot
Sep 27 2015 07:51
jones-codes sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 390 | @matko95 | http://www.freecodecamp.com/matko95
Devon Jones
@jones-codes
Sep 27 2015 07:52
I think it could work maybe?
Maybe reverse the logic though
you shouldn't return true until you know they all match, right?
Alexander
@teichopsia-
Sep 27 2015 07:53
maybe, I don't know... it's nearly 3 a.m over here... so I'll call it quits and continue tomorrow. Thanks for all the help @jones-codes
CamperBot
@camperbot
Sep 27 2015 07:53
teichopsia- sends brownie points to @jones-codes :sparkles: :thumbsup: :sparkles:
:star: 183 | @jones-codes | http://www.freecodecamp.com/jones-codes
Alexander
@teichopsia-
Sep 27 2015 07:54
good points
thanks, good night everyone.
CamperBot
@camperbot
Sep 27 2015 07:54
if you want to thank someone, put an @ before their name!
Devon Jones
@jones-codes
Sep 27 2015 07:55
No worries , let me know if it works out! that's an interesting strategy
Mateja Trifunovski
@Matko95
Sep 27 2015 07:55
@teichopsia- good night !
Randy Goldsmith
@Dueldrawer8
Sep 27 2015 07:56
function VowelCount(str) { 

  var vowels = "aeiouAEIOU";
  var count = 0;
  for(var i = 0; i < str.length; i++) {
    if(vowels.indexOf(str[i]) != -1) {
      count += 1;
    }
  }
  return count; 

}
could someone explain to me what the if() statement means using he indexOf method?
my goal was given a string, count the number of vowels in that string and return it out
the indexOf method i thought gives back an index(a number)
Alexander
@teichopsia-
Sep 27 2015 07:57
@Matko95 nice pic, good night.
@jones-codes will do.
Mateja Trifunovski
@Matko95
Sep 27 2015 07:59
@Dueldrawer8 ok so first off.. the method .indexOf(); returns -1 if the given parameter was not found, and if it is found it returns the index number. It tests if the string contains vowels, if it does it will return a number different from -1 and the count will go up
Randy Goldsmith
@Dueldrawer8
Sep 27 2015 08:01
ahh @Matko95 so if the string was "eye" str[0] is equal to e.. which is in the vowels string and will return a number other than one so count will go up?
Mateja Trifunovski
@Matko95
Sep 27 2015 08:02
@Dueldrawer8 yep "eye".indexOf("e") would return 0, which is different from -1
@Dueldrawer8 you could also write >-1 >=0 or anything
Randy Goldsmith
@Dueldrawer8
Sep 27 2015 08:03
@Matko95 wouldnt it be "aeiouAEIOU".indexOf('e')?
Mateja Trifunovski
@Matko95
Sep 27 2015 08:03
@Dueldrawer8 sure it could be, i just gave an example :)
Randy Goldsmith
@Dueldrawer8
Sep 27 2015 08:03
oh okay thanks
CamperBot
@camperbot
Sep 27 2015 08:03
if you want to thank someone, put an @ before their name!
Randy Goldsmith
@Dueldrawer8
Sep 27 2015 08:04
@Matko95 thanks
i mean.. thanks @Matko95 lol
CamperBot
@camperbot
Sep 27 2015 08:04
dueldrawer8 sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 391 | @matko95 | http://www.freecodecamp.com/matko95
Randy Goldsmith
@Dueldrawer8
Sep 27 2015 08:04
that was an easy coderbyte problem.. i have problems doing those
Mateja Trifunovski
@Matko95
Sep 27 2015 08:04
np :)
Randy Goldsmith
@Dueldrawer8
Sep 27 2015 08:04
i got the loops and everything.. i just didnt include the vowels variable
nor didnt know to use the indexOf method
Mateja Trifunovski
@Matko95
Sep 27 2015 08:05
@Dueldrawer8 if something is unclear you can always look up the documentation https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf
Randy Goldsmith
@Dueldrawer8
Sep 27 2015 08:05
yes... i did but still i get confused
i guess i just needed to think on it more.. i was about to put it in google console and see how it worked
or.. glad you answered because you explained in perfectly
Mateja Trifunovski
@Matko95
Sep 27 2015 08:06
That's a good way aswell :)
Devon Jones
@jones-codes
Sep 27 2015 08:06
@Matko95 can you point me in the right direction of what to read to understand that? I'm quite confused lol
Abhisek Pattnaik
@abhisekp
Sep 27 2015 08:06
@Matko95 http://devdocs.io is also a nice doc search base. :)
Mateja Trifunovski
@Matko95
Sep 27 2015 08:07
@jones-codes to understand what?
@abhisekp Bookmarked ! :)
Abhisek Pattnaik
@abhisekp
Sep 27 2015 08:09
@Matko95 while suggesting others abt MDN, you can replace it with devdocs e.g. for the above suggestion, http://devdocs.io/#q=js+String+indexOf
Devon Jones
@jones-codes
Sep 27 2015 08:09
function end(str, target) {
  return str.substr(-target.length)==target ? true : false;
}
Mateja Trifunovski
@Matko95
Sep 27 2015 08:10
@jones-codes well it's just a shorter if statement :)
function end(str, target) {
if (str.substr(-target.length)===target){
return true;
}
else
{
return false
}
}
same thing
Devon Jones
@jones-codes
Sep 27 2015 08:11
ahhh ok got that part
but why does -target.length give you the starting letter of the last substring in str?
Mateja Trifunovski
@Matko95
Sep 27 2015 08:13
@jones-codes if you put a negative value, it will go from (str.length-target.length,str.length)
@jones-codes it gives you the starting letter only if it's true
Devon Jones
@jones-codes
Sep 27 2015 08:14
why would it do that?
Mateja Trifunovski
@Matko95
Sep 27 2015 08:17
@jones-codes let's say our string is "Hello World"(length=11) , and target is "World"(length=5), if we put str.substr(11-5,11), so it's str.substr(6,11); and it will extract exactly World
Devon Jones
@jones-codes
Sep 27 2015 08:20
I follow there. It just seems like a negative sign is producing the first str.length out of thin air
Devon Jones
@jones-codes
Sep 27 2015 08:20
I understand the 2nd paramater is of substr is implied because it ends at str.length
I have that page open lol
but where does str.length in str.length - target.length come from?
Ohhhhh nevermind, I got it
Mateja Trifunovski
@Matko95
Sep 27 2015 08:23
@jones-codes i've just put it so you would get the idea
Abhisek Pattnaik
@abhisekp
Sep 27 2015 08:24
@Matko95 Did you know?
You can dynamically link to devdocs using quick search.
http://devdocs.io/ then append #q=js (to limit the search to js only) and then append +String+substr to find substr method in String object.
The full url would be http://devdocs.io/#q=js+String+substr (click this)
Devon Jones
@jones-codes
Sep 27 2015 08:25
thanks @Matko95 it makes a lot more sense now
CamperBot
@camperbot
Sep 27 2015 08:25
jones-codes sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:warning: jones-codes already gave matko95 points
Mateja Trifunovski
@Matko95
Sep 27 2015 08:25
@abhisekp well i know now :)
Devon Jones
@jones-codes
Sep 27 2015 08:25
That if statement is trippin me out, but I get it I think lol
Trevor Old
@Frogz1
Sep 27 2015 08:28
Just finished debugging my first zipline, can I get some feedback? http://s.codepen.io/Frogz1/debug/ZbYywP?
Mateja Trifunovski
@Matko95
Sep 27 2015 08:40
@Frogz1 so you fixed the nav scroll issue :) great work!
Trevor Old
@Frogz1
Sep 27 2015 08:40
@Matko95 hey man, yeah I did , I finally finished , thanks!
CamperBot
@camperbot
Sep 27 2015 08:40
frogz1 sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 392 | @matko95 | http://www.freecodecamp.com/matko95
Javed
@JayBee007
Sep 27 2015 08:42
@Frogz1 there is problem with the portoflio..at least on my laptop..the placeholders are quite big..
Trevor Old
@Frogz1
Sep 27 2015 08:44
@JayBee007 can you post a screenshot? they are kinda big but should fit 3 comfortably
@JayBee007 this is my first creation from scratch and I definitely didn't do my best for different screensizes , well smaller thatn 20.3 inch and cross browser(well edge and ie) isn't the best
Javed
@JayBee007
Sep 27 2015 08:47
@Frogz1 you can also check mine and lemme know your feedback
blob
blob
Trevor Old
@Frogz1
Sep 27 2015 08:51
@JayBee007 yeah ideally they show the whole placeholder , I really need to learn how to incorporate different resolutions and screensize, and I will once I'm back from my smoke break
Javed
@JayBee007
Sep 27 2015 08:54
@Frogz1 am waiting for your feedback too..
Trevor Old
@Frogz1
Sep 27 2015 08:55
@JayBee007 looks nice man !, I kinda took the reverse engineering a bit too seriously , on my next ziplines i'll go at it with a bit more creative freedom. Only thing I would suggest is making your footer inline
@JayBee007 are you a graphic designer as well?
@JayBee007 and I like the scrolling active on the navbar, I was just about to add that but i spent way too long as it is so I made myself stop adding things, nice work man
Javed
@JayBee007
Sep 27 2015 08:57
@Frogz1 thanks..nope am not a graphic person..))
CamperBot
@camperbot
Sep 27 2015 08:57
jaybee007 sends brownie points to @frogz1 :sparkles: :thumbsup: :sparkles:
:star: 113 | @frogz1 | http://www.freecodecamp.com/frogz1
Javed
@JayBee007
Sep 27 2015 08:58
@Frogz1 the active thing is available in bootstrap..if am not mistaken its called scrollspy
Trevor Old
@Frogz1
Sep 27 2015 08:58
@JayBee007 just ask because your website weapons of choice is photoshop! one other thing is that I would like the navbar items to be centered , not on the edges of screen,
@JayBee007 i'll try to add it now
Javed
@JayBee007
Sep 27 2015 08:59
@Frogz1 Yes..need to add the contents of navigation inside a container..
Fahad Uddin
@FahadUddin92
Sep 27 2015 09:08
Working on Zipline "Zipline: Build a Pomodoro Clock." I don't understand where to begin from.
Javed
@JayBee007
Sep 27 2015 09:08
@Frogz1 its getting active but not its overflowing the nav bar
@enggfahd may by defining what is pomodoro?
Trevor Old
@Frogz1
Sep 27 2015 09:08
@JayBee007 it seems to have caused my scroll to stutter
Javed
@JayBee007
Sep 27 2015 09:09
@JayBee007
blob
Fahad Uddin
@FahadUddin92
Sep 27 2015 09:09
@JayBee007 Its a long technique for studying. What I understood from the problem is I need to create a timer which starts from 25:0:0 and ends when 25 minutes pass.
Trevor Old
@Frogz1
Sep 27 2015 09:10
@JayBee007 ah, yes another symptom of me not doing the resolution/screensize i've been saying, on mine it looks normal
Javed
@JayBee007
Sep 27 2015 09:10
@enggfahd not only..u need to add long break short break..
Fahad Uddin
@FahadUddin92
Sep 27 2015 09:10
@JayBee007 : Thats bonus. The basic aim is just what I stated.
Javed
@JayBee007
Sep 27 2015 09:11
@enggfahd ok..i didnt read it yet..i just finished first zipline..portfolio page..how was Eid?
Fahad Uddin
@FahadUddin92
Sep 27 2015 09:12
@JayBee007 : The Eid went fine. Like just another one. Slept most of the time.
Sam
@xpkc34
Sep 27 2015 09:52
Hello, I have a quick question. I have an array (call it Array), the first element of which is another array. I want to access this entire element. But if I use Array[0], it only seems to return the first element of the nested array, not the whole nester array, which is what I want. How can I do this?
The array in question is an arguments objects, if that makes a difference.
medully
@medully
Sep 27 2015 09:52
sa
`
`

<div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3>
<div class="row">
<h4>
<div class="col-xs-6">

<div class="well" id="left-well ">
<button class="btn btn-default target"></button>
<button class="btn btn-default target"></button>
<button class="btn btn-default target"></button>
</div>
</div>
</h4>
<h4>
<div class="col-xs-6">

<div class="well" id="right-well">
<button class="btn btn-default target"></button>
<button class="btn btn-default target"></button>
<button class="btn btn-default target"></button>
</div>
</div>

</div>
</div>

medully
@medully
Sep 27 2015 09:58
Add an h4 element to each of your <div class="col-xs-6"> elements. error
please help
Sam
@xpkc34
Sep 27 2015 10:06
(no need to respond to my above query anymore)
Sam
@xpkc34
Sep 27 2015 10:13
Okay I have a new question though. I have the following function (this is just how it was set up by default in the bonfire, I haven't added any code yet).
function destroyer(arr) {
  return arr
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I assume Arr is supposed to be an arguments object. But returning arr gives the result [1, 2, 3, 1, 2, 3] but NOT the other two arguments, 2, 3. Why is this? It means that I cannot access the last two arguments, and I need to in order to complete the exercise...
This message was deleted
js has a special arguments keyword, so you can use arguments[0] for [1,2,3 etc], and arguments[1] for 2, etc
Sam
@xpkc34
Sep 27 2015 10:21
ah okay thanks @Coira !
CamperBot
@camperbot
Sep 27 2015 10:21
xpkc34 sends brownie points to @coira :sparkles: :thumbsup: :sparkles:
:star: 241 | @coira | http://www.freecodecamp.com/coira
Coira Ellison
@Coira
Sep 27 2015 10:21
um i've just look at the link, it doesn't explain anything! i'll find a better one, or you can just ask me if yoyu don't understand
this is better i think http://javascript.info/tutorial/arguments (scroll down to Accessing the unnamed arguments)
Sam
@xpkc34
Sep 27 2015 10:25
I think I've got what I need to solve the exercise from the short explanation you just typed, although I agree that link isn't great! Cheers
Coira Ellison
@Coira
Sep 27 2015 10:25
great :)
Fahad Uddin
@FahadUddin92
Sep 27 2015 10:27
Completed the Pomodoro clock:
http://codepen.io/FahadUddinPK/pen/qOqjVa
I haven't designed it but it works fine.
medully
@medully
Sep 27 2015 10:41
blob
please help
Add an h4 element to each of your <div class="col-xs-6"> elements. error
all undestand
Michelle Z
@mzulli
Sep 27 2015 10:52
@medully it wants you to add an <h4> element within the col-xs-6 elements
medully
@medully
Sep 27 2015 10:55
@mzulli understand
bharathi2312
@bharathi2312
Sep 27 2015 11:04
where should i paste the google font
Chris Phillips
@christoph-phillips
Sep 27 2015 11:08

Hi, could someone please help me with the palindromes bonfire - I am getting true to work if string is palindrome but not to return false if not. function palindrome(str) {
// Good luck!
var strRemoved = str.replace(/[^\w\s]|_/g, "").toLowerCase();
var strReversed = strRemoved.split().reverse().join();

if(strRemoved === strReversed) {
return true;
}
else {
return false;
}
}

palindrome("eye");

function palindrome(str) {
// Good luck!
var strRemoved = str.replace(/[^\w\s]|_/g, "").toLowerCase();
var strReversed = strRemoved.split().reverse().join();
if(strRemoved === strReversed) {
return true;
}
else {
return false;
}
}
palindrome("eye");
James Riall
@JamesRiall
Sep 27 2015 11:13
hi all, i'm doing the zipline show the local weather. I've build the HTML and CSS to get the structure of the page where I want it. I'm now starting to research how to us an API to pull in all of the information I need. Since the map hasn't covered this yet, I'm assuming that this won't be building from scratch and that i'll be copy+pasting a lot of code from an api website?>
mientje
@mientje
Sep 27 2015 11:14
Can I build the twitch tv app using ajax and javascript ? I've got problems with the codepen example. I'm not the only one that can't connect and an issue for this has been opened on Github but it is not yet resolved. This is not encouraging and now I feel small, frightened and confused.
James Riall
@JamesRiall
Sep 27 2015 11:14
i'm guessing this is the way to do it (obviously I'll have to modify the code somewhat), but I just want to make sure I'm not cheating on the zipline and missing out on something I should be doing and learning for myself from scratch
mientje
@mientje
Sep 27 2015 11:16
@JamesRiall I went to the wunderground site for that. Their API is easy to use. You'll need a key (there are instructions for that), and they show you examples on how to connect and all that. The instructions are not difficult to follow. It's free of charge. I enjoyed that one.
@JamesRiall Google Weather Underground or Wunderground
James Riall
@JamesRiall
Sep 27 2015 11:20
@mientje awesome, thanks for that
CamperBot
@camperbot
Sep 27 2015 11:20
jamesriall sends brownie points to @mientje :sparkles: :thumbsup: :sparkles:
:star: 266 | @mientje | http://www.freecodecamp.com/mientje
mientje
@mientje
Sep 27 2015 11:21
@JamesRiall You're welcome
DrHaker
@DrHaker
Sep 27 2015 12:05
This message was deleted
Aleksander Gębicki
@Takumar
Sep 27 2015 12:10
@DrHaker they are asking you to put your <input> tag between <form> tags.
i.e.
<form action="/submit-cat-photo">
<input type="text" ...
</form>
I see you deleted message, so you managed to do it yourself?
barbsy
@barbsy
Sep 27 2015 12:13
hi i'm new on this forum and am currently doing challenges on way point and would like to find out how to comment and uncomment tags and deleting trails
Aleksander Gębicki
@Takumar
Sep 27 2015 12:15
@barbsy you have to use <!-- and --> tags on start and end of your block you want to hide from the browser.
@barbsy look at this waypoint
And of course welcome on this forum :-)
minakasiin
@minakasiin
Sep 27 2015 12:20

array = array.filter(function(val){

  return val <= 5;

});
The "val" after the function, can I add a random name to it, or does it have to be "val" as in value? Code works, just trying to understand what everything does.
barbsy
@barbsy
Sep 27 2015 12:28
Be sure to delete all trailing comment tags, i.e. -->.
how do you do that
Aleksander Gębicki
@Takumar
Sep 27 2015 12:28
@minakasiin I think that you can name this parameter as you wish: value, param, or something else
barbsy
@barbsy
Sep 27 2015 12:29
i'm failing to go to the next challenge coz of that challenge
Aleksander Gębicki
@Takumar
Sep 27 2015 12:30
@barbsy just clear your code and remove all tags which comment your code.
minakasiin
@minakasiin
Sep 27 2015 12:30
Well I could have just tested it before asking to be honest.
Thanks @Takumar
CamperBot
@camperbot
Sep 27 2015 12:30
minakasiin sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 355 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Sep 27 2015 12:31

i.e. before

<!-- <p>Some text</p> -->

after

<p>Some text</p>
This message was deleted
@minakasiin Of course I personally would use value as the name of this argument because it is simple and clear and used in documentation.
Balaji Vijayan
@balajivijayan
Sep 27 2015 12:41
Hi Guys Which code editor to use for developing restful javascript clients?
Can it be done in sublime text?
Mohsin Mumtaz
@mohmum
Sep 27 2015 12:49
The instructions in waypoint : Iterate over Arrays with map is not clear.. Can someone please explain me
Balaji Vijayan
@balajivijayan
Sep 27 2015 12:51
@mohmum when you use map function in javascript, you can manipulate each element in the array. So now you need to add 3 to every element in that array to pass that waypoint
Mohsin Mumtaz
@mohmum
Sep 27 2015 13:08
@balajivijayan Why it is not explained in detail? Will it be covered later?
x34passenger
@x34passenger
Sep 27 2015 13:27
Regarding the Bonfire: Arguments Optional, I don't know how to isolate the numbers in expect(add(2)(3)).to.equal(5);
I don't know how to get 2 and 3 to be able to add them
Sebastian Hewelt
@sebhewelt
Sep 27 2015 13:28
Hey guys, I am trying to solve this for hours and still have no clue what does not work. I want the background to change everytime the window is loaded to etiher first or the second url of the array.
Raygendary
@raygendary
Sep 27 2015 13:35

whats is wrong with this code?

[secondToLastLetterOfLastName.length - 1];

i mean this one

var lastName = "Lovelace";

var secondToLastLetterOfLastName = lastName[secondToLastLetterOfLastName.length - 1];

im trying to find the letter c
Moisés Man
@moigithub
Sep 27 2015 13:36
then should be -2
counting from end to first character.. its the second
Raygendary
@raygendary
Sep 27 2015 13:37
@moigithub I tried that and it is still and error it is a waypoint
Moisés Man
@moigithub
Sep 27 2015 13:38
secondToLastLetterOfLastName
sound like u should return
"ovelace"
or
"velace" ??
then u should use substr OR substring OR slice
Stefan Stokic
@StefanStokic
Sep 27 2015 13:42
I'm thinking about skipping the second half of the bonfires, doing the first zipline to get a portfolio up for freelance, and then go back to bonfires..Thoughts?
x34passenger
@x34passenger
Sep 27 2015 13:44
@KingInTheNorth not a bad idea if you already know what you are doing
Stefan Stokic
@StefanStokic
Sep 27 2015 13:44
@x34passenger Because for the first waypoint it's just html and css, which I am already familiar with..and once I get a portfolio site up I'll go back to bonfires
Sebastian Hewelt
@sebhewelt
Sep 27 2015 13:44
I wouldn't. Bonfires don't take that much time and and patience is important in learning.
x34passenger
@x34passenger
Sep 27 2015 13:45
@KingInTheNorth If you already know what you are doing html and css wise, go for it. I have no knowledge of that stuff so I personally did all the waypoints, but if you already know, more power to you
Sebastian Hewelt
@sebhewelt
Sep 27 2015 13:46
But bonfires are about JS not HTML and CSS. And ziplines take JS knowledge
x34passenger
@x34passenger
Sep 27 2015 13:47
There are separate waypoints for JS, KingInTheNorth is talking about the html and css waypoints
and KingInTheNorth is talking about just doing the first zipline which requires no JS
Sebastian Hewelt
@sebhewelt
Sep 27 2015 13:49
Yeah, but who needs an empty portfolio. I mean - what's the points?
point*
x34passenger
@x34passenger
Sep 27 2015 13:49
@sebastianhew don't know ask @KingInTheNorth
Sebastian Hewelt
@sebhewelt
Sep 27 2015 13:50
@KingInTheNorth All the experienced programmers i talked to always say - do not rush things, or you won't be a good programmer. I think they're right :)
x34passenger
@x34passenger
Sep 27 2015 13:54
I don't understand what needs to be returned expect(add(2)([3])).to.be.undefined;add(...) is not a function
How do you return 'is not a function'?
Can anyone help me with Bonfire: Steamroller, I don't know how to flatten arrays within arrays with arrays, etc.
CamperBot
@camperbot
Sep 27 2015 13:57
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Malcolm
@Fext
Sep 27 2015 14:12
@KingHippo you are on the right lines with Mutations. You need to check every letter in arr[1] is in arr[0]. So you need to loop through all the letters in arr[1] and check if in arr[0]. If just one does not match then it is game over. have a look at different ways of looping through stuff for some hints
Abhisek Pattnaik
@abhisekp
Sep 27 2015 14:17

Douglas Crockford has just released a Javascript Encyclopedia Book [Old and Incomplete]

http://www.crockford.com/javascript/encyclopedia/

— Douglas Crockford, inventor of JSON, JSLint and JSMin
Author of JavaScript: The Good Parts Book
Videos by Douglas Crockford https://www.youtube.com/playlist?list=PL62E185BB8577B63D
Anubhav652
@Anubhav652
Sep 27 2015 14:18
I need help.
//Let's create an object with a two functions. One attached as a property and one not.
var Car = function() {
  this.gear = 1;
  function addStyle(styleMe){
    return 'The Current Gear Is: ' + styleMe;
  }
  this.getGear = function() {
    return addStyle(this.gear);
  };
};

var Bike = function() {
  // Only change code below this line.
  speed = 100;
  function addUnit(value) {
    return value + "KM/H";
  }

   function getSpeed() {
    return addUnit(speed);
  };

};

// Only change code above this line.
var myCar = new Car();
var myBike = new Bike();
console.log( myBike.getSpeed() );

if(myBike.hasOwnProperty('getSpeed')){(function() {return JSON.stringify(myBike.getSpeed());})();};
How to make getSpeed by used outside?
be*
anyone?
Anubhav652
@Anubhav652
Sep 27 2015 14:27
Problem is solved.
sina
@sigma161
Sep 27 2015 14:50

<link href="http://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">

<style>
.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;

.smaller-image { width: 100px;}
}
</style>

<h2 class="red-text">CatPhotoApp</h2>

<img src="https://bit.ly/fcc-relaxing-cat" class="smaller-image">

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

i need help with this
x34passenger
@x34passenger
Sep 27 2015 14:58
How do you create a new object in Bonfire: Map the Debris?
jdreiser1
@jdreiser1
Sep 27 2015 15:10
I'm on Basic Algorithm Scripting, challenge 3 (bonfire): Factorialize a Number, and whenever I open up the challenge, my browser immediately freezes and I can't do anything. Please help.
nevermind! website was undergoing changes. Thanks guys!
CamperBot
@camperbot
Sep 27 2015 15:14
if you want to thank someone, put an @ before their name!
azaleas
@azaleas
Sep 27 2015 15:40

Hi fellow campers,

I'm on Bonfire: Convert HTML Entities right now, but I can't get any results from my code:

function convert(str) {
  // &colon;&rpar;
  entities = ["amp|AMP|#x00026|#38", "lt|LT|#x0003C|#60", "gt|GT|#x0003E|#62", "quot|QUOT|#x00022|#34", "apos|#x00027|#39"];

  str = str.split("");


  exp = ["&", "<", ">", "", "'"];

  for (var i=0; i < str.length; i++){
    for (var y=0; y < str.length; y++){
      if(str[i]==exp[y]){
          str[i] = "&(" + entities[y] + ");"; 
      }
    }
  }

  str = str.join("");

  return str;
}

convert('"Hamburgers < Pizza < Tacos');

Any1 can help me with this?

Callie Brooks
@CalliEliza
Sep 27 2015 15:59
Hello, I'm stuck on Bonfire: Seek and Destroy. Anyone here want to help or pair? Thanks.
Jason Wood
@catapixel
Sep 27 2015 16:27
@azaleas It looks like you are inserting opening and closing parentheses around your html entities. This not correct. A proper entities is & followed by the entity name and closed with a semi-colon
@CalliEliza what's your question on seek and destroy?
tva10
@tva10
Sep 27 2015 16:28
@catapixel he use str.length twice in two different loops. He done this task
Jason Wood
@catapixel
Sep 27 2015 16:29
@tva10 I just noticed it was old but appreciate you letting me know...
Callie Brooks
@CalliEliza
Sep 27 2015 16:31
I kinda feel completely lost. I am trying to use the arguments object to loop through the array and filter out the matching numbers.
tva10
@tva10
Sep 27 2015 16:32
@CalliEliza put code here, mb we can foun problems
Callie Brooks
@CalliEliza
Sep 27 2015 16:33
function destroyer(arr){
    var args = arr.slice.call(arguments);
    var filteredArr = [];
    for (var i = 1; i < args.length; ++i) {
        for (var j = 0; arr.length; ++j) {
            if ( args[i] !== arr[j]) {
                filteredArr.push(j);
            }
        }
    }
    return  filteredArr;
}
tva10
@tva10
Sep 27 2015 16:40
@CalliEliza one minute plz. I look a this code. And first I find that you don't have Exit condition in second loop
Jason Wood
@catapixel
Sep 27 2015 16:41
@CalliEliza the helpful link points toward Array.filter(). I would highly suggest trying this method. Did you look into it?
Callie Brooks
@CalliEliza
Sep 27 2015 16:41
Ok. Yes. I did. I don't have the code anymore that I tried, but I am going to try to use the filter() again.
tva10
@tva10
Sep 27 2015 16:41
yes .filter() is best way here//
Jason Wood
@catapixel
Sep 27 2015 16:42
@CalliEliza good. That method returns an array with all of the values that pass the test you write. It will greatly simplify your code
Callie Brooks
@CalliEliza
Sep 27 2015 16:42
I'm going to give it another shot, and see if I can get something to work.
tva10
@tva10
Sep 27 2015 16:43
@CalliEliza also you can use combo with .every() too
Anderson Balena Fernandes
@AndersonBalena
Sep 27 2015 16:44
You should be displaying the result of the slot numbers in the corresponding slots.
Callie Brooks
@CalliEliza
Sep 27 2015 16:44
Ok. I'll look at that. I was only trying to implement filter() before.
Thanks
CamperBot
@camperbot
Sep 27 2015 16:44
if you want to thank someone, put an @ before their name!
Anderson Balena Fernandes
@AndersonBalena
Sep 27 2015 16:44
how can I solve this?
exercise number 156
This isn't working
$($(".slot")[0]).html(slotOne);
$($(".slot")[ 1 ]).html(slotTwo);
$($(".slot")[2]).html(slotThree);
Aleksander Gębicki
@Takumar
Sep 27 2015 16:45
@AndersonBalena don't write number of exercise but it's title - it will be easier to find.
Anderson Balena Fernandes
@AndersonBalena
Sep 27 2015 16:46
Thanks @Takumar
CamperBot
@camperbot
Sep 27 2015 16:46
andersonbalena sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
Anderson Balena Fernandes
@AndersonBalena
Sep 27 2015 16:46
Waypoint: Bring your JavaScript Slot Machine to Life
CamperBot
@camperbot
Sep 27 2015 16:46
:star: 357 | @takumar | http://www.freecodecamp.com/takumar
tva10
@tva10
Sep 27 2015 16:46
@AndersonBalena I try your's code and It is passed
but withought whitespaces
$($(".slot")[0]).html(slotOne);
     $($(".slot")[1]).html(slotTwo);
     $($(".slot")[2]).html(slotThree);
Anderson Balena Fernandes
@AndersonBalena
Sep 27 2015 16:47
I'll Reset
Jason Wood
@catapixel
Sep 27 2015 16:48
@AndersonBalena I agree with @tva10 that there's nothing wrong with your code once you remove the spaces around your "1" index
Anderson Balena Fernandes
@AndersonBalena
Sep 27 2015 16:48
at which point you out this code
put*
Jason Wood
@catapixel
Sep 27 2015 16:49
@AndersonBalena ?
tva10
@tva10
Sep 27 2015 16:49
@AndersonBalena Waypoint: Bring your JavaScript Slot Machine to Life
after // Only change code below this line.
Anderson Balena Fernandes
@AndersonBalena
Sep 27 2015 16:50
Sorry, if you aren't understanding me, I'm brazilian and don't speak english fluently
tva10
@tva10
Sep 27 2015 16:50
@AndersonBalena me too
Jason Wood
@catapixel
Sep 27 2015 16:50
@AndersonBalena
    // Only change code below this line.

    $($(".slot")[0]).html(slotOne);
    $($(".slot")[1]).html(slotTwo);
    $($(".slot")[2]).html(slotThree);

    // Only change code above this line.
Anderson Balena Fernandes
@AndersonBalena
Sep 27 2015 16:51
Thanks for help
CamperBot
@camperbot
Sep 27 2015 16:51
if you want to thank someone, put an @ before their name!
Anderson Balena Fernandes
@AndersonBalena
Sep 27 2015 16:51
Now its working
Jason Wood
@catapixel
Sep 27 2015 16:51
@AndersonBalena :thumbsup:
tva10
@tva10
Sep 27 2015 16:52
gut
Anderson Balena Fernandes
@AndersonBalena
Sep 27 2015 16:52
I've put in the incorrect point
Yan Kozlovskiy
@YanKozlovskiy
Sep 27 2015 17:02
What does this code do? (I completely don't understand the block in the for loop)?
var x = [1,5,7,13];
for(i=0; i < x.length; i++)
{
/*THIS IS THE LINE I DON\'T UNDERSTAND*/
x[i] = x[3-i] + 2;
}
tva10
@tva10
Sep 27 2015 17:04
@YanKozlovskiy on the first loop it put in x[0] = 13+2;
on second x[1]=7+2;
Yan Kozlovskiy
@YanKozlovskiy
Sep 27 2015 17:04
Why 13?
tva10
@tva10
Sep 27 2015 17:04
index of 13 in x array is 3-0
Aleksander Gębicki
@Takumar
Sep 27 2015 17:04
This message was deleted
Yan Kozlovskiy
@YanKozlovskiy
Sep 27 2015 17:05
Isn't index 0 equal to 1 though?
@tva10 you have the right answer, but i don't get it
Oh, I get it now wow I didn't know it could be done like that
Thanks everyone!!!
CamperBot
@camperbot
Sep 27 2015 17:06
if you want to thank someone, put an @ before their name!
tva10
@tva10
Sep 27 2015 17:07
Indexing of array starts from 0. In your code it is from 0 to 3 inclusively
Joey Lin
@pujoey
Sep 27 2015 17:12
THIS IS AN OUTRAGE!!! Bonfire: Truncate a string makes no sense to me. At first I thought the rule of truncating is by first word so I was writing str.split(" ")[0]+"..." but actually the rule of truncating is splice(0, num-3) as I read on the help forum. How does that make freaking sense? 1. No where does it say the rule of truncating is 3 position before the num of characters. 2. How would a user using truncating function even KNOW that??? 3. Truncating should be by words not number of characters to prevent words cut in half.
Callie Brooks
@CalliEliza
Sep 27 2015 17:12
Ok. So I think I may almost be there. Anyone want to help? Here is the code for Seek and Destroy. My for loop doesn't seem to be working.
function filtered(value) {
    for (var i = 0; i < args.length; ++i) {
        return value != args[i];
    }
}

function destroyer(arr) {
    args = arr.slice.call(arguments);
    args.shift();
    return arr.filter(filtered);
}
tva10
@tva10
Sep 27 2015 17:15
@CalliEliza update your function to this one:
function filtered(value) {
    for (var i = 0; i < args.length; ++i) {
        if(value ===args[i]) return false;
    }
  return true;
}
@CalliEliza you need to look if you find value in array you need to remove it(return false)
Callie Brooks
@CalliEliza
Sep 27 2015 17:16
ahhh. ok.
tva10
@tva10
Sep 27 2015 17:16
@CalliEliza if you don't found then on first iteration you can find that in other....
@CalliEliza so if you don't find that value in args... you also will get last line(return true);
Callie Brooks
@CalliEliza
Sep 27 2015 17:18
ok. that makes sense. Thanks @tva10
CamperBot
@camperbot
Sep 27 2015 17:18
callieliza sends brownie points to @tva10 :sparkles: :thumbsup: :sparkles:
:star: 260 | @tva10 | http://www.freecodecamp.com/tva10
tva10
@tva10
Sep 27 2015 17:18
@CalliEliza I prefer .every() function there
Callie Brooks
@CalliEliza
Sep 27 2015 17:18
Yea. You mentioned trying that one too.
x34passenger
@x34passenger
Sep 27 2015 17:19
can anyone help me with Bonfire: Pairwise
CamperBot
@camperbot
Sep 27 2015 17:19
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
tva10
@tva10
Sep 27 2015 17:19
@CalliEliza it looks like that one line code....
function filtered(value) {
    return args.every(function(args_i){return args_i!==value;});
}
@CalliEliza so this function mean, that if for every args_i function returns truthly value... every function return true.
Callie Brooks
@CalliEliza
Sep 27 2015 17:22
Yea. Thanks. It makes sense, and I've seen this used before. I just wasn't thinking about using it.
CamperBot
@camperbot
Sep 27 2015 17:22
if you want to thank someone, put an @ before their name!
Callie Brooks
@CalliEliza
Sep 27 2015 17:22
@tva10 , thanks again.
tva10
@tva10
Sep 27 2015 17:23
no problem)
Pratik Ratnaparkhi
@pratikr1593
Sep 27 2015 17:25
var min = 0;
var max = 9;
function myFunction() {
  // Make myFunction return a random number between zero and nine instead of a decimal
  // Only change code below this line.


  Math.floor(Math.random() * (9 - 0 + 1)) + 0;

  return Math.random();

}

// Only change code above this line.
// We use this function to show you the value of your variable in your output box.
(function(){return myFunction();})();

it says:

the random number that's generated by myFunction should be an integer.

you should be using the function given in the description to calculate the random in number in a range.
which is

Math.floor(Math.random() * (max - min + 1)) + min

tva10
@tva10
Sep 27 2015 17:27
@pratikr1593 you need to return this line Math.floor(Math.random() * (9 - 0 + 1)) + 0;
or save it in variable and return that variable
@pratikr1593 so there is dummy test cases in this waypoint. So you need to use this line Math.floor(Math.random() * (max - min + 1)) + min
Pratik Ratnaparkhi
@pratikr1593
Sep 27 2015 17:33
@tva10 the second line worked but now I am stuck with this one:
The random number that's generated by myFunction should be an integer
tva10
@tva10
Sep 27 2015 17:34
@pratikr1593 when you use Math.random() you got Float number between 0.0 to 1.0
@pratikr1593 to make it integer you need to use Math.floor()on it
jeevan-kr
@jeevan-kr
Sep 27 2015 17:35
Hey guys, on the git-it challenge. I am getting a permission denied from the git-it repo
Can anybody please help?
Pratik Ratnaparkhi
@pratikr1593
Sep 27 2015 17:36
var min = 0;
var max = 9;
function myFunction() {
  // Make myFunction return a random number between zero and nine instead of a decimal
  // Only change code below this line.


  Math.floor(Math.floor() * (max - min + 1)) + min

  return Math.random();

}

// Only change code above this line.
// We use this function to show you the value of your variable in your output box.
(function(){return myFunction();})();
@tva10 Check this out, Hope I did it right?
tva10
@tva10
Sep 27 2015 17:36
@pratikr1593 Nope
then you write Math.floor(Math.random() * (max - min + 1)) + min; you didn't save it
try this one
  // Only change code below this line.

  return Math.floor(Math.random() * (max - min + 1)) + min;
I mean that....
Pratik Ratnaparkhi
@pratikr1593
Sep 27 2015 17:39
@tva10 You're a hero! haha. was stuck with that for quite a while, didn't knew we can return whole line of code. Thanks
CamperBot
@camperbot
Sep 27 2015 17:39
pratikr1593 sends brownie points to @tva10 :sparkles: :thumbsup: :sparkles:
:star: 261 | @tva10 | http://www.freecodecamp.com/tva10
tva10
@tva10
Sep 27 2015 17:40
@pratikr1593 when you write line before.... you only eval that functions... but you need to save and return that...
Pratik Ratnaparkhi
@pratikr1593
Sep 27 2015 17:44
will remember that from next time for sure. thanks again @tva10
CamperBot
@camperbot
Sep 27 2015 17:44
pratikr1593 sends brownie points to @tva10 :sparkles: :thumbsup: :sparkles:
:warning: pratikr1593 already gave tva10 points
tva10
@tva10
Sep 27 2015 17:45
@pratikr1593 look how functions works for example... sometimes you can find that in docs
Jonathan Lee Slew
@jlslew
Sep 27 2015 17:46
hello, anyone know where npm look for packages?
tva10
@tva10
Sep 27 2015 17:48
@jlslew web interface: https://www.npmjs.com/
with search and info
Jonathan Lee Slew
@jlslew
Sep 27 2015 17:49
then why am i getting an error on cloud9 'npm ERR! git clone git@github.com:@linclark/pkg' when executing 'npm install @linclark/pkg'
tva10
@tva10
Sep 27 2015 17:51
@jlslew really don't know... can not try what now.
@jlslew try to ask in Fcc main chat
Will Moody
@willmoody
Sep 27 2015 17:52
Hey folks! Getting a little frazzled on Bonfire: Sorted Union, would appreciate a fresh set of eyes to go over my code and help me deduce where I'm messing up! Here's where I am right now:
function unite(arr1, arr2, arr3) {
  var that = this; //allows reference to properties on this function from within other closures
  that.caught = []; //this is where we'll be building our output array
  //arr1 = arr1.sort() //deprecated for now, trying to use indexOf instead of directly comparing indexes
  //arr2 = arr2.sort()
  //arr3 = arr3.sort()



  var checkAgainst = function(arr, caught)
    { //accepts a single item from the current array, and sees if it matches anything in that.caught
      console.log("Checking " + arr + " against " + caught);

      if (caught.length > 0) 
        { //if there's anything in that.caught to compare against, we start a for loop
          for (var i = 0; i < caught.length; i++)
             { //we determine whether arr[i] exists in that.caught by seeing if its indexOf = -1     
              if (caught.indexOf(arr) !== -1)
                { //if it doesn't, we know we already caught it, so we let it go
                  console.log(caught.indexOf(arr) + " doesn't seem to equal -1")
                  console.log(arr + " already exists within " + caught);
                }
               else
                 { //if it does, we caught something that doesn't exist in that.caught, so we push it there
                    console.log(caught.indexOf(arr) + " seems to equal -1")
                    console.log ("Pushing " + arr + " to " + caught);
                    caught.push(arr);
                 };
             };
         }
        else
                 { //if there's nothing to compare arr[i] against, we simply push it to that.caught
                    console.log("Seems like the length of caught isn't greater than 0")
                    console.log ("Pushing " + arr + " to " + caught);
                    caught.push(arr);
                 };
      };



  console.log("TESTING ARR1: " + arr1)
  for (var i = 0; i < arr1.length; i++)
    { //pass each item in arr1 to checkAgainst()
      checkAgainst(arr1[i], that.caught);    
    };



  console.log("TESTING ARR2: " + arr2)
  for (var i = 0; i < arr2.length; i++)
    { //pass each item in arr2 to checkAgainst()
      checkAgainst(arr3[i], that.caught);    
    };



  console.log("TESTING ARR3: " + arr3)
  for (var i = 0; i < arr3.length; i++)
    { //pass each item in arr2 to checkAgainst()
      checkAgainst(arr3[i], that.caught);    
    };




  return that.caught;
}

unite([1, 3, 2], [5, 2, 1, 4], [2, 1]);
tva10
@tva10
Sep 27 2015 17:54
@fractal-mind soooo much code ))
@fractal-mind first
than you test second arr
you use arr3[i]
Pratik Ratnaparkhi
@pratikr1593
Sep 27 2015 18:00
var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;
function myFunction(){
  // Create an if-else statement here to return "heads" if flip is 0. Otherwise return "tails".

  // Only change code below this line.
if (flip=0)
  {

    return ("heads");
  }

else 
{

  return("tails");
}

  // Only change code above this line.
}

// We use this function to show you the value of your variable in your output box.
var result = myFunction();if(typeof(flip) !== "undefined" && typeof(flip) === "number" && typeof(result) !== "undefined" && typeof(result) === "string"){(function(y,z){return 'flip = ' + y.toString() + ', text = ' + z;})(flip, result);}

it says:

'myFunction should return heads when flip equals 0 and tails when flip equals 1.');myFunction should return heads when flip equals 0 and tails when flip equals 1.

Jonathan Lee Slew
@jlslew
Sep 27 2015 18:01
@pratikr1593 : if (flip == 0)
Pratik Ratnaparkhi
@pratikr1593
Sep 27 2015 18:01
@jlslew Thanks, my bad.
CamperBot
@camperbot
Sep 27 2015 18:01
pratikr1593 sends brownie points to @jlslew :sparkles: :thumbsup: :sparkles:
:star: 241 | @jlslew | http://www.freecodecamp.com/jlslew
tva10
@tva10
Sep 27 2015 18:07
@fractal-mind second:
@fractal-mind I rewrite this:
/*
  console.log("TESTING ARR1: " + arr1)
  for (var i = 0; i < arr1.length; i++)
    { //pass each item in arr1 to checkAgainst()
      checkAgainst(arr1[i], that.caught);    
    };



  console.log("TESTING ARR2: " + arr2)
  for (var i = 0; i < arr2.length; i++)
    { //pass each item in arr2 to checkAgainst()
      checkAgainst(arr2[i], that.caught);    
    };



  console.log("TESTING ARR3: " + arr3)
  for (var i = 0; i < arr3.length; i++)
    { //pass each item in arr2 to checkAgainst()
      checkAgainst(arr3[i], that.caught);    
    };
  */
  console.log('Testing... ');
  for(var i=0;i< arguments.length;i++){
    console.log('Testing '+i+'\'s array in arguments');
    if(Array.isArray(arguments[i])){
       for (var j = 0; j < arguments[i].length; j++)
        { //pass each item in arr to checkAgainst()
          checkAgainst(arguments[i][j], that.caught);    
        };
    }
  }
@fractal-mind because sometimes test cases give you two arguments....
your code passed all tests after that :+1:
Alexander
@teichopsia-
Sep 27 2015 18:27
Does anyone know if this is a bug in the Palindrome bonfire? I don't see how this could be a palindrome. My function passes all the tests except for that one.
"0_0 (: /-\\ :) 0-0"
tva10
@tva10
Sep 27 2015 18:28
@teichopsia- you need to remove special characters there
@teichopsia- after that it will be 0000
Alexander
@teichopsia-
Sep 27 2015 18:28
@tva10 thanks.
CamperBot
@camperbot
Sep 27 2015 18:28
teichopsia- sends brownie points to @tva10 :sparkles: :thumbsup: :sparkles:
:star: 262 | @tva10 | http://www.freecodecamp.com/tva10
Skip Hendriks
@SkipHendriks
Sep 27 2015 18:29

The following code should show a gray scale version of the image and add FontAwesome icon on top of it while hovering over the img-block div:

jQuery:

$('.img-block').hover(function() {
  $(this).find('.img-hover').toggleClass('hidden');
  $(this).find('img').toggleClass('gray-scale');
});

CSS:

.gray-scale {
  -webkit-filter: grayscale(50%);
  -moz-filter: grayscale(50%);
  -o-filter: grayscale(50%);
  -ms-filter: grayscale(50%);
  filter: grayscale(50%);
}

HTML:

<div class="col-sm-6 col-md-4">
        <div class="row img-block">
          <div class="img-hover hidden">
            <div class="img-hover-content text-center">
              <i class="fa fa-fire fa-3x"></i>
            </div>
          </div>
          <img src="https://scontent-ams3-1.xx.fbcdn.net/hphotos-xtp1/v/t1.0-9/10341775_10153541763590929_762569902419242178_n.jpg?oh=038b07b0f153f3b0a0be32c5a50e2626&oe=564B76B0" class="img-responsive portfolio-img" alt="That's me!">
        </div>
        <div class="row text-block-portfolio text-center">Pacman Tic Tac Toe
          <br />
          <h5>CSS and jQuery</h5>
        </div>
      </div>

The problem is that only the gray scale image is visible. When you comment out $(this).find('img').toggleClass('gray-scale'); you can see that the first line does in fact work.

CodePen: link

Skip Hendriks
@SkipHendriks
Sep 27 2015 18:38
In the CodePen there are comments to mark the related code.
Alexander
@teichopsia-
Sep 27 2015 18:39
@jones-codes the solution you wanted to see.
function palindrome(str) {
    var er = /[\_\W\s]/gi
    str = str.toLowerCase().replace(er, '');
    console.log(str)
    var index = 0;
    var last = str.length -1
    while (index < str.length) {
        if (str[index] == str[last - index]) {
            index++;
            if (index == last) {
            return true;
            }
        }
        else {
            return false;
            }
        }
    }
Jonathan Lee Slew
@jlslew
Sep 27 2015 18:41
@SkipHendriks add .img-hover {z-index: 1}
Skip Hendriks
@SkipHendriks
Sep 27 2015 18:43
@jlslew Massive thanks! I'll google z-index.
CamperBot
@camperbot
Sep 27 2015 18:43
skiphendriks sends brownie points to @jlslew :sparkles: :thumbsup: :sparkles:
:star: 242 | @jlslew | http://www.freecodecamp.com/jlslew
henry fritz
@henryamster
Sep 27 2015 18:49
@SkipHendriks in jQuery, you can assign this with the .css function- .css('z-index',1); onto the end of that $(this).find statement
Skip Hendriks
@SkipHendriks
Sep 27 2015 19:07
@henryamster that's not really necessary. it works fine as a css declaration. thanks for the input though!
CamperBot
@camperbot
Sep 27 2015 19:07
skiphendriks sends brownie points to @henryamster :sparkles: :thumbsup: :sparkles:
:star: 259 | @henryamster | http://www.freecodecamp.com/henryamster
Abhisek Pattnaik
@abhisekp
Sep 27 2015 19:10

@teichopsia- you don't need to escape any characters literals inside the [ ] (brackets) in a regex.

NOTE: you must escape the - (hyphen) character if it's not at the first or last inside [ ].
i.e. /[p\-A]/ vs /[A-]/ vs /[-p]/

@teichopsia- This also works var er = /[_\W]/gi;

NOTE: Removed \s and the \ before _ (underscore)

cbgesbocker
@cbgesbocker
Sep 27 2015 19:47
how to set the H1 to lobster font?
Jonathan Lee Slew
@jlslew
Sep 27 2015 19:55
h1 {font-family: lobster}
E-Tank
@E-Tank
Sep 27 2015 20:01
Had some help from a friend in coming up with this for bonfire 'title case a sentence' but I can't figure out why it's not capitalizing the first character.
function titleCase(str) {
  newArray = str.toLowerCase().split('');
  for(i in newArray){
newArray[i].charAt(0).toUpperCase();
}
  var newString = newArray.join('');
  return newString;
}

titleCase("I'm a little tea pot", "");
CamperBot
@camperbot
Sep 27 2015 20:01
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
E-Tank
@E-Tank
Sep 27 2015 20:02
. .. thank you Camperbot, I had no idea about the 'help bonfires chatroom'. I'll go there and bug them.
CamperBot
@camperbot
Sep 27 2015 20:02
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
DTing
@dting
Sep 27 2015 20:05
@E-Tank strings are immutable
CamperBot
@camperbot
Sep 27 2015 20:05
dting sends brownie points to @e-tank :sparkles: :thumbsup: :sparkles:
:star: 249 | @e-tank | http://www.freecodecamp.com/e-tank
DTing
@dting
Sep 27 2015 20:05
lol your name triggers the brownie points thats funny
you cant change the character in the string directly
wiki immutable
CamperBot
@camperbot
Sep 27 2015 20:05

:point_right: js immutable [wiki]

Immutable means unchangeable i.e. you can't change.

Javascript has lots of immutable types e.g. string primitive type. Try this in your console.

s = "red";
console.log(s[1]); //→ "e"
s[1] = "x";
console.log(s) //→ "red"

the s didn't change! WAT!

:pencil: read more about js immutable on the FCC Wiki

DTing
@dting
Sep 27 2015 20:06
toUpperCase doesnt mutate a string it just returns the capitalized version
DTing
@dting
Sep 27 2015 20:14
you can replace the entire string in newArr with a new string with the correct capitalization to join
E-Tank
@E-Tank
Sep 27 2015 20:15
Ah, I see. Thanks.
CamperBot
@camperbot
Sep 27 2015 20:15
if you want to thank someone, put an @ before their name!
. . .thanks @dting
Yeah, my name triggers the brownie points. I didn't know that until it popped up recently.
the worst part is I can't give brownie points, it seems.
Isabek Tashiev
@Isabek
Sep 27 2015 20:17
Hi guys! My English is not fluent. But I want to solve this http://freecodecamp.com/challenges/bonfire-exact-change problem. Could you describe it more clearly, please?
Devon Jones
@jones-codes
Sep 27 2015 20:18
Thanks @teichopsia- really interesting way to solve that
CamperBot
@camperbot
Sep 27 2015 20:18
jones-codes sends brownie points to @teichopsia- :sparkles: :thumbsup: :sparkles:
:star: 181 | @teichopsia- | http://www.freecodecamp.com/teichopsia-
Devon Jones
@jones-codes
Sep 27 2015 20:18
did you want to look at the short version?
E-Tank
@E-Tank
Sep 27 2015 20:18
Hello @isabek What are you having issues understanding?
Isabek Tashiev
@Isabek
Sep 27 2015 20:19
I don't understand description of variables(price, cash, cid).
What should I do?
E-Tank
@E-Tank
Sep 27 2015 20:20
Price is the Price of the item. Cash is the amount of money paid for the item. CID is 'Cash in drawer'
basically the amount of money kept in the register.
Isabek Tashiev
@Isabek
Sep 27 2015 20:21
Could you describe this >> if cash-in-drawer is less than the change due. <<?
What is the change due?
Jonathan Lee Slew
@jlslew
Sep 27 2015 20:22
change due is the amount the shop keeper need to give you back
E-Tank
@E-Tank
Sep 27 2015 20:22
Okay, say someone pays for a dollar item with a 5 dollar bill. But your cash register only has 3 dollars. You can't make change for them, you have insufficient funds.
@isabek does that help?
Isabek Tashiev
@Isabek
Sep 27 2015 20:24
Thank you :)
CamperBot
@camperbot
Sep 27 2015 20:24
if you want to thank someone, put an @ before their name!
Isabek Tashiev
@Isabek
Sep 27 2015 20:25
Thank you @E-Tank
CamperBot
@camperbot
Sep 27 2015 20:25
isabek sends brownie points to @e-tank :sparkles: :thumbsup: :sparkles:
:star: 250 | @e-tank | http://www.freecodecamp.com/e-tank
E-Tank
@E-Tank
Sep 27 2015 20:25
No worries
Jason
@Jauble
Sep 27 2015 20:48
Can anyone tell me what I'm doing wrong here?
  var rem = /\s\.,/gi;
  str = str.toLowerCase();
  str = str.remove(rem, "");
Coira Ellison
@Coira
Sep 27 2015 20:49
@Jauble i don't think String has a remove function, perhaps you want replace() ?
Jason
@Jauble
Sep 27 2015 20:50
oops lol thanks @Coira
CamperBot
@camperbot
Sep 27 2015 20:50
jauble sends brownie points to @coira :sparkles: :thumbsup: :sparkles:
:star: 242 | @coira | http://www.freecodecamp.com/coira
Coira Ellison
@Coira
Sep 27 2015 20:50
np!
Jason
@Jauble
Sep 27 2015 20:52
I still think I got something wrong with the regex because it doesn't work either way.
renren89
@renren89
Sep 27 2015 20:52
what is the difference between return () & return {}. Is it preference or is return {} more preferrable to objects
Jason
@Jauble
Sep 27 2015 20:53
I still end up with "a man, a plan, a canal. panama"
Coira Ellison
@Coira
Sep 27 2015 20:54
@Jauble post all your code? tho i'm not sure i can help with regex, i muddled my way through that one
Jason
@Jauble
Sep 27 2015 20:56
This is a all I have right now, my code disappeared from last night. That was the main part that wasn't working for me.
                var rem = /\s\.,/gi;
                str = str.toLowerCase();
                str = str.replace(rem, "");
.toLowerCase() works, but that's it
I've been testing in an editor so I can console.log the output and i get "a man, a plan, a canal. panama"
Devon Jones
@jones-codes
Sep 27 2015 21:04
what bonfire is that?
donyd
@donyd
Sep 27 2015 21:04
@Jauble Hi there, I had something similar, though i'm not too familiar with regex, so might not be entirely correct. I think you're missing a closing '/' so your regex should be ' /\s.,/gi/ ' the validator in freecodecamp doesn't show you this but i've been banging my head against jsfiddle and firefox console for nearly a month on this and it shows you that
Coira Ellison
@Coira
Sep 27 2015 21:06
@Jauble i haven't tested it, but /\W/g; removes all the punctuation from the "a man..." line
i don't know if it'll pass all the tests tho
Jason
@Jauble
Sep 27 2015 21:07
@jones-codes Check for Palindromes
@donyd thanks I'll try that. @Coira thanks, didn't think about that.
CamperBot
@camperbot
Sep 27 2015 21:07
jauble sends brownie points to @donyd and @coira :sparkles: :thumbsup: :sparkles:
:warning: jauble already gave coira points
:star: 191 | @donyd | http://www.freecodecamp.com/donyd
Jason
@Jauble
Sep 27 2015 21:08
@Coira this is basically what I had, I typed it up really quick, so I might have missed something:
function palindrome(str) {
  var rem = /\s\.,/gi;
  str = str.toLowerCase();
  str = str.remove(rem, "");
  var str2 = str.split('');
  str2 = str2.reverse();
  str2 = str2.join();
  if (str = str2) {
    return true;
  }
  else {
    return false;
  }
}

palindrome("eye");
Devon Jones
@jones-codes
Sep 27 2015 21:08
@Coira yeah that's what i used, with an i in front of the g. but i was told that wasn't necessary since you convert to lowercase anyways
that looks like it should work, don't know how to read that reg ex though. And replace instead of remove
Coira Ellison
@Coira
Sep 27 2015 21:10
oh good, I did it in a much uglier way, but saw \W in chat
Devon Jones
@jones-codes
Sep 27 2015 21:11
yeah I had a much longer version, but hunted that lovely \W down
Jason
@Jauble
Sep 27 2015 21:12
oh yeah, forgot to change it to replace in FCC
DTing
@dting
Sep 27 2015 21:13
@Jauble you dont need the case insensitive flag since you arent matching any letters
@Jauble you have an assignment in the if conditional instead of a comparison
Jason
@Jauble
Sep 27 2015 21:13
@dting true, kind of a habit, thanks
CamperBot
@camperbot
Sep 27 2015 21:13
jauble sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1265 | @dting | http://www.freecodecamp.com/dting
Jason
@Jauble
Sep 27 2015 21:17
@dting oops, (str === str2). Coira was asking for my full code, but it was gone when I logged back on today and just typed it up real quick, so there's probably a few more mistakes.
DTing
@dting
Sep 27 2015 21:17

another thing is, if you are just going to return what the conditional evaluates to without any other operations or logic, you can just:

return str === str2;

With the if else statement you have to read that code and check what you are returning in each case. where as just returning the comparison can be read like. return if str is === str2 rather than if (condition) return something else return something.

Jason
@Jauble
Sep 27 2015 21:18
@dting thanks, makes sense, didn't think about that
CamperBot
@camperbot
Sep 27 2015 21:18
jauble sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:warning: jauble already gave dting points
Jason
@Jauble
Sep 27 2015 21:20
@dting makes it a lot cleaner
Anyone know if there's a way to do console.log() in jsfiddle or anywhere else? I like to use it test stuff and it's kind of a pain switching back and forth between the editor and browser
or to see the console I should say
Coira Ellison
@Coira
Sep 27 2015 21:24
if you're using firefox\chrome and windows, press f12
otherwise, in menu, web development console
or do this waypoint http://www.freecodecamp.com/challenges/waypoint-use-the-javascript-console (which really should be introduced earlier)
Jason
@Jauble
Sep 27 2015 21:26
Ya, I'm just trying to find something that's all in one online, so I don't have to switch back and forth between the editor and chrome. I guess I could try to do it all in chrome.
Coira Ellison
@Coira
Sep 27 2015 21:28
seems like you can press f12 in jsfiddle to have it show up in the console
Rory Smith
@alanbuchanan
Sep 27 2015 21:28
anyone know how to get around the problematic stages of how-to-npm?
Coira Ellison
@Coira
Sep 27 2015 21:28
unless there's a non-browser version?
Jason
@Jauble
Sep 27 2015 21:31
@Coira I tried that, it keeps giving me errors. Thanks for the idea though.
CamperBot
@camperbot
Sep 27 2015 21:31
jauble sends brownie points to @coira :sparkles: :thumbsup: :sparkles:
:warning: jauble already gave coira points
Coira Ellison
@Coira
Sep 27 2015 21:35
@Jauble hm, what about the firebug answer from here http://stackoverflow.com/questions/17382200/print-var-in-jsfiddle ? I tried it in chrome and it worked for me
Jason
@Jauble
Sep 27 2015 21:39
@Coira Thanks I'll check that out
CamperBot
@camperbot
Sep 27 2015 21:39
jauble sends brownie points to @coira :sparkles: :thumbsup: :sparkles:
:warning: jauble already gave coira points
Jason
@Jauble
Sep 27 2015 21:44
@Coira Awesome it works! Thanks!
CamperBot
@camperbot
Sep 27 2015 21:44
jauble sends brownie points to @coira :sparkles: :thumbsup: :sparkles:
:warning: jauble already gave coira points
Coira Ellison
@Coira
Sep 27 2015 21:44
great!
Michael Sanford
@mikethecodegeek
Sep 27 2015 21:49
has anyone done the Inventory Update Bonfire yet?
Devon Jones
@jones-codes
Sep 27 2015 21:50
no way to save that in JSFiddle?
It just disappears when i refresh
Jason
@Jauble
Sep 27 2015 21:51
Not that I know of. I was thinking about that too. I just saved it to my bookmarks
Devon Jones
@jones-codes
Sep 27 2015 21:52
Word
Jason
@Jauble
Sep 27 2015 21:52
Oh, I tried the \W, and it passes everything except the last one which uses random characters lol, oh well
Devon Jones
@jones-codes
Sep 27 2015 21:53
what did your whole reg ex look like?
Jason
@Jauble
Sep 27 2015 21:53
function palindrome(str) {
  var rem = /\W/g;
  str = str.toLowerCase();
  str = str.replace(rem, "");
  var str2 = str.split('');
  str2 = str2.reverse();
  str2 = str2.join('');
  return (str === str2);
}

palindrome("Hi, there.");
Moisés Man
@moigithub
Sep 27 2015 21:55
before return
add
console.log(str," ", str2);
then open devtools ( F12 ) and check what u have logged on console tab
Jason
@Jauble
Sep 27 2015 21:58
Ya, I've been doing console.log in jsfiddle
hithere
erehtih
Devon Jones
@jones-codes
Sep 27 2015 21:59
I'm lost, the solution I saved isn't working anymore smh
Jason
@Jauble
Sep 27 2015 22:00
It passes everything on the left side in FCC except the last: assert(palindrome("0_0 (: /-\ :) 0-0") === true, '"0_0 (: /-\ :) 0-0" should return true.');"0_0 (: /-\ :) 0-0" should return true.
@jones-codes for console.log in jsfiddle? https://getfirebug.com/firebug-lite-debug.js
Devon Jones
@jones-codes
Sep 27 2015 22:00
no no, the palindrome bonfire
Jason
@Jauble
Sep 27 2015 22:01
Oh ok
I'm not sure why this wasn't working or at least doing something var rem = /\s.,/gi;
I'm not very familiar with regex
forget the i
Jesse L Lawson
@rocketNeck
Sep 27 2015 22:04
anyone know what I am doing wrong? Repeat a string, return empty string if num is negative.
function repeat(str, num) {
  var emptyStr = "";
  var a = str.repeat(num);
  if (num < 1){
    return emptyStr;
  }else {
    return a;
  }
}
Jason
@Jauble
Sep 27 2015 22:09
Did you try calling the function?
Tim P
@xTimpi
Sep 27 2015 22:09
you should check if num is below zeor before you call the function since negative numbers will result in range errors, I am not sure if that is the problem, though
Jason
@Jauble
Sep 27 2015 22:09
repeat("hello", 5);
Tim P
@xTimpi
Sep 27 2015 22:09
*zero
Jason
@Jauble
Sep 27 2015 22:09
works for me hellohellohellohellohello
@xTimpi good idea
Jesse L Lawson
@rocketNeck
Sep 27 2015 22:11
@Jauble yeah the bonfire calls the function. @xTimpi I did use 0 as well.
It passes the first 2 tests just doesn't return empty string/
Tim P
@xTimpi
Sep 27 2015 22:11
what does it return then?
Jason
@Jauble
Sep 27 2015 22:12
When I tried it on jsfiddle with 0 it gave me "(an empty string)"
Tim P
@xTimpi
Sep 27 2015 22:12
the test should print you the outcome before saying what it expected it to be
Jesse L Lawson
@rocketNeck
Sep 27 2015 22:13
assert(repeat("", 3) === "**", '"", 3 should return "**".');
assert(repeat("abc", 3) === "abcabcabc", '"abc", 3 should return "abcabcabc".');
assert(repeat("abc", -2) === "", '"abc", -2 should return "".');Invalid count value
"Invalaid count value"
Jason
@Jauble
Sep 27 2015 22:16
@xTimpi are you very familiar with regex?
Tim P
@xTimpi
Sep 27 2015 22:16
@Jauble not at all
Jason
@Jauble
Sep 27 2015 22:16
Ok thanks
CamperBot
@camperbot
Sep 27 2015 22:16
if you want to thank someone, put an @ before their name!
Jesse L Lawson
@rocketNeck
Sep 27 2015 22:19
@xTimpi @Jauble Thanks for the help. I don't know what "Invalid count value" is so... next bonfire.
CamperBot
@camperbot
Sep 27 2015 22:19
cannibal-dance sends brownie points to @xtimpi and @jauble :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for jauble
:star: 288 | @xtimpi | http://www.freecodecamp.com/xtimpi
Don Price
@KingHippo
Sep 27 2015 22:19
Can someone help me a bit with the Bonfire: Mutation? I am having trouble figuring this one out. Here is my code.
function mutation(arr) {
  var stringArray = arr[0].toLowerCase().split("");
  var searchKey = arr[1].toLowerCase().split("");
  if (stringArray.indexOf(searchKey) == -1) {
    return false;
  } else if (stringArray.indexOf(searchKey) != 1) {
    return true;
  }
}

mutation(["elloH", "Hey"], "");
CamperBot
@camperbot
Sep 27 2015 22:19
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Jason
@Jauble
Sep 27 2015 22:20
@cannibal-dance no prob!
Tim P
@xTimpi
Sep 27 2015 22:24
@cannibal-dance I can’t even try it for you because aparently repeat is an undefined function lol
@cannibal-dance a work-around for this would be to use a for-loop and string.concat()
bonfire mutation
CamperBot
@camperbot
Sep 27 2015 22:27

:fire:Bonfire: Mutations :link:

function mutation(arr) {
  return arr;
}

mutation(['hello', 'hey']);

Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

more info:  bf details | bf links | hint

Jason
@Jauble
Sep 27 2015 22:27
@KingHippo I think you might need another = (!==)
@KingHippo also, do you possibly mean == 1 and not == -1?
Tim P
@xTimpi
Sep 27 2015 22:29
@KingHippo I think you misunderstood the bonfire, you should check every single character in the second argument, not the whole string
@KingHippo your code just checks if „hey“ is inside of „hello“ but it should check if „h“ „e“ AND „y“ are inside of „hello"
Don Price
@KingHippo
Sep 27 2015 22:33
@Jauble I changed the -1 to a one and all tests pass now except the first and last test. @xTimpi I thought that's what I was doing. I turned Hey into and array then looked through the other array to see if any strings match. At least I though I did haha
Tim P
@xTimpi
Sep 27 2015 22:34
@KingHippo -1 is correct because thats what you get when the string or char is not in the string that is searched
@KingHippo I am not sure if you can pass an array into the indexOf() function
@KingHippo but I would be surprised if you can, lol
Don Price
@KingHippo
Sep 27 2015 22:36
@xTimpi aaah damn! I guess I need a new approach.
I thought indexOf() was for arrays
Tim P
@xTimpi
Sep 27 2015 22:37
@cannibal-dance strings have an indexof() method, too
@cannibal-dance works pretty much the same since you can turn any string into an array with the split() method
Jason
@Jauble