These are chat archives for FreeCodeCamp/HelpJavaScript

23rd
Mar 2016
Gabriel Freire
@Maslor
Mar 23 2016 00:00
function myReplace(str, before, after) {
  return str.replace(before,after);
}
How do I match the case of the replaced string?
swimrr
@swimrr
Mar 23 2016 00:00
I'm stuck
eeflores
@eeflores
Mar 23 2016 00:01
@swimrr you can add another return statement, you can do return lookup[somehting]
@swimrr the exercise is saying to assign the value to result
Andrew Charlebois
@andrewchar
Mar 23 2016 00:03
help Binary Agents
CamperBot
@camperbot
Mar 23 2016 00:03

:point_right: algorithm binary agents [wiki]

Explanation:

This problem is very straight forward, you will get a string that will represent a sentence in binary code, and you need to translate that into words. There is not direct way to do this so you will have to translate twice.

:pencil: read more about algorithm binary agents on the FCC Wiki

swimrr
@swimrr
Mar 23 2016 00:04
  // Only change code below this line
  var lookup = {
    "alpha":"Adams",
    "bravo":"Boston",
    "charlie":"Chicago",
    "delta":"Denver",
    "echo":"Easy",
    "foxtrot":"Frank"

  };

  result = lookup[val];
got ti
got it!
man, that was all trial and error (and help for you guys)
I'd have never gotten that on my own
thanks everyone!
I need to learn the order these things are processed
abtak mustapha
@mustapha88
Mar 23 2016 00:06
congratulation @swimrr
swimrr
@swimrr
Mar 23 2016 00:06
thanks @mustapha88 but I'm not sure I get it!
CamperBot
@camperbot
Mar 23 2016 00:06
swimrr sends brownie points to @mustapha88 :sparkles: :thumbsup: :sparkles:
:star: 91 | @mustapha88 | http://www.freecodecamp.com/mustapha88
swimrr
@swimrr
Mar 23 2016 00:07
that was a brute force attack
abtak mustapha
@mustapha88
Mar 23 2016 00:07
just keep going
Marc
@wumpafruits
Mar 23 2016 00:10
@swimrr play with a similar problem (or the same one) in your browser or codepen
switch out diff things and just mess around with it
create your own if/else statements, functions, objects, Constructors etc when you hit those challenges.
Vik
@vvang044
Mar 23 2016 00:32
hey guys
zseiman
@zseiman
Mar 23 2016 00:38
Dang I just did that one today
Lauren
@LaurenDoughty
Mar 23 2016 00:48
I am doing something wrong with the "return early pattern for functions" - I can get the function to exit at the first return but I can't get it to continue to the second console.log /return sequence.
console.log(a < 0 || b < 0);
return undefined;
console.log (a > 0 && b > 0);
Coy Sanders
@coymeetsworld
Mar 23 2016 00:50
@codebonobo you want to use an if/else statement
Lauren
@LaurenDoughty
Mar 23 2016 00:50
I can get it to exit and say undefined but not move on to the rest
Coy Sanders
@coymeetsworld
Mar 23 2016 00:50
or a case/switch statement
bitgrower
@bitgrower
Mar 23 2016 00:50
@codebonobo -- that's the point of a return statement, it returns from the function, so it won't progress to the next line ... which challenge is it ?
Coy Sanders
@coymeetsworld
Mar 23 2016 00:50
once you declare a return statement nothing else gets done so that last line will never run
David Weedmark
@DavidWeedmark
Mar 23 2016 00:52
@codebonobo your second console.log really isn't saying anything useful. try deleting it and see what you get
Lauren
@LaurenDoughty
Mar 23 2016 00:52
The title is "return early pattern for functions": Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
Coy Sanders
@coymeetsworld
Mar 23 2016 00:53
you also shouldn't use the console.log function
bitgrower
@bitgrower
Mar 23 2016 00:53
okay ... first, you need to have an "if" statement ...
Coy Sanders
@coymeetsworld
Mar 23 2016 00:53
that just outputs something to the console
Vik
@vvang044
Mar 23 2016 00:54
has anyone completed "title case a sentence"?
Lauren
@LaurenDoughty
Mar 23 2016 00:54
Alright, I was trying to extrapolate from the example but sometimes that doesn't work apparently...
Coy Sanders
@coymeetsworld
Mar 23 2016 00:55
yes @vvang044
Chris Dalton
@manwithgills
Mar 23 2016 00:55

Hi everyone. I am working on the Seek and Destroy Bonfire. I am confused and could use some help. Here is the code:

function destroyer(arr) {
  // Remove all the values
  return arr;
}

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

What I am confused about is how to access destroyer1 for a lack of better words. If I call arr I get the array, and if I use arr[i] I get that index in the array, not the items that I need to use to filter the array. I assume this is where the Arguments Object is used but the instructions are completely foreign to me.

bitgrower
@bitgrower
Mar 23 2016 00:55
@manwithgills -- I believe in the instructions they refer you to the arguments object MDN page ... ?
Vik
@vvang044
Mar 23 2016 00:55
@coymeetsworld im bit slow at this but....do i need to split into array change the it to lower case first
Coy Sanders
@coymeetsworld
Mar 23 2016 00:56
that is one way to do it yeah @vvang044
Chris Dalton
@manwithgills
Mar 23 2016 00:56
@bitgrower correct, and like many of the MDN pages it does not make a lot of sense.
Vik
@vvang044
Mar 23 2016 00:56
it says something about the connecting words the and of....how should i get around that?
bitgrower
@bitgrower
Mar 23 2016 00:56
here's what you need to understand, @manwithgills -- nearly any js function can be passed any number of arguments ... in the above challenge, your function is passed 3 arguments ...
Coy Sanders
@coymeetsworld
Mar 23 2016 00:56
you basically need to do two things to each word: make the first letter capitalized if its not already, and make all other letters lower case if not already
nothing to get around @vvang044
Chris Dalton
@manwithgills
Mar 23 2016 00:57
@bitgrower im with you so far.
bitgrower
@bitgrower
Mar 23 2016 00:57
on the MDN page for arguments object, there's a line of code which shows you how to convert the arguments object to an array ..
Coy Sanders
@coymeetsworld
Mar 23 2016 00:57
normally you don't capitalize those words in proper English
but to simplify the exercise they're telling you to do it
so Short And Stout should really be Short and Stout in English, but here they're saying just capitalize every word, makes the code simpler
bitgrower
@bitgrower
Mar 23 2016 00:58
the arguments object is an "array like" object ... so there are some things you can do with it, like use .length -- and other things you can't, like you can't do this arguments.filter()
Vik
@vvang044
Mar 23 2016 00:58
ok
let me give this a try....
bitgrower
@bitgrower
Mar 23 2016 00:58
the arguments object is re-defined every time your code opens a new scope ...
anyway .. you CAN find out how long the arguments object is using .length, and you can reference each object using the array bracket notation ...
....but you'll really want to convert your arguments object into something far more useful, like an array ...
Chris Dalton
@manwithgills
Mar 23 2016 01:00
@bitgrower Okay. What I did is used that line and then called the variable. It showed the whole thing as an array. Thanks for the tip.
CamperBot
@camperbot
Mar 23 2016 01:00
manwithgills sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 905 | @bitgrower | http://www.freecodecamp.com/bitgrower
Vik
@vvang044
Mar 23 2016 01:01
if i do str.toUppercase the whole word gets capitalized
Coy Sanders
@coymeetsworld
Mar 23 2016 01:01
yes
Marc
@wumpafruits
Mar 23 2016 01:02
function where(arr, num) {
 //sort array
  arr.sort(function(a, b) {
  return a - b;
});
//console.log(arr);
for (var i = 0; i < arr.length; i++){
if (arr.indexOf(num) >= arr[i]){
  }
}
return arr.indexOf(num);
}
//keep in mind you're returning the LOWEST possible index
where([3, 10, 5], 3);
Hmm...might be heading down teh wrong tunnel here! 3/7 greenlights on this one but i'm jumbling myself on the if statement
Vik
@vvang044
Mar 23 2016 01:02
but thats not what i want it should be the first letter ......
Coy Sanders
@coymeetsworld
Mar 23 2016 01:02
your for loop isn't doing anything @wumpafruits
Marc
@wumpafruits
Mar 23 2016 01:03
where([3, 10, 5], 3);
where([5, 3, 20, 3], 5);
where([10, 20, 30, 40, 50], 30);
all passed
Coy Sanders
@coymeetsworld
Mar 23 2016 01:03
yes @vvang044, so you need to split up the string
Marc
@wumpafruits
Mar 23 2016 01:03
hmm
Sujit Karki
@Swoozeki
Mar 23 2016 01:03
@wumpafruits buddy, there's nothing inside your if statement.
bitgrower
@bitgrower
Mar 23 2016 01:03

yw, @manwithgills -- that's basically how you do it ... :)

...people have tried using the arguments object directly, or, worse yet, hardcoding the actual number of arguments object ...

array.filter, as indicated on the page, works very nicely on seek and destroy ...

I spent many hours figuring out how the arguments object 'n' things worked ... at the time, I didn't actually get any help from the gitter rooms when I asked :( ... so, I kinda pieced it together ...

Vik
@vvang044
Mar 23 2016 01:04
indeed this is tricky
Coy Sanders
@coymeetsworld
Mar 23 2016 01:04
you may want to read the documentation they linked in the challenge: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split
you basically are going to do 3 things: split the string, modify the split parts, then put the string back together
Vik
@vvang044
Mar 23 2016 01:05
oh cool thanks let me read it
Andrew Charlebois
@andrewchar
Mar 23 2016 01:05
not sure what i am missing here... doing binary agents algorithm. i figure i need to use the loop. go thought the binary code. parseint to get my character code and use charCodeAt to give me the letter. but im getting an error, charCodeAt is not a function?
function binaryAgent(str) {

  str = str.split(" ");

  var newStr = "";
  for (var i = 0; i < str.length; i++) {
  newStr += str.charCodeAt(parseInt(str[i],2));
  console.log(newStr);
  }

}

binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");
Chris Dalton
@manwithgills
Mar 23 2016 01:05
@bitgrower Its pretty amazing how helpful this room is. Its no doubt I have been able to make it this far because of the community.
Sujit Karki
@Swoozeki
Mar 23 2016 01:06
@andrewchar haha, still there? I gave up on it few hours ago too, sighh...
Andrew Charlebois
@andrewchar
Mar 23 2016 01:07
@Swoozeki i left for a while after getting frustrated with it, went shooting, let some of the frustration out lol
bitgrower
@bitgrower
Mar 23 2016 01:07
@wumpafruits -- you need to compare the numbers ...and then return the index ... :)
Sujit Karki
@Swoozeki
Mar 23 2016 01:07
@andrewchar ah yea, I too went shooting ...movies, that is
bitgrower
@bitgrower
Mar 23 2016 01:07
LOL ... @andrewchar is a master of persistence ... greatly admire that ... :)
Sujit Karki
@Swoozeki
Mar 23 2016 01:07
and by that I mean, watch the shot movies
Andrew Charlebois
@andrewchar
Mar 23 2016 01:07
@Swoozeki small game hunting :)
i feel like im close
Josh Bivens
@joshbivens
Mar 23 2016 01:08
Hey @iheartkode you still there?
Andrew Charlebois
@andrewchar
Mar 23 2016 01:08
just need to figure out how to make my methods work together i think
bitgrower
@bitgrower
Mar 23 2016 01:10
@andrewchar -- any time you get something like "not a function" it means that you are most likely trying to apply a method for a data type on a variable which is not of that type
Andrew Charlebois
@andrewchar
Mar 23 2016 01:11
oh
so its still numbers when its trying to run then
bitgrower
@bitgrower
Mar 23 2016 01:11
I think, rather, that you turned str into an array ... but I may have mis-read ...
Andrew Charlebois
@andrewchar
Mar 23 2016 01:12
omg
ofc i did
with split
bitgrower
@bitgrower
Mar 23 2016 01:14
@vvang044 -- the tricky thing to remember about title case is that strings are immutable ... so, even though it would be cool to be able to index into the string and make that one character uppercase, you can't do it ... you'd have to assign it to a new variable ... and even then, the new variable will only be 1 character ...
Andrew Charlebois
@andrewchar
Mar 23 2016 01:15
@Swoozeki i have a hard time giving up on an algorithm and moving onto the next, for me that means ive lost the battle. i dont like to loose battles :P
Vik
@vvang044
Mar 23 2016 01:15
yeah that's where i got stuck.....haha
bitgrower
@bitgrower
Mar 23 2016 01:16
@andrewchar -- walking away from a problem, surprisingly, is one of the most productive things you can do ... here's the myth ... you think your conscious mind is figuring this stuff out ... it's not, it's your unconscious mind, and you need to give it a break from time to time so it can work on the problem in the background ...
Sujit Karki
@Swoozeki
Mar 23 2016 01:16
@andrewchar its not about losing a battle. It's about giving your mind enough time to refresh. I always have much easier time in the morning after, man
Lloyd Consolacion
@cowboybebot
Mar 23 2016 01:16
@andrewchar should you be using fromCharCode( stringWithNumbersInside ) instead of charCodeAt
Andrew Charlebois
@andrewchar
Mar 23 2016 01:18
i never said i dont walk away from them, i do a lot, i just never give up and move to the next, i feel defeated in a way
bitgrower
@bitgrower
Mar 23 2016 01:18
:point_up: March 22, 2016 6:16 PM @Swoozeki ... which is why it's easier in the morning ... :)
Lloyd Consolacion
@cowboybebot
Mar 23 2016 01:19
..after int parsing the string
Andrew Charlebois
@andrewchar
Mar 23 2016 01:19
@cowboybebot maybe, im not sure lol
bitgrower
@bitgrower
Mar 23 2016 01:20
@andrewchar -- don't feel defeated ... it just means your brain needs a bit more time ... and sometimes doing something related, but not the same, can leverage insights ... (kinda like taking exams, answering one question ... then later working on another, and then getting insight into the previously answered question (so you know for sure whether it's wrong or right) ...
Frank XC
@tenkdayz
Mar 23 2016 01:20
having problem with event listener when window loads .. I think.. can someone check the code to see what my be wrong? http://cygnusix.com/twitchapp/twitchproject.html
Andrew Charlebois
@andrewchar
Mar 23 2016 01:20
@cowboybebot oh maybe your right, ive been thinking about this the wrong way i think
Frank XC
@tenkdayz
Mar 23 2016 01:20
might*
Lloyd Consolacion
@cowboybebot
Mar 23 2016 01:20
use String.fromCharCode(num)
String which is the prototype
Lauren
@LaurenDoughty
Mar 23 2016 01:26
How do I put my coding screen in chat? My problem is that part of the code is preset and I have to edit it a certain way.
There's setup and a last part and I can only edit the middle.
Marc
@wumpafruits
Mar 23 2016 01:27
function where(arr, num) {
arr.sort(function(a, b) {
  return a - b;
});
for (var i = 0; i < arr.length; i++){
if (arr[i] >= num){
return arr.indexOf(arr[i]);
  }
}
}
where([40, 60], 50);
passed 6/7 tests...still trying to figure out if num > arr[i]
Andrew Charlebois
@andrewchar
Mar 23 2016 01:27
how can it give you the "not a function" message if your using the prototype of the methods
Matt Green
@mattxgreen
Mar 23 2016 01:28
@codebonobo you can put code in chat with 3 backticks and then press shift-enter... paste in your code, then ctrl-enter
Lloyd Consolacion
@cowboybebot
Mar 23 2016 01:29
@andrewchar can you type in your current code?
Andrew Charlebois
@andrewchar
Mar 23 2016 01:30
String.fromCharCode(String.charCodeAt(parseInt(str[i],2))); is what im trying but it gives me the "not a function" so i was wondering why cause im using the String.
Lauren
@LaurenDoughty
Mar 23 2016 01:30

// Setup
function abTest(a, b) {
// Only change code below this line
}switch (a, b) {
case a < 0:
a = undefined;
break;
case b < 0:
b = undefined;
break;
default:

// Only change code above this line
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
// Change values below to test your code
abTest(2,-2);

Andrew Charlebois
@andrewchar
Mar 23 2016 01:31
i know that im working from an array so i know why its giving me the error
just did not think because i use the prototype it would
RyanEnright
@RyanEnright
Mar 23 2016 01:32

I have a question about how this function works?..

function end(str, target) {
  return str.substr(-target.length) === target;
}

is -target.length starting at the last index of str then indexing forward the length of the target string?

Lloyd Consolacion
@cowboybebot
Mar 23 2016 01:32
@andrewchar you dont need the charCodeAt
Andrew Charlebois
@andrewchar
Mar 23 2016 01:32
lol
frig
there we go
Lloyd Consolacion
@cowboybebot
Mar 23 2016 01:33
charCodeAt accepts character you wanna get the character code of
the binary number is already the code
Andrew Charlebois
@andrewchar
Mar 23 2016 01:34
yeah im being dumb :(
Lloyd Consolacion
@cowboybebot
Mar 23 2016 01:34
it happens man ..fatigue sets in
bitgrower
@bitgrower
Mar 23 2016 01:35
@RyanEnright -- that sounds about right ... don't really trust my memory that well (and am concerned that I may not understand your question correctly) ... you may want to refer to the MDN page ...
Lauren
@LaurenDoughty
Mar 23 2016 01:36
I'm getting a return not in function error, and I think the braces are wrong but I don't know how to fix them.
There's no indications in the code window that there's errors anymore, so I'm at a loss.
Andrew Charlebois
@andrewchar
Mar 23 2016 01:38
@cowboybebot thanks for the tips!
CamperBot
@camperbot
Mar 23 2016 01:38
andrewchar sends brownie points to @cowboybebot :sparkles: :thumbsup: :sparkles:
:star: 334 | @cowboybebot | http://www.freecodecamp.com/cowboybebot
Lloyd Consolacion
@cowboybebot
Mar 23 2016 01:38
@RyanEnright looks like the -target.length is counting the forn the end of the str and seeing if its the same as target
Andrew Charlebois
@andrewchar
Mar 23 2016 01:38
thanks @bitgrower aswell
CamperBot
@camperbot
Mar 23 2016 01:38
andrewchar sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 906 | @bitgrower | http://www.freecodecamp.com/bitgrower
Lloyd Consolacion
@cowboybebot
Mar 23 2016 01:38
@andrewchar for sure!
RyanEnright
@RyanEnright
Mar 23 2016 01:39
@bitgrower thanks
CamperBot
@camperbot
Mar 23 2016 01:39
ryanenright sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 907 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 23 2016 01:41
yw @RyanEnright , @andrewchar
RickWisneske
@rwisneske
Mar 23 2016 01:42
Can I adjust this JS parallax to not move inverted and move with the mouse? I'm not not sure how.
http://codepen.io/rwhiskey/pen/ZQZRpM
RyanEnright
@RyanEnright
Mar 23 2016 01:43
@cowboybebot I understand what the function is doing as a whole. It's comparing the last word of str to target. I just wasnt sure about the .substr method . I didn't know you could pass a variable to it as a parameter. Thanks
CamperBot
@camperbot
Mar 23 2016 01:43
ryanenright sends brownie points to @cowboybebot :sparkles: :thumbsup: :sparkles:
:star: 335 | @cowboybebot | http://www.freecodecamp.com/cowboybebot
Marc
@wumpafruits
Mar 23 2016 01:43
function where(arr, num) {
arr.sort(function(a, b) {
  return a - b;
});
for (var i = 0; i < arr.length; i++){
if (arr[i] >= num){
return arr.indexOf(arr[i]);
  }
}
}
where([2, 5, 10], 15);
where([40, 60], 50); //returned 1 *passed*
where([10, 20, 30, 40, 50], 35); //returned 3 *passed*
where([10, 20, 30, 40, 50], 30); //returned 2 *passed*
where([3, 10, 5], 3); //returned 0 *passed*
where([5, 3, 20, 3], 5); //returned 2 *passed*
where([2, 20, 10], 19); //returned 2 *passed*
where([2, 5, 10], 15); //failed to return 3...not sure what to do with arr[i] < num
Lloyd Consolacion
@cowboybebot
Mar 23 2016 01:44
@RyanEnright glad be able to help man
RickWisneske
@rwisneske
Mar 23 2016 01:45
How do I adjust the Parallax Background Image move with the mouse and not move inverted from the mouse?
    var lFollowX = 0,
    lFollowY = 0,
    x = 0,
    y = 0,
    friction = 1 / 30;

    function moveBackground() {
        x += (lFollowX - x) * friction;
        y += (lFollowY - y) * friction;

        translate = 'translate(' + x + 'px, ' + y + 'px) scale(1.1)';

        $('.bg').css({
            '-webit-transform': translate,
            '-moz-transform': translate,
            'transform': translate
        });

        window.requestAnimationFrame(moveBackground);
    }

    $(window).on('mousemove click', function(e) {

        var lMouseX = Math.max(-100, Math.min(100, $(window).width() / 2 - e.clientX));
        var lMouseY = Math.max(-100, Math.min(100, $(window).height() / 2 - e.clientY));
        lFollowX = (10 * lMouseX) / 100; // 100 : 12 = lMouxeX : lFollow
        lFollowY = (10 * lMouseY) / 100;

    });

    moveBackground();
Marc
@wumpafruits
Mar 23 2016 01:46
if (arr[i] < num){
return arr[i] + 1;}
passes that test but i'm failing to incorporate it!
MarkWh1te
@MarkWh1te
Mar 23 2016 01:47
hi everyone
devonwilson1
@devonwilson1
Mar 23 2016 01:47
someone wanna help me with why this code is wrong? it says return statements are only valid inside functions for the assignment "selecting from many options with switch statements

function myTest(val) {
var answer = "";
// Only change code below this line
switch (val) {
case 1:
answer = "alpha";
break;
case 2:
answer ="beta";
break;
case 3:
answer = "gamma";
break;
case 4:
answer = "delta";
break;
}

}

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

// Change this value to test
myTest(2);

Lauren
@LaurenDoughty
Mar 23 2016 01:48
extra brace at the bottom maybe
since they give you one at the bottom you have to keep
so just put one brace after the break
answer = "delta";
break;
}
and then get rid of the last brace
Lloyd Consolacion
@cowboybebot
Mar 23 2016 01:51
@wumpafruits code only works if a number in the array is more than num. one solution is to include number in the array and get its index after sort
Greg Duncan
@GregatGit
Mar 23 2016 01:51
@devonwilson1 You'v accidently put return answer outside the function
the function has no return in it
Brandon Wozniewicz
@brandonwoz
Mar 23 2016 01:52

Wikipedia viewer challenge:
I'm think my code is correct, but nothing is happening and when I check the console I get a "No 'Access-Control-Allow-Origin' header is present on the requested resource." error.

$(document).ready(function(){
var url = "https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrsearch=cars";

var getSearch = function(data) {
  var info = data.query.pages[0].title;
  $(".apiTest").text(info);
};

$.getJSON(url, getSearch, "jsonp");

});

Any help would be appreciated.

bitgrower
@bitgrower
Mar 23 2016 01:52
lol ... yeah, that's about the most elegant way, @cowboybebot
Lauren
@LaurenDoughty
Mar 23 2016 01:52
@devonwilson1 if you get rid of your last brace that should work I think, since they give you one at the end part
Marc
@wumpafruits
Mar 23 2016 01:52
function where(arr, num) {
arr.sort(function(a, b) {
  return a - b;
});
for (var i = 0; i < arr.length; i++){
if (arr[i] >= num){
return arr.indexOf(arr[i]);
  }
}
return arr.length;
}
where([2, 5, 10], 15);
this ended up working
bitgrower
@bitgrower
Mar 23 2016 01:53
@brandonwoz -- look up your error message with google ... and you'll be guided to information about things like CORS, JSONP, etc ...
Marc
@wumpafruits
Mar 23 2016 01:54
i actually feel like that is a mistake but it pasased the last test
bitgrower
@bitgrower
Mar 23 2016 01:54
also ask in the frontend room ...there's a site you can use to get around that problem ...
help rooms
CamperBot
@camperbot
Mar 23 2016 01:54
Chris Dalton
@manwithgills
Mar 23 2016 01:54
help filter
CamperBot
@camperbot
Mar 23 2016 01:54

:point_right: challenge filter arrays with filter [wiki]

Filter is a useful method that can filter out values that don't match a certain criteria.

var array = [1,2,3,4,5,6,7,8,9,10];
  // Only change code below this line.
array = array.filter(function(val) {
  return val <= 5;
});

:pencil: read more about challenge filter arrays with filter on the FCC Wiki

devonwilson1
@devonwilson1
Mar 23 2016 01:54
anyone
Lauren
@LaurenDoughty
Mar 23 2016 01:55
@devonwilson1 take out the last brace you have
devonwilson1
@devonwilson1
Mar 23 2016 01:55
thanks @GregatGit
CamperBot
@camperbot
Mar 23 2016 01:55
devonwilson1 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
Lauren
@LaurenDoughty
Mar 23 2016 01:55
@devonwilson1 the } on your last line, because they give you one you have an extra which is closing the function early
CamperBot
@camperbot
Mar 23 2016 01:55
:star: 390 | @gregatgit | http://www.freecodecamp.com/gregatgit
devonwilson1
@devonwilson1
Mar 23 2016 01:56
thanks @codebonobo
Greg Duncan
@GregatGit
Mar 23 2016 01:56
@brandonwoz You should take this to the HelpFrontEnd room - you'll probably get better help there
CamperBot
@camperbot
Mar 23 2016 01:56
devonwilson1 sends brownie points to @codebonobo :sparkles: :thumbsup: :sparkles:
:star: 209 | @codebonobo | http://www.freecodecamp.com/codebonobo
Brandon Wozniewicz
@brandonwoz
Mar 23 2016 01:57
@GregatGit I posted there too :) url was wrong in my snippet, but not on my actual code. I edited the snippet above- it still gives me the error. @bitgrower I did do a search, right now most of the results seemed like a foreign language ( no pun intended). I'll head over to the front end help and see what they say.
Dan Coman
@dancomanlive
Mar 23 2016 01:57
Hello everyone, new here. Where can I get some assistance with Convert Celsius to Fahrenheit ?
Lauren
@LaurenDoughty
Mar 23 2016 01:58
I just started all this Friday, so I have a couple of basic questions. 1. How do I put a screenshot of my code in chat -- Is it a key combination? Or is there a button somewhere? and once I manage to do that, what in the world is wrong with my code...I've tried a few things and managed to break it about 25 ways but not get it to work successfully.
Greg Duncan
@GregatGit
Mar 23 2016 01:59

@brandonwoz this what i did to get my wiki one working

$.getJSON(myUrl, function(json) {
    buildHtml(json);
  });

buildHtml was a function I wrote

DJ
@qualitymanifest
Mar 23 2016 02:00
help format
CamperBot
@camperbot
Mar 23 2016 02:00

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

DJ
@qualitymanifest
Mar 23 2016 02:00
@codebonobo :point_up:
Lauren
@LaurenDoughty
Mar 23 2016 02:01
@qualitymanifest Ok, didn't know that was what a backtick was, I was using backspace, tyvm :)
Vik
@vvang044
Mar 23 2016 02:01
@bitgrower can you look at my code
Greg Duncan
@GregatGit
Mar 23 2016 02:02
@brandonwoz so try that with the url I posted
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:02
@codebonobo what @qualitymanifest ...i had the same trouble formatting code..after you know about the three back ticks you can create a private chat room to practice with. the two text balloon button on the right of the input toggles code/chat mode
Marc
@wumpafruits
Mar 23 2016 02:02
function where(arr, num) {
arr.sort(function(a, b) {
  return a - b;
});
for (var i = 0; i < arr.length; i++){
if (arr[i] >= num){
return arr.indexOf(arr[i]);
  }
}
return arr.length;
}
where([2, 5, 10], 15);
Can someone explain teh return arr.length part to me...it was a wild guess by me and i messed around with diff returns...i passed 6/7 tests before that.
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:02

*what @qualitymanifest ...i had the same trouble formatting code..after you know about the three back ticks you can create a private chat room to practice with. the two text balloon button on the right of the input toggles code/chat mode

*what @qualitymanifest said...lol

Brandon Wozniewicz
@brandonwoz
Mar 23 2016 02:04
@GregatGit Sorry just saw it. I'll give it a shot.
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:04
@wumpafruits nice solution...return terminates loop early
so it gives different lenghts for diff situations
Brandon Wozniewicz
@brandonwoz
Mar 23 2016 02:05
@GregatGit With your link -same error message in console.
Miguel T Rivera
@mtrivera
Mar 23 2016 02:06
wiki title case
CamperBot
@camperbot
Mar 23 2016 02:06

:point_right: algorithm title case a sentence [wiki]

Explanation:

We have to return a sentence with camel case. This means that the first letter will always be in uppercase and the rest lowercase.

:pencil: read more about algorithm title case a sentence on the FCC Wiki

Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:06
@wumpafruits i think thats whats happening or it maybe a bug lol
Marc
@wumpafruits
Mar 23 2016 02:06
@cowboybebot lol thanks
CamperBot
@camperbot
Mar 23 2016 02:06
wumpafruits sends brownie points to @cowboybebot :sparkles: :thumbsup: :sparkles:
:star: 336 | @cowboybebot | http://www.freecodecamp.com/cowboybebot
Marc
@wumpafruits
Mar 23 2016 02:07
@cowboybebot im going to look for another soliution that is similar...there was a .push solution that pushed the num into the array and found the index of it that was WAY easier than what i did
Lauren
@LaurenDoughty
Mar 23 2016 02:08
Ok, I can't get the code to paste in a screen, it's just the text and not in a screen
and I'm using the backticks but nothing special is happening
it's just pasting my text
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:09
@codebonobo i think you need to shift+enter after the first 3 backticks
Nicolas May
@hynso
Mar 23 2016 02:10
Hi all.. I just wrapped up the least common multiple algorithm... Mine works, but I suspect there's a simpler way. Mine relies on two additional custom functions getPrimeFactors and getNumberOfFactors (which simply the returns the count of a given number in an array. Would someone be willing to privately chat to take a look?
Marc
@wumpafruits
Mar 23 2016 02:10
function where(arr, num) {
    arr.sort(function(a, b) {
        return a - b;
        });
    for (var a in arr){
        if (arr[a] >= num)
            return parseInt(a);
    }
    return arr.length;
}
^Github solution from user Rafase282 ended w/ return arr.length as well hmm
Lauren
@LaurenDoughty
Mar 23 2016 02:11
// Setup
function abTest(a, b) {
  // Only change code below this line
} switch (a, b) {
  case a < 0:
    a = undefined;
    break;
  case b < 0:
    b = undefined;
    break;
  default:






  // Only change code above this line

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

// Change values below to test your code
abTest(2,-2);
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:12
@codebonobo woo black box
Lauren
@LaurenDoughty
Mar 23 2016 02:12
I'm getting the error return not in function but I can't have 2 open braces in a row so now what?
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:12
:)
Lauren
@LaurenDoughty
Mar 23 2016 02:12
@cowboybebot yeah, the small victory of tonight
This has taken about an hour
between Googling and finding nothing useful
jdenver90
@jdenver90
Mar 23 2016 02:13
@codebonobo yeah with javascript it takes me forever to solve one problem, most of time is spent googling help lol
Lauren
@LaurenDoughty
Mar 23 2016 02:14
Ok, so I moved the closing brace from the first line to after the default. Now part of the code works, but not the cases. I get null returned instead of undefined.
thank God it's not just me, I was really ready to throw in the towel
David Weedmark
@DavidWeedmark
Mar 23 2016 02:15
@codebonobo omg. no it certainly isn't just you!
RyanEnright
@RyanEnright
Mar 23 2016 02:16
This seems pretty straightforward any hints as to why this is not passing?
function repeatStringNumTimes(str, num) {
  if (num < 0){
      return "";
  }
  else {
  return str.repeat(num);
  }
}

repeatStringNumTimes("abc", 3);
jdenver90
@jdenver90
Mar 23 2016 02:17
@codebonobo it can be frustrating for sure. Try and solve just one each day, and eventually you'll get better. Thats what I have to tell myself lol
Lauren
@LaurenDoughty
Mar 23 2016 02:17
I started Friday and just crossed the 200 mark today.
So it, ah, hasn't exactly been the slow and steady approach.
DJ
@qualitymanifest
Mar 23 2016 02:19
@RyanEnright passes when i copy and paste it, try refreshing the page
David Weedmark
@DavidWeedmark
Mar 23 2016 02:19
I can still vividly recall exactly where I was the first time I wrote for i=0; i<array.length+1; i++ without having to look
jdenver90
@jdenver90
Mar 23 2016 02:19
@DavidWeedmark I cant wait for me to have that day haha
Lauren
@LaurenDoughty
Mar 23 2016 02:20
At least now I have four of the six conditions I need to proceed on. The functions that should be returned as undefined are not. They're being returned as null.
jdenver90
@jdenver90
Mar 23 2016 02:20
@DavidWeedmark speaking of that, not 15 mins ago i had to look up a for loop lol
Nicolas May
@hynso
Mar 23 2016 02:20
For the points... Thanks @cowboybebot !
CamperBot
@camperbot
Mar 23 2016 02:20
hynso sends brownie points to @cowboybebot :sparkles: :thumbsup: :sparkles:
:star: 337 | @cowboybebot | http://www.freecodecamp.com/cowboybebot
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:21
@hynso sure thing
David Weedmark
@DavidWeedmark
Mar 23 2016 02:21
it will come soon enough. I still go back to the algorithms and thumb through my JavaScript Pocket Reference on a regular basis
RyanEnright
@RyanEnright
Mar 23 2016 02:21
@qualitymanifest lol, thanks
CamperBot
@camperbot
Mar 23 2016 02:21
ryanenright sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1098 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Marc
@wumpafruits
Mar 23 2016 02:22
whoa caesars cipher is really cool
i never knew about ROT13
DJ
@qualitymanifest
Mar 23 2016 02:27
ROT26 is really where it's at :trollface:
rphares
@rphares
Mar 23 2016 02:30
(from the example for that part alpha[2]...
except that your table is not named alpha, yours is called lookup,
and you want to get whats associated with val, not 2...
and you would also need to connect that to the return result part by storing it in what you will return...
;) @wilsonb026 )
( @qualitymanifest :blush:)
Lauren
@LaurenDoughty
Mar 23 2016 02:32
So for this, the test value is supposed to show up as undefined but it keeps showing as null instead:
// Setup
function abTest(a, b) {
  // Only change code below this line
} switch (a, b) {
  case a < 0:
    a = undefined;
    break;
  case b < 0:
    b = undefined;
    break;
  default:






  // Only change code above this line

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

// Change values below to test your code
abTest(2,-2);
```
Oh I moved a brace since I copied that, the first brace in front of switch I moved to after the default command.
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:34
@codebonobo you can just return without doing anything on those cases i think.. so the function returns undefined
Lauren
@LaurenDoughty
Mar 23 2016 02:36
I don't understand, what's wrong with the code though?
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:36
when you do something with a or b in your last return it will result in null (and not an error suz javascript is cool like that)
Lauren
@LaurenDoughty
Mar 23 2016 02:37
the assignment is early return
to get it to exit before the last return
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:37
yah
Lauren
@LaurenDoughty
Mar 23 2016 02:37
so originally I had another return
but then the rest of the code wasn't being processed, I couldn't figure out how to get past the first return because it terminated then
so I can get one or the other to work but I can't figure out how to get them both to work
and the example wasn't helpful
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:39
what's the name of the exercise again. need to see the test cases
?
Lauren
@LaurenDoughty
Mar 23 2016 02:39
return early pattern for functions
Jason
@jpr00
Mar 23 2016 02:39
@codebonobo does it specify you have to use a switch? an if statement would be easier
Lauren
@LaurenDoughty
Mar 23 2016 02:40
it doesn't
Jason
@jpr00
Mar 23 2016 02:41
what about just ```
if (a<0 || b<0) {
return undefined;
}
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:42
@codebonobo jpr00 solution is easier. i don't think switch accepts (a,b)
but you can do switch (true)
if you still wanna do switch in your code
Lauren
@LaurenDoughty
Mar 23 2016 02:42
@jpr00 thanks that worked
CamperBot
@camperbot
Mar 23 2016 02:42
codebonobo sends brownie points to @jpr00 :sparkles: :thumbsup: :sparkles:
:star: 292 | @jpr00 | http://www.freecodecamp.com/jpr00
Lauren
@LaurenDoughty
Mar 23 2016 02:43
@cowboybebot I don't think I've done that one yet
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:43
its not normally how you make switch
but i use it if theres a lot of if statements
Jason
@jpr00
Mar 23 2016 02:44
I think switch won't work with multiple arguments
Lauren
@LaurenDoughty
Mar 23 2016 02:45
@jpr00 yeah, I wasn't sure if it would, I thought it would get flagged but I guess not
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:45
you should try it with switch(true)
Lauren
@LaurenDoughty
Mar 23 2016 02:46
@ jpr00 thanks so much though, that code worked, I was banging my head against a wall
@cowboybebot that must come later in the tutorials
Jason
@jpr00
Mar 23 2016 02:46
@codebonobo You're welcome
Lloyd Consolacion
@cowboybebot
Mar 23 2016 02:47
@codebonobo its not a common practice
Lauren
@LaurenDoughty
Mar 23 2016 02:48
well I just started Friday, so I'm still in the starting portion
Jason
@jpr00
Mar 23 2016 02:49
@codebonobo Reading on stack overflow about using switch(true)...... Interesting how it works, kind of confusing
Andrew Charlebois
@andrewchar
Mar 23 2016 02:51
help Everything Be True
CamperBot
@camperbot
Mar 23 2016 02:51

:point_right: algorithm everything be true [wiki]

Explanation:

The program needs to check if the second argument is a truthy element, and it must check this for each object in the first argument.

Hint: 1

Remember to iterate through the first argument to check each object.

Hint: 2

Only if all of them are truth will we return true, so make sure all of them check.

Hint: 3

You could use loops or callbacks functions, there are multiple ways to solve this problem.

Spoiler Alert!

687474703a2f2f7777772e796f75726472756d2e636f6d2f796f75726472756d2f696d616765732f323030372f31302f31302f7265645f7761726e696e675f7369676e5f322e676966.gif

Solutions ahead!

:pencil: read more about algorithm everything be true on the FCC Wiki

Gerard Jorgensen
@gerardjorgensen
Mar 23 2016 02:56
I'm doing the profile lookup function and this is what I have right now, but I realized that doing firstName==contacts[firstName] is incorrect since it only checks one value out of all the names and I was wondering if I have to loop through all of contacts and check all of its firstName value or if there was a better way to do it.
function lookUp(firstName, prop){
// Only change code below this line
  if(firstName == contacts[firstName])
    {
      if(prop == contacts[prop])
        {
          return contacts[prop];
        }
      else
        {
          return "No such property";
        }
    }
  else
    {
      return "No such contact";
    }
//
Tony
@Rogers187
Mar 23 2016 02:58
So I'm doing word blanks in JavaScript. And I've found where someone has used a solution to complete the task. And this is what they did

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

// Your code above this line

return result;
}

Everything I've learned in JavaScript so far has never said anything about puttin +myNoun+ like that. Why did they do this?
Andrew Charlebois
@andrewchar
Mar 23 2016 02:59
@Rogers187 myNoun is one of the parameters being passed in
@Rogers187 and they are just concatenating everything to a string
Tony
@Rogers187
Mar 23 2016 03:00
but they didn't show me to put the + sign like that.
Lloyd Consolacion
@cowboybebot
Mar 23 2016 03:00
@Rogers187 + is just a string and array concatenation method
Tony
@Rogers187
Mar 23 2016 03:01
I was shown myNoun + myNoun + myNoun not +myNoun+ +myNoun+
Lloyd Consolacion
@cowboybebot
Mar 23 2016 03:01
it dont have to be right beside it, too. it can be + myNoun + with spaces
javascript ignores those white spaces
Andrew Charlebois
@andrewchar
Mar 23 2016 03:01
@Rogers187 there is a "" between the +
Tony
@Rogers187
Mar 23 2016 03:02
Oh so if I put spaces like I was shown that will work also?
Lloyd Consolacion
@cowboybebot
Mar 23 2016 03:03
@Rogers187 yah the spaces are just for the viewers of the code
Andrew Charlebois
@andrewchar
Mar 23 2016 03:03
@Rogers187 yeah having a space inside your parenthesis will add a space to the string
Tony
@Rogers187
Mar 23 2016 03:03
OMG I've been scratching my head over this for hours.
Thanks @andrewchar & @cowboybebot
CamperBot
@camperbot
Mar 23 2016 03:03
rogers187 sends brownie points to @andrewchar and @cowboybebot :sparkles: :thumbsup: :sparkles:
:star: 338 | @cowboybebot | http://www.freecodecamp.com/cowboybebot
:star: 386 | @andrewchar | http://www.freecodecamp.com/andrewchar
Lloyd Consolacion
@cowboybebot
Mar 23 2016 03:04
happens to all of us @Rogers187
Ken Haduch
@khaduch
Mar 23 2016 03:05
@codebonobo or just return undefined (not a quoted string, but a value, as you're doing.)
maybe you already got an answer...
Lucky charm
@luckycharm223
Mar 23 2016 03:07
Ive been stIckes on this question for too long, help please?
'''
CamperBot
@camperbot
Mar 23 2016 03:08
:bulb: to format code use backticks! ``` more info
96street
@96street
Mar 23 2016 03:12
Can someone look at my code? - http://codepen.io/anon/pen/eZWdOr I want to add .black-font to <a>'s after 500ms but it's not working
Artur Sęp
@a-sep
Mar 23 2016 03:12
help format
CamperBot
@camperbot
Mar 23 2016 03:12

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Andrew Charlebois
@andrewchar
Mar 23 2016 03:15
kinda trying something new with setting a variable to a boolean for evaluating like this but for my tests, its returning 4 of 9 tests correct. not really getting what is going wrong.
function every(collection, pre) {

  //console.log(collection[0].hasOwnProperty(pre));
  var flag;
  for (var i = 0; i < collection.length; i++) {
    if (collection[i].hasOwnProperty(pre) === false) {
      flag = false;
     break;
    } else {
      flag = true;
    }

  }
  console.log(flag);
  return flag;


}

every([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
Lucky charm
@luckycharm223
Mar 23 2016 03:16
Help me with this challenge please https://www.freecodecamp.com/challenges/word-blanks
CamperBot
@camperbot
Mar 23 2016 03:16
no wiki entry for: me with this challenge please httpswwwfreecodecampcomchallengesword-blanks
Lloyd Consolacion
@cowboybebot
Mar 23 2016 03:17
@camperbot you are funny
@96street havent done much dom manipulation with vanilla js but i think the reference to the event is not getting passed form this line pages[i].addEventListener("mouseover", changeButton);
Arpit Saxena
@arpit-saxena
Mar 23 2016 03:22
Hey please help me with Friendly Date Ranges challenge
I have completed the code and I think it should work
It doesn't pass one test case.
makeFriendlyDates(["2016-12-01", "2018-02-03"])
my program returns
["December 1st, 2016","February 3rd, 2018"]
it expects
["December 1st, 2016","February 3rd, 2018"]
I don't even see any diff. between the two
96street
@96street
Mar 23 2016 03:23
what's wrong with that line? @cowboybebot
Lloyd Consolacion
@cowboybebot
Mar 23 2016 03:25
@96street i don't know/think that changebutton has the event bound to it. thats my guess(just a guess)
..have been using jquery for events
Schuyler Lewis
@spblewis
Mar 23 2016 03:26
Is anyone available to help me understand why my code doesn't work?
rphares
@rphares
Mar 23 2016 03:27
@spblewis , its not usually about if people are available or not, as much as if they know. Easiest if you state the name of the challenge and paste your code-- people will chime in if they can :blush:
96street
@96street
Mar 23 2016 03:28
@cowboybebot it adds the class successfully, but some properties such as background-color don't work. font-weight does work, can you explain this? http://codepen.io/anon/pen/eZWdOr
Schuyler Lewis
@spblewis
Mar 23 2016 03:28
Ok. Working on steamroller. I don't understand why this recursion doesn't work as expected. I can write another solution, but I would like to understand why this one doesn't work:

'''
function steamroller(arr) {
// I'm a steamroller, baby
var flatArr = [];
function roll(x) {
for (var i in x) {
if (x[i].isArray !== true) {
flatArr.push(x[i]);
} else {
roll(x[i]);
}
}
}
roll(arr);
return flatArr;
}

steamroller([1, 2, [3, [[4]]]]);
'''

CamperBot
@camperbot
Mar 23 2016 03:29
:bulb: to format code use backticks! ``` more info
rphares
@rphares
Mar 23 2016 03:29
ah... i will not be able to help, shall leave it to the room :blush: good luck and happy coding!
Schuyler Lewis
@spblewis
Mar 23 2016 03:29
function steamroller(arr) {
  // I'm a steamroller, baby
  var flatArr = [];
  function roll(x) {
    for (var i in x) {
      if (x[i].isArray !== true) {
        flatArr.push(x[i]);
      } else {
        roll(x[i]);
      }
    }
  }
  roll(arr);
  return flatArr;
}

steamroller([1, [2], [3, [[4]]]]);
Miguel T Rivera
@mtrivera
Mar 23 2016 03:32
wiki largest number
CamperBot
@camperbot
Mar 23 2016 03:32

:point_right: algorithm return largest numbers in arrays [wiki]

Explanation:

You will get an array that contains sub arrays of numbers and you need to return an array with the largest number from each of the sub arrays.

:pencil: read more about algorithm return largest numbers in arrays on the FCC Wiki

Lloyd Consolacion
@cowboybebot
Mar 23 2016 03:33
@96street the css on #main-nav li a is interfering
try adding the another class onload to specify a background color
and setTimeout another one after a few seconds
96street
@96street
Mar 23 2016 03:38
try adding the another class onload to specify a background color
what do you mean? Can you show me?
@cowboybebot
Savvis
@Savvis
Mar 23 2016 03:40
Can someone help me on Javascript: Return Early Pattern for Functions?
rphares
@rphares
Mar 23 2016 03:42
@Savvis , could you paste your code, please? :blush:
Savvis
@Savvis
Mar 23 2016 03:42

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

// Only change code above this line

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

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

oops
Okay, it says modify abTest so that if a or b are less than 0 the function will exit with a value of undefined
Le Twitch
@notalkingplz
Mar 23 2016 03:43
@Savvis You need 3 back ticks and they have to be on a different line, above and below
RyanEnright
@RyanEnright
Mar 23 2016 03:43
I'm stuck on Truncate a string bonfire. the two tests that I can't pass are trying to pass a .length rather than a number into the argument. Is this Correct or a bug?
Savvis
@Savvis
Mar 23 2016 03:43
so I tried the following: ```
Le Twitch
@notalkingplz
Mar 23 2016 03:44
@Savvis Shift + Enter for a new line
Savvis
@Savvis
Mar 23 2016 03:44
thank you
Le Twitch
@notalkingplz
Mar 23 2016 03:44
@Savvis You're welcome
Lloyd Consolacion
@cowboybebot
Mar 23 2016 03:44
@96street remove the background color on the interfering class. add the background though the javascript code on loading. then add another class after setTimeout 5 sec
Savvis
@Savvis
Mar 23 2016 03:45
here is what I tried
if (a || b > 0 {
 return undefined;
}
}
Le Twitch
@notalkingplz
Mar 23 2016 03:46
@Savvis That's not how conditionals work. It's gotta be
if (a > 0 || b > 0) {
}
Savvis
@Savvis
Mar 23 2016 03:46
I see. that makes sense
Lloyd Consolacion
@cowboybebot
Mar 23 2016 03:46
@96street i removed the background on the #main-nav li a - css and it showed another color
wire2111
@wire2111
Mar 23 2016 03:47
hi everyone, i am having trouble with some basic jquery.html updating that I can seem to figure out. any help would be much appreciated! http://codepen.io/DrewMullaney/pen/vGmXNE
96street
@96street
Mar 23 2016 03:48
@cowboybebot I want the grey color on #main-nav li a to be there initially
if you remove it then it's just white?
Le Twitch
@notalkingplz
Mar 23 2016 03:49
@96street You'll probably find better help in HelpFrontEnd
Lloyd Consolacion
@cowboybebot
Mar 23 2016 03:50
@96street yah but you can give it a background color on your javascript code when document loads
so you prevent the css and js from interfering with each other. cuz the css is not there to begin with
96street
@96street
Mar 23 2016 03:52
can you show me your code? isn't it easier just to have an initial colour, and then javascript to change it?
Lloyd Consolacion
@cowboybebot
Mar 23 2016 03:52
k let me edit real quick
96street
@96street
Mar 23 2016 03:53
thanks
wire2111
@wire2111
Mar 23 2016 03:57
nevermind - i opened chrome dev console and saw "$" not defined, i have to include jquery! it works now.
Jeff Day
@realitygenerator
Mar 23 2016 03:57
can someone help me figure out why this returns an empty array?
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var chunkArr = [];
  if (arr.length < size){
    chunkArr.push(arr.slice(0, (size-1)));

  }return chunkArr;

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Lloyd Consolacion
@cowboybebot
Mar 23 2016 03:58
@96street pmed you
96street
@96street
Mar 23 2016 03:59
how do I check pm's? @cowboybebot
Coy Sanders
@coymeetsworld
Mar 23 2016 03:59
@realitygenerator arr.length isn't less than size, ever
Lloyd Consolacion
@cowboybebot
Mar 23 2016 04:00
this is just a draft in jquery so you have to toggle the background..but it shows that you can get a background on load in js http://codepen.io/cowboybebot/pen/yObagj?editors=0110
i know there is an onload event in vanilla but i dont have time to quickly research for the syntax
@96street
Jeff Day
@realitygenerator
Mar 23 2016 04:01
thank you @coymeetsworld
CamperBot
@camperbot
Mar 23 2016 04:01
realitygenerator sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 367 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
V Bhargav Chowdary
@bhargav4
Mar 23 2016 04:01
This message was deleted
Coy Sanders
@coymeetsworld
Mar 23 2016 04:01
np @realitygenerator
96street
@96street
Mar 23 2016 04:01
@cowboybebot that's the same I had before? just in red
the background-color not changing
Lloyd Consolacion
@cowboybebot
Mar 23 2016 04:01
yah but its generated in js
Rafael
@rafaelpdl
Mar 23 2016 04:02

Hi everyone, I have the following code. I want one variable (str) to remain with its content. But when I do "strReverse=str.reverse()", the content of the original string is also changed. Does anyone knows why?

function palindrome(str) {
  // Good luck!

  str = str.replace(/\W/g, '').toLowerCase().split("");

  var strReverse;

  strReverse = str.reverse();

  console.log(str);
  console.log(strReverse);

  }

palindrome("paPA%gaio");

In the above case, for example, the outputs are:

console.log(str) = ["o", "i", "a", "g", "a", "p", "a", "p"]
console.log(strReverse())= ["o", "i", "a", "g", "a", "p", "a", "p"]

Lloyd Consolacion
@cowboybebot
Mar 23 2016 04:02
you have to do more code to toggle it
96street
@96street
Mar 23 2016 04:02
jQuery code for the toggle?
@cowboybebot
Miguel T Rivera
@mtrivera
Mar 23 2016 04:03
wiki ending
CamperBot
@camperbot
Mar 23 2016 04:03

:point_right: algorithm confirm the ending [wiki]

Explanation:

The function is a whole Boolean operation. You need to return true if the first argument ends with the second argument. This means that for the problem script, it should return true for the end('Bastian', 'n'); case.

:pencil: read more about algorithm confirm the ending on the FCC Wiki

Lloyd Consolacion
@cowboybebot
Mar 23 2016 04:03
@96street i got spoiled with jquery but vanilla have some code i would imagine for that
96street
@96street
Mar 23 2016 04:04
thanks for the help @cowboybebot
CamperBot
@camperbot
Mar 23 2016 04:04
96street sends brownie points to @cowboybebot :sparkles: :thumbsup: :sparkles:
:star: 339 | @cowboybebot | http://www.freecodecamp.com/cowboybebot
Lloyd Consolacion
@cowboybebot
Mar 23 2016 04:04
@96street youre welcome!
96street
@96street
Mar 23 2016 04:05
i'll try do it in jQuery because it's probably easier. just trying to learn JS atm
Lloyd Consolacion
@cowboybebot
Mar 23 2016 04:07
jquery and vanilla keeps getting similar with each version.
can't go wrong with learning just one or the two at the same time
@96street you could toggle with toggleClass or add/remove Class. or hard code with $(selector).css
Lloyd Consolacion
@cowboybebot
Mar 23 2016 04:13
@wire2111 you have to link jquery for your pen
demipixel
@demipixel
Mar 23 2016 04:19
@Ayan5 It wants you to convert a 1D array into a 2D array

So

1 2 3 4

turns in to

1 2
3 4
Ayan Bhowmick
@Ayan5
Mar 23 2016 04:21
hmm.
demipixel
@demipixel
Mar 23 2016 04:21

Or, in javascript terms, turn:

[1, 2, 3, 4]

in to

[[1, 2],   [3, 4]]
Ayan Bhowmick
@Ayan5
Mar 23 2016 04:22
Ok lets try.
Rafael
@rafaelpdl
Mar 23 2016 04:30

Hi everyone, I have the following code. I want one variable (str) to remain with its content. But when I do "strReverse=str.reverse()", the content of the original string is also changed. Does anyone knows why?

function palindrome(str) {
  // Good luck!

  str = str.replace(/\W/g, '').toLowerCase().split("");

  var strReverse;

  strReverse = str.reverse();

  console.log(str);
  console.log(strReverse);

  }

palindrome("paPA%gaio");

In the above case, for example, the outputs are:

console.log(str) = ["o", "i", "a", "g", "a", "p", "a", "p"]
console.log(strReverse())= ["o", "i", "a", "g", "a", "p", "a", "p"]

While I wanted it to be:

console.log(str) = ["p", "a", "p", "a", "g", "a", "i", "o"]
console.log(strReverse())= ["o", "i", "a", "g", "a", "p", "a", "p"]

Kurt Johnson
@pompan129
Mar 23 2016 04:32
@rafaelpdl The reverse() method reverses an array in place. The first array element becomes the last and the last becomes the first.... from MDN
copy it , then reverse it
Rafael
@rafaelpdl
Mar 23 2016 04:43

@pompan129 Thanks. What do you mean by copying it? Creating another variable that is equal to str?

Example:
var strOriginal = str;

This? Because I tried it, but when I do the .reverse(), it also changes the value of this other array that I had used to copy it. I do now know why

CamperBot
@camperbot
Mar 23 2016 04:43
rafaelpdl sends brownie points to @pompan129 :sparkles: :thumbsup: :sparkles:
:star: 439 | @pompan129 | http://www.freecodecamp.com/pompan129
Jason
@jpr00
Mar 23 2016 04:45
@rafaelpdl try this var strReverse = str; strReverse.reverse();
Kent
@kenthub
Mar 23 2016 04:46

I am stuck on the practice code below. I cannot make sense of it at all. Any helpful advice?

var arr = [ [1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14] ]; arr[0]; // equals [1,2,3] arr[1][2]; // equals 6 arr[3][0][1]; // equals 11

Kurt Johnson
@pompan129
Mar 23 2016 04:47
@jpr00 @rafaelpdl that wont work. variables will reference same object I believe. revstr = str.slice().reverse()
Ariel
@abibliophile
Mar 23 2016 04:48
Hi everyone! Any advice for the challenge Profile Lookup? Specifically, did y'all use nested loops and did y'all use for in loops? I know we haven't covered those (or at least I don't remember covering them) but the research I've done seems to say that they would be useful, if not necessary
Jason
@jpr00
Mar 23 2016 04:48
@rafaelpdl then use var strReverse = str.slice();
@pompan129 Good call
Kurt Johnson
@pompan129
Mar 23 2016 04:49
@jpr00 :)
Pascal T.
@omegga
Mar 23 2016 04:49
@rafaelpdl @pompan129 I guess it's because arrays are objects, and when assigning one object to multiple variables, they (variables) all reference the same unique object, so working on one variable affects all variables at the same time
Joseph
@revisualize
Mar 23 2016 04:49
Hello. I have about 20min. Does anyone need assistance with the Basic Algos?
Pascal T.
@omegga
Mar 23 2016 04:50
This message was deleted
Kurt Johnson
@pompan129
Mar 23 2016 04:50
@Scriptonaut yeah. variables actually reference the memory location of the object so they point to the same thing
Ariel
@abibliophile
Mar 23 2016 04:51
Hi @revisualize , I would love some help!
Catalin Scripcariu
@CatalinScr
Mar 23 2016 04:51
Help No repeats please
CamperBot
@camperbot
Mar 23 2016 04:51

:point_right: algorithm no repeats please [wiki]

Problem Explanation:

  • This task requires us to look at each possible permutation of a string. This is best done using a recursion function. Being able to build a function which collects all permutations of a string is a common interview question, so there is no shortage of tutorials out there on how to do this, in many different code languages.
  • This task can still be daunting even after watching a tutorial. You will want to send each new use of the function 3 inputs: 1. a new string (or character array) that is being built, 2. a position in your new string that's going to be filled next, and 3. an idea of what characters (more specifically positions) from the original string have yet to be used. The pseudo code will look something like this:

    ```
    var str = ???;
    perm(current position in original string, what's been used in original string, current string build thus far){
    if(current string is finished) {
    print current string;
    }else{
    for(var i = 0; i < str.length; i++) {

    if(str[i] has not been used) {
      put str[i] into the current position;
      mark str[i] as used
      perm(current position in original string, what's been used in original string, current string build thus far)
      unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
    }

    }
    }
    }
    :pencil: read more about algorithm no repeats please on the FCC Wiki

Joseph
@revisualize
Mar 23 2016 04:51
@abibliophile Sorry, I just popped in.. What do you need assistance with?
Kenta Kikui
@kkas
Mar 23 2016 04:51
@kenthub which practice is it? Could you give me the link?
Ariel
@abibliophile
Mar 23 2016 04:51
@revisualize no worries, so did I! I am working on the Profile Lookup challenge
Joseph
@revisualize
Mar 23 2016 04:51
Okay.
Ariel
@abibliophile
Mar 23 2016 04:52
I had a couple of questions on the outset about its structure. I'm thinking I need to use for in loops, but we haven't covered those. Is that true? @revisualize
Also was wondering whether I need nested loops
Joseph
@revisualize
Mar 23 2016 04:53
@abibliophile I did use a loop.
Kenta Kikui
@kkas
Mar 23 2016 04:53
@kenthub OK. got it. Do you know where exactly have a problem?
Joseph
@revisualize
Mar 23 2016 04:53
@abibliophile I did not use a nested loop.
Ariel
@abibliophile
Mar 23 2016 04:53
@revisualize just a for loop?
Joseph
@revisualize
Mar 23 2016 04:53
Just 1 for loop and nested if statements.
Ariel
@abibliophile
Mar 23 2016 04:54
okay! thanks!
and just .hasOwnProperty() to check for the properties, and returning that? or?
Joseph
@revisualize
Mar 23 2016 04:54
@abibliophile pretty much.
@abibliophile Of course there is a little more than that but, Yeah.
Pascal T.
@omegga
Mar 23 2016 04:55
@pompan129 thanks
CamperBot
@camperbot
Mar 23 2016 04:55
scriptonaut sends brownie points to @pompan129 :sparkles: :thumbsup: :sparkles:
:star: 440 | @pompan129 | http://www.freecodecamp.com/pompan129
Kenta Kikui
@kkas
Mar 23 2016 04:55
This is basically an array of arrays: Each element in “arr” is an array.
Ariel
@abibliophile
Mar 23 2016 04:55
thanks so much @revisualize !
CamperBot
@camperbot
Mar 23 2016 04:55
abibliophile sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 773 | @revisualize | http://www.freecodecamp.com/revisualize
Ariel
@abibliophile
Mar 23 2016 04:55
helps to know what direction to go in
Kurt Johnson
@pompan129
Mar 23 2016 04:56
@Scriptonaut :)
Ariel
@abibliophile
Mar 23 2016 04:56
I'm going to tinker with it a while
Kent
@kenthub
Mar 23 2016 04:56
@kkas yes I am confused on the part of finding out how those are indexed to produce the given value
Rafael
@rafaelpdl
Mar 23 2016 04:57
@Scriptonaut @jpr00 @pompan129 Thank you for the help and explanations! I wil try the slice method. Thank you very much
CamperBot
@camperbot
Mar 23 2016 04:57
rafaelpdl sends brownie points to @scriptonaut and @jpr00 and @pompan129 :sparkles: :thumbsup: :sparkles:
:warning: rafaelpdl already gave pompan129 points
:star: 323 | @scriptonaut | http://www.freecodecamp.com/scriptonaut
:star: 294 | @jpr00 | http://www.freecodecamp.com/jpr00
Joseph
@revisualize
Mar 23 2016 04:57
@abibliophile You basically loop through the list of profiles. Then check.. If the profile is one of the names ... Do you check of the prop. ... Then after you have looped through the names. And you don't get a result. You return that there isn't a name in that list.
Kenta Kikui
@kkas
Mar 23 2016 05:00
@kenthub OK. This is basically an array of arrays: Each element in “arr” is an array. So, "arr[0]” refers to the first element of “arr”, and which returns [1,2,3]. Likewise, "arr[1][2]” returns the third element in the second element in “arr”.
Ariel
@abibliophile
Mar 23 2016 05:02
@revisualize so you look through to check if the name matches up, then stop and have it check if the prop matches up, then return the results, and if you don't get a result, have it return that there isn't a name?
Joseph
@revisualize
Mar 23 2016 05:02
@abibliophile pretty much.
Ariel
@abibliophile
Mar 23 2016 05:02
thanks!
Joseph
@revisualize
Mar 23 2016 05:03
@abibliophile You don't really "stop". It is just an if statement.
Kent
@kenthub
Mar 23 2016 05:03
@kkas ok that makes more sense that what was explained or how I read it. Thanks! :+1:
CamperBot
@camperbot
Mar 23 2016 05:03
kenthub sends brownie points to @kkas :sparkles: :thumbsup: :sparkles:
:star: 308 | @kkas | http://www.freecodecamp.com/kkas
Ariel
@abibliophile
Mar 23 2016 05:03
okay got it
function lookUp(firstName, prop){
// Only change code below this line


for (var i=0;i<contacts.length;i++){
  if(contacts[i].hasOwnProperty(firstName)) {
    if (contacts[i].hasOwnProperty(prop)) {
      return firstName + prop; 
    }
    else {return "No such property";}
  }
  else {return "No such contact";}
 }
}
so this is what I have
it's returning "No such contact" even though there is one
Kenta Kikui
@kkas
Mar 23 2016 05:05
@kenthub no problem!
Joseph
@revisualize
Mar 23 2016 05:06
@abibliophile It is working As you have coded it.
Ariel
@abibliophile
Mar 23 2016 05:06
how do you mean?
Joseph
@revisualize
Mar 23 2016 05:06
@abibliophile You want to FIRST loop through the list. and return if found.
If NOT found after you have looped through the list. Then return no contact.
Ariel
@abibliophile
Mar 23 2016 05:07
okay, so put the loop for the if statement and then the else statements outside of the loop?
Joseph
@revisualize
Mar 23 2016 05:07
Why an else?
If a return happens your code HALTS.
Jalon Dodson
@JEDodson
Mar 23 2016 05:08
Okay so I know I messed up but I don't know how. I'm not good with JS
This message was deleted
Ariel
@abibliophile
Mar 23 2016 05:08
@revisualize but you can't have an if without an else right?
Jalon Dodson
@JEDodson
Mar 23 2016 05:08
This message was deleted
how do I do the code thjign lol.
thing*
Joseph
@revisualize
Mar 23 2016 05:09
@abibliophile Why can't you have an if without an else?
if true do this.
if false do... nothing.
no else needed.
Jalon Dodson
@JEDodson
Mar 23 2016 05:10
@revisualize
How do I put script into a code thing on here?
Joseph
@revisualize
Mar 23 2016 05:10
```
// code
```
The backticks need to be on their own lines.
SHIFT+` = ~
On most keyboards.
Jalon Dodson
@JEDodson
Mar 23 2016 05:12
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  result = "I had became friends with a " + wordBlanks;
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");
I know I messed up but I don't know how
I'm not entirely familiar with JS.
Ariel
@abibliophile
Mar 23 2016 05:12
oooh @revisualize but also how do I make it output that particular statement?
@JEDodson you should put in myNoun into that space I think
instead of wordBlanks as a whole
Rafael
@rafaelpdl
Mar 23 2016 05:13

Guys, how can I remove non-alphanumeric characters? I was trying to use

replace(/\W/g, '')

but that only chages some stuff.

Joseph
@revisualize
Mar 23 2016 05:14
@abibliophile Let's say this..
Let's say I give you a small bucket of change. In there you have 25 coins.
Think of the bucket like a for loop.
What happens if I ask you to pull out a 50cent piece and you don't find one AFTER looking through the whole bucket?
You then return to me with .. coin isn't found.
BUT! if you find the coin BEFORE finishing the bucket. You return to me with the coin.
Slava Ustiuzhanin
@ustiuzhanin
Mar 23 2016 05:15
wiki Testing Objects for Properties
CamperBot
@camperbot
Mar 23 2016 05:15

:point_right: challenge testing objects for properties [wiki]

Challenge: Testing Objects for Properties

Sometimes it is useful to check if the property of a given object exists or not. We can use the .hasOwnProperty([propname]) method of objects to determine if that object has the given property name. .hasOwnProperty() returns true or false if the property is found or not.

Example

var myObj = {
  top: "hat",
  bottom: "pants"
};
myObj.hasOwnProperty("top");    // true
myObj.hasOwnProperty("middle");

:pencil: read more about challenge testing objects for properties on the FCC Wiki

Joseph
@revisualize
Mar 23 2016 05:16
@abibliophile Really you're close to solving the solution. You just need to fix your.
return firstName + prop;
and move some items around.
96street
@96street
Mar 23 2016 05:16
When I hover over an <a> every <a> changes colour. I just want the <a> i'm hovering over to change colour (this) http://codepen.io/anon/pen/wGdzxP
Slava Ustiuzhanin
@ustiuzhanin
Mar 23 2016 05:17
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)) {
  return myObj[checkProp];
}
  return 'Not Found';
}
console.log(checkProp);
// Test your code by modifying these values
checkObj("gift");
Ariel
@abibliophile
Mar 23 2016 05:17
@revisualize here's what I have right now
for (var i=0;i<contacts.length;i++){
  if(contacts[i].hasOwnProperty(firstName)) {
    if (contacts[i].hasOwnProperty(prop)) {
      return firstName + prop; 
    }
  return "No such property";
  }
  return "No such contact";
}

}
Slava Ustiuzhanin
@ustiuzhanin
Mar 23 2016 05:17
what am I doing wrong?
Ariel
@abibliophile
Mar 23 2016 05:17
I feel super close but ahhh
Steve Hanlon
@SixStringsCoder
Mar 23 2016 05:17
I'm stuck on a challenge, can someone give a hint how I'm missing the point?
Here is code:
Ariel
@abibliophile
Mar 23 2016 05:17
ooh just a sec @ustiuzhanin let me go back and look what I did cause I remember hving an issue with that
Steve Hanlon
@SixStringsCoder
Mar 23 2016 05:17

function repeatStringNumTimes(str, num) {
// repeat after me
var times = str.repeat(num);
var empty = "";
if (num < 0) {
str = "";
} else {
return times;
}
}

repeatStringNumTimes("abc", -1);

Joseph
@revisualize
Mar 23 2016 05:17
@abibliophile You're now missing 1 else statement. and you need to move some stuff.
Kenta Kikui
@kkas
Mar 23 2016 05:17
@rafaelpdl I think “/W” matches anything other than a letter, number or underscore.
Slava Ustiuzhanin
@ustiuzhanin
Mar 23 2016 05:18
@abibliophile alright=)
Kenta Kikui
@kkas
Mar 23 2016 05:18
@rafaelpdl so, unless you are replacing underscores, I don’t know why your code is not working...
Joseph
@revisualize
Mar 23 2016 05:18
@abibliophile you're like.. ehhhh.. close.
Ariel
@abibliophile
Mar 23 2016 05:19
@ustiuzhanin which challenge was that?
Slava Ustiuzhanin
@ustiuzhanin
Mar 23 2016 05:19
@abibliophile Testing Objects for Properties
Rafael
@rafaelpdl
Mar 23 2016 05:19

@kkas Hi. I am trying to do it with the following expression:

0_0 (: /-\ :) 0-0

Joseph
@revisualize
Mar 23 2016 05:19
@abibliophile You're also checking for a prop.. But, you aren't returning that prop.
cannelflow
@cannelflow
Mar 23 2016 05:20
@ustiuzhanin remove console.log line from there
Slava Ustiuzhanin
@ustiuzhanin
Mar 23 2016 05:20
@cannelflow haha
Jeff
@meankraken
Mar 23 2016 05:21
Could anyone please look at their "Make a Person" bonfire in adv algorithms and tell me why this is expected:
Object.keys(bob).length should return 6.
Shouldn't there be 7 since there's 6 methods and one property (firstAndLast) ?
Slava Ustiuzhanin
@ustiuzhanin
Mar 23 2016 05:21
@cannelflow its working now, thank you)
CamperBot
@camperbot
Mar 23 2016 05:21
ustiuzhanin sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 995 | @cannelflow | http://www.freecodecamp.com/cannelflow
cannelflow
@cannelflow
Mar 23 2016 05:21
@ustiuzhanin :+1:
Kenta Kikui
@kkas
Mar 23 2016 05:21
@rafaelpdl Are you trying to solve any particular problem?
Ariel
@abibliophile
Mar 23 2016 05:22
@revisualize I'm not returning the prop as in I should be and I'm not or I'm not supposed to?
cannelflow
@cannelflow
Mar 23 2016 05:22
@rafaelpdl is it palindrome ex ?
Joseph
@revisualize
Mar 23 2016 05:22
@abibliophile I'm trying to think how to answer this.

@abibliophile Okay, so... you're doing this...

if (contacts[i].hasOwnProperty(prop)) {

What if my prop is number ... or what if my prop is likes.
You want to return the contacts prop.

Ariel
@abibliophile
Mar 23 2016 05:24
okay @revisualize sorry I'm having trouble grasping this :/
yeah
hm...
Joseph
@revisualize
Mar 23 2016 05:25
It is a basic object return.
note: there is a reason I copied that line of code as well. You're checking if it has the prop. now.. return the prop.
Jeff Day
@realitygenerator
Mar 23 2016 05:27
I think this for loop isn't iterating more thank once and I'm having trouble figuring out why. Can someone help?
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var chunkArr = [];
  if (arr.length > size){
    chunkArr.push(arr.slice(0, (size)));

  }for(var i = size;i < arr.length;i++){
    if (i % arr.length === 0){
     chunkArr.push(arr.slice(arr[i], (size*2)));
   }
  }return chunkArr;

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Kenta Kikui
@kkas
Mar 23 2016 05:29
@realitygenerator It should iterate twice.
Ariel
@abibliophile
Mar 23 2016 05:30
@revisualize I'm looking back at the testing objects for properties exercise
I feel like I'm getting closer
Kenta Kikui
@kkas
Mar 23 2016 05:30
@realitygenerator Are you sure it iterates only once??
Jeff Day
@realitygenerator
Mar 23 2016 05:31
no, but I've done some testing and it appears that way
Joseph
@revisualize
Mar 23 2016 05:31
@abibliophile Do you have skype or google hangout?
Kenta Kikui
@kkas
Mar 23 2016 05:32
@realitygenerator Could you share what you have done for testing?
Jeff Day
@realitygenerator
Mar 23 2016 05:32
I realize that I have too much code there I did some fixing but it's still only going once
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var chunkArr = [];
  for(var i = 0;i < arr.length;i++){
    if (i % arr.length === 0){
     chunkArr.push(arr.slice(i, (size)));
   }
  }return chunkArr;

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Ariel
@abibliophile
Mar 23 2016 05:32
@revisualize yes I do but I'm not sure how comfortable I'd be with that
it's okay I'm getting closer I can figure it out :)
96street
@96street
Mar 23 2016 05:33
struggling here. when I hover over an <a> every <a> changes colour. I just want the <a> i'm hovering over to change colour http://codepen.io/anon/pen/wGdzxP
Manikanth
@manikanth1024
Mar 23 2016 05:33

var count = 0;

function cc(card) {
// Only change code bel
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 10:
case 'J':
case 'O':
case 'K':
case 'A':
count--;
break;
}
if(count>0){
return count+ " Bet";

}
else {
return count+ " Hold";
}

}
cc(7);cc('A');

What's wrong w/this code?
Jeff Day
@realitygenerator
Mar 23 2016 05:34
I have changed where the slice ends and where i starts in various different tests. if I start i at 0 then it pushes the first (size) number of elements to the list. if I start i at 1 then it simply adds an empty array to the list.
Manikanth
@manikanth1024
Mar 23 2016 05:34

var count = 0;

function cc(card) {
// Only change code bel
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 10:
case 'J':
case 'O':
case 'K':
case 'A':
count--;
break;
}
if(count>0){
return count+ " Bet";

}
else {
return count+ " Hold";
}

}
cc(7);cc('A');

Joseph
@revisualize
Mar 23 2016 05:34
@manikanth1024 Please stop spamming your code.
Kenta Kikui
@kkas
Mar 23 2016 05:34
@realitygenerator To me, there is only one condition that terminates the loop is the “i < arr.length” unless it contains errors.
Manikanth
@manikanth1024
Mar 23 2016 05:35
what @revisualize...
Joseph
@revisualize
Mar 23 2016 05:35
@manikanth1024 You pasted a long code block into this chat twice.
Jeff Day
@realitygenerator
Mar 23 2016 05:35
it's not returning any errors and it looks that way to me as well but it's still only pushing the first set
Manikanth
@manikanth1024
Mar 23 2016 05:36
I cann't see the first one that's why i pasted it twice
Kenta Kikui
@kkas
Mar 23 2016 05:36
@realitygenerator OK. so the problem is not your loop condition. probably in the slice part...
Joseph
@revisualize
Mar 23 2016 05:37
@manikanth1024 change your > to an <=
Jeff Day
@realitygenerator
Mar 23 2016 05:37
also @manikanth1024 use ``` before and after your code to make it readable in chat
Joseph
@revisualize
Mar 23 2016 05:38
help format
CamperBot
@camperbot
Mar 23 2016 05:38

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Manikanth
@manikanth1024
Mar 23 2016 05:38
ok.
Jeff Day
@realitygenerator
Mar 23 2016 05:39
thank you @revisualize
CamperBot
@camperbot
Mar 23 2016 05:39
realitygenerator sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 775 | @revisualize | http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 23 2016 05:40
okay. 50minutes ago, I said that I had 20 minutes. .. I'm out to :zzz: ... :v:
Ariel
@abibliophile
Mar 23 2016 05:40
I'm gonna sleep on this some. Thanks again for all your help and patience @revisualize !
CamperBot
@camperbot
Mar 23 2016 05:40
abibliophile sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: abibliophile already gave revisualize points
Ariel
@abibliophile
Mar 23 2016 05:40
Sleep well!
Joseph
@revisualize
Mar 23 2016 05:40
@abibliophile Your code is really close.
Ariel
@abibliophile
Mar 23 2016 05:40
@revisualize Betcha I'll get it in the morning ^_^
Joseph
@revisualize
Mar 23 2016 05:41
@abibliophile I'd recommend looking at what you have in your Testing Objects for Properties solution.
Manikanth
@manikanth1024
Mar 23 2016 05:41
I didn't get it@revisualize
Ariel
@abibliophile
Mar 23 2016 05:41
@revisualize Thanks. I have been and I feel even closer.
CamperBot
@camperbot
Mar 23 2016 05:41
abibliophile sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: abibliophile already gave revisualize points
Ariel
@abibliophile
Mar 23 2016 05:41
Night!
Joseph
@revisualize
Mar 23 2016 05:42
:v:
Kenta Kikui
@kkas
Mar 23 2016 05:42
@realitygenerator I see why your code is not working. Check what you get from “0 % 4” and “1 % 4”.
This is why you get an empty array.
Joseph
@revisualize
Mar 23 2016 05:42
@abibliophile PM Me your solution then I'll pm you mine. It is a little trick that may help you later.
Pascal T.
@omegga
Mar 23 2016 05:44
@realitygenerator
arr.slice(i, i+size)
//slice(beginning,end)
Jeff Day
@realitygenerator
Mar 23 2016 05:45
still same result with that @Scriptonaut
I'm getting no output from 0%4 or 1%4
Pascal T.
@omegga
Mar 23 2016 05:46
@realitygenerator your code says i%arr.length but arr.length is 4 so you condition is true only when i=0 and i=4 works.But you need to slice at i=2
Kenta Kikui
@kkas
Mar 23 2016 05:47
@realitygenerator try this:
if (i % size === 0){
Jeff Day
@realitygenerator
Mar 23 2016 05:47
BAM thank you @kkas
CamperBot
@camperbot
Mar 23 2016 05:47
realitygenerator sends brownie points to @kkas :sparkles: :thumbsup: :sparkles:
:star: 309 | @kkas | http://www.freecodecamp.com/kkas
Jeff Day
@realitygenerator
Mar 23 2016 05:48
I knew I was close
also thank you @Scriptonaut
CamperBot
@camperbot
Mar 23 2016 05:49
realitygenerator sends brownie points to @scriptonaut :sparkles: :thumbsup: :sparkles:
:star: 324 | @scriptonaut | http://www.freecodecamp.com/scriptonaut
Pascal T.
@omegga
Mar 23 2016 05:49
you're welcome
Kenta Kikui
@kkas
Mar 23 2016 05:50
@realitygenerator glad to help.
Jason Lee
@JsonLitz
Mar 23 2016 06:05

'''
function myTest(val) {
var result = "";
// Only change code below this line

if (val > 5) {
result = "Bigger than 5";

} else (val <= 5) {
result = "5 or Smaller";
}

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

// Change this value to test
myTest(3);
'''

Not sure why my code isn't working, any tips?

CamperBot
@camperbot
Mar 23 2016 06:05
:bulb: to format code use backticks! ``` more info
Coy Sanders
@coymeetsworld
Mar 23 2016 06:06
do you need to print out the string @JsonLitz ? because you're not with that code
Jason Lee
@JsonLitz
Mar 23 2016 06:06
No
Just trying to test out the function https://www.freecodecamp.com/challenges/introducing-else-statements @coymeetsworld
Kenta Kikui
@kkas
Mar 23 2016 06:07
@JsonLitz you can’t put conditions after else.
Jason Lee
@JsonLitz
Mar 23 2016 06:08
@kkas thanks
CamperBot
@camperbot
Mar 23 2016 06:08
jsonlitz sends brownie points to @kkas :sparkles: :thumbsup: :sparkles:
:star: 311 | @kkas | http://www.freecodecamp.com/kkas
Coy Sanders
@coymeetsworld
Mar 23 2016 06:08
@kkas wait what condition after else? @JsonLitz
Olawale Akinseye
@brainyfarm
Mar 23 2016 06:08
@JsonLitz
Instead of else (val <= 5), do else if(val <= 5)
Kenta Kikui
@kkas
Mar 23 2016 06:09
@brainyfarm that is what I meant.
Coy Sanders
@coymeetsworld
Mar 23 2016 06:09
right @brainyfarm has it
Olawale Akinseye
@brainyfarm
Mar 23 2016 06:09
:wave: @kkas && @coymeetsworld
Darrel Adams
@dadams-510
Mar 23 2016 06:17
Can anyone help with the "Profile Lookup" challenge?
shawne90
@shawne90
Mar 23 2016 06:22
can someone tell me whats wrong with this

var fahrenheit;
var celsius;

var farenheit = celsius * 9/5 + 32;

harpoon747
@harpoon747
Mar 23 2016 06:25

Can some one tell me what is wrong with the below code queue function queue(arr, item) {
// Your code here
if(arr !== null)
{
removedElement =arr.shift();
arr.push(item);
return removedElement;
}
else
return item;
// Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue([],1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

uriznik
@uriznik
Mar 23 2016 06:25
@shawne90 missing an 'h' in fahrenheit
shawne90
@shawne90
Mar 23 2016 06:26
omg @uriznik thanks buddy
CamperBot
@camperbot
Mar 23 2016 06:26
shawne90 sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:star: 351 | @uriznik | http://www.freecodecamp.com/uriznik
Yeldar Slyamov
@yeldarslyamov
Mar 23 2016 06:26
function destroyer(arr) {
  // Remove all the values

  return arr.filter(function callback() {
    for (var i = 1; i < arguments.length; i++) {
      for (var j = 0; j < arguments[i].length; j++) {
        if (arguments[i][j] !== arguments[i][j]) {
          return false;
        }
        return true;
      }
    }
  });  
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
please help
uriznik
@uriznik
Mar 23 2016 06:26
np :)
shawne90
@shawne90
Mar 23 2016 06:26
such a silly error
Markus Kiili
@Masd925
Mar 23 2016 06:27
@yeldarslyamov The filter callback function has its own arguments object. -> you are not accessing destroyers arguments there.
You only need one loop over arguments from index 1... Use those arguments and arr.
uriznik
@uriznik
Mar 23 2016 06:30
@harpoon747 for this one make sure you're making the changes in the order that the challenge says
Jalon Dodson
@JEDodson
Mar 23 2016 06:31
Hello
// Declare your variable here

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

// Only change code above this line
function fun2() {
  var output = "";
  if (typeof myGlobal != "undefined") {
    output += "myGlobal: " + myGlobal;
  }
  if (typeof oopsGlobal != "undefined") {
    output += " oopsGlobal: " + oopsGlobal;
  }
  console.log(output);
}
Did I do that right?

It told me to:
Declare a global variable myGlobal outside of any function. Initialize it to have a value of 10

Inside function fun1, assign 5 to oopsGlobal without using the var keyword.

Lloyd Consolacion
@cowboybebot
Mar 23 2016 06:33
@JEDodson looks like you did it per directions
shanky
@shaanky
Mar 23 2016 06:33
Hello guys
Lloyd Consolacion
@cowboybebot
Mar 23 2016 06:33
@shaanky hello!
shanky
@shaanky
Mar 23 2016 06:33
Anyone can help me with "Return Largest Numbers in Arrays"
Here is my code::
function largestOfFour(arr) { 
  var arry = [];

  for(var i=0; i<arr.length; i++)
    {
      for(var j=i; j<arr.length; j++)
        {
           if(arr[i] < arr[j])
             {
               arry = arr[j];
             }
          else
            {
              arry = arr[j];
            }          
        }
    }
 return arry;
}


largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Lloyd Consolacion
@cowboybebot
Mar 23 2016 06:34
@shaanky just from the title im guessing it involves sort
shanky
@shaanky
Mar 23 2016 06:35
I am getting the last array but not the largest number from all array :smile:
harpoon747
@harpoon747
Mar 23 2016 06:36
@uriznik Thanks .. that worked like magic! got the order wrong there :)
CamperBot
@camperbot
Mar 23 2016 06:36
harpoon747 sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:star: 352 | @uriznik | http://www.freecodecamp.com/uriznik
uriznik
@uriznik
Mar 23 2016 06:37
@harpoon747 not that your code was wrong as the result is the same but they seem to test for it - though on an empty array the order might matter...
V Bhargav Chowdary
@bhargav4
Mar 23 2016 06:38
This message was deleted
Lloyd Consolacion
@cowboybebot
Mar 23 2016 06:38
@shaanky to populate arry you want to type - arry.push(arr[j]) as an example
Jeff Day
@realitygenerator
Mar 23 2016 06:42
I'm having some trouble with the indexOf() function. as I understand it from reading the reference it should return -1 if "subString" is not found in "string" for string.indexOf(subString) am I incorrect?
Olawale Akinseye
@brainyfarm
Mar 23 2016 06:42
This message was deleted
Yes @realitygenerator .
You are correct.
Yeldar Slyamov
@yeldarslyamov
Mar 23 2016 06:44
@Masd925 thank u
CamperBot
@camperbot
Mar 23 2016 06:44
yeldarslyamov sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1214 | @masd925 | http://www.freecodecamp.com/masd925
Jeff Day
@realitygenerator
Mar 23 2016 06:45

here is my code

function mutation(arr) {
  arr[0].toLowerCase();
  arr[1].toLowerCase();
  for (var i =0;i < arr[1].length;i++){
   if (arr[0].indexOf(arr[1][i]) !==-1);{
     return true;
   }
  }
}

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

it always returns true but when I console.log(arr[0].indexOf(arr[1])); i get -1 -1 -1 -1 -1 in the console.

Markus Kiili
@Masd925
Mar 23 2016 06:46
@realitygenerator Strings are immutable so your first two lines do nothing.
uriznik
@uriznik
Mar 23 2016 06:46
@realitygenerator you have an extra semicolon after the if
Jeff Day
@realitygenerator
Mar 23 2016 06:46
thank you @Masd925
CamperBot
@camperbot
Mar 23 2016 06:46
realitygenerator sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1215 | @masd925 | http://www.freecodecamp.com/masd925
Jeff Day
@realitygenerator
Mar 23 2016 06:47
thank you @uriznik
CamperBot
@camperbot
Mar 23 2016 06:47
realitygenerator sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:star: 353 | @uriznik | http://www.freecodecamp.com/uriznik
Jeff Day
@realitygenerator
Mar 23 2016 06:47
I'm still having the same issue.
shawne90
@shawne90
Mar 23 2016 06:51
i feel like im totally off here
var myStr = \backslash\ \t tab\t \t tab\t \r carriage-return\r \n new-line\n;
Jalon Dodson
@JEDodson
Mar 23 2016 06:52
function queue(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
I'm not sure what to do. May be because I'm tired, I don't know.
Underneath the first comment..
uriznik
@uriznik
Mar 23 2016 06:53
@realitygenerator that console.log line is different (no [i]). Also, what happens after you find the first char?
Olawale Akinseye
@brainyfarm
Mar 23 2016 06:54
@shawne90
Read the instructions again, for example when you are escaping a new line in a string, you would have \n and no need for the new-line.
Jalon Dodson
@JEDodson
Mar 23 2016 06:54

@shawne90

here:

Olawale Akinseye
@brainyfarm
Mar 23 2016 06:54
@JEDodson
Please don't share the solution man :D
Jalon Dodson
@JEDodson
Mar 23 2016 06:54
example: myStr = \ \t \t
formatting isn't the best. lol. and im not just showing an example
Jeff Day
@realitygenerator
Mar 23 2016 06:55
right @uriznik it returns true and escapes the for loop. thank you
CamperBot
@camperbot
Mar 23 2016 06:55
realitygenerator sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:warning: realitygenerator already gave uriznik points
Jalon Dodson
@JEDodson
Mar 23 2016 06:55
@brainyfarm Can you help me out? I'm having issues with this.
Olawale Akinseye
@brainyfarm
Mar 23 2016 06:55
@JEDodson
You should push item into arr then delete (shift) and return the first item.
Jalon Dodson
@JEDodson
Mar 23 2016 06:56
I forgot about push and shift lol.
V Arun Kumar
@arunvkumr
Mar 23 2016 06:56
@JEDodson
insert an elem at end of array.. for that read about push, then remove the first elem for that read about shift. :grinning: .. i'm pasing some links..
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/push
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
shawne90
@shawne90
Mar 23 2016 06:56
@brainyfarm and @JEDodson thanks fam! I misread that
CamperBot
@camperbot
Mar 23 2016 06:56
shawne90 sends brownie points to @brainyfarm and @jedodson :sparkles: :thumbsup: :sparkles:
:star: 1668 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
:star: 185 | @jedodson | http://www.freecodecamp.com/jedodson
V Arun Kumar
@arunvkumr
Mar 23 2016 06:58
@brainyfarm for not sharing solution.. :point_up: March 23, 2016 12:24 PM and you did :point_up: March 23, 2016 12:25 PM :wink2:
Olawale Akinseye
@brainyfarm
Mar 23 2016 06:59
@arunkumrv
Thanks for the feedback, message modified.
CamperBot
@camperbot
Mar 23 2016 06:59
brainyfarm sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 391 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Le Twitch
@notalkingplz
Mar 23 2016 07:02
Can someone explain to me why this doesn't work?
function largestOfFour(arr) {
  // You can do this!
  var store = 0,
      arrayNum = 0,
      array = arr;

  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; i++) {
      var val = arr[i][j];
      if (arrayNum < val) {
        arrayNum = val;
      }
      array[i] = arrayNum;
    }
  }
  return array;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
V Arun Kumar
@arunvkumr
Mar 23 2016 07:03
@notalkingplz in j loop, take a look at the increment part
kirbyedy
@kirbyedy
Mar 23 2016 07:03
for (var j = 0; j < arr[i].length; i++) <-- j then i ?
how does that work ?
adam-v
@adam-v
Mar 23 2016 07:04
Hi does anyone have a solution for "Generate Random Fractions with JavaScript"
Le Twitch
@notalkingplz
Mar 23 2016 07:04
@arunkumrv @kirbyedy The j loop can't access the var i?
kirbyedy
@kirbyedy
Mar 23 2016 07:05
no you are incrementing the i
in the j loop
check the last parameter
Le Twitch
@notalkingplz
Mar 23 2016 07:06
@kirbyedy OHH such a silly mistake :S Thanks @arunkumrv abd @kirbyedy
CamperBot
@camperbot
Mar 23 2016 07:06
notalkingplz sends brownie points to @kirbyedy and @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 392 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
:star: 724 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
kirbyedy
@kirbyedy
Mar 23 2016 07:06
@adam-v we dont give solutions here, but we help solving the problems together
adam-v
@adam-v
Mar 23 2016 07:08
@kirbyedy "Change myFunction to return a random number instead of returning 0." where can you find information on this
kirbyedy
@kirbyedy
Mar 23 2016 07:08
did you read the instructions ?
adam-v
@adam-v
Mar 23 2016 07:08
@kirbyedy yes. they are useless
kirbyedy
@kirbyedy
Mar 23 2016 07:09
how about this line from the instructions: Thus Math.random() can return a 0 but never quite return a 1
adam-v
@adam-v
Mar 23 2016 07:09
@kirbyedy its cryptic. How about giving an example and then we can write out what the question is asking for?
kirbyedy
@kirbyedy
Mar 23 2016 07:09
and your task is: "Generate Random Fractions with JavaScript"
math.random() method will give you a random number between 0 and 1
so if you assign this method to your variable, you will get a random number
and that is your task
adam-v
@adam-v
Mar 23 2016 07:11
@kirbyedy i still have no idea what im supposed to be doing or how to do it
maybe this text will clear it up a bit
there are examples in the text below
Jalon Dodson
@JEDodson
Mar 23 2016 07:13
This is so confusing.
adam-v
@adam-v
Mar 23 2016 07:13
@kirbyedy how do i give myFunction that random stuff
Jalon Dodson
@JEDodson
Mar 23 2016 07:13
function queue(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
This is probably the easiest thing in the world but I'm struggling with it I'm not sure what to do
kirbyedy
@kirbyedy
Mar 23 2016 07:16
@adam-v you just have to return math random
adam-v
@adam-v
Mar 23 2016 07:16
@kirbyedy how
@kirbyedy do you have any suggestions on reading/videos/tutorials for beginners. I just cannot get to grips with codeacademy or freecodecamp.
@kirbyedy they make learning incredibly difficult and frustrating for beginners.
Pascal T.
@omegga
Mar 23 2016 07:22
@JEDodson what's the exercise ?
Jalon Dodson
@JEDodson
Mar 23 2016 07:23
Stand in Line
@Scriptonaut
kirbyedy
@kirbyedy
Mar 23 2016 07:25
Jalon Dodson
@JEDodson
Mar 23 2016 07:25
function queue(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift(item);
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
That's what I have, idk if I'd change it to return arr? no thta's not right. grrr idk.
adam-v
@adam-v
Mar 23 2016 07:26
@kirbyedy thanks!
CamperBot
@camperbot
Mar 23 2016 07:26
adam-v sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 725 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
uriznik
@uriznik
Mar 23 2016 07:27
Pascal T.
@omegga
Mar 23 2016 07:27
@JEDodson the shift() method does 2 things : it removes first element of array and at the same time returns that removed element
Jalon Dodson
@JEDodson
Mar 23 2016 07:29
queue([], 1) should return 1
queue([2], 1) should return 2
queue([5,6,7,8,9], 1) should return 5
After queue(testArr, 10), testArr[4] should be 10
That's the checklist, I've got 1 and 4 I'm at a complete stump.
I don't see what they're wanting me to do, I followed instructions
I removed the first element, and added the number to the end of the array
Michael Suchorolski
@mikesuchor
Mar 23 2016 07:30

Having trouble with the profile lookup exercise. This is what I have so far:

function lookUp(firstName, prop){
for(var i=0; i<contacts.length; i++){
if(contacts[i].firstName===firstName && contacts[i].hasOwnProperty(prop)===true){
return contacts[i][prop];
}

If I try to add this, it just outputs "No such contact" for everything and the first part stops working. What am I missing?

else if(contacts[i].firstName!==firstName){
  return "No such contact";
}
Pascal T.
@omegga
Mar 23 2016 07:31
@JEDodson with arr.push(item) you have added the item into array at the end.You must then remove the first element with shift and return that removed element
Michael Suchorolski
@mikesuchor
Mar 23 2016 07:31
The first part seems to work on its own
Jalon Dodson
@JEDodson
Mar 23 2016 07:32
how do i return the removed element? I already removed the element with shift()
Coy Sanders
@coymeetsworld
Mar 23 2016 07:33
shift returns the removed element
Jalon Dodson
@JEDodson
Mar 23 2016 07:33
then what's the problem what am i doing wrong
Pascal T.
@omegga
Mar 23 2016 07:33
@JEDodson shift() is doing the job.It does 2 things : remove 1st element and return the removed element
@JEDodson you are returning item.Item = 6 in the first example.You must return 1
@JEDodson and no need to use parameters on shift()
Jalon Dodson
@JEDodson
Mar 23 2016 07:36
Before: [1,2,3,4,5]
6
After: [2,3,4,5,6]
that's waht the console shows, which is what i was supposed to do, the default value is 6, do i have to edit it or what??
Manikanth
@manikanth1024
Mar 23 2016 07:36

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

// Only change code below this line
val={
"alpha": "Adams",
"bravo" :"Boston",
"charlie":"Chicago",
"delta": "Denver",
"echo " :"Easy",
"foxtrot":"Frank"
};
result=val[charlie];
// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup("charlie"); ```

could any one help me w/this?
Pascal T.
@omegga
Mar 23 2016 07:36
@JEDodson you have to return 1
Jalon Dodson
@JEDodson
Mar 23 2016 07:38
it says i've already done that

queue([], 1) should return 1

says i have done that, the things it says i havent done is:

queue([2], 1) should return 2

and

queue([5,6,7,8,9], 1) should return 5

I'll just work on it more tomorrow
Pascal T.
@omegga
Mar 23 2016 07:42
@JEDodson you have to add 1 to array , delete 2 and return 2
@JEDodson you know how to add 1 with push, use shift to do the rest
Michael Suchorolski
@mikesuchor
Mar 23 2016 07:44
function lookUp(firstName, prop){
// Only change code below this line
for(var i=0; i<contacts.length; i++){
if(contacts[i].firstName===firstName && contacts[i].hasOwnProperty(prop)===true){
return contacts[i][prop];
}
else if(contacts[i].firstName!==firstName){
return "No such contact";
}
}
Why is the else if overriding the rest of the code? Been stuck on this for hours
Mark Dickinson
@monoposon
Mar 23 2016 07:48
@mikesuchor the loop is checking the firstname for the first contact, seeing that it doesnt match, and doing the else statement.
Manikanth
@manikanth1024
Mar 23 2016 07:49

what's wrong w/this code?

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

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

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

// Change this value to test
phoneticLookup("charlie"); ```

pankaj kumar
@pankajkumar229
Mar 23 2016 07:49
Instructions : Declare a local variable myVar inside myFunction
Code :

function myFunction() {
'use strict';

var myVar = 10;
console.log(myVar);
}
myFunction();

// run and check the console
// myVar is not defined outside of myFunction
// console.log(myVar);

// now remove the console log line to pass the test

not sure why I am getting the error "No global myVar variable"
Michael Suchorolski
@mikesuchor
Mar 23 2016 07:50
ah I see
@monoposon thanks
CamperBot
@camperbot
Mar 23 2016 07:50
mikesuchor sends brownie points to @monoposon :sparkles: :thumbsup: :sparkles:
:star: 193 | @monoposon | http://www.freecodecamp.com/monoposon
Mark Dickinson
@monoposon
Mar 23 2016 07:51
i got stuck on that one not too long ago, with the same problem
JScapin
@JScapin
Mar 23 2016 07:51
Hi all ! I very get stuck at the JS exercice "Seek and Destroy" because I dont know how to return the inverse of the arguments in .filter ... someone knows?
I know that i have to chech if arguments.length >1 but after i get stuck
uriznik
@uriznik
Mar 23 2016 07:53
@manikanth1024 obj["a"] will look up a, obj.a will do the same, and obj[var] will look up the property based on the value of var
Coy Sanders
@coymeetsworld
Mar 23 2016 07:53
try using the not operator @JScapin (i.e. !)
Darrel Adams
@dadams-510
Mar 23 2016 07:54
Can anyone help me with the Profile lookup challenge?
JScapin
@JScapin
Mar 23 2016 07:54
@coymeetsworld does this will works : arr.filter(function(a){return!a}) ?
Darrel Adams
@dadams-510
Mar 23 2016 07:55
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop){
// Only change code below this line
    for(var i = 0; i < contacts.length; i++) {
      for(var j = 0; j < contacts[i]; j++) {
        if()
      }
    }
// Only change code above this line
}
Manikanth
@manikanth1024
Mar 23 2016 07:55
i didn't understand uriznik
Coy Sanders
@coymeetsworld
Mar 23 2016 07:56
@JScapin idk, I'm not sure what you're trying to do. What do you mean by inverse of the array?
JScapin
@JScapin
Mar 23 2016 07:56
@dadams-510 if contacts[i].firstname === firstname ;)
kirill-2l
@kirill-2l
Mar 23 2016 07:57
@JScapin Hi!
Pascal T.
@omegga
Mar 23 2016 07:57
@JScapin return element !== argumentI guess this works
JScapin
@JScapin
Mar 23 2016 07:57
@coymeetsworld if an argument is find by the filter : dont return this but all which is not this
@kirill-2l hi!! ou encglish is bad but if i speak french or you speah russian, we will never understand each other :D
Darrel Adams
@dadams-510
Mar 23 2016 07:58
@JScapin How would I check if the value matches the "prop" paramenter?
kirill-2l
@kirill-2l
Mar 23 2016 07:58
@JScapin :smile:
Darrel Adams
@dadams-510
Mar 23 2016 07:59
It wants me to check if firstName is correct but also if the firstName and value is correct.

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

JScapin
@JScapin
Mar 23 2016 08:00
@dadams-510 warninig : reag again the exercice : prop it is what you have to check in the Object if the object.fisrtname propriety is your argument "firstname" ;) (firstname is an argument and also a propriety
Coy Sanders
@coymeetsworld
Mar 23 2016 08:00
right @JScapin so the Array.filter command takes in a function and this function is run on every item in the array
the function needs to return true or false, if it returns false the item is filtered out, if its true it stays in
so you wouldn't do !a
JScapin
@JScapin
Mar 23 2016 08:01
@coymeetsworld okay thanks im gonna try and i will come back if i get stuck again
CamperBot
@camperbot
Mar 23 2016 08:01
jscapin sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 374 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Mar 23 2016 08:02
ok, try reading the code example on the challenge it should help, you should only need to make a minor tweak to it
JScapin
@JScapin
Mar 23 2016 08:02
@coymeetsworld so the functon has to be function(a){return a }?
Coy Sanders
@coymeetsworld
Mar 23 2016 08:02
well that won't filter anything
JScapin
@JScapin
Mar 23 2016 08:02
I am a nooooob
:'(
Coy Sanders
@coymeetsworld
Mar 23 2016 08:03
its ok lol
Darrel Adams
@dadams-510
Mar 23 2016 08:03
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop){
// Only change code below this line
    for(var i = 0; i < contacts.length; i++) { //iterate over the array
      for(var j = 0; j < contacts[i]; j++) {
        if(contacts[i].firstname === firstname) {
          return prop;
        }
        else if (contacts[i].firstName != firstname) {
          return "No such contact";
        }
        else {
          return "No such property";
        }
      }
    }
Coy Sanders
@coymeetsworld
Mar 23 2016 08:03
just try reading what the example is telling you
Pascal T.
@omegga
Mar 23 2016 08:03
@JScapin if you return true, filter keeps element otherwise it doesnt keep element
JScapin
@JScapin
Mar 23 2016 08:04
@dadams-510 if contacts[i].firstname === firstname you have to check if this object has the propriety "prop"
Darrel Adams
@dadams-510
Mar 23 2016 08:04
@JScapin do I check this within the first "if" statement?
JScapin
@JScapin
Mar 23 2016 08:04
element is it a global object like arguments?
Pascal T.
@omegga
Mar 23 2016 08:05
@JScapin the element im talking about is the item that filter is analysing each time
pankaj kumar
@pankajkumar229
Mar 23 2016 08:06

@pankajkumar229
Instructions : Declare a local variable myVar inside myFunction
Code :
function myFunction() {
'use strict';

   var myVar = 10;
   console.log(myVar);
}
myFunction();

// run and check the console 
// myVar is not defined outside of myFunction
// console.log(myVar);

// now remove the console log line to pass the test

not sure why I am getting the error "No global myVar variable". Please help

JScapin
@JScapin
Mar 23 2016 08:06
@Scriptonaut can we say that element is like currentVal?
sorry if i get very wrong
Pascal T.
@omegga
Mar 23 2016 08:07
@JScapin
array.filter(function(element) {  
return true;  //keeps element in the array
return true; //does not keep element
return element; //also keeps element
});
kirill-2l
@kirill-2l
Mar 23 2016 08:07
@pankajkumar229 inside function write myVar = 5; for example
Pascal T.
@omegga
Mar 23 2016 08:08
@JScapin yes element in my example is the current item in the loop of filter()
pankaj kumar
@pankajkumar229
Mar 23 2016 08:09
that makes the error stay and also adds another error "Add a local myVar variable"
lpix
@lpix
Mar 23 2016 08:09
@JScapin element is like using a variable for your function...you can call it anything you want
JScapin
@JScapin
Mar 23 2016 08:09
like a called it "a" in my exemples
i think i will write a function myFilter(a){if (a===true){return true}return false;} then call it in the filter
Pascal T.
@omegga
Mar 23 2016 08:11
@JScapin
[1,2,3,4,5].filter(function(element){
return element>3; //will return [4,5] because condition is "true" on 4 and 5
});
JScapin
@JScapin
Mar 23 2016 08:11
so how do complicated when it is simple maybe
kirill-2l
@kirill-2l
Mar 23 2016 08:11
@pankajkumar229

@pankajkumar229 function myFunction() {
var myVar = 2;

console.log(myVar);
}
myFunction();

JScapin
@JScapin
Mar 23 2016 08:12
@Scriptonaut so to keep items which are not in the filter your function would return !element, is it good ?
:'(
Pascal T.
@omegga
Mar 23 2016 08:14

@JScapin
you can do something like that :

[1,2,3,4,5].filter(function(element){
return element!==3; //will return [1,2,4,5]
})

there are different ways depending on the exercice

pankaj kumar
@pankajkumar229
Mar 23 2016 08:14
@kirill-2l thanks. Not sure why 2 instead of 10 worked
CamperBot
@camperbot
Mar 23 2016 08:14
pankajkumar229 sends brownie points to @kirill-2l :sparkles: :thumbsup: :sparkles:
:star: 3 | @kirill-2l | http://www.freecodecamp.com/kirill-2l
JScapin
@JScapin
Mar 23 2016 08:16
ooooh and in a for loop can i write something like this : (myArr = arr.filter(function(element){return element !== (arguments[i])}));
or the function can't call the i variable
Pascal T.
@omegga
Mar 23 2016 08:17
@JScapin you can do anything(loops,etc) inside filter(), as long as in the end you return true(and choose to keep the item) or false(not keeping it)
JScapin
@JScapin
Mar 23 2016 08:18
Thanks @Scriptonaut @lpix @coymeetsworld and enjoy your brownies !!!
CamperBot
@camperbot
Mar 23 2016 08:18
jscapin sends brownie points to @scriptonaut and @lpix and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: jscapin already gave coymeetsworld points
:star: 311 | @lpix | http://www.freecodecamp.com/lpix
:star: 326 | @scriptonaut | http://www.freecodecamp.com/scriptonaut
Coy Sanders
@coymeetsworld
Mar 23 2016 08:19
np @JScapin
Pascal T.
@omegga
Mar 23 2016 08:19
@JScapin
[1,2,3,4,5].filter(function(element){
var ok = true;
for(var i=0;i <someArray.length;i++){
if( element!==someArray[i]){
ok = false;
}
return ok;
})
kirill-2l
@kirill-2l
Mar 23 2016 08:20
i have passed my first chalange, congratulate me :smile:
JScapin
@JScapin
Mar 23 2016 08:20
congratulation !!! which one is it ?
kirill-2l
@kirill-2l
Mar 23 2016 08:21
@JScapin JS introdution :smile:
JScapin
@JScapin
Mar 23 2016 08:24
In french we say Félicitations for congratulate ^^ For my part there are 3exercice left to finish Basic Algorithm scripting :) and I cant wait to discover AJAX
I can't wait discovering Ajax
kirill-2l
@kirill-2l
Mar 23 2016 08:28
@JScapin now i am at Basic Algorithm scripting, which you have already finished
JScapin
@JScapin
Mar 23 2016 08:36
good luck and get the wiki of array methods open in your browser :D
kirill-2l
@kirill-2l
Mar 23 2016 08:38
@JScapin i have already opened :smile: Here is rather difficult
JScapin
@JScapin
Mar 23 2016 08:41
yes but algorythmic needs to realy well read what is asked. Take time to read can avoid you to loose a lot of time... because sometiimes it is easier that what you thought