These are chat archives for FreeCodeCamp/Help

2nd
Sep 2015
Steven Parker
@Philosophist
Sep 02 2015 00:09
Is no one available at the moment to help with permutation recursion?
Rob
@BobsHub
Sep 02 2015 00:10
I've completed that one but not sure If I have the algorithm correct
If you do it recursively the browser crashes
Steven Parker
@Philosophist
Sep 02 2015 00:11
function permAlone(str) {
  var num = 0;
  var newStr, uArr = [], pArr = [];

  for(i = 0; i < str.length; i++) {
    uArr.push(false); 
    pArr.push("x");
  }

  function perm(curPos, usedArr, tmpArr){
    console.log("IN\ncurPos: " + curPos + "\n" + "usedArr: " + usedArr + "\n" + "tmpArr: " + tmpArr + "\n");
    if(curPos === str.length) {
      newStr = tmpArr.join();
      if(!newStr.match(/(.)\1/g)) {
        num += 1;
      }
      console.log(newStr + "\n");
    }else{
      for(var i = 0; i < str.length; i++) {
        if(usedArr[i] === true){

        }else{
          tmpArr[curPos] = str[i];
          usedArr[i] = true;
    console.log("OUT\ncurPos: " + curPos + "\n" + "usedArr: " + usedArr + "\n" + "tmpArr: " + tmpArr + "\n");
          perm(curPos + 1, usedArr, tmpArr);
        }
      }

    }
  }
  //console.log(str.length);
  perm(0, uArr, pArr);
  return num;
}

permAlone('abc');
Rob
@BobsHub
Sep 02 2015 00:12
// Group and sort clusters of similar characters
// "cdedfdgg" ==> [c,[d,d,d],e,f,[g,g]];
function group(str) {
    var alp = "0123456789abcdefghijklmnopqrstuvwxyz";
    var arr = [];
    for(var i in alp) {
        var patt = new RegExp(alp[i], 'g');
        var grp = str.match(patt);
        if(grp) arr.push(grp);        
    }
    return arr;
}

// Its easier to first find all permutations of
// repeating sequential characters
// total = (factorial of group count) 
// * (factorial of repititions within each group)
// * (group count) to the power of:
//      ( # of groups with more than 1 repitition - 1 )
//                  1    2    3 4   5     <-- group count (5)
// If our group is [c,[d,d,d],e,f,[g,g]]
//                  1    3    1 1   2     <-- reps within each group
// there are 2 groups [d,d,d] and [g,g] 
// that have > 1 rep (to the power of 1). Count from 0
// Thats 5! * 3! * 2! * (5 pow 1)
function repeats(arr) {
    var rep = 0;
    var total = factorial(arr.length);         
    arr.forEach(function(item) {
        if(item.length > 1) ++rep;
        total *= factorial( item.length );
    });
    if(rep == 0) ++rep;
    total *= Math.pow(arr.length, rep-1);
    return total;    
}

// The non repeating permutations
// Simply the total # of permutations minus the repeats
// (factorial of character count) - repeat total
function noRepeats(str, totalRepeats) {
    var totalPermutations = factorial( str.length );
    return totalPermutations - totalRepeats;
}

function factorial(n) {
    var product = 1;
    while(n > 1) product *= n--;
    return product;        
}

function permAlone(str) {
    if(typeof str !== "string")
        throw TypeError( typeof(str) + " not a valid type!");
    if( !str.match(/[a-z0-9]/gi) )
        return str;      

    console.log("Total permutations", factorial(str.length));
    var groupArr = group(str);
    console.log(groupArr);

    var rep = repeats(groupArr);
    console.log("Repeating permutations:", rep);

    var noRep = noRepeats(str, rep);
    console.log("Non repeating permutations:", noRep);  
     return noRep;
}

permAlone("975179957493");
thats passes the tests, but not sure if its right
Steven Parker
@Philosophist
Sep 02 2015 00:14
I just need to figure out why the recursion isn't doubling back through the for loop for each recursion. i increases, but prematurely.
as if it's global
Rob
@BobsHub
Sep 02 2015 00:15
there would be far too many recursive calls to to a large string like "aabcdef"
Chad Schmidt
@TheHexorcist
Sep 02 2015 00:15
Tips on http://www.freecodecamp.com/challenges/bonfire-everything-be-true i dont know why but the second arguement is sometimes a string and an object.
According to assertion
Steven Parker
@Philosophist
Sep 02 2015 00:15
the idea is that most of them just skip through as nothing happening
Rob
@BobsHub
Sep 02 2015 00:18
/* ///////////////////////////////////////////////////////////////////////
// Recursive calls to find permutations
//        ind
//         2                     ind  
// [a, b, (c), d]                 2                   ind  
//   ----------> pass [c],[a, b, (d)]                  0
//                           ----------> pass [c, d],[(a), b]
//
// [c, d],[(a), b]                     0
//       -----------> pass [c, d, a], [b]
//                            ---------=> pass [c, d, a, b], []  perm ready 
// 
function next(arrIn, arrOut) {
    var len = arrIn.length, index = 0;

    if(len == 0) {
        var str = arrOut.join('');
        if( !charRepeated(str) )
            console.log(str);
    }   

    while(index < len) {
        var ch = arrIn.splice(index, 1);
        arrOut.push(ch);
        next(arrIn, arrOut);
        arrOut.pop();
        arrIn.splice(index++, 0, ch);
    }
}

function charRepeated(arr) {
    var len = arr.length - 1;
    for(var i = 0; i < len; ++i)  
        if(arr[i] === arr[i+1])
            return true;
    return false;
}

function permutation(str) {
    var arr = str.split('');
    next(arr, []);
}

permutation("aabb");
*/ //////////////////////////////////////////////////////////////
that works but only with short strings
Camilolwi
@Camilolwi
Sep 02 2015 00:21
hi guys! u're awesome love freecodecamp
Mike Varela
@mikevarela
Sep 02 2015 00:22
Hey guys, question. Coming from the earlier version of free code camp with the great help section and previous answers given for problems. not here on gitter, am I supposed to just copy code here and as a question. and how do i research the same problem others have had
Manolo
@Manolo-S
Sep 02 2015 00:22
Hi, I'm working on Bonfire Title case a sentence and I believe my code is correct but I can't pass the first test. It insists that I should provide the string "I\'m" in stead of "I'm"
I couldn't find any post so far addressing this. Did any of you run into this?

My code: function titleCase(str) {
console.log(str);
b = ""
array = str.split(" ");
for (var i = 0; i < array.length; i++){
effe = array[i];
up = effe.charAt(0).toUpperCase();
lower = effe.slice(1).toLowerCase();
a = up + effe.slice(1) + " ";
b = b + a;
}
return b;
}

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

DTing
@dting
Sep 02 2015 00:24
bf title
CamperBot
@camperbot
Sep 02 2015 00:24

:fire:Bonfire: Title Case a Sentence :link:

function titleCase(str) {
  return str;
}

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

Return the provided string with the first letter of each word capitalized.

more info:  bf details | bf links | hint

John Sanchez
@john8801
Sep 02 2015 00:24
wp
bf
CamperBot
@camperbot
Sep 02 2015 00:24
we're talking about bonfire :fire: Bonfire: Title Case a Sentence
John Sanchez
@john8801
Sep 02 2015 00:24
zipline
DTing
@dting
Sep 02 2015 00:25
@Manolo-S your problem isnt the I\'m it's the extra space at the end of each string
@Manolo-S also you correctly realize you need to lowercase the rest of the word and do it. but then dont use it when you concat your string
up = effe.charAt(0).toUpperCase();
lower = effe.slice(1).toLowerCase(); // this should be used
a = up + effe.slice(1) + " "; // here
you can fix this either by adding the trailing space conditionally with an if statement in your for loop, by trimming the returned string with b.trim() or by returning all but the last letter of b. or by pushing each word to an array and joining with a space arr.join(' ')
Tony Collier
@tcollier2
Sep 02 2015 00:34
Hey all, I'm running into some trouble in the jQuery section here. The task is to make the second of the well class elements bounce using the :nth-child() selector. Here's my code, I'm what's wrong. Any help is greatly appreciated.
$(".well:nth-child(2)").addClass("animated bounce");
DTing
@dting
Sep 02 2015 00:35
@tcollier2 you can either put a space between .well and :nth-child
or you can use ".target:nth-child(2)"
Tony Collier
@tcollier2
Sep 02 2015 00:37
@dting Great, thanks!!
CamperBot
@camperbot
Sep 02 2015 00:37
tcollier2 sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 931 | @dting | http://www.freecodecamp.com/dting
Noah holley
@noahholley
Sep 02 2015 00:40
how do you Factorialize a user input in js?
DTing
@dting
Sep 02 2015 00:41
@noahholley probably by using recursion or a forloop or a while loop
Noah holley
@noahholley
Sep 02 2015 00:45
k ive been experimenting with all the loops i just cant figure out how to formulate the solution. can you guide me along without giving me the answer. i really want to learn how to do this.
DTing
@dting
Sep 02 2015 00:46
factorial is:
n!==1n! == 1 if n==0n == 0
and
n!==n×(n1)!n! == n \times (n - 1)! if n>0n > 0
Jose E. Pimentel
@jedpimentel
Sep 02 2015 00:47
@noahholley I'd say recursion would probably be the best way. Since factorial(x)=x*factorial(x-1),
DTing
@dting
Sep 02 2015 00:48
so it's basicaly all the numbers in a range from 1..n1 .. n multiplied by each other
1×2×3×...×n1 \times 2 \times 3 \times ... \times n
Rob
@BobsHub
Sep 02 2015 00:49
just remember doing it recursively is for learning purposes. It's silly to factorialize using recusion
DTing
@dting
Sep 02 2015 00:50
so your loop could be:
var result = 1;
for ( some loop that goes from 1 to n inclusive)
  result * looping variable 
return result
Rob
@BobsHub
Sep 02 2015 00:54
https://www.youtube.com/watch?v=bN8PE3eljdA great toping for a coding problem
DTing
@dting
Sep 02 2015 00:55
es6 will be tail call optimized so factorial using recursion will be :thumbsup:
Mateja Trifunovski
@Matko95
Sep 02 2015 00:57
@BobsHub interesting..
Rob
@BobsHub
Sep 02 2015 00:57
I'm working on that one now hehe
Mateja Trifunovski
@Matko95
Sep 02 2015 00:59
@BobsHub trying to find a palindrome of 196? :D
Rob
@BobsHub
Sep 02 2015 00:59
hell no, cant do it in js
maybe 12
Mateja Trifunovski
@Matko95
Sep 02 2015 01:01
seems fun
Manolo
@Manolo-S
Sep 02 2015 01:03
@dting Getting rid of that last space solved it. Thank you! The error that was generated threw me off. Thanks again!
CamperBot
@camperbot
Sep 02 2015 01:03
manolo-s sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 932 | @dting | http://www.freecodecamp.com/dting
DTing
@dting
Sep 02 2015 01:17
@Manolo-S nps
michaelpcampbell
@michaelpcampbell
Sep 02 2015 01:18

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

<style>
h2 {
font-family: Lobster, Monospace;
}

.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
</style>

<div class="container-fluid">
<div class="row">
<div class="col-xs-6">
<h2 class="text-primary text-center">CatPhotoApp</h2>
</div>
<div class="row">
<div class="col-xs-6">
<a href="#"><img class="img-responsive thick-green-border" src="https://bit.ly/fcc-relaxing-cat"></a>
</div>
</div>
<img src="http://bit.ly/fcc-running-cats" class="img-responsive">
<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>
<div class="row">
<div class="col-xs-6">
<button class="btn btn-block btn-info"><i class="fa fa-info-circle"></i> Info</button>
</div>
</div>
<dic class="row">
<div class="col-xs-6">
<button class="btn btn-block btn-danger"><i class="fa fa-trash"></i> Delete</button>
</div>

<p>Things cats <span class="text-danger">love:</span></p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
<form action="/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor"> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label>
<label><input type="checkbox" name="personality"> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Crazy</label>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</div>

DTing
@dting
Sep 02 2015 01:18
which one is that?
michaelpcampbell
@michaelpcampbell
Sep 02 2015 01:18
Nest each of your radio buttons inside its own div with the class col-xs-6.
Make sure each of your div elements has a closing tag.
KcirdnekC
@KcirdnekC
Sep 02 2015 01:19
Working on Waypoint: Target a Specific Child of an Element Using jQuery. It passed, but I am wondering how it knew to select the "well" class. $(".target:nth-child(2)").addClass("animated bounce")
DTing
@dting
Sep 02 2015 01:19
bf radio
CamperBot
@camperbot
Sep 02 2015 01:19
Sorry, can't find a bonfire called radio. [ Check the map? ]
DTing
@dting
Sep 02 2015 01:19
@KcirdnekC it isnt targeting .well
michaelpcampbell
@michaelpcampbell
Sep 02 2015 01:19
Waypoint: Responsively Style Radio Buttons
DTing
@dting
Sep 02 2015 01:19
@KcirdnekC it's finding all the .target elements
Mateja Trifunovski
@Matko95
Sep 02 2015 01:20
@michaelpcampbell What seems to be the problem?
DTing
@dting
Sep 02 2015 01:20
you can target .well too by using $(".well :nth-child(2)") notice the space
KcirdnekC
@KcirdnekC
Sep 02 2015 01:20
Ahhh thanks I get it
CamperBot
@camperbot
Sep 02 2015 01:20
if you want to thank someone, put an @ before their name!
michaelpcampbell
@michaelpcampbell
Sep 02 2015 01:20
cant seem to close all divs and col-xs-6 isnt going well
Mateja Trifunovski
@Matko95
Sep 02 2015 01:21
@michaelpcampbell So you don't understand the concept on how to wrap them?
DTing
@dting
Sep 02 2015 01:21
@michaelpcampbell
what did you try it looks like you just pasted the original code?
michaelpcampbell
@michaelpcampbell
Sep 02 2015 01:21
@Matko95 thats correct
@dting i changed all the col-xs-? to 6 and did all divs in rows but cant seem to figure why it wont go through
Mike Varela
@mikevarela
Sep 02 2015 01:22
Trying to figure why this won't work

function palindrome(str) {

str = str.replace(/.[{}]!@#$%^&*-'"_=+/g, "");
str = str.replace(/\s+/g, "");
var lowerString = str.toLowerCase();

var reversedString = lowerString.split('').reverse().join('');

if (lowerString === reversedString) {

return true;

}
else
{
return false;
}

}

palindrome("eye");

Mateja Trifunovski
@Matko95
Sep 02 2015 01:23
<div class="row">
<div class="col-xs-6">*Radio button here*</div>
<div class="col-xs-6">*Radio button here*</div>
</div>
So you see, the idea is that you make a row and fill it with 2 "columns"
DTing
@dting
Sep 02 2015 01:23
it wants you to put these 2 lines
    <label><input type="radio" name="indoor-outdoor"> Indoor</label>
    <label><input type="radio" name="indoor-outdoor"> Outdoor</label>
okay matkos posted the answer
Mike Varela
@mikevarela
Sep 02 2015 01:23
Won't work for this
assert.deepEqual(palindrome("A man, a plan, a canal. Panama"), true);
Pallindrome problem
michaelpcampbell
@michaelpcampbell
Sep 02 2015 01:24
@Matko95 so for every div it wants that
DTing
@dting
Sep 02 2015 01:24
@michaelpcampbell just that code @Matko95 posted replaces this code:
    <label><input type="radio" name="indoor-outdoor"> Indoor</label>
    <label><input type="radio" name="indoor-outdoor"> Outdoor</label>
Mateja Trifunovski
@Matko95
Sep 02 2015 01:25
@michaelpcampbell yes, picture making a grid.. the grid row contains 12 individual containers, and you spread the first radio button across the first six containers, and the second radio button across the other six
@mikevarela Can you send your output for "A man, a plan, a canal. Panama"?
theres one of these special characters that can help you clean up removing punctuations
michaelpcampbell
@michaelpcampbell
Sep 02 2015 01:26
@Matko95 well there are 3 buttons so i need 3 containers for each button
@Matko95 i meant 4
Mateja Trifunovski
@Matko95
Sep 02 2015 01:27
@michaelpcampbell If i am not wrong, there are 2 radio buttons, and 3 checkboxes, you should pay attention only to the radio buttons now.
michaelpcampbell
@michaelpcampbell
Sep 02 2015 01:27
@Matko95 like info and delete are the butons
Mateja Trifunovski
@Matko95
Sep 02 2015 01:28
@michaelpcampbell Are you trying to style the radio buttons, or those buttons?
michaelpcampbell
@michaelpcampbell
Sep 02 2015 01:29
@Matko95 radio buttons i guess i dont understand what radio buttons mean
on the right side
Mahtab
@RoadToCode822
Sep 02 2015 01:34
Why isn’t my code working?
<!doctype html>
<html lang="en" ng-app>
<head>
    <meta charset="utf-8">
    <title>Hello World</title>
</head>
<body>
    <h1 ng-controller="HelloWorldCtrl">{{helloMessage}}</h1>

    <script src="angular.min.js"></script>
    <script type="text/javascript">
        function HelloWorldCtrl($scope) {
            $scope.helloMessage = "Hello World";
        }
    </script>
</body>
</html>
CamperBot
@camperbot
Sep 02 2015 01:34
:trollface: troll problems? notify admins here
dleemagic002
@dleemagic002
Sep 02 2015 01:39
This message was deleted
DTing
@dting
Sep 02 2015 01:41
@RoadToCode822 i dont see you creating your module and making HelloWorldCtrl a controller
CamperBot
@camperbot
Sep 02 2015 01:41
:trollface: troll problems? notify admins here
Danny Fritz
@dannyfritz
Sep 02 2015 01:44
@RoadToCode822 should look more like this: http://jsbin.com/zozoqenuja/1/edit?html,js,console,output
Mahtab
@RoadToCode822
Sep 02 2015 01:46
Is there any explanation online for how the parameters are defined for angular.module. For example, why is there an empty array as a second parameter
DTing
@dting
Sep 02 2015 01:48
thats a dependency array
Danny Fritz
@dannyfritz
Sep 02 2015 01:48
@RoadToCode822 i believe it is for dependency injection: https://docs.angularjs.org/api/ng/function/angular.module
DTing
@dting
Sep 02 2015 01:48
if you dont have any dependencies then its an empty array
Mahtab
@RoadToCode822
Sep 02 2015 01:48
Thanks man :)
CamperBot
@camperbot
Sep 02 2015 01:48
if you want to thank someone, put an @ before their name!
Mahtab
@RoadToCode822
Sep 02 2015 01:48
Thanks @dting and @dannyfritz
CamperBot
@camperbot
Sep 02 2015 01:49
roadtocode822 sends brownie points to @dting and @dannyfritz :sparkles: :thumbsup: :sparkles:
:star: 112 | @dannyfritz | http://www.freecodecamp.com/dannyfritz
:star: 935 | @dting | http://www.freecodecamp.com/dting
DTing
@dting
Sep 02 2015 01:54
@RoadToCode822 nps
x34passenger
@x34passenger
Sep 02 2015 01:55
I am on waypoint 13 of jquery, is it a bug?
my left-well element does have a red background but still says not right
Mateja Trifunovski
@Matko95
Sep 02 2015 01:57
@x34passenger can you send that line of code?
x34passenger
@x34passenger
Sep 02 2015 02:01
$("#left-well").parent().css("background-color", "red")
Mateja Trifunovski
@Matko95
Sep 02 2015 02:02
@x34passenger the idea is that you target a child of left-well, so left-well would be a parent of that target
you now targeted the left-well parent, and every child got painted of course
Neka
@NekaB
Sep 02 2015 02:03
hello i've been stuck for the longest time on this "<form action="/submit-cat-photo" id="cat-photo-form">" and it's saying i need to "Your form element should have the background-color of green." help anyone? lol
I already put the "#cat-photo-element { background-color: green; }" in my style code
Mateja Trifunovski
@Matko95
Sep 02 2015 02:04
@NekaB you are targetting #cat-photo-element , and your id is equal to #cat-photo-form
Virginia Winter
@FreeCodeCamp319
Sep 02 2015 02:05
Thanks to @Rafase282 for his article at https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/bonfire-arguments-optional. I had been so confused as to how to return a function awaiting an argument.
CamperBot
@camperbot
Sep 02 2015 02:05
freecodecamp319 sends brownie points to @rafase282 :sparkles: :thumbsup: :sparkles:
:star: 384 | @rafase282 | http://www.freecodecamp.com/rafase282
x34passenger
@x34passenger
Sep 02 2015 02:05
@Matko95 got it, I see my mistake, thanks!
CamperBot
@camperbot
Sep 02 2015 02:05
x34passenger sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 190 | @matko95 | http://www.freecodecamp.com/matko95
Mateja Trifunovski
@Matko95
Sep 02 2015 02:06
@x34passenger np :)
Neka
@NekaB
Sep 02 2015 02:07
I input it within my form like this <form action="/submit-cat-photo" #cat-photo-element id="cat-photo-form">
Rafael J. Rodriguez
@Rafase282
Sep 02 2015 02:08
Glad to help @FreeCodeCamp319, everyone else I'm working on the wiki pages at the moment so a few pages will be update, particulalry the bonfires and the bonfire tempalte page. https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Bonfire-Wiki-Template
CamperBot
@camperbot
Sep 02 2015 02:08
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Neka
@NekaB
Sep 02 2015 02:09
I'm wondering if I'm supposed to input brackets somewhere
Mateja Trifunovski
@Matko95
Sep 02 2015 02:09
@NekaB I'm not sure what you are trying to do but your form should look like <form action="/submit-cat-photo" id="cat-photo-form"> and then your css should be #cat-photo-form { background-color: green; }
@NekaB if you wanted to add cat-photo-element to the form as an id you would have to do this <form action="/submit-cat-photo" id="cat-photo-form cat-photo-element">
the "#" in the css is just saying that it's targeting an id, it doesn't mean anything in the html code
Patrick McWilliams
@patrickmac110
Sep 02 2015 02:16
can anyone understand why my stuff gets shifted to the left when I apply bootstrap?
http://codepen.io/patrcikmac110/pen/xwKXdm
Mike Varela
@mikevarela
Sep 02 2015 02:17
@Matko95 assert.deepEqual(palindrome("A man, a plan, a canal. Panama"), true);expected false to deeply equal true
Mateja Trifunovski
@Matko95
Sep 02 2015 02:18
@patrickmac110 apply a text-center class and it will go to middle
@mikevarela can you post the code?
Patrick McWilliams
@patrickmac110
Sep 02 2015 02:19
to the rows?
Mateja Trifunovski
@Matko95
Sep 02 2015 02:20
@patrickmac110 to whatever you need to center, and i see that you are missing a closing ">" before your G+ button
Reggie
@Reggie01
Sep 02 2015 02:20

@patrickmac110 You may want to take a look at grids http://getbootstrap.com/css/#grid. Also, you have your buttons in

 <div class="col-md-4" </div>

which only allows a width of col-md-4. Try removing it.

or close the bracket
 <div class="col-md-4"> </div>
Mateja Trifunovski
@Matko95
Sep 02 2015 02:22
@Reggie01 it actually works when you add the missing ">"
Jesse Croxford
@Jcroxford
Sep 02 2015 02:23
hey guys I just got to bonfire roman numeral and I honestly have no idea where to start can anyone give me some sort of direction? haha
Mateja Trifunovski
@Matko95
Sep 02 2015 02:25
@AuricSlayer try lots of if statements :D
Jesse Croxford
@Jcroxford
Sep 02 2015 02:27
haha I thought about doing that but it seems terribly inefficient. It seems like there should be an easier way
Patrick McWilliams
@patrickmac110
Sep 02 2015 02:27
@Reggie01 that helped a lot, thanks for noticing that!
CamperBot
@camperbot
Sep 02 2015 02:27
patrickmac110 sends brownie points to @reggie01 :sparkles: :thumbsup: :sparkles:
:star: 170 | @reggie01 | http://www.freecodecamp.com/reggie01
Mateja Trifunovski
@Matko95
Sep 02 2015 02:28
@AuricSlayer well since it says that you should use .splice(), .join() and .indexOf() you should think in that direction
and if you get nothing, you can always ask camperbot for a hint
Jason Confere
@wvmtnboy
Sep 02 2015 02:29
for some reason, I cannot get jQuery waypoint #1 to work.....
I enter it as it is shown and instructed, and I receive a myriad of errors
Mateja Trifunovski
@Matko95
Sep 02 2015 02:29
@wvmtnboy can you send the code?
Jesse Croxford
@Jcroxford
Sep 02 2015 02:30
alright Ill give it some thought
Rich Churcher
@richchurcher
Sep 02 2015 02:30
funny thing about a myriad of errors... you fix the first one, then the next, till there's no more ;)
then you miss a semicolon and the whole dance begins again!
Jason Confere
@wvmtnboy
Sep 02 2015 02:30
$(document).ready(function() { then it tells me to close it on the next line with });
but it just won't work....
Cory Lundgren
@cml0401
Sep 02 2015 02:31
bf hint
CamperBot
@camperbot
Sep 02 2015 02:31
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
GeoffG-oz
@GeoffG-oz
Sep 02 2015 02:31
hi all trying to add the code for bootstrap spyscroll to the body tag in a pen but there doesn't appear to be any straightforward way to do that. when i try it just adds a second body tag.
Jason Confere
@wvmtnboy
Sep 02 2015 02:31
I was thinking it should be $(document).ready(function()) { closing with };
Rich Churcher
@richchurcher
Sep 02 2015 02:31
@wvmtnboy
```
Jason Confere
@wvmtnboy
Sep 02 2015 02:32
my bad
new to this
Rich Churcher
@richchurcher
Sep 02 2015 02:32
$(document).ready(function() {

});
like that
Mateja Trifunovski
@Matko95
Sep 02 2015 02:32
@wvmtnboy you closed it too soon actually .ready(function() {});
Rich Churcher
@richchurcher
Sep 02 2015 02:33
the last ) closes the .ready()
Jason Confere
@wvmtnboy
Sep 02 2015 02:33
@richchurcher much thanks! it worked, though I can't see a difference between that and what I entered
CamperBot
@camperbot
Sep 02 2015 02:33
wvmtnboy sends brownie points to @richchurcher :sparkles: :thumbsup: :sparkles:
:star: 291 | @richchurcher | http://www.freecodecamp.com/richchurcher
Jason Confere
@wvmtnboy
Sep 02 2015 02:34
@Matko95 thank you, as well!
Mateja Trifunovski
@Matko95
Sep 02 2015 02:34
@wvmtnboy
$(document).ready(function()) { closing with };
you see that you called .ready(function())
Rich Churcher
@richchurcher
Sep 02 2015 02:34
my guess is there was a subtle typo you couldn't see in the first example you posted
Mateja Trifunovski
@Matko95
Sep 02 2015 02:34
and function doesn't do anything
Jason Confere
@wvmtnboy
Sep 02 2015 02:35
I appreciate the help!
x34passenger
@x34passenger
Sep 02 2015 02:37
I'm at basic javascript waypoint 20, is it a bug
Reggie
@Reggie01
Sep 02 2015 02:37
@GeoffG-oz I did not implement the spyscroll myself. Somebody had a previous issue with spyscroll and they just added bootstrap.js in the settings in codepen. Also, include jquery first.
x34passenger
@x34passenger
Sep 02 2015 02:37
myArray.pop()
Mateja Trifunovski
@Matko95
Sep 02 2015 02:38
@x34passenger post the code again :)
x34passenger
@x34passenger
Sep 02 2015 02:39
myArray.pop()
DJ
@qualitymanifest
Sep 02 2015 02:39
@x34passenger what is the problem?
x34passenger
@x34passenger
Sep 02 2015 02:40
@Matko95 assert((function(d){if(d[0] == 'cat' && d[1] == 2 && d[2] == undefined){return true;}else{return false;}})(removed), 'myArray should only have the first two values left(["cat"], 2)');
@qualitymanifest assert((function(d){if(d[0] == 'cat' && d1 == 2 && d[2] == undefined){return true;}else{return false;}})(removed), 'myArray should only have the first two values left(["cat"], 2)');
DJ
@qualitymanifest
Sep 02 2015 02:41
assert((function(d){if(d[0] == 'cat' && d1 == 2 && d[2] == undefined){return true;}else{return false;}})(removed), 'myArray should only have the first two values left(["cat"], 2)');
GeoffG-oz
@GeoffG-oz
Sep 02 2015 02:42
the issue is that the body tag is already inserted in the pen like the head and meta tags but there doesn't appear to be any way to edit the actual body tag . its not that big an issue so i may just not bother. lol
x34passenger
@x34passenger
Sep 02 2015 02:42
@qualitymanifest the test is not passing
Neka
@NekaB
Sep 02 2015 02:43
@Matko95 Thanks. I don't know what I did wrong. I thought I put the code correctly in my style tags but I'm going to really analyze it before i move on thanks again xoxox
CamperBot
@camperbot
Sep 02 2015 02:43
nekab sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 191 | @matko95 | http://www.freecodecamp.com/matko95
Mateja Trifunovski
@Matko95
Sep 02 2015 02:44
@x34passenger you were given an array
x34passenger
@x34passenger
Sep 02 2015 02:44
@Matko95 yes okay
Mateja Trifunovski
@Matko95
Sep 02 2015 02:45
The idea is to use .pop() to remove the last element
You have to store that value, and then return it
x34passenger
@x34passenger
Sep 02 2015 02:47
@Matko95 got it thanks!
CamperBot
@camperbot
Sep 02 2015 02:47
x34passenger sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:warning: x34passenger already gave matko95 points
Nathan Wind
@Nathan-Wind
Sep 02 2015 03:01
Derrrr

ar ourArray = [3,2,1];

ourArray[0] = 1; // equals [1,2,1]

Now modify the data stored at index 0 of myArray to the value of 3.

nevermind.
figured it out
Reggie
@Reggie01
Sep 02 2015 03:27

@GeoffG-oz you can use jquery to modify the body tag.

$(document).ready(function() {
   $('body').css("background-color","red");
});

http://getbootstrap.com/javascript/#scrollspy Look at sub-heading via Javascript for spyscroll. Also, if your working on a zipline and need help try the zipline channel.

Mike Varela
@mikevarela
Sep 02 2015 03:39

@Matko95 function palindrome(str) {

str = str.replace(/.[{}]!@#$%^&*-'"_=+/g, "");
str = str.replace(/\s+/g, "");
var lowerString = str.toLowerCase();

var reversedString = lowerString.split('').reverse().join('');

if (lowerString === reversedString) {

return true;

}
else
{
return false;
}

}

palindrome("eye");

Philip Warkentien II
@warkentien2
Sep 02 2015 03:42

@mikevarela @Matko95 or a:
return (lowerString === reversedString) ? true : false;

to simplify the code.

Mateja Trifunovski
@Matko95
Sep 02 2015 03:45
@mikevarela use str = str.replace(/[.,]/g, ""); instead of str = str.replace(/.[{}]!@#$%^&*-'"_=+/g, "");
Steven Parker
@Philosophist
Sep 02 2015 03:46
@BobsHub @deaninous @dting I figured out Bonfire: No repeats please. I decided to create the Wiki page for it and to put my 2 cents into explaining it for others who are having trouble with it.
Mike Varela
@mikevarela
Sep 02 2015 03:48
@Matko95 Great, thanks. Was the [] the issue. Thought I had included all the symbols that might have been included
CamperBot
@camperbot
Sep 02 2015 03:48
mikevarela sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 192 | @matko95 | http://www.freecodecamp.com/matko95
Mateja Trifunovski
@Matko95
Sep 02 2015 03:49
@mikevarela sometimes less is better :D
Ginna
@Desiderata33
Sep 02 2015 03:51
Hi can someone help me with bonfire Bonfire: Truncate a string
please
mtbdanimal
@mtbdanimal
Sep 02 2015 03:52
hi all, had a bit of a hiatus on freecodecamp, go back to my "Map" see tons of new lessons. anyone else notice that? areas i had completed are now incomplete.
Ginna
@Desiderata33
Sep 02 2015 03:52
@mtbdanimal they added new stuff
Rich Churcher
@richchurcher
Sep 02 2015 03:53
@Desiderata33 what's the problem you're having?
mtbdanimal
@mtbdanimal
Sep 02 2015 03:53
@Desiderata33 i had been cranking on the codeacademy lessons they had for javascript, now its all baked into their tool
@Desiderata33 guess that means i get more practice!
Ginna
@Desiderata33
Sep 02 2015 03:54
@richchurcher
function truncate(str, num) {
  // Clear out that junk in your trunk
  if (str.length > num) {
   console.log(str.slice(0, num-3)+ "...");
  }
  return str;
}

truncate('Peter Piper picked a peck of pickled peppers', 14);
@richchurcher When I put this in somewhere outside of FCC it works, but it won’t let me pass in FCC
Rich Churcher
@richchurcher
Sep 02 2015 03:55
Which test is it failing?
Ginna
@Desiderata33
Sep 02 2015 03:56
yes, but when I run it outside of FCC I get the same expected anwers
Rich Churcher
@richchurcher
Sep 02 2015 03:56
right away I reckon it'll fail if num is 2 or less
because you index num -3
Hans van Riet
@hansinla
Sep 02 2015 03:57
@Desiderata33 Slice doesn’t change the array it invokes.
Rich Churcher
@richchurcher
Sep 02 2015 03:57
yeah, that too :)
Steven Parker
@Philosophist
Sep 02 2015 03:57
Where should I upload an image for use in the github FCC wiki?
Rich Churcher
@richchurcher
Sep 02 2015 03:57
@Philosophist I like imgur
Ginna
@Desiderata33
Sep 02 2015 03:57
@mtbdanimal Yeah, we all get more practice :)
@richchurcher @hansinla Okay, I’ll keep working at it. Thanks
CamperBot
@camperbot
Sep 02 2015 04:01
desiderata33 sends brownie points to @richchurcher and @hansinla :sparkles: :thumbsup: :sparkles:
:star: 334 | @hansinla | http://www.freecodecamp.com/hansinla
:star: 292 | @richchurcher | http://www.freecodecamp.com/richchurcher
Nathan Wind
@Nathan-Wind
Sep 02 2015 04:01

function myFunction(){
var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;
// Create an if-else statement here to return "heads" if flip is 0. Otherwise return "tails".

// Only change code below this line.

if (var flip === 0){
return heads;
}

else {
return tails;
}
why not working?

Mateja Trifunovski
@Matko95
Sep 02 2015 04:02
@Nathan-Wind try removing the var in the if() statement
Nathan Wind
@Nathan-Wind
Sep 02 2015 04:03
still no worky
Mateja Trifunovski
@Matko95
Sep 02 2015 04:03
and your return should return a string, meaning it should say return "heads"; return "tails";
Nathan Wind
@Nathan-Wind
Sep 02 2015 04:04
hmmm still no worky
Mateja Trifunovski
@Matko95
Sep 02 2015 04:04
can you post the code again
Nathan Wind
@Nathan-Wind
Sep 02 2015 04:04
yeah

function myFunction(){
var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;
// 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";
}

here are the instructions Waypoint: Use Conditional Logic with IfElse Statements
We can use if statements in JavaScript to only execute code if a certain condition is met.

if statements require some sort of boolean condition to evaluate.

Example:

if (1 === 2) {

  return true;

}

else {

  return false;

}

Let's use if and else statements to make a coin-flip game.

Create an if-else statement to return heads if the flip var is zero, or else return tails if it's not.

Mateja Trifunovski
@Matko95
Sep 02 2015 04:07
@Nathan-Wind do you know what is your output?
Nathan Wind
@Nathan-Wind
Sep 02 2015 04:08
I think the output is heads or tails right?
Mateja Trifunovski
@Matko95
Sep 02 2015 04:08
@Nathan-Wind yeah, but on the left side there is a small black console window
what does it say?
Nathan Wind
@Nathan-Wind
Sep 02 2015 04:09
oh , yes "no user tests were run"
Mateja Trifunovski
@Matko95
Sep 02 2015 04:09
try adding a "}" at the bottom
Nathan Wind
@Nathan-Wind
Sep 02 2015 04:10
hehe
yep
you da man
thanks
CamperBot
@camperbot
Sep 02 2015 04:10
if you want to thank someone, put an @ before their name!
Nathan Wind
@Nathan-Wind
Sep 02 2015 04:10
@Matko95 thanks
CamperBot
@camperbot
Sep 02 2015 04:10
nathan-wind sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
Mateja Trifunovski
@Matko95
Sep 02 2015 04:10
@Nathan-Wind no prob :)
CamperBot
@camperbot
Sep 02 2015 04:10
:star: 194 | @matko95 | http://www.freecodecamp.com/matko95
Nathan Wind
@Nathan-Wind
Sep 02 2015 04:11
Quincy is gettin tricky
lol
ok later
Philip Warkentien II
@warkentien2
Sep 02 2015 04:11

@Nathan-Wind for multiple outputs, go to https://jsfiddle.net/
press F12 and choose the 'console' tab.
run your code there.
use console.log(); for anything to appear on screen.

in your case console.log(myFunction());

Steven Parker
@Philosophist
Sep 02 2015 04:11
@richchurcher Good enough. Thanks!
CamperBot
@camperbot
Sep 02 2015 04:11
philosophist sends brownie points to @richchurcher :sparkles: :thumbsup: :sparkles:
:star: 293 | @richchurcher | http://www.freecodecamp.com/richchurcher
Patrick McWilliams
@patrickmac110
Sep 02 2015 04:15
why are my 3 hello buttons not staying put?
http://codepen.io/patrcikmac110/pen/xwKXdm
Mateja Trifunovski
@Matko95
Sep 02 2015 04:17
@patrickmac110 where should they go?
Patrick McWilliams
@patrickmac110
Sep 02 2015 04:17
I would like them to constantly stay at the top right of the page
I have them absolutely positioned, but they're not sticking
Mateja Trifunovski
@Matko95
Sep 02 2015 04:20
This message was deleted
Philip Warkentien II
@warkentien2
Sep 02 2015 04:20
@patrickmac110 nice transition! I dunno mutch, since I did it all with bootstrap.
but should it be 'position: fixed;' to keep them in place while scrolling?
Rich Churcher
@richchurcher
Sep 02 2015 04:20
sometimes position absolute doesn't mean what you think it means
Hans van Riet
@hansinla
Sep 02 2015 04:20
@patrickmac110 if you change their div to this it will work:
<div id="btns" class="container" style="position: fixed;”>
Mateja Trifunovski
@Matko95
Sep 02 2015 04:20
like this?
Rich Churcher
@richchurcher
Sep 02 2015 04:20
yep, what @warkentien2 said... position fixed is the way to go
in a way 'absolute' is really badly named
Patrick McWilliams
@patrickmac110
Sep 02 2015 04:22
@Matko95 why does absolute not work where they were?
Mateja Trifunovski
@Matko95
Sep 02 2015 04:22
@patrickmac110 lol sorry, i thought you wanted to put them in the top left corner, not make the fixed to it :D
Patrick McWilliams
@patrickmac110
Sep 02 2015 04:23
@Matko95 no you made it do what i wanted, thanks, but why did that work
CamperBot
@camperbot
Sep 02 2015 04:23
patrickmac110 sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 197 | @matko95 | http://www.freecodecamp.com/matko95
Patrick McWilliams
@patrickmac110
Sep 02 2015 04:23
i see you moved them up to the top
Mateja Trifunovski
@Matko95
Sep 02 2015 04:24
@patrickmac110 Well the order of the elements is important
Kayrat
@kairatomurbek2
Sep 02 2015 04:25
Waypoint: Make Object Properties Private help me!
Patrick McWilliams
@patrickmac110
Sep 02 2015 04:25
so absolute only works if its above other elements with different positionings?
Kayrat
@kairatomurbek2
Sep 02 2015 04:26

//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.
this.speed = 100;
function addUnit(value) {
return value + "KM/H";
}

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());})();};

I do not know how to do
Mateja Trifunovski
@Matko95
Sep 02 2015 04:26
@patrickmac110 Oh so you wanted to make it absolute and then position it by yourself?
Patrick McWilliams
@patrickmac110
Sep 02 2015 04:27
@Matko95 yes
Kayrat
@kairatomurbek2
Sep 02 2015 04:28

var = code "//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.
this.speed = 100;
function addUnit(value) {
return value + "KM/H";
}

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

'''
CamperBot
@camperbot
Sep 02 2015 04:28
:bulb: to format code use backticks! ``` more info
Kayrat
@kairatomurbek2
Sep 02 2015 04:28

//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.
this.speed = 100;
function addUnit(value) {
return value + "KM/H";
}

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());})();};
''''

CamperBot
@camperbot
Sep 02 2015 04:28
:bulb: to format code use backticks! ``` more info
Kayrat
@kairatomurbek2
Sep 02 2015 04:29
//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.
  this.speed = 100;
  function addUnit(value) {
    return value + "KM/H";
  }

  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());})();};
@camperbot thanks!
CamperBot
@camperbot
Sep 02 2015 04:29
kairatomurbek2 sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
Mateja Trifunovski
@Matko95
Sep 02 2015 04:29
CamperBot
@camperbot
Sep 02 2015 04:29
:star: 145 | @camperbot | http://www.freecodecamp.com/camperbot
Kayrat
@kairatomurbek2
Sep 02 2015 04:30
help me
CamperBot
@camperbot
Sep 02 2015 04:30

:point_right: adding environment variables [wiki]

  1. Download Varpanel.
  2. Open Varpanel.
  3. In PATH variable, add the relevant path.

:pencil: read more about adding environment variables on the FCC Wiki

Sumit Sen
@sumit1sen
Sep 02 2015 04:31
@edgcastillo Your solution to where(arr,num) is really elegant but why doesn't the natural sort order work for this problem? I.e. why did you need to provide a sort function?
Mateja Trifunovski
@Matko95
Sep 02 2015 04:31
@patrickmac110 is that ok now?
Patrick McWilliams
@patrickmac110
Sep 02 2015 04:31
yeah, what did you change?
Kayrat
@kairatomurbek2
Sep 02 2015 04:32
assert(typeof(myBike.getSpeed)!=='undefined' && typeof(myBike.getSpeed) === 'function', 'The method getSpeed of myBike should be accessible outside the object');The method getSpeed of myBike should be accessible outside the object
Mateja Trifunovski
@Matko95
Sep 02 2015 04:34
@patrickmac110 you must assign a top:0; value
Will Moody
@willmoody
Sep 02 2015 04:35
Hay folks, I'm trying to get the client's location as part of the weather site zipline, and I was using the example at http://www.w3schools.com/htmL/tryit.asp?filename=tryhtml5_geolocation , but as soon as I try to get the showPosition function to instead write the lat and long to variables, the geolocation function seems to stop working entirely, and I'm not sure what I'm doing wrong. Here's what my current attempt looks like, for reference:
<script>
var x = document.getElementById("demo");
var clientLat = "";
var clientLong = "";
function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else { 
        x.innerHTML = "Geolocation is not supported by this browser.";
    }
}

function showPosition(position) {
     clientLat = position.coords.latitude;
    clientLong = position.coords.latitude;
}
</script>
Mateja Trifunovski
@Matko95
Sep 02 2015 04:35
@patrickmac110 and if you want to absolutely pin it to top, put padding-top: 0;
Patrick McWilliams
@patrickmac110
Sep 02 2015 04:36
wow, it's all making sense now! thanks a bunch
CamperBot
@camperbot
Sep 02 2015 04:36
if you want to thank someone, put an @ before their name!
Kayrat
@kairatomurbek2
Sep 02 2015 04:38
assert(typeof(myBike.speed) === 'undefined', 'myBike.speed should remain undefined.');myBike.speed should remain undefined.
help me
Mateja Trifunovski
@Matko95
Sep 02 2015 04:38
@fractal-mind i think you need to call getLocation() first
Nathan Wind
@Nathan-Wind
Sep 02 2015 04:38
$($(".slot")
[0]).html(slotOne);
$($(".slot")
[1]).html(slotTwo);
$($(".slot")
[2]).html(slotThree);
error You should have used the the selector given in the description to select each slot and assign it the value of slotOne, slot
Hans van Riet
@hansinla
Sep 02 2015 04:38
@fractal-mind You call showPosition but don’t pass variables
Nathan Wind
@Nathan-Wind
Sep 02 2015 04:39
selector given is $(".slot")
Will Moody
@willmoody
Sep 02 2015 04:39
@Matko95 Oh, yeah, the original tutorial has a button which calls getLocation(), you can check out the codepen where I was trying to get it to work here: http://codepen.io/fractalmind/pen/EVxOJj
Nathan Wind
@Nathan-Wind
Sep 02 2015 04:40
this is Waypoint: Bring your JavaScript Slot Machine to Life
Will Moody
@willmoody
Sep 02 2015 04:40
It works until I change showPosition, but once I did the button stopped working
Nathan Wind
@Nathan-Wind
Sep 02 2015 04:40
@Matko95 any idea on this one you genius?
:)
Mateja Trifunovski
@Matko95
Sep 02 2015 04:42
@fractal-mind what did you want it to do? it currently only sets the value of variables
@fractal-mind and change the clientLong = position.coords.longitude;btw
Will Moody
@willmoody
Sep 02 2015 04:44
@Matko95 the idea is to pass the variables to an api endpoint in a $.getJSON call down the line, but that's on a different codepen that I didn't want to risk messing up as I'm playing around with getLocation, haha
@Matko95 Ahh, thanks, missed that one.
CamperBot
@camperbot
Sep 02 2015 04:44
fractal-mind sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 198 | @matko95 | http://www.freecodecamp.com/matko95
Mateja Trifunovski
@Matko95
Sep 02 2015 04:44
@fractal-mind yes, i know, but currently on this pen, how do you know it's not working?
formatting
Will Moody
@willmoody
Sep 02 2015 04:45
@Matko95 When I console.log(clientLat);, it returns undefined, and I can't get the data over to where I want it
I should just show you my main pen, haha
Nila
@star1671
Sep 02 2015 04:46
Hello :) Could someone tell me what I'm doing wrong please with this code for 'Bonfire: reverse a string'
function reverseString(str) {
  return str;
}

var str = reverseString('hello');


var output = str.split("").reverse().join("");
Will Moody
@willmoody
Sep 02 2015 04:47
And btw, the get location button on the main pen is not working, but for seemingly an entirely different reason, haha
Mateja Trifunovski
@Matko95
Sep 02 2015 04:48
This message was deleted
Will Moody
@willmoody
Sep 02 2015 04:48
It doesn't seem to want to run the function unless I actually put it in <script> tags in the html section, for some reason.
Farhad ali
@alifarhad
Sep 02 2015 04:49
@star1671 your logic should go right into the body of function
Mateja Trifunovski
@Matko95
Sep 02 2015 04:49

@star1671

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

would work, you must put your operations in the function which reverses the string, and then return the reversed string

Reggie
@Reggie01
Sep 02 2015 04:49
@fractal-mind I have not tried using the methods but there was a discussion earlier about them in the zipline chatroom. You may try asking about it there.
Will Moody
@willmoody
Sep 02 2015 04:50
@Reggie01 Oh, hey, I should join that room, haha.
@Reggie01 Thanks, I didn't think to look for a zipline room
CamperBot
@camperbot
Sep 02 2015 04:50
fractal-mind sends brownie points to @reggie01 :sparkles: :thumbsup: :sparkles:
:star: 172 | @reggie01 | http://www.freecodecamp.com/reggie01
Nila
@star1671
Sep 02 2015 04:52
@Matko95 @alifarhad It still says it is undefined after putting it inside the function.

function reverseString(str) {
  return str;
  var str = reverseString('hello');
  var output = str.split("").reverse().join("");
  return output;
}
Mateja Trifunovski
@Matko95
Sep 02 2015 04:52
@star1671 delete return str;, you can't have 2 returns
Yihan Wang
@yihanwang91
Sep 02 2015 04:53
I successfully completed a Bonfire, but when I went back the code that I submitted disappeared (the challenge was basically reset). However, Map shows the Bonfire as completed. Has anyone else experienced this?
Mateja Trifunovski
@Matko95
Sep 02 2015 04:53
@yihanwang91 It's normal, don't worry :D
Farhad ali
@alifarhad
Sep 02 2015 04:53
yeah been getting that @yihanwang91
Bruce Young
@mutantspore
Sep 02 2015 04:53
@yihanwang91 you should see it in your profile
Farhad ali
@alifarhad
Sep 02 2015 04:54
@star1671 why are you returning the str in the first line of your code? this will take the original string and return it back right as it is
return breaks the execution of the function so what you are doing will simply return the original string and just stop there . remove it
Nila
@star1671
Sep 02 2015 04:56
@alifarhad ohh okay, i removed it, but still says undefined..
function reverseString(str) {
  var str = reverseString('hello');
  var output = str.split("").reverse().join("");
  return output;
}
Farhad ali
@alifarhad
Sep 02 2015 04:57
well now you need to remove the var str line coz essentially it is not doing anything good to your code either @star1671
you only need the last two lines @star1671
Mateja Trifunovski
@Matko95
Sep 02 2015 04:58
@fractal-mind it returns the coords for me
Nila
@star1671
Sep 02 2015 04:58
ohh okay thank you! @alifarhad for some reason i thought i had to define str as a variable as well lol
CamperBot
@camperbot
Sep 02 2015 04:58
star1671 sends brownie points to @alifarhad :sparkles: :thumbsup: :sparkles:
:star: 168 | @alifarhad | http://www.freecodecamp.com/alifarhad
Mateja Trifunovski
@Matko95
Sep 02 2015 04:59
@fractal-mind but it keeps saying getLocation is not defined for some reason
Farhad ali
@alifarhad
Sep 02 2015 04:59
you wc and you can still shorten it a bit like this
function reverseString(str) {
  return str.split("").reverse().join("");
}
coz the str variable is already defined as a parameter in your function
and it holds all the strings you need to reverse()
Mateja Trifunovski
@Matko95
Sep 02 2015 05:01
@fractal-mind http://codepen.io/Matko95/pen/vNYQoJ i think it works now
Farhad ali
@alifarhad
Sep 02 2015 05:04
@Matko95 is it supposed to show the location when the button is clicked? if so, it didn't work for me
Erica
@Buzzlightyear90
Sep 02 2015 05:04
I need some help on exercise 6 of learnyounode
Mateja Trifunovski
@Matko95
Sep 02 2015 05:04
no, it just loads them into variables
Erica
@Buzzlightyear90
Sep 02 2015 05:04
how many times do I mention a callback function?
Farhad ali
@alifarhad
Sep 02 2015 05:04
might be working then xD @Matko95
Will Moody
@willmoody
Sep 02 2015 05:06
@Matko95 Oh!! You fixed it :D What did you change?
Mateja Trifunovski
@Matko95
Sep 02 2015 05:07
@fractal-mind to be visible in the html you need to define the function like this window.getLocation = function()
as far as i understood :D
Erica
@Buzzlightyear90
Sep 02 2015 05:07
has anyone completed nodeschool?
Ashraful Islam
@iashraful
Sep 02 2015 05:09
@dting morning!
DTing
@dting
Sep 02 2015 05:09
hello all
Md Mostafizur Rahman
@jahid32
Sep 02 2015 05:11
Bonfire: Return Largest Numbers in Arrays Anyone working on it
CamperBot
@camperbot
Sep 02 2015 05:11
Sorry, can't find a bonfire called return largest numbers in arrays anyone working on it. [ Check the map? ]
Md Mostafizur Rahman
@jahid32
Sep 02 2015 05:12
Bonfire: Return Largest Numbers in Arrays
CamperBot
@camperbot
Sep 02 2015 05:12

:fire:Bonfire: Return Largest Numbers in Arrays :link:

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

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.

more info:  bf details | bf links | hint

Md Mostafizur Rahman
@jahid32
Sep 02 2015 05:13
bf details
CamperBot
@camperbot
Sep 02 2015 05:13

:fire:Bonfire: Return Largest Numbers in Arrays :link:

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

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.
Remember, you can iterate through an array with a simple for loop, and access each member with array syntax arr[i] .
If you are writing your own Chai.js tests, be sure to use a deep equal statement instead of an equal statement when comparing arrays.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.
links:
Farhad ali
@alifarhad
Sep 02 2015 05:13
yeah me @jahid32 just cracked it up xD
ok im sorry im at the return the largest word bonfire - my bad
Erica
@Buzzlightyear90
Sep 02 2015 05:15
has anyone completed any nodeschool exercise?
justindobbs
@justindobbs
Sep 02 2015 05:21
i completed one of them
Mateja Trifunovski
@Matko95
Sep 02 2015 05:21
@Buzzlightyear90 which ones do you mean? :D
Erica
@Buzzlightyear90
Sep 02 2015 05:22
@Matko95 exercise 6
make it modular
this is all i wrote


module.exports = function(dir, ext, callback){
    fs.readdir(dir, callback){
    if (err) {
        return callback(err);
    }else{
        data.forEach(function(value){
            if(path.extname(value) == '.' + ext){
                value;
            }
        })
    }
    };
}

callback(err, data){
    if (err){

    }
}
Mateja Trifunovski
@Matko95
Sep 02 2015 05:23
not even sure what that is
about @Buzzlightyear90
CamperBot
@camperbot
Sep 02 2015 05:23
:star: 1 | @buzzlightyear90 | http://www.freecodecamp.com/buzzlightyear90
Will Moody
@willmoody
Sep 02 2015 05:23

@Matko95 So! while I can actually get the coords now, when I change clientLat and clientLong to the lat and long, it only takes effect within that function for some reason, it doesn't seem to update the vars at the start of the script. http://codepen.io/fractalmind/pen/EVxGxV

As you can see, console.log(clientLat) returns the desired variable when it's above the curly braces, but when it's below it returns undefined.

Reggie
@Reggie01
Sep 02 2015 05:23
@Buzzlightyear90 try the HelpBasejumps room. People there will be currently working on nodeschool or have completed the nodeschool exercises.
Will Moody
@willmoody
Sep 02 2015 05:23
@Matko95 (and by the way, thank you so much for all your help thus far)
CamperBot
@camperbot
Sep 02 2015 05:23
fractal-mind sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:warning: fractal-mind already gave matko95 points
Erica
@Buzzlightyear90
Sep 02 2015 05:28
so i'm pretty much screwed. I have a problem and no one is around to help
Mateja Trifunovski
@Matko95
Sep 02 2015 05:29
@fractal-mind gotta sleep now :D good luck!
Will Moody
@willmoody
Sep 02 2015 05:29
@Matko95 Thanks again! :D
CamperBot
@camperbot
Sep 02 2015 05:29
fractal-mind sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:warning: fractal-mind already gave matko95 points
Mateja Trifunovski
@Matko95
Sep 02 2015 05:29
@Buzzlightyear90 well this is channel for freecodecamp, not nodeschool
soo..
Erica
@Buzzlightyear90
Sep 02 2015 05:29
but the node exercises is on nodeschool
Philip Warkentien II
@warkentien2
Sep 02 2015 05:30
@Buzzlightyear90 what's your problem?
Erica
@Buzzlightyear90
Sep 02 2015 05:31
again. I am having a problem on exercise #6. I just need a clarification on callbacks
exercise #6 on learnyounode called make it modular
Emil Aasa
@emilaasa
Sep 02 2015 05:32
Dudes, can I just add prototype functions to objects?
Farhad ali
@alifarhad
Sep 02 2015 05:33
I have heard about adding functions(mehtods) to prototypes but ug? @emilaasa
Emil Aasa
@emilaasa
Sep 02 2015 05:35
like add a String.prototype.somethingCool function and then call it with some string.somethingCool() ?
Reggie
@Reggie01
Sep 02 2015 05:35
Yeah, you can. You may not want to add them to standard library objects, i.e Array, Object, String
Farhad ali
@alifarhad
Sep 02 2015 05:35
yeah it will work @emilaasa but ppl keep telling me we should not do that lol
Emil Aasa
@emilaasa
Sep 02 2015 05:36
well I guess that means that prototype is just an object too
Reggie
@Reggie01
Sep 02 2015 05:36
ype
Emil Aasa
@emilaasa
Sep 02 2015 05:36
sort of helps understanding
Reggie
@Reggie01
Sep 02 2015 05:36
yep
Philip Warkentien II
@warkentien2
Sep 02 2015 05:36
@Buzzlightyear90 so many #6s. still trying to figure out which one you're talking about
Mateja Trifunovski
@Matko95
Sep 02 2015 05:36
@warkentien2
Farhad ali
@alifarhad
Sep 02 2015 05:36
yeah well once i made a function named it "circle" and copied the logic from "reverse()" then doing str.circle() would do just the same xD
DTing
@dting
Sep 02 2015 05:36
javascript allows you to do that. but imagine if people starting doing that to the Global objects. then when you use different librarys and people overwrite methods you'd end up wiht a mess
Mateja Trifunovski
@Matko95
Sep 02 2015 05:37
He is talking about another website
Emil Aasa
@emilaasa
Sep 02 2015 05:37
Im still a bit unsure like if I create var emil = {} and then whats the difference if I add a normal method or a prototype?
feel free to tell me to rtfm btw
Farhad ali
@alifarhad
Sep 02 2015 05:38
every object has a class. and what a class can or can not do is defined by a prototype. and every object is an instance of some class. so adding something into the prototype of that class will make it visible to the every instance of the said class @emilaasa
Philip Warkentien II
@warkentien2
Sep 02 2015 05:38
@Matko95 I just remembered you mentioned it. I'm too tired to go to another site. well @Buzzlightyear90 they should have a help forum.
Farhad ali
@alifarhad
Sep 02 2015 05:38
This message was deleted
did it help ? if not, i can dish out an example
Emil Aasa
@emilaasa
Sep 02 2015 05:40
Yeah I think It does, I’m reading MDN now too
Emil Aasa
@emilaasa
Sep 02 2015 05:41
So in the MDN example they kind of try to show examples
Farhad ali
@alifarhad
Sep 02 2015 05:41
the only thing I have ever been able to get out of MDN is a solid headache
their language gives me cancer
Emil Aasa
@emilaasa
Sep 02 2015 05:42
hah
Im yet to find an easier tutorial on understanding prototypes
Nathan Wind
@Nathan-Wind
Sep 02 2015 05:44
thing thing workin?
Farhad ali
@alifarhad
Sep 02 2015 05:45
bonfire tile a case
CamperBot
@camperbot
Sep 02 2015 05:45
Sorry, can't find a bonfire called tile a case. [ Check the map? ]
Nathan Wind
@Nathan-Wind
Sep 02 2015 05:45
$($(".slot")
[0]).html(slotOne);
$($(".slot")
[1]).html(slotTwo);
$($(".slot")
[2]).html(slotThree);

small prob with this one
app works perfect but get error that says You should have used the the selector given in the description to select each slot and assign it the value of slotOne, slotTwo and slotThree respectively

I did that though... so ??

Farhad ali
@alifarhad
Sep 02 2015 05:45
bonfire title a case
CamperBot
@camperbot
Sep 02 2015 05:45
Sorry, can't find a bonfire called title a case. [ Check the map? ]
Farhad ali
@alifarhad
Sep 02 2015 05:45
ug dumb me
Nathan Wind
@Nathan-Wind
Sep 02 2015 05:46
It's the slot app
Farhad ali
@alifarhad
Sep 02 2015 05:49
this here works for me @Nathan-Wind
   $($(".slot")[0]).html(slotOne);
    $($(".slot")[1]).html(slotTwo);
    $($(".slot")[2]).html(slotThree);
try removing that enter thingy from there. your code is fine
Emil Aasa
@emilaasa
Sep 02 2015 05:49
thanks @alifarhad and @dting
CamperBot
@camperbot
Sep 02 2015 05:49
emilaasa sends brownie points to @alifarhad and @dting :sparkles: :thumbsup: :sparkles:
:star: 170 | @alifarhad | http://www.freecodecamp.com/alifarhad
:star: 939 | @dting | http://www.freecodecamp.com/dting
Farhad ali
@alifarhad
Sep 02 2015 05:50
you welcome @emilaasa :)
Nathan Wind
@Nathan-Wind
Sep 02 2015 05:59
hey guys sorry but another question
$($('.slot')[0]).html('<img src = "' + images[slotOne-0] + '">');
$($('.slot')1).html('<img src = "' + images[slotTwo-1] + '">');
$($('.slot')[2]).html('<img src = "' +images[slotThree-2] + '">');
oh wait
it shows up when i paste it here lol
actually it just pastes wrong
$($('.slot')[0]).html('<img src = "' + images[slotOne-0] + '">');
$($('.slot')[1]).html('<img src = "' + images[slotTwo-1] + '">');
$($('.slot')[2]).html('<img src = "' +images[slotThree-2] + '">');
Erica
@Buzzlightyear90
Sep 02 2015 06:00
@warkentien2 it's called keep it modular
Nathan Wind
@Nathan-Wind
Sep 02 2015 06:00
lets try that again
$($('.slot')[0]).html('<img src = "' + images[slotOne-0] + '">');
$($('.slot')[1]).html('<img src = "' + images[slotTwo-1] + '">');
$($('.slot')[2]).html('<img src = "' +images[slotThree-2] + '">');
so this is for the slot app
DTing
@dting
Sep 02 2015 06:01
@Nathan-Wind are you missing that space?
Erica
@Buzzlightyear90
Sep 02 2015 06:01
@warkentien2 no it's "make it modular" it is under learnyounode
DTing
@dting
Sep 02 2015 06:01
$($('.slot')[2]).html('<img src = "' +**SPACE**images[slotThree-2] + '">');
Nathan Wind
@Nathan-Wind
Sep 02 2015 06:01
getting the error "Use the provided code three times. One for each slot"
but the app functions again
DTing
@dting
Sep 02 2015 06:01
they use string matching if that space is missing,
it wont pass
Nathan Wind
@Nathan-Wind
Sep 02 2015 06:02
@dting uhhhh where?
must be that but I don;t see it
still can;t find it
actually this is what I have...
$($('.slot')[0]).html('<img src = "' + images[slotOne-1] + '">');
$($('.slot')[1]).html('<img src = "' + images[slotTwo-2] + '">');    
$($('.slot')[2]).html('<img src = "' + images[slotThree-3] + '">');
I mean $($('.slot')[0]).html('<img src = "' + images[slotOne-1] + '">');
$($('.slot')1).html('<img src = "' + images[slotTwo-2] + '">');
$($('.slot')2).html('<img src = "' + images[slotThree-3] + '">');
this is getting ugly my bad
oh here is my final paste
$($('.slot')[0]).html('<img src = "' + images[slotOne-1] + '">');
$($('.slot')1).html('<img src = "' + images[slotTwo-2] + '">');
$($('.slot')[2]).html('<img src = "' + images[slotThree-3] + '">');
DTing
@dting
Sep 02 2015 06:05
$($('.slot')[0]).html('<img src = "' + images[slotOne-1] + '">');
$($('.slot')[1]).html('<img src = "' + images[slotTwo-2] + '">');    
$($('.slot')[2]).html('<img src = "' + images[slotThree-3] + '">');
Nathan Wind
@Nathan-Wind
Sep 02 2015 06:06
yeah I have that
DTing
@dting
Sep 02 2015 06:06
hmm
Nathan Wind
@Nathan-Wind
Sep 02 2015 06:06
weird how the 1 looks different when i paste it
here
DTing
@dting
Sep 02 2015 06:06
$($('.slot')[0]).html('<img src = "' + images[slotOne-1] + '">');
$($('.slot')[1]).html('<img src = "' + images[slotTwo-1] + '">');
$($('.slot')[2]).html('<img src = "' + images[slotThree-1] + '">');
Nathan Wind
@Nathan-Wind
Sep 02 2015 06:07
yep that was it - why?
DTing
@dting
Sep 02 2015 06:07
hmm looks.
try refreshing
Nathan Wind
@Nathan-Wind
Sep 02 2015 06:07
yeah its working now and better
why does the slot number only have a 1 after it?
for all three
??
kinda confused bout that
DTing
@dting
Sep 02 2015 06:11
what do you mean?
Dona Hertel
@cocofan
Sep 02 2015 06:11
You need to minus 1 from the slot number to get the index into the array. Indexes start at zero but the slot numbers start at one.
Farhad ali
@alifarhad
Sep 02 2015 06:12
guys is there any way to capture the very first character in a string using regex, no matter what the character?
say I have, "hello" and "bye" and i want to capture only "h" from the 1st string and "b" from the second
?
Nathan Wind
@Nathan-Wind
Sep 02 2015 06:13
Ok I see... sorta half get it.. but I get it a little :P
@dting @cocofan thanks
CamperBot
@camperbot
Sep 02 2015 06:15
nathan-wind sends brownie points to @dting and @cocofan :sparkles: :thumbsup: :sparkles:
:warning: nathan-wind already gave dting points
:star: 177 | @cocofan | http://www.freecodecamp.com/cocofan
Farhad ali
@alifarhad
Sep 02 2015 06:21
never mind got it working
MD Arefin Saad
@arefinsaaad
Sep 02 2015 06:36
javascript started .... <3 <3
Marvin Casagnap
@marzim
Sep 02 2015 06:39
this is ugly...anyone can improve it?

```function chunk(arr, size) {
var newArr2 = [];
var i = 0;
var y = arr.length/size;
for(var x=0;x<y;x++){
var newArr = [];
var newSize = size;
while(newSize != 0 && i <= arr.length-1){
newArr.push(arr[i]);
i++;
newSize--;
}
newArr2.push(newArr);
}

// Break it up.
return newArr2;
}

chunk([0, 1, 2, 3, 4, 5], 4);

damn I don't know how to post a code
DTing
@dting
Sep 02 2015 06:42
@marzim mine looks like this:
function chunk(arr, size) {
  var narr = [];
  for (var i = 0; i < arr.length; i+=size) 
    narr.push(arr.slice(i, i+size));
  return narr;
}
help formatting
CamperBot
@camperbot
Sep 02 2015 06:42

: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

Marvin Casagnap
@marzim
Sep 02 2015 06:44
@dting that's nice
Farhad ali
@alifarhad
Sep 02 2015 06:44
guys can someone help me bit with regex?
Marvin Casagnap
@marzim
Sep 02 2015 06:44
@alifarhad shoot
Farhad ali
@alifarhad
Sep 02 2015 06:48
im using the following regex to match the first char of every string element and replace it with the uppercase version of it
var up = e.replace(/\b\w/g, replacer);
it works fine for the most case but when it's provided "i'm" it ends up matching the both
it should only match "i" but it's matching "i'm" both at the same time
DTing
@dting
Sep 02 2015 06:49
thats because \w doesnt include '
Farhad ali
@alifarhad
Sep 02 2015 06:50
so is there a way to fix this? @dting
DTing
@dting
Sep 02 2015 06:50
oh actually
no
Farhad ali
@alifarhad
Sep 02 2015 06:50
there has to be something!
anknits
@anknits
Sep 02 2015 06:51
function drop(arr, func) {
  // Drop them elements.
  var count=0;
  for (var a=0; a<arr.length; a++){
    while (func(arr[a])){
      count++;
    }
  }
  for (var i=0; i<count; i++){
    arr.shift();
  }
  return arr;
}

drop([1, 2, 3], function(n) {return n < 3; });
Mbos95
@Mbos95
Sep 02 2015 06:52
function titleCase(str) {
  var re = /\s/;
  array = str.split(re);
  var arrayresult= []
var result;
for(i = 0; i < array.length; i++) {
    result = array[i].charAt(0);
    var resultofresult = result.toUpperCase();
  arrayresult.push(resultofresult)
  }
return arrayresult;
}
titleCase("I'm a little tea pot");
Hey guys, can someone help me ? I got a way to get all the first letters of a string to go to UpperCase.. but now my result misses the rest of the string :D Any idea on how to do it better ? (charAt(0); but then uppercase that instead of cut it out of the string?)
Farhad ali
@alifarhad
Sep 02 2015 06:53
@Mbos95 im working on the same thing except im using regex to uppercase stuff.i have got it all working only this tiny '`' thing has got me stuck lol
here's my solution
function titleCase(str) {

  strA = str.toLowerCase().split(" ");
  var ans = [];
 strA.forEach(function(e) {
   function replacer(match) {
     return match.toUpperCase();
   }
 var up =  e.replace(/\b\w/g, replacer);
   ans.push(up);
 });
 ans = ans.join(" ");
  return ans;
}


titleCase("I'm a little tea pot");
Simon Danner
@danners
Sep 02 2015 06:53
Hey i am doing the bonfire symmetric difference. in the description it states: "The mathematical term symmetric difference refers to the elements in two sets that are in either the first or second set, but not in both." The second tests is assert.deepEqual(sym([1, 2, 5], [2, 3, 5], [3, 4, 5]), [1, 4, 5], 'should return the symmetric difference of the given arrays'); How is it possible that 5 is in the expected output? It is in every of the three input arrays and i expect thats why it cant be in the sym difference.
Farhad ali
@alifarhad
Sep 02 2015 06:53
it passes everything except the bloody I'm part lol can you believe my luck
Mbos95
@Mbos95
Sep 02 2015 06:54
xD xD
what happens with it ? It deletes it or..?
Marvin Casagnap
@marzim
Sep 02 2015 06:54
@Mbos95 make the string .toLowerCase() first
Tim P
@xTimpi
Sep 02 2015 06:54
@danners I had problems with that, too - if there are more than 2 arrays and a number is in every single one of them it should be in the output, thats what the definition says
DTing
@dting
Sep 02 2015 06:54
@danners think of sym(a,b,c,d) as sym(a, sym(b, sym(c, d))))
Mbos95
@Mbos95
Sep 02 2015 06:54
@alifarhad we are little tea pots
@marzim That sounds good, yes yes. forgot about that step :)
Marvin Casagnap
@marzim
Sep 02 2015 06:55
then first charAt(0) replace with same char but to .toUpperCase()
Simon Danner
@danners
Sep 02 2015 06:55
@xTimpi @dting: okay thanks will think about it
CamperBot
@camperbot
Sep 02 2015 06:55
danners sends brownie points to @xtimpi and @dting :sparkles: :thumbsup: :sparkles:
:star: 276 | @xtimpi | http://www.freecodecamp.com/xtimpi
:star: 943 | @dting | http://www.freecodecamp.com/dting
Farhad ali
@alifarhad
Sep 02 2015 06:55
i want it to only match "I" when "I'm" is given but it ends up matching the whole word because of the apostrophe @Mbos95
Mbos95
@Mbos95
Sep 02 2015 06:56
@marzim That last one sounds cryptic.. can you rephrase?
Farhad ali
@alifarhad
Sep 02 2015 06:57
how do we exclude something with regex say i don't want it to mach apostrophe, what's the code for that
^ thing?
Mbos95
@Mbos95
Sep 02 2015 06:58
well, that makes sense to use that one specificly to make it NOT use punctuation things
Ashraful Islam
@iashraful
Sep 02 2015 07:01
@alifarhad I used /^./
selects the first letter in of each array item :D
DTing
@dting
Sep 02 2015 07:03
@alifarhad you can use .replace(/\S+/g, ...
Farhad ali
@alifarhad
Sep 02 2015 07:04
let met ry that @iashraful
DTing
@dting
Sep 02 2015 07:05
that would select non spaces
which is what you want
Marvin Casagnap
@marzim
Sep 02 2015 07:05
here it is...just work on the extra space
```function titleCase(str) {
var arr = str.toLowerCase().split(' ');
var newStr = "";
for(var i=0;i<arr.length;i++){
newStr += " " + arr[i][0].replace(arr[i][0], arr[i][0].toUpperCase()) + arr[i].substr(1, arr[i].length-1);
}
return newStr;
}
damn I can't get the code works..sorry
Farhad ali
@alifarhad
Sep 02 2015 07:06
whoa man @iashraful that worked!
@dting nope that kind of ends up matching the whole string
but how is it working again? @iashraful
DTing
@dting
Sep 02 2015 07:06
are you trying to get the first letter?
Farhad ali
@alifarhad
Sep 02 2015 07:06
yep @dting
Ashraful Islam
@iashraful
Sep 02 2015 07:06
:D
Caroline Dikibo
@cdikibo
Sep 02 2015 07:07
I need help with the bonfire everything be true
CamperBot
@camperbot
Sep 02 2015 07:07
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
DTing
@dting
Sep 02 2015 07:07
just use bracket str[0]
dont use regex for that
Austin
@austinhollenbaugh
Sep 02 2015 07:07
Hey, can anyone here help me with the Javascript slot machine thing?
Farhad ali
@alifarhad
Sep 02 2015 07:07
what does ^. mean in regex?
Ashraful Islam
@iashraful
Sep 02 2015 07:07
@cdikibo please show us your code
DTing
@dting
Sep 02 2015 07:07
^ means start of a string
unless its in a bracket which means negate
Farhad ali
@alifarhad
Sep 02 2015 07:08
that seems a viable solution too @dting let me try that too
Austin
@austinhollenbaugh
Sep 02 2015 07:08
It's the "Waypoint: Create a JavaScript Slot Machine"
Caroline Dikibo
@cdikibo
Sep 02 2015 07:08
function every(collection, pre) {
  // Does everyone have one of these?
  for(i=0; i<collection.length;i++){
    for (var key in collection){
    if(collection[i].hasOwnProperty(key) || collection[i][key]==pre[key]){ 
      if(i == collection.length){
        return true;
      }else{
        return false;
      }
    }
    }
  }
}
every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex');
Farhad ali
@alifarhad
Sep 02 2015 07:08
and what is . after that? @dting
Ashraful Islam
@iashraful
Sep 02 2015 07:08
@alifarhad ^ means starts with, . means match any character
I think str[0] would've been a better solution
DTing
@dting
Sep 02 2015 07:09
:point_up:
Farhad ali
@alifarhad
Sep 02 2015 07:09
well should not that match the whole word tho @iashraful
yeah @dting thanks for that insight
CamperBot
@camperbot
Sep 02 2015 07:09
alifarhad sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 944 | @dting | http://www.freecodecamp.com/dting
Ashraful Islam
@iashraful
Sep 02 2015 07:09
@alifarhad nope
Mbos95
@Mbos95
Sep 02 2015 07:09
@cdikibo you are quite knowledgable on teletubbies
Ashraful Islam
@iashraful
Sep 02 2015 07:10
@cdikibo that looks odd, which bonfire is this?
Farhad ali
@alifarhad
Sep 02 2015 07:10
you are saying it to start and match everything with /^./ or not? @iashraful
Mbos95
@Mbos95
Sep 02 2015 07:10
@alifarhad when you're done, can you share your code ? It might be nice to read through yours . might get some idea :)
Ashraful Islam
@iashraful
Sep 02 2015 07:10
@alifarhad just matches one
DTing
@dting
Sep 02 2015 07:10
also you can use "hello".charAt(0) if you need to support IE7
Caroline Dikibo
@cdikibo
Sep 02 2015 07:10
@iashraful Everything be true
Farhad ali
@alifarhad
Sep 02 2015 07:10
there you go @Mbos95
function titleCase(str) {

  strA = str.toLowerCase().split(" ");
  var ans = [];
 strA.forEach(function(e) {
   function replacer(match) {
     return match.toUpperCase();
   }
 var up =  e.replace(/^./g, replacer);
   ans.push(up);
 });
 ans = ans.join(" ");
  return ans;
}


titleCase("I'm a little tea pot");
Ashraful Islam
@iashraful
Sep 02 2015 07:10
bf everything be true
CamperBot
@camperbot
Sep 02 2015 07:10

:fire:Bonfire: Everything Be True :link:

function every(collection, pre) {
  // Does everyone have one of these?
  return pre;
}

every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex');

Check if the predicate (second argument) returns truthy (defined) for all elements of a collection (first argument).

more info:  bf details | bf links | hint

Mbos95
@Mbos95
Sep 02 2015 07:11
thank you! :)
CamperBot
@camperbot
Sep 02 2015 07:11
if you want to thank someone, put an @ before their name!
Farhad ali
@alifarhad
Sep 02 2015 07:11
yeah that's what im trying to understand how does that matches only one? @iashraful
you welcome
Mbos95
@Mbos95
Sep 02 2015 07:11
for me you tell it to NOT select dots.. only the rest.. but then you select the whole string..
Caroline Dikibo
@cdikibo
Sep 02 2015 07:12
it fails this test:assert.strictEqual(every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex'), true, 'should return true if predicate returns truthy for all elements in the collection');
Luis Felipe López G.
@luishendrix92
Sep 02 2015 07:12
I think, since he didn't put the g (global flag) it will only return one wildcard (any character not whitespace)
and by using ^ at the beginning, it turns out to be the first one in the string
Ashraful Islam
@iashraful
Sep 02 2015 07:12
@alifarhad if I had the dot all by itself it'd select everything
Mbos95
@Mbos95
Sep 02 2015 07:12
hey, you're not walter white! my life was a liieee!
Ashraful Islam
@iashraful
Sep 02 2015 07:12
^ means only one
Luis Felipe López G.
@luishendrix92
Sep 02 2015 07:12
Nah, I was asked in uni to use github for code-submitting
Ashraful Islam
@iashraful
Sep 02 2015 07:13
sorry /g means all
Mbos95
@Mbos95
Sep 02 2015 07:13
How does that mean only one? /^b/
Luis Felipe López G.
@luishendrix92
Sep 02 2015 07:13
and I had to change my pic for the teachers to identify me
Mbos95
@Mbos95
Sep 02 2015 07:13
what does that mean then
Oh oke :D @luishendrix92
DTing
@dting
Sep 02 2015 07:13
@iashraful no ^ means start of string
unless its in brackets
Caroline Dikibo
@cdikibo
Sep 02 2015 07:13
but pass both these tests: assert.strictEqual(every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], {'sex': 'female'}), false, 'should return false if predicate returns falsey for any element in the collection');
assert.strictEqual(every([{'user': 'Tinky-Winky', 'sex': 'female'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], {'sex': 'female'}), false, 'should return false if predicate returns falsey for any element in the collection');
Mbos95
@Mbos95
Sep 02 2015 07:13
IT does ? o.0
Ashraful Islam
@iashraful
Sep 02 2015 07:13
@alifarhad if I did /^./ only one is selected
Farhad ali
@alifarhad
Sep 02 2015 07:13
so ^. means only select the first char in the string?
Ashraful Islam
@iashraful
Sep 02 2015 07:14
if I added a standard /^.+/ a whole line would be selected
Caroline Dikibo
@cdikibo
Sep 02 2015 07:14
@iashraful so what do you think?
Mbos95
@Mbos95
Sep 02 2015 07:14
wauw, this regexp thing is complicated for my little brain xD
Farhad ali
@alifarhad
Sep 02 2015 07:14
i get it that . is a wildcard that matches everything there is and ^ is used to define the start of something. so using both means only match the first char in any string. did i get that write?
Ashraful Islam
@iashraful
Sep 02 2015 07:14
@alifarhad you can play around with what does what in http://www.regexr.com/
Luis Felipe López G.
@luishendrix92
Sep 02 2015 07:14
@Mbos95 It is if you want to get creative but the basics are pretty basic (lol)
Farhad ali
@alifarhad
Sep 02 2015 07:15
yeah i have got this instead for playing around regex http://rubular.com/
Ashraful Islam
@iashraful
Sep 02 2015 07:15
by default regexp only select one instance of the match
Mbos95
@Mbos95
Sep 02 2015 07:15
This message was deleted
Ashraful Islam
@iashraful
Sep 02 2015 07:15
you need to use /g and +{} to select more
Luis Felipe López G.
@luishendrix92
Sep 02 2015 07:15
'Giving up is an option'.replace(/is|up's/gi, function(negative) {return ('is') ? 'is not' : ('up's) ? 'up is not' : '';}); !!
Farhad ali
@alifarhad
Sep 02 2015 07:16
right there @iashraful
did you try it working with str[0] tho? @iashraful
Ashraful Islam
@iashraful
Sep 02 2015 07:16
no, am regexp :D
@alifarhad I suggest http://www.regexr.com/, rubular is giving me /./ as invalid
:D
Farhad ali
@alifarhad
Sep 02 2015 07:17
I have still no idea how ^. gets the job done tho :)
Ashraful Islam
@iashraful
Sep 02 2015 07:17
^ means starts with
Caroline Dikibo
@cdikibo
Sep 02 2015 07:17
Hey @all did you see that?
Ashraful Islam
@iashraful
Sep 02 2015 07:17
. means any possible character
Farhad ali
@alifarhad
Sep 02 2015 07:18
I see
what happens if you don't use ^ ?
Luis Felipe López G.
@luishendrix92
Sep 02 2015 07:18
@alifarhad ^ and $ are the cornerstones of input field validation, $ is "ending of the string" and ^ is the "beginning of the string", using both acts as a delimiter.
Ashraful Islam
@iashraful
Sep 02 2015 07:18
only one char I guess
but, if you get something like " mango", it'll select the " " space
Mbos95
@Mbos95
Sep 02 2015 07:19
@iashraful why is the dodo wearing a top hat?
Ashraful Islam
@iashraful
Sep 02 2015 07:19
:D
DTing
@dting
Sep 02 2015 07:19
function titleCase(str) {
  return str.toLowerCase().replace(/\S+/g, function(m) {
    return m[0].toUpperCase()+m.slice(1);
  });
}
function titleCase(str) {
  return str
    .toLowerCase()
    .split(' ')
    .map(function(w) {return w[0].toUpperCase() + w.slice(1);})
    .join(' ');
}
Farhad ali
@alifarhad
Sep 02 2015 07:19
thanks for that @luishendrix92
CamperBot
@camperbot
Sep 02 2015 07:19
alifarhad sends brownie points to @luishendrix92 :sparkles: :thumbsup: :sparkles:
:star: 330 | @luishendrix92 | http://www.freecodecamp.com/luishendrix92
Luis Felipe López G.
@luishendrix92
Sep 02 2015 07:19
It will match the first occurence of any char, which is in turn, the first character lol (unless it's whitespace)
Ashraful Islam
@iashraful
Sep 02 2015 07:20
its actually meaning select any character at the starting of the word :D
regexp is hard to explain actually
Farhad ali
@alifarhad
Sep 02 2015 07:20
got it now thank you @iashraful
CamperBot
@camperbot
Sep 02 2015 07:20
alifarhad sends brownie points to @iashraful :sparkles: :thumbsup: :sparkles:
:star: 334 | @iashraful | http://www.freecodecamp.com/iashraful
Ashraful Islam
@iashraful
Sep 02 2015 07:20
I can use it but can't explain why something is something
Caroline Dikibo
@cdikibo
Sep 02 2015 07:20
@iashraful can you help me or not?
Mbos95
@Mbos95
Sep 02 2015 07:20
thank you @alifarhad @iashraful @luishendrix92 @alifarhad @iashraful
CamperBot
@camperbot
Sep 02 2015 07:20
mbos95 sends brownie points to @alifarhad and @iashraful and @luishendrix92 and @alifarhad and @iashraful :sparkles: :thumbsup: :sparkles:
:star: 171 | @alifarhad | http://www.freecodecamp.com/alifarhad
:star: 335 | @iashraful | http://www.freecodecamp.com/iashraful
:star: 171 | @alifarhad | http://www.freecodecamp.com/alifarhad
:star: 335 | @iashraful | http://www.freecodecamp.com/iashraful
:star: 331 | @luishendrix92 | http://www.freecodecamp.com/luishendrix92
Farhad ali
@alifarhad
Sep 02 2015 07:20
@dting I don't get the "math" thingy yet xD but those solu are a sight to the sore eyes xD
DTing
@dting
Sep 02 2015 07:20
@cdikibo can you post the code using the formatting
help formatting
CamperBot
@camperbot
Sep 02 2015 07:20

: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

Ashraful Islam
@iashraful
Sep 02 2015 07:20
@cdikibo ok what's your problem again?
@dting if I do the bonus user stories do I get any benefits/advantages?
:D
DTing
@dting
Sep 02 2015 07:21
nopes
haha
Ashraful Islam
@iashraful
Sep 02 2015 07:21
then?
Caroline Dikibo
@cdikibo
Sep 02 2015 07:21
@iashraful everything be true
Ashraful Islam
@iashraful
Sep 02 2015 07:21
just to show off then?
@dting here is @cdikibo's code
function every(collection, pre) {
  // Does everyone have one of these?
  for(i=0; i<collection.length;i++){
    for (var key in collection){
    if(collection[i].hasOwnProperty(key) || collection[i][key]==pre[key]){ 
      if(i == collection.length){
        return true;
      }else{
        return false;
      }
    }
    }
  }
}
every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex');
Farhad ali
@alifarhad
Sep 02 2015 07:22
@dting if you don't mind what m.slice(1) is doing in your code?
Ashraful Islam
@iashraful
Sep 02 2015 07:23
@alifarhad m.slice(1) is giving out the string from index 1
m = "hello"; m.slice(1)" // => ello
Farhad ali
@alifarhad
Sep 02 2015 07:23
ah that's so beautiful and here i was bashing my head with regex and what not
xD
DTing
@dting
Sep 02 2015 07:23
@alifarhad oops sorry looked away
Farhad ali
@alifarhad
Sep 02 2015 07:24
thanks got it @iashraful @dting
CamperBot
@camperbot
Sep 02 2015 07:24
alifarhad sends brownie points to @iashraful and @dting :sparkles: :thumbsup: :sparkles:
:warning: alifarhad already gave iashraful points
:warning: alifarhad already gave dting points
DTing
@dting
Sep 02 2015 07:24
String.slice's first argument is beginIndex
second argument is option that defaults to end of string
Caroline Dikibo
@cdikibo
Sep 02 2015 07:25
@iashraful @dting it fails this test:assert.strictEqual(every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex'), true, 'should return true if predicate returns truthy for all elements in the collection');
Farhad ali
@alifarhad
Sep 02 2015 07:25
they should give the link to .slice() in the helpful links section for this particular bonfire: title case a sentence. should not they ?
CamperBot
@camperbot
Sep 02 2015 07:25
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Farhad ali
@alifarhad
Sep 02 2015 07:25
got it @dting
Mbos95
@Mbos95
Sep 02 2015 07:26
var slaying = true;
var youHit = Math.floor(Math.random() * 2);
var damageThisround = Math.floor(Math.random()*10 + 1);
var totalDamage = 0;
var dragonHealth = 20;
var user = prompt("You encountered an dragon! You need to make a decision in an split second! Will you fight or run?!").toUpperCase();
var fight = function() {
        if(youHit) {
        console.log("You hit the dragon! Good job!");
        totalDamage += damageThisround;
        dragonHealth -= totalDamage;
        console.log("The dragons health is now " + dragonHealth);
            if(dragonHealth <5) {
                console.log("You defeated the dragon succesfully!");
                slaying = false;
                }else{
                    fight();
                    }
        }else {
            console.log("The dragon defeated you!");
            slaying = false;
            }
    }
switch(user) {
    case'FIGHT':
            fight();
            break;
            case 'RUN':
                console.log("You ran away");
            break;
            case 'NOT ACTIVE':
                console.log("not active");
            break;
}
Farhad ali
@alifarhad
Sep 02 2015 07:26
i mean, if i knew this slice() thing existed i might have not gone for regex
DTing
@dting
Sep 02 2015 07:26
bf every
CamperBot
@camperbot
Sep 02 2015 07:26

:fire:Bonfire: Everything Be True :link:

function every(collection, pre) {
  // Does everyone have one of these?
  return pre;
}

every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex');

Check if the predicate (second argument) returns truthy (defined) for all elements of a collection (first argument).

more info:  bf details | bf links | hint

Ashraful Islam
@iashraful
Sep 02 2015 07:26
@alifarhad you'll need to understand regexp, it real world, it saves a lot of typing and headache
for example to check validity of a phone number(coming up on adv. bonfires)
Farhad ali
@alifarhad
Sep 02 2015 07:27
yeah that it does @iashraful
Ashraful Islam
@iashraful
Sep 02 2015 07:27
@dting its asking if the first args' elements have the second argument present
or so I understand
so has own property should be fine me think
Mbos95
@Mbos95
Sep 02 2015 07:29
aww my code isn't willing to run
Ashraful Islam
@iashraful
Sep 02 2015 07:30
@cdikibo your bug is herepre[key]
pre is a string
not an obj
DTing
@dting
Sep 02 2015 07:31
also key in that loop will be indices of the collection array
you probably dont want to loop over arrays using indicies
Ashraful Islam
@iashraful
Sep 02 2015 07:31
yes, that for(key in value) is unnecessary
this might help
Mbos95
@Mbos95
Sep 02 2015 07:32
thank you @dting @dting @dting @dting
CamperBot
@camperbot
Sep 02 2015 07:32
mbos95 sends brownie points to @dting and @dting and @dting and @dting :sparkles: :thumbsup: :sparkles:
:star: 946 | @dting | http://www.freecodecamp.com/dting
:star: 946 | @dting | http://www.freecodecamp.com/dting
:star: 946 | @dting | http://www.freecodecamp.com/dting
:star: 946 | @dting | http://www.freecodecamp.com/dting
Ashraful Islam
@iashraful
Sep 02 2015 07:32
also what is with all the i ===collection.length
DTing
@dting
Sep 02 2015 07:33
thats the conditional to check if he's reached the end of the collection. i think he meant to use for (var key in collection[i])
and loop over each key in the object at collection[i]
Ashraful Islam
@iashraful
Sep 02 2015 07:34
no
am talking about this
if(i == collection.length){
        return true;
      }else{
        return false;
      }
what's this for?
DTing
@dting
Sep 02 2015 07:34
i'm guessing to check if he's checked every element in the array
Caroline Dikibo
@cdikibo
Sep 02 2015 07:34
so i've changed it
DTing
@dting
Sep 02 2015 07:34
but the logic inside is broken
Caroline Dikibo
@cdikibo
Sep 02 2015 07:35
function every(collection, pre) {
  // Does everyone have one of these?
  for(i=0; i<collection.length;i++){
    if(collection[i].hasOwnProperty(pre) || collection[i][pre]==pre){ 
      if(i == collection.length){
        return true;
      }else{
        return false;
      }
    }
  }
}
every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex');
Ashraful Islam
@iashraful
Sep 02 2015 07:35
@cdikibo || collection[i][pre]==pre this is always false
@dting ok, got the purpose of that if/else block now, sorry I got excited :D
DTing
@dting
Sep 02 2015 07:36
that part isn't needed all you need to check is if that property is defined
Caroline Dikibo
@cdikibo
Sep 02 2015 07:36
it fails everything now
Ashraful Islam
@iashraful
Sep 02 2015 07:36
yes || collection[i][pre]==pre is always false
@cdikibo you do it like this
function every(collection, pre) {
  // Does everyone have one of these?
  for(i=0; i<collection.length;i++){
    if(collection[i].hasOwnProperty(pre)){ 
      if(i == collection.length){
        return true;
      }else{
        return false;
      }
    }
  }
}
but then again, that if/else will strike the whole thing down
if say it finds the first element has the pre key defined, it'll immediately enter the internal if/else and return false breaking your program
Caroline Dikibo
@cdikibo
Sep 02 2015 07:39
that did not work
DTing
@dting
Sep 02 2015 07:39
function every(collection, pre) {
  for(i=0; i<collection.length;i++){
   // if the pre is not a property of collection[i] return false
  }
  // after the loop return true 
}
Ashraful Islam
@iashraful
Sep 02 2015 07:39
it won't
:point_up: what dting says
:(
I feel the urge to post the solution, but s/he seems to just copy and paste it back and run without studying what is what
Farhad ali
@alifarhad
Sep 02 2015 07:42
@iashraful i checked the string[0] solution as suggested by @dting next to our regex one. and the results were exactly the same
but using regex here has started to look like an overkill to me xD
Ashraful Islam
@iashraful
Sep 02 2015 07:43
yes, that's expected
@alifarhad try learning regex early because lateron there are challenges which will completely depend on regexp, if you don't try your hand now, you'll be in deep sea
Caroline Dikibo
@cdikibo
Sep 02 2015 07:44
@iashraful i've figured it out
Ashraful Islam
@iashraful
Sep 02 2015 07:44
great! :D
Caroline Dikibo
@cdikibo
Sep 02 2015 07:44
I've been stuck for over a month
Ashraful Islam
@iashraful
Sep 02 2015 07:45
:(
Caroline Dikibo
@cdikibo
Sep 02 2015 07:46
I have four of the intermediate bonfires that I was stuck on
DTing
@dting
Sep 02 2015 07:46
@cdikibo nice
Caroline Dikibo
@cdikibo
Sep 02 2015 07:46
I've been do them by myself
can't pair program
Ashraful Islam
@iashraful
Sep 02 2015 07:47
:( which ones are you stuck on?
Caroline Dikibo
@cdikibo
Sep 02 2015 07:47
i finally figured out another one of them earlier yesterday night
Ashraful Islam
@iashraful
Sep 02 2015 07:47
show us your code
Caroline Dikibo
@cdikibo
Sep 02 2015 07:47
binary agents and smallest common multiple
Aleksandar B.
@aleksandar-b
Sep 02 2015 07:48
@dting Can i install Node.js on my laptop if I am running 32 bit OS(Linux Mint)? Or is it Node.js only for 64 bit OS?
Farhad ali
@alifarhad
Sep 02 2015 07:48
got that boss @iashraful xD
Caroline Dikibo
@cdikibo
Sep 02 2015 07:48
I have to find my code first :sigh:
Steve Tang
@Thescuba
Sep 02 2015 07:48
bf Where art thou
CamperBot
@camperbot
Sep 02 2015 07:48

:fire:Bonfire: Where art thou :link:

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

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });

Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument).

more info:  bf details | bf links | hint

Ashraful Islam
@iashraful
Sep 02 2015 07:48
@samosale node has both 32/64
DTing
@dting
Sep 02 2015 07:49
node works for both
Steve Tang
@Thescuba
Sep 02 2015 07:49
bf details
CamperBot
@camperbot
Sep 02 2015 07:49

:fire:Bonfire: Where art thou :link:

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

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument).
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.
links:
Steve Tang
@Thescuba
Sep 02 2015 07:49
hint
CamperBot
@camperbot
Sep 02 2015 07:49
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Aleksandar B.
@aleksandar-b
Sep 02 2015 07:49
@iashraful @dting tnx
CamperBot
@camperbot
Sep 02 2015 07:49
samosale sends brownie points to @iashraful and @dting :sparkles: :thumbsup: :sparkles:
:star: 948 | @dting | http://www.freecodecamp.com/dting
:star: 336 | @iashraful | http://www.freecodecamp.com/iashraful
Ashraful Islam
@iashraful
Sep 02 2015 07:53
@dting say I don't do my ziplines on codepen, instead I do on jsbin.com
what happens?
DTing
@dting
Sep 02 2015 07:54
i don't think it matters
Ashraful Islam
@iashraful
Sep 02 2015 07:54
:open_mouth: really!
I have this weakness for the JSBin interface, codepen looks archaic
DTing
@dting
Sep 02 2015 07:55
haha
Ashraful Islam
@iashraful
Sep 02 2015 07:55
also, codepen often doesn't reload after changes, could be my browser though
anknits
@anknits
Sep 02 2015 08:02
function binaryAgent(str) {
  var str2='';
  var arr=str.split(' ');
  for (var i=0; i<arr.length; i++){
    str2.concat(String.fromCharCode(arr[i]));
  }
  return str2;
}
bonfire binary agents. please help.
CamperBot
@camperbot
Sep 02 2015 08:02
Sorry, can't find a bonfire called binary agents please help. [ Check the map? ]
Mbos95
@Mbos95
Sep 02 2015 08:07
function largestOfFour(arr) {
  for(i = 0; i < largestOfFour.length; i++){
   largestOfFour[i]


  }
  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Hey guys, How would i be able to iterate through one specific sub array?
DTing
@dting
Sep 02 2015 08:08
@Mbos95 you could use another for loop inside
Mbos95
@Mbos95
Sep 02 2015 08:09
yea oke, but now I cycle through the whole thing
How could I say that it needs to cycle only through [4, 5, 1, 3]
largestOfFour[0]?
DTing
@dting
Sep 02 2015 08:09
var a = [[1,2,3],[1,2],[1,2,3,4,5]];
for (var i = 0; i < a.length; i++) {
  var subArray = a[i];
  for (var j = 0; j < subArray.length; j++) {
    var elementOfSubArray = subArray[j];
  }
}
you shouldnt be using largestOfFour that is your function n ame
Mbos95
@Mbos95
Sep 02 2015 08:10
but that is the name of the Array.
DTing
@dting
Sep 02 2015 08:10
@Mbos95 what array? your array is named arr
Mbos95
@Mbos95
Sep 02 2015 08:11
oh yea, it is xD
sorry, confused..
hmm I don't really get the piece of code oyu just made, but i'll rebuild it for myself like that and see if i get it when I actualyl build it
Mbos95
@Mbos95
Sep 02 2015 08:19
    for(i=0;i < largestOfFour[1].length; i++){


    }
why doesn't that work?
Ashraful Islam
@iashraful
Sep 02 2015 08:19
:( what is this?
DTing
@dting
Sep 02 2015 08:19
because largestOfFour is your function name
not your array
Mbos95
@Mbos95
Sep 02 2015 08:20
but why did it work the first time
DTing
@dting
Sep 02 2015 08:20
you weren't trying to index your function the first time
Ashraful Islam
@iashraful
Sep 02 2015 08:20
heh :D
Mbos95
@Mbos95
Sep 02 2015 08:21
function largestOfFour(arr) {
  for(i = 0; i < largestOfFour.length; i++){
   var array = largestOfFour[i]
   var resultsearch = 0;
    for(i=0;i < array[1].length; i++){
      largestOfFour[i]

    }


  }
  return ;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
DTing
@dting
Sep 02 2015 08:22
you still aren't using arr
Mbos95
@Mbos95
Sep 02 2015 08:22
function largestOfFour(arr) {
  for(i = 0; i < largestOfFour.length; i++){
   var array = largestOfFour[i]
   var resultsearch = 0;
    for(i=0;i < array[1].length; i++){
      array[i]

    }


  }
  return ;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
http://www.freecodecamp.com/challenges/bonfire-return-largest-numbers-in-arrays
oops -.-
function largestOfFour(arr) {
  for(i = 0; i < arr.length; i++){
   var array = arr[i]
   var resultsearch = 0;
    for(i=0;i < array[1].length; i++){
      array[i]

    }


  }
  return ;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
sorry for t he spam
but hey, am I using arr?
DTing
@dting
Sep 02 2015 08:23
function largestOfFour(arr) {
  for(i = 0; i < arr.length; i++){ // dont use global for looping variables, use var i
   var array = arr[i]
   var resultsearch = 0;
    for(i=0;i < array[1].length; i++){ // use a different looping variable you want to use array.length
      array[i]
    }
  }
  return ;
}
Mbos95
@Mbos95
Sep 02 2015 08:24
I don't get your hints
use var i where?
but array.length will get me exactly the same as the first for loop
DTing
@dting
Sep 02 2015 08:25
no it wont
Mbos95
@Mbos95
Sep 02 2015 08:25
oh it doesn't
then I don't get why it gives me anything else
DTing
@dting
Sep 02 2015 08:25
because inside every loop of the outer for loop you change var array to arr[i]
use
for (var i = 0; i < arr.length; i++) {
  var array = arr[i];
  var resultsearch = 0;
  for (var j = 0; j < array.length; j++) {
    // do something here
  }
}
Mbos95
@Mbos95
Sep 02 2015 08:27
ah yes. sorry. sorry. when I get confused I just make myself more confused
Hmmm.. are there rules to which you use ? I or J or anything else ?
if i make it J it takes the last sub array
DTing
@dting
Sep 02 2015 08:28
no just dont use the same variable in nested loops
Mbos95
@Mbos95
Sep 02 2015 08:29
oke
DTing
@dting
Sep 02 2015 08:29
im off to bed good luck
Mbos95
@Mbos95
Sep 02 2015 08:29
oh.. well good night
sorry for making you go to bed xD
Aleksandar B.
@aleksandar-b
Sep 02 2015 08:31
I have done all bonfires except Map the Debris and friendly Date Range. Should I go to Angular.js part?
DTing
@dting
Sep 02 2015 08:35
@samosale why don't you just finish those 2? but ya if you are tired of working on them you can just move on.
Aleksandar B.
@aleksandar-b
Sep 02 2015 08:36
@dting too complicated..
DTing
@dting
Sep 02 2015 08:36
angular is going to give you a headache then lol
but in a good way
ya if you think you got the rest of the material angular basic javascript but the concepts are a bit abstract
Aleksandar B.
@aleksandar-b
Sep 02 2015 08:40
@dting yeah, but those words avg altitude, PM, orbital periods, don't know what they mean
@dting I am learning to code, not physics
DTing
@dting
Sep 02 2015 08:41
coding involves solving problems. really it's not asking you to know the physics rather write the code the solve an equation.
Andrew Gregory
@angregor
Sep 02 2015 08:41
@samosale Finding the Gravitational equation is just a google search away :) After that its a good challenge for practicing javascript.
DTing
@dting
Sep 02 2015 08:43
the date one. that's a headache
i don't feel like that challenge is well defined.
Aleksandar B.
@aleksandar-b
Sep 02 2015 08:49
@dting How to write code if I don't even know an equatation for that?
Andrew Gregory
@angregor
Sep 02 2015 08:52
@samosale The equation can be found online with a quick Google search. Physics equations are thankfully posted everywhere due to people constantly having questions
Ashraful Islam
@iashraful
Sep 02 2015 09:03
@dting which is better?
// Bonfire: Binary Agent
//option a:
function binaryAgent(str) {
  return str.replace(/[10]+ ?/g, function(bin){
     return String.fromCharCode(parseInt(bin,2));
  });
}

// option b:
function binaryAgent(str) {
  return str.split(' ').map(function(e) {
    return String.fromCharCode(parseInt(e, 2));
  }).join('');
}
Vikrant Negi
@vikrantnegi
Sep 02 2015 09:20

function myFunction(){
var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;
// Create an if-else statement here to return "heads" if flip is 0. Otherwise return "tails".
if(flip===0){
return heads;
}
// Only change code below this line.
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.
(function(){return myFunction();})();

Help this code doesn't work
```javascript
CamperBot
@camperbot
Sep 02 2015 09:20
no wiki entry for: this code doesnt workjavascript
:pencil: click here to create one now!after creating your page type update to reload it here
Vikrant Negi
@vikrantnegi
Sep 02 2015 09:21
This code doesn't work:
function myFunction(){
  var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;
  // Create an if-else statement here to return "heads" if flip is 0. Otherwise return "tails".
if(flip===0){
  return heads;
}
  // Only change code below this line.
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.
(function(){return myFunction();})();
techstonia
@techstonia
Sep 02 2015 09:24
@iashraful I like b more as it's more logical for me. you split and then map :-)
Rahul
@RahulReddy75
Sep 02 2015 09:27
This message was deleted

http://www.freecodecamp.com/challenges/bonfire-truncate-a-string
wats wrong here.. suggesstions plz..
function truncate(str, num) {
var str1 ;
if( str.length > num){
str1 = str.slice(0,num);

} else {
str1 = str;
}
return (str1 + "...");
}

truncate('A-tisket a-tasket A green and yellow basket', 11);

anknits
@anknits
Sep 02 2015 09:29
someone please help me here. what is wrong with this code for Bonfire: Binary Agents
CamperBot
@camperbot
Sep 02 2015 09:29
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
anknits
@anknits
Sep 02 2015 09:29
function binaryAgent(str) {
  var str2="";
  var arr=str.split(' ');
  for (var i=0; i<arr.length; i++){
    str2.concat(String.fromCharCode(arr[i]));
  }
  return str2;
}
binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111');
or this
function binaryAgent(str) {
  var str2="";
  var arr=str.split(' ');
  for (var i=0; i<arr.length; i++){
    str2.concat(String.fromCharCode(parseInt(arr[i])));
  }
  return str2;
}
binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111');
Bruce Young
@mutantspore
Sep 02 2015 09:34
one thing I can see straight off is that you need to tell parseInt what number base you are working with. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
Kayrat
@kairatomurbek2
Sep 02 2015 09:45
function telephoneCheck(str) {
  // Good luck!
  return true;
}



telephoneCheck("555-555-5555");
help me
CamperBot
@camperbot
Sep 02 2015 09:45

:point_right: adding environment variables [wiki]

  1. Download Varpanel.
  2. Open Varpanel.
  3. In PATH variable, add the relevant path.

:pencil: read more about adding environment variables on the FCC Wiki

Vikrant Negi
@vikrantnegi
Sep 02 2015 09:47
Anyone help me. This code is somehow incorrect.
function myFunction(){
  var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;
  // Create an if-else statement here to return "heads" if flip is 0. Otherwise return "tails".
if(flip===0){
  return heads;
}
  // Only change code below this line.
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.
(function(){return myFunction();})();
Conor Sinclair
@conordot
Sep 02 2015 09:48

```<script> $(document).ready(function(){

});</script>```

Ooops, anyway, that code above makes the objectives disappear from the waypoint (Waypoint: Learn how Script Tags and Document Ready Work) and it just won't work
Marvin Casagnap
@marzim
Sep 02 2015 09:48
var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 1;
Vikrant Negi
@vikrantnegi
Sep 02 2015 09:49
@marzim that is default code. And even then its giving error
Bruce Young
@mutantspore
Sep 02 2015 09:50
@vikrantnegi007 which is this?
Marvin Casagnap
@marzim
Sep 02 2015 09:51
@vikrantnegi007 is that from waypoint random numbers?
Soumya Rauth
@soumyaRauth
Sep 02 2015 09:53
I need help with the pomodoro clock zipline. Anyone there to help?
I don't know why the setTimeout function isn't working?
Bruce Young
@mutantspore
Sep 02 2015 09:56
@soumyaRauth keep talking :)
Soumya Rauth
@soumyaRauth
Sep 02 2015 09:57
@mutantspore :)
Well, would you take a look at the codepen.io code.
Bruce Young
@mutantspore
Sep 02 2015 09:58
@vikrantnegi007 heads and tails are supposed to be strings. as in “heads” “tails”
@soumyaRauth yes :)
Soumya Rauth
@soumyaRauth
Sep 02 2015 09:59
I am just trying to make a change in the minute & second section. Why is it not changing... http://codepen.io/soumya_rauth/pen/PPoZMM
Bruce Young
@mutantspore
Sep 02 2015 09:59
@marzim I found it… Waypoint: Use Conditional Logic with IfElse Statements
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:00
@mutantspore Change means while I click the start button.....
Vikrant Negi
@vikrantnegi
Sep 02 2015 10:01
@mutantspore Thanks.
CamperBot
@camperbot
Sep 02 2015 10:01
vikrantnegi007 sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 332 | @mutantspore | http://www.freecodecamp.com/mutantspore
Bruce Young
@mutantspore
Sep 02 2015 10:02
ok one thing.. you’ll need to assign setTimeout to something to keep track of it’s id to be able to stop it later.
actually I didn’t use that. I used setInterval
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:05
@mutantspore Should I use setInterval???
Bruce Young
@mutantspore
Sep 02 2015 10:07
I haven’t used setTimeout so I’m not sure how it works. SetInterval wil call a function every so many milliseconds . as you have with the 1000
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:07
@mutantspore But, it's not doing anything while I click the start button. I should have changed the min and sec value atleast for once right?
Bruce Young
@mutantspore
Sep 02 2015 10:07
but I’m trying to understand what your function f is supposed to do
wel it looks lik eit will cause the secs to race to 0 and make the mins go down byy 1
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:08
@mutantspore exactly.
Bruce Young
@mutantspore
Sep 02 2015 10:10
where to you tell that clock to chaange based on those changes in f ?
you can get some debug feedback by putting console.log(); statements in varios places to see whats happening
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:12
@mutantspore Ok let me try.
@kairatomurbek2 Was it a poke??? :)
Kayrat
@kairatomurbek2
Sep 02 2015 10:13
@soumyaRauth yes
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:13
@kairatomurbek2 Well I guess there are some angular stuff.
Kayrat
@kairatomurbek2
Sep 02 2015 10:14
@soumyaRauth example?
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:14
@kairatomurbek2 The look is great. But, It's not a finished product right?
@kairatomurbek2 you used angular js.
Kayrat
@kairatomurbek2
Sep 02 2015 10:14
@soumyaRauth finish
@soumyaRauth yes angular.js
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:15
@kairatomurbek2 But I can't set time interval and the duration of the clock. It's just same all the time.
Kayrat
@kairatomurbek2
Sep 02 2015 10:16
@soumyaRauth footer
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:17
@kairatomurbek2 Sorry I didn't see it. It's awesome.
Kayrat
@kairatomurbek2
Sep 02 2015 10:17
@soumyaRauth red and green
MD MOJIBUL HOQUE
@Mojibul
Sep 02 2015 10:17
I am back
Bruce Young
@mutantspore
Sep 02 2015 10:18
@soumyaRauth do you need to add $('#clock').text(minutes+":"+seconds); inside your function f
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:18
@kairatomurbek2 Ya i saw it. Thats why I wrote AWESOME.
MD MOJIBUL HOQUE
@Mojibul
Sep 02 2015 10:18
I need help to solve Waypoint: Learn how Script Tags and Document Ready Work
Kayrat
@kairatomurbek2
Sep 02 2015 10:18
@soumyaRauth ok
MD MOJIBUL HOQUE
@Mojibul
Sep 02 2015 10:19
I need help to solve Waypoint: Learn how Script Tags and Document Ready Work
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:20
@mutantspore The second and minutes are global variable and already set to show the value instantly when they changes..
Kayrat
@kairatomurbek2
Sep 02 2015 10:20

Bonfire: Validate US Telephone Numbers
Difficulty:

function telephoneCheck(str) {
  // Good luck!
  var phoneRe = /^(?:\(\d{3}\)|\d{3})(?: *- *)?\d{3}(?: *- *)?\d{4}$/;
  var digits = str.replace(/\D/g, "");
  return (digits.match(phoneRe) !== null);
}



telephoneCheck("555-555-5555");

Who knows how to do it?

CamperBot
@camperbot
Sep 02 2015 10:20
Sorry, can't find a bonfire called validate us telephone numbersdifficulty function telephonecheckstr good luck var phonere d3d3 - d3 - d4 var digits strreplacedg return digitsmatchphonere nulltelephonecheck555-555-5555who knows how to do it. [ Check the map? ]
MD MOJIBUL HOQUE
@Mojibul
Sep 02 2015 10:20
I need help to solve Waypoint: Learn how Script Tags and Document Ready Work
I need help to solve Waypoint: Learn how Script Tags and Document Ready Work
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:22
@kairatomurbek2 Please take a look at my code. What I am trying to do initially is, when I click the start button the value of minute and second changes. But, I do not know why it is not happening? http://codepen.io/soumya_rauth/pen/PPoZMM
MD MOJIBUL HOQUE
@Mojibul
Sep 02 2015 10:22
I need help to solve Waypoint: Learn how Script Tags and Document Ready Work
Kayrat
@kairatomurbek2
Sep 02 2015 10:22
@soumyaRauth one mins
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:22
@kairatomurbek2 ok.
Vikrant Negi
@vikrantnegi
Sep 02 2015 10:23
I need help in Waypoint: Bring your JavaScript Slot Machine to Life
I'm using this code:
 $($(".slot")[0]).html(slotOne);
@Mojibul what help? where are you struck?
Bruce Young
@mutantspore
Sep 02 2015 10:24
@soumyaRauth I just forked your code and put $('#clock').text(minutes+":"+seconds); inside the loop. the time now changes. It’s not doing it correctly as your code fo rteh counter is not right but it’s now changing
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 10:25
I'm doing the Twitch zipline. Can someone tell me why nothing happens here....not even a simple "yes" or "no"?
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:25
@mutantspore Really....!!!!!
Kayrat
@kairatomurbek2
Sep 02 2015 10:25
foreach
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:26
But it should have worked in that way right? I do not know what went wrong?
@kairatomurbek2 instead of for loop?? why?
MD MOJIBUL HOQUE
@Mojibul
Sep 02 2015 10:26
I fix it . Here is the code '''<script> $(document).ready(function(){}); </script>'''
CamperBot
@camperbot
Sep 02 2015 10:26
:bulb: to format code use backticks! ``` more info
Bruce Young
@mutantspore
Sep 02 2015 10:27
you need to tell the #clock’ to update the mins and secs each time you call f
MD MOJIBUL HOQUE
@Mojibul
Sep 02 2015 10:27
I fix it. Here is the code <script> $(document).ready(function(){}); </script>
Pooja
@PoojaCsc
Sep 02 2015 10:27
Hello everyone . I need help with the bonfire : title case a sentence
Bruce Young
@mutantspore
Sep 02 2015 10:27
also just counting down like lightning the seconds to 0 isn’t right.
Pooja
@PoojaCsc
Sep 02 2015 10:28
I split the string . After that how do I capitalize the first letters?
Bruce Young
@mutantspore
Sep 02 2015 10:28
the function f is called each second. you need to express your overall time in seconds .. decrement that once per call to f
Soumya Rauth
@soumyaRauth
Sep 02 2015 10:28
@mutantspore Yes it's working. Thanks.
CamperBot
@camperbot
Sep 02 2015 10:28
soumyarauth sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 333 | @mutantspore | http://www.freecodecamp.com/mutantspore
Kayrat
@kairatomurbek2
Sep 02 2015 10:28
Pooja
@PoojaCsc
Sep 02 2015 10:28
maybe through replacement?
Bruce Young
@mutantspore
Sep 02 2015 10:28
then convert the seconds to mins and secs for display purposes
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 10:29
@kairatomurbek2 I don't want to copy and paste.
I'm trying to understand
Pooja
@PoojaCsc
Sep 02 2015 10:30
Hello
Kayrat
@kairatomurbek2
Sep 02 2015 10:30
@TheHighPriestess $http.jsonp()
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 10:31
@kairatomurbek2 What is that?
Kayrat
@kairatomurbek2
Sep 02 2015 10:34
@TheHighPriestess by you $.getJSON()
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 10:34
huh?
Kayrat
@kairatomurbek2
Sep 02 2015 10:35
no
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 10:35
no what?
MD MOJIBUL HOQUE
@Mojibul
Sep 02 2015 10:36
I get " Use the jQuery addClass() function to give the classes animated and bounce to your button elements. " Error . Here is my code <script> $(document).ready(function() { $("button").addClass("animatedbounce"); }); </script>
Aleksandar B.
@aleksandar-b
Sep 02 2015 10:38
@TheHighPriestess in console you have an error, you must use jsonp
Pooja
@PoojaCsc
Sep 02 2015 10:38
@Mojibul . You need to give space between animated and bounce
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 10:39
@samosale so...I need to use .ajax in that case, right?
MD MOJIBUL HOQUE
@Mojibul
Sep 02 2015 10:40
Thanks PoojaKumar. I fix it now.
CamperBot
@camperbot
Sep 02 2015 10:40
if you want to thank someone, put an @ before their name!
MD MOJIBUL HOQUE
@Mojibul
Sep 02 2015 10:41
Thanks @PoojaKumar . I have fix it now.
CamperBot
@camperbot
Sep 02 2015 10:41
mojibul sends brownie points to @poojakumar :sparkles: :thumbsup: :sparkles:
:star: 164 | @poojakumar | http://www.freecodecamp.com/poojakumar
Aleksandar B.
@aleksandar-b
Sep 02 2015 10:41
no, you must add 3rd paramether, 'JSONP' , after the 2nd parameter function closing brackets
Pooja
@PoojaCsc
Sep 02 2015 10:42
blob
Aleksandar B.
@aleksandar-b
Sep 02 2015 10:42
And freecodecamp is not defined
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 10:42
@samosale I did it this way and still nothing is happening: http://codepen.io/highpriestess/pen/MaWxoP
Aleksandar B.
@aleksandar-b
Sep 02 2015 10:42
you must use paramether in your function yo access the object data
Pooja
@PoojaCsc
Sep 02 2015 10:42
how do I proceed ?
Aleksandar B.
@aleksandar-b
Sep 02 2015 10:43
that is channel
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 10:43
@samosale I don't understand
Aleksandar B.
@aleksandar-b
Sep 02 2015 10:44
'freecodecamp["stream"] == null' do not exist
use channel instead of freecodecamp
channel["stream"]
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 10:45
@samosale that doesn't work either
...and what does "channel" refer to?
I hate doing things without understanding why
Mbos95
@Mbos95
Sep 02 2015 10:46
hey guys!
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 10:46
@samosale shouldn't it be "data"?
Mbos95
@Mbos95
Sep 02 2015 10:47
    if(beginningdialog !== null){
      beginningdialog2 = prompt("You must be on your way to restore honour and wealth to your house than. Do you already have an plan of action? Type yes or no");
        if(beginningdialog2 === yes){
          answer1 = prompt("But I bet you didn't hear about the dragon attacks in our neighbouring kingdom, Logech, yet! Or did you ?");
Why doesn't it check if it equals yes? I type yes and it just doesn't execute the if statement
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 10:47
yeah...I changed it to "data" and it works now
Mbos95
@Mbos95
Sep 02 2015 10:47
oeh, that code looks weird
    if(beginningdialog !== null){
      beginningdialog2 = prompt("You must be on your way to restore honour and wealth to your house than. Do you already have an plan of action? Type yes or no");
        if(beginningdialog2 === yes){
          answer1 = prompt("But I bet you didn't hear about the dragon attacks in our neighbouring kingdom, Logech, yet! Or did you ?");
Rahul
@RahulReddy75
Sep 02 2015 10:48
This message was deleted
Pooja
@PoojaCsc
Sep 02 2015 10:49
Hey , I need help with this bonfire : Title case sentence
CamperBot
@camperbot
Sep 02 2015 10:49
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Mbos95
@Mbos95
Sep 02 2015 10:51
already got it. nevermind!
Pooja
@PoojaCsc
Sep 02 2015 11:23
Hey all, I need help with the bonfire : Title case a Sentence
CamperBot
@camperbot
Sep 02 2015 11:23
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Pooja
@PoojaCsc
Sep 02 2015 11:24
blob
I split the sentence . Now how do I proceed ?
Mbos95
@Mbos95
Sep 02 2015 11:33
bonfire title case a sentence
CamperBot
@camperbot
Sep 02 2015 11:33

:fire:Bonfire: Title Case a Sentence :link:

function titleCase(str) {
  return str;
}

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

Return the provided string with the first letter of each word capitalized.

more info:  bf details | bf links | hint

Mbos95
@Mbos95
Sep 02 2015 11:33
Oke. so you split the sentence. what does it return? ( return newstr )
@PoojaKumar
Pooja
@PoojaCsc
Sep 02 2015 11:35
@Mbos95 I will return the sentence after joining back the words with capitalised first letters
@Mbos95 I am not getting how to capitalize
Mbos95
@Mbos95
Sep 02 2015 11:35
Well, you need .toUpperCase();
but you need to select all the first letters of all the words first so you can .toUpperCase them
I suggest using a regexp
Pooja
@PoojaCsc
Sep 02 2015 11:37
ok... I was trying to use replace() with regex
I don't know which regex to use
I can select using charAt(0)
but since Strings are immutable how do I actually change it?
@Mbos95
Mbos95
@Mbos95
Sep 02 2015 11:39
I used regex /^./
it selects the first of a string
Pooja
@PoojaCsc
Sep 02 2015 11:40
ok
@Mbos95 What will I give as second argument to the replace () method?
Some function to return the capitalized letter?
Mbos95
@Mbos95
Sep 02 2015 11:44
Yes. I had a function which made uppercase
```
function replacer(---) {
return ---.toUpperCase();
}
function replacer(---) {
return ---.toUpperCase();
}
and replacer was in the second argument of the replace() method
by the way, remember to first make all the possible characters lowercase :) don't want to trip over having capital letters in the middle of a string and missing them
anknits
@anknits
Sep 02 2015 11:55
need help with Arguments Optional. Below is my code:
function add() {
  if ((isNaN(arguments[0])) || (isNaN(arguments[1]))){
    return undefined;
  }
  else if (arguments.length<2){
    var x = arguments[0];
    function addwith(a){
      return add(x,a);
    }
    return addwith();
  }
  else return arguments[0]+arguments[1];
}

add(2,3);
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 12:04
Help me understand why a Javascript object would have a private method. If I create an object with a private method...and and then I create an instance of that object....I have no access to the method, right? So...what's the point of a private method?
CamperBot
@camperbot
Sep 02 2015 12:04
no wiki entry for: me understand why a javascript object would have a private method if i create an object with a private methodand and then i create an instance of that objecti have no access to the method right sowhats the point of a private method
:pencil: click here to create one now!after creating your page type update to reload it here
KieronDowie
@KieronDowie
Sep 02 2015 12:04
I'm trying to perform an operation on every element on an array, but I can't remember the function that does that. I thought it was array.filter, but after googling it obviously isn't. Anyone know the right function?
Or is it impossible and I just have to for loop it?
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 12:08
For example. Let's say that we have this:
```
var Car = function() {
  this.gear = 1;
  function addStyle(styleMe){
    return 'The Current Gear Is: ' + styleMe;
  }
  this.getGear = function() {
    return addStyle(this.gear);
  };
};
So...if I'm understanding this correctly...the point here is that the instances of the Car object do not have the ability to change the gear style. ALL instances of Car have a certain type of gear.
I think this is right...I just want to be sure.
anknits
@anknits
Sep 02 2015 12:12
@TheHighPriestess let's say, instance of X = Y. Here X is the class and Y is an object of class.
Sure, a private method of an object can change properties or alter behaviour of the object.
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 12:13
@anknits but not by directly accessing the method
anknits
@anknits
Sep 02 2015 12:14
However, a private method denotes that other objects won't be able to change the behavior of the previous object that had it's method declared as private.
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 12:14
for example in that example above...it would be necessary to change gear
anknits
@anknits
Sep 02 2015 12:14
Sure it can.
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 12:14
how?
I just tried it..and it didn't work

You can't do this, for example:

var test = myCar.addStyle("3");

it won't allow you because that method is private
so...you would have to change the gear first
actually..no..that wouldn't work either
I'm just trying to figure out what "styleMe" is set to
anknits
@anknits
Sep 02 2015 12:18
i have not reached that far in FCC, but I'll soon be there. I however know a little bit of oops, and what I have stated is from my knowledge about the same. I hope someone helps you better.
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 12:18
Thank you for your help....
CamperBot
@camperbot
Sep 02 2015 12:18
if you want to thank someone, put an @ before their name!
anknits
@anknits
Sep 02 2015 12:19
this.setgear = function(a){
this.gear = a;}
@TheHighPriestess doesn't this work
Adam Sickmiller
@progmacattack
Sep 02 2015 12:20
Hi all
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 12:20
@anknits I don't know. I thought I understood it...but now I'm pretty lost
Adam Sickmiller
@progmacattack
Sep 02 2015 12:21
I'm working on the portfolio and I'm having trouble with a hover transition
I can't get the .portfolio-icon class to transition: 0.5s;
so when you mouse over, the fade works like i want but the icon comes and goes abruptly
can't seem to figure it out
Aleksandar B.
@aleksandar-b
Sep 02 2015 12:23
@TheHighPriestess when I looked in your code the paramether in callback function was set to be channel. I was reffering to that paaramether, not the new one.
Elizabeth Hatleli
@TheHighPriestess
Sep 02 2015 12:24
@samosale I changed them both to "data"
anknits
@anknits
Sep 02 2015 12:24
Bonfire: Arguments Optional
CamperBot
@camperbot
Sep 02 2015 12:24

:fire:Bonfire: Arguments Optional :link:

function add() {
  return false;
}

add(2,3);

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

more info:  bf details | bf links | hint