These are chat archives for FreeCodeCamp/HelpJavaScript

16th
Jun 2016
Alex Harshaw
@aharshaw
Jun 16 2016 00:00
I don't know. @Chrono79. My logic is saying, "if the item entered into checkObj() === gift, then return myObj.gift;
But I know that's not what the exercise is looking for
I understand why my code is wrong now, but I don't know how to fix it
Thomas G.
@CaptainMurphey
Jun 16 2016 00:01
hey guys i need a little help with the twitter API, for the random quote machine project heres http://codepen.io/CaptainMurphey/pen/zqXvMM but im converting the quote with function share(){
var quoteTweet = quote;
quoteTweet = encodeURI(quoteTweet);
window.open( href="https://twitter.com/intent/tweet?text=" + quoteTweet );
console.log(quoteTweet);
in the console it show quote tweet as the quote correctly formatted but it wont ad it to the url link, anyone know why?
Jamil Akhtar
@frontender007
Jun 16 2016 00:03
hi guys
I'm at ecape sequence in a string section
my code is not working please
var myStr = '\ \t\t \r \n'; // Change this
Diego Mayer
@Chrono79
Jun 16 2016 00:04
@frontender007 you're missing some space between the tabs
Jamil Akhtar
@frontender007
Jun 16 2016 00:05
thanks @Chrono79
CamperBot
@camperbot
Jun 16 2016 00:05
frontender007 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1189 | @chrono79 |http://www.freecodecamp.com/chrono79
David Halls
@DavidHalls
Jun 16 2016 00:08
@CaptainMurphey not sure what you mean, it takes me to twitter
shahutsav
@shahutsav
Jun 16 2016 00:08
@Byzgig Can't believe I messed that. Lol
@Byzgig thanks a lot!
CamperBot
@camperbot
Jun 16 2016 00:08
shahutsav sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 322 | @byzgig |http://www.freecodecamp.com/byzgig
Thomas G.
@CaptainMurphey
Jun 16 2016 00:08
@Byzgig yeah but it should be adding the quote to the text box thats inside the new twitter page
David Halls
@DavidHalls
Jun 16 2016 00:09
@CaptainMurphey your code is opening two twitter windows, one of them has the quote in it, one of them doesnt
Thomas G.
@CaptainMurphey
Jun 16 2016 00:10
@Byzgig really? what browser are you using, mine just opens one with a blank
David Halls
@DavidHalls
Jun 16 2016 00:11
@CaptainMurphey firefox
Bryant Biggs
@bryantbiggs
Jun 16 2016 00:12
help caesars cipher
CamperBot
@camperbot
Jun 16 2016 00:12

:point_right: algorithm caesars cipher [wiki]

Algorithm Caesars Cipher

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

  • You need to write a function, which will take a string encoded with Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is shifted by 13 places. e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.

:pencil: read more about algorithm caesars cipher on the FCC Wiki

Thomas G.
@CaptainMurphey
Jun 16 2016 00:13
@Byzgig ok cool so now i know its just some weird chrome BS
nsloc22
@nsloc22
Jun 16 2016 00:17
@CaptainMurphey you have two share functions in different scopes, first window.open gets blocked by chrome, second opens this url "https://twitter.com/intent/tweet?text="
ComicCaper
@ComicCaper
Jun 16 2016 00:19
Hi all.
I'm stuck on this statement, can't get it to work: collection[id][prop].push("value");
Stephen James
@sjames1958gm
Jun 16 2016 00:23
@ComicCaper value is a variable so it shouldn't be in ""
@ComicCaper Also, track property may not exist, you will need to check it and initialize to [] before push
lettda
@lettda
Jun 16 2016 00:28
just learned about regular expressions....pretty dope
ComicCaper
@ComicCaper
Jun 16 2016 00:30
@sjames1958gm Ok, I think the other version I tried, "value" wasn't in quotes. Ah, ok, it's probably the check it and initialize part, I need to work on. Thanks
CamperBot
@camperbot
Jun 16 2016 00:30
comiccaper sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1570 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 16 2016 00:30
@ComicCaper :+1:
Eric Averitt
@EricAveritt
Jun 16 2016 00:36
Quick question. In jQuery when I do addClass how do I know where it's being added from? For example, if I do .addClass("shake") it should use the animate.css. In the next example I have to do .addClass("btn-primary") and that uses Bootstrap I'm assuming. But how can I know?
.addClass("animated shake")*
estnimbus
@estnimbus
Jun 16 2016 00:38
Anybody knows the answer to Counting Cards
David Halls
@DavidHalls
Jun 16 2016 00:41
@estevenimbus yes
lettda
@lettda
Jun 16 2016 00:42
@EricAveritt yes the btn-primary is for bootstrap, only way to know is to check the docs I think. But I believe when you add the framework to your code it allows access to functions and variables that are from that framework...if that makes sense
Eric Averitt
@EricAveritt
Jun 16 2016 00:43
@lettda So it can pull from all css you have added to your html page then?
lettda
@lettda
Jun 16 2016 00:43
@EricAveritt you mean from that specific class?
if you addClass("btn-primary") what ever CSS you have for that class will effect all elements with that class name
Eric Averitt
@EricAveritt
Jun 16 2016 00:46

@lettda From this in the challenge "Target the same element with multiple jQuery Sectors" it has this code:

<script>
  $(document).ready(function() {
     $("button").addClass("animated");
     $(".btn").addClass("shake");
    $("#target1").addClass("btn-primary");

  });
</script>

Which would tell me it's using a class from the animate.css (which FreeCodeCamp said was preloaded in the page) and the Bootstrap css

Is that correct or are there classes for animate and shake in Bootstrap?
Sean DiSanti
@badc0ded
Jun 16 2016 00:47
if you inspect element and look at styles, it will say where the style came from
Eric Averitt
@EricAveritt
Jun 16 2016 00:50
@badc0ded Thanks. I'm trying to find it on the page... O.O
CamperBot
@camperbot
Jun 16 2016 00:50
ericaveritt sends brownie points to @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 380 | @badc0ded |http://www.freecodecamp.com/badc0ded
Eric Averitt
@EricAveritt
Jun 16 2016 00:55
@badc0ded I guess I need practice at the inspection but this helped. I guess what I want to know is that jQuery's addClass will add any class that you have css for? Even if you have 5 different .css pages and you do an addClass, it can add classes from any of those other css?
Sean DiSanti
@badc0ded
Jun 16 2016 00:55
it will add literally whatever you tell it to
the css being there is irrellevant
all it does is put the literal string into the class attribute
the css is applied when it's rendered
estnimbus
@estnimbus
Jun 16 2016 00:56

@Byzgig

var count = 0;

function cc(card) {
// Only change code below this lin

$$LaTeX code$$

'''
if( 1 < card < 7 ){ return(count += 1);}

else if ( 6 < card < 10){ return ( count = count + 0);}

else{ return (count = count - 1);}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
'''

CamperBot
@camperbot
Jun 16 2016 00:56
:bulb: to format code use backticks! ``` more info
Eric Averitt
@EricAveritt
Jun 16 2016 00:57
@badc0ded oh!!!! Got it now! Click for me. Thanks so much!
CamperBot
@camperbot
Jun 16 2016 00:57
ericaveritt sends brownie points to @badc0ded :sparkles: :thumbsup: :sparkles:
:warning: ericaveritt already gave badc0ded points
Eric Averitt
@EricAveritt
Jun 16 2016 00:57
@lettda Thank you as well lettda
Sean DiSanti
@badc0ded
Jun 16 2016 00:57
no problem, i'm glad i could help
CamperBot
@camperbot
Jun 16 2016 00:57
ericaveritt sends brownie points to @lettda :sparkles: :thumbsup: :sparkles:
:cookie: 249 | @lettda |http://www.freecodecamp.com/lettda
estnimbus
@estnimbus
Jun 16 2016 00:58
'''
if( 1 < card < 7 ){ return(count += 1);}
else if ( 6 < card < 10){ return ( count = count + 0);}
else{ return (count = count - 1);}
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
CamperBot
@camperbot
Jun 16 2016 00:58
:bulb: to format code use backticks! ``` more info
estnimbus
@estnimbus
Jun 16 2016 00:59
if( 1 < card < 7 ){ return(count += 1);}
else if ( 6 < card < 10){ return ( count = count + 0);}
else{ return (count = count - 1);}
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Sean DiSanti
@badc0ded
Jun 16 2016 00:59
help format
CamperBot
@camperbot
Jun 16 2016 00:59

: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 thecode`.

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

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

estnimbus
@estnimbus
Jun 16 2016 00:59
@Byzgig
Moisés Man
@moigithub
Jun 16 2016 01:00
on javascript u need to make multiple expression and join by a logical operator...
if( 1 < card < 7 ){ <--doesnt work
@estevenimbus
(card>1 && card<7)
estnimbus
@estnimbus
Jun 16 2016 01:01
@moigithub
thanks
I think my logic is still wrong if you would check that out for me @moigithub
If you did that already of course @moigithub
Moisés Man
@moigithub
Jun 16 2016 01:03
after evaluate and inc/dec count.. u need to evaluate the value of count.. and return bet or hold.. according to the instructions @estevenimbus
Ryan Marten
@RyanMarten
Jun 16 2016 01:17
I am having major issues with a post reuest
with ajax and php
can someone help?
$.ajax({
            type: 'POST',
            url: '../db-interaction/remove.php', 
            data: "{'data1':'" + value1+ "', 'data2':'" + value2+ "', 'data3':'" + value3+ "'}"
           // data: "{'id' : " + id + ", 'action' : 'remove'}"
        })
        .done(function(data){

            // show the response
            $('#status').html('<i>Successful: ' + data + '</i>');

        })
        .fail(function() {

            // just in case posting your form failed
            $('#status').html('<i>Failed</i>');

        });
if ($_SERVER["REQUEST_METHOD"] == "POST") {
                $queue = new Queue($db);
                echo 'TEST';
                echo "<pre>";
                print_r($_POST);
                echo "</pre>";
                if($_POST['action']=='remove'){
                    echo "HELLO!";
                    $myQueue->removeTicketFromID($_POST['id']);
                }
            }
Test shows up
and an array
but it is empty
Mariya
@mariyadiminsky
Jun 16 2016 01:22
f anyone worked with Phaser before..I installed Phaser with node. I keep getting Phaser is not defined in my main.js, and I can't require since it's client side...I tried adding in webpack but in the end I still get the same error...Phaser is not defined. Has anyone else run into this issue?
Also tried adding this in index.html before my main.js script since I npm installed it..Same issue: <script type="text/javascript" src='./node_modules/phaser/build/phaser.js'></script>
walkermarquan
@walkermarquan
Jun 16 2016 01:24
I'm not sure how to write the code for "Finding a remainder in JavaScript" can anyone help pls ??
Fernando Souza
@fernandosouza
Jun 16 2016 01:35
Hi guys. I finished the "Sum All Numbers in a Range Incomplete" challenge but I would like to compare my solution with yours. How can I do that?
Eden Coleman
@nede36
Jun 16 2016 01:36
@walkermarquan I can help, what do you have so far?
just use the "%" @walkermarquan
Ari
@arilaverty
Jun 16 2016 01:36
How do I isolate the first number in each sub-array? I have made it so each subarray arranges the number from highest to lowest, now I want the first number of each.
function largestOfFour(arr) {
    var array = [arr];
    var newArray = array[0];

    for (var i = 0; i < array.length; i++) {
        array[i].map(function(x) {
            return x.sort(function(a, b) {
                return b - a;
            });
        });

    }

return newArray; // Returns each subarray rerranged from highest to lowest YEY!


}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
walkermarquan
@walkermarquan
Jun 16 2016 01:41
I have everything but it keeps saying "you should use the % operator @nede36
Coy Sanders
@coymeetsworld
Jun 16 2016 01:42
@himynameisari arr[0]?
Ari
@arilaverty
Jun 16 2016 01:44
@coymeetsworld for some reason if I don't it comes out as an array within an array and then the sub arrays
eg. [[1, 2, [3]]]
Coy Sanders
@coymeetsworld
Jun 16 2016 01:44
array.map doesn't mutate the array, you have to assign it back
verdelegend
@verdelegend
Jun 16 2016 01:45
I don't understand"understanding uninitialized variables"
Eden Coleman
@nede36
Jun 16 2016 01:45
Can you send an image of your code?
@walkermarquan
IndiraShrestha
@IndiraShrestha
Jun 16 2016 01:46
Hi, I am working on the falsy bounce challenge and here is my code so far
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  function checkBooleanValue (valueFromArr){
    return valueFromArr === true;   
  }  
  return arr.filter(checkBooleanValue);
}

bouncer([7, "ate", "", false, 9]);
Ari
@arilaverty
Jun 16 2016 01:46
@coymeetsworld Sorry, not sure what that means, pretty novice
IndiraShrestha
@IndiraShrestha
Jun 16 2016 01:46
not sure why it's returning an empty array
Coy Sanders
@coymeetsworld
Jun 16 2016 01:46
try looking at the documentation for map @himynameisari : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
Ari
@arilaverty
Jun 16 2016 01:47
Ok will do, thanks @coymeetsworld
CamperBot
@camperbot
Jun 16 2016 01:47
himynameisari sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1154 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 16 2016 01:47
np, also map is not necessary for this challenge, it can be done with strictly for loops
if you're having trouble understanding how it works maybe skip maps for later, you can use them at another time
verdelegend
@verdelegend
Jun 16 2016 01:47
var a;
how do I make that equal 6
Coy Sanders
@coymeetsworld
Jun 16 2016 01:48
you use the equals operator @verdelegend
and put the value you want to assign the left side to on the right
like var a = 6;
Eden Coleman
@nede36
Jun 16 2016 01:48
for example @walkermarquan var remainder = 11 % 3;

var count = 0;
function cc(card) {
// Only change code below this line
if (1 < card < 7) {
return (count += 1);
} else if (6 < card < 10) {
return (count + 0);

} else {
return (count = count -1);
}

return "Change Me";
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(5); cc(5); cc(7); cc('K'); cc('A');

What am I missing?
Coy Sanders
@coymeetsworld
Jun 16 2016 01:50
you're not accounting for the face cards or ace @nede36
also return statements are wrong
you want to return count + either Bet or Hold, like "5 Bet", "0 Hold", etc
I would suggest using a case/switch statement to strictly modify the count variable where appropriate, and then check the count on whether to print out Bet or Hold
there is no 1 card either so you can remove that
just like a normal playing card deck
Eden Coleman
@nede36
Jun 16 2016 01:53
I was looking at the "1" as an Ace so thank you for clarifying. Awesome thank you for mentioning switch statements, I thought of that but I wasn't sure. Back to the drawing board @coymeetsworld
CamperBot
@camperbot
Jun 16 2016 01:53
nede36 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1155 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
FM
@mafelix
Jun 16 2016 01:53
I have a question on where do I belong
Is the last test broken?
Coy Sanders
@coymeetsworld
Jun 16 2016 01:53
switch is good, much shorter code than doing a bunch of if else statements
FM
@mafelix
Jun 16 2016 01:54
find
CamperBot
@camperbot
Jun 16 2016 01:54

find undefined

more entries:
undefined

Coy Sanders
@coymeetsworld
Jun 16 2016 01:54
also better for handling Strings (face cards and ace) and numbers
FM
@mafelix
Jun 16 2016 01:54
where do i belong the last test I think is broken.
nvm
IndiraShrestha
@IndiraShrestha
Jun 16 2016 01:59
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  function checkBooleanValue (valueFromArr){

    return valueFromArr === true;
  }  
  return arr.filter(checkBooleanValue);
}

bouncer([7, "ate", "", false, 9]);
the function is work out here for checking the boolean in array
any suggestions?
FM
@mafelix
Jun 16 2016 02:00
@IndiraShrestha I don't understand what you mean
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:00
it's for the challenge falsy bounce
FM
@mafelix
Jun 16 2016 02:00
I still don't get what you mean
what are you asking?
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:00
and my thought process is to pass the boolean function to filter
FM
@mafelix
Jun 16 2016 02:01
that's fine
it works
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:01
@mafelix I guess in short my code is wrong
FM
@mafelix
Jun 16 2016 02:01
yes it is wrong.
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:01
@mafelix my question is how do i fix it
FM
@mafelix
Jun 16 2016 02:02
you have to figure out to logic to put in your function checkBooleanValue
what is that function doing?
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:02
@mafelix that was my question
FM
@mafelix
Jun 16 2016 02:02
and what do you want it to do?
so you just want me to give you the answer?
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:02
@mafelix no not the answer
Eden Coleman
@nede36
Jun 16 2016 02:03

@coymeetsworld This more on the right track?:
var count = 0;

function cc(card) {
// Only change code below this line

switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count = card + 1;
break;
case 7:
case 8:
case 9:
count = card + 0;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count = card - 1;
break;
}

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

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

FM
@mafelix
Jun 16 2016 02:03
then tell me what is that function doing right now, and what do you want it to do?
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:03
i think i am returning if the valueofArr is true
Eden Coleman
@nede36
Jun 16 2016 02:03
Sorry for copying and pasting I don't know how to get the code screenshots in here lol
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:03
which is then passed on to filter the array
Coy Sanders
@coymeetsworld
Jun 16 2016 02:03
don't add the card to the count @nede36
FM
@mafelix
Jun 16 2016 02:03
yes
Coy Sanders
@coymeetsworld
Jun 16 2016 02:03
you just need to increment the count by 1, decrement by 1, or do nothing
FM
@mafelix
Jun 16 2016 02:04
so what does that mean in that function?
break it down
and break down what you want to do
whats the arguement you're taking in that function?
what is valueofArr?
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:05
@mafelix the function is just returning if the value of the array is true which is then passed on to filter
FM
@mafelix
Jun 16 2016 02:05
and how are you getting the value of the array?
where is that code?
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:06
from my understanding valueFromArr is parameter which will take an argument when i call in when i use arr.filter(checkBooleanValue)
FM
@mafelix
Jun 16 2016 02:06
?
you're wrong
yes you're right
but where do you get that arguement from?
arr.filter(checkBooleanValue) <--- you are not passing any parameters right now
why is that?
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:07
@mafelix i was reading the mozilla website for filter method
FM
@mafelix
Jun 16 2016 02:08
so does your code run?
you're calling filter on arr
and passing another function as a parameter
Rada
@Radascript
Jun 16 2016 02:08
hey guys, when there is a line:
if (--timer < 0)
is it doing timer=timer-1 within the condition, or is it just evaluating whether timer-1<0?
FM
@mafelix
Jun 16 2016 02:08
but that function takes a parameter itself
so when you test your code what happens?
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:08
arr is a parameter for a function bouncer
it just gives empty array
FM
@mafelix
Jun 16 2016 02:08
why?
because valueofArr is never defined
Coy Sanders
@coymeetsworld
Jun 16 2016 02:09
@Radascript I believe it first decrements the timer variable by 1, then checks if its less than 0
FM
@mafelix
Jun 16 2016 02:09
and your own code in there is return valueofArr === true
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:09
from what i am gathering a argument won't work for filter
FM
@mafelix
Jun 16 2016 02:09
so that never ever ever runs
Rada
@Radascript
Jun 16 2016 02:09
@coymeetsworld makes sense, thank you :)
CamperBot
@camperbot
Jun 16 2016 02:09
radascript sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1156 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 16 2016 02:09
no problem :thumbsup:
FM
@mafelix
Jun 16 2016 02:09
then if it doesn't work then you need to change your code no?
make the checkBooleanValue take no parameters
do something like this
Chipi
@Chipsta
Jun 16 2016 02:10
hey guys ran into a problem in problem number (200) called "Counting Cards".
Eden Coleman
@nede36
Jun 16 2016 02:10
So in the switch when I make count -= 1 etc. I also need it to display "Bet" or "Hold" where exactly would I add those strings in the switch statement? @coymeetsworld
Coy Sanders
@coymeetsworld
Jun 16 2016 02:11
you don't
Chipi
@Chipsta
Jun 16 2016 02:11

var count = 0;

function cc(card) {
// Only change code below this line
var count = cc;
switch (card) {
case 1,2,3,4,5,6:
return "5 Bet" ;
break ;
case 7,8,9 :
return "0 Hold";
break;
case 10,"J","Q","K","A" :
return "-5 Hold" ;
break;
case 3,7,"Q",8,"A" :
return "-1 Hold" ;
break ;
case 2,2,10 :
return "1 Bet" ;
break ;
case 2,"J",9,2,7:
return "1 Bet" ;
break ;
case 3,2,"A", 10,"K":
case 3,7,"Q",8,"A" :
return "-1 Hold" ;
break ;

}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(10); cc("J"); cc("Q"); cc("K"); cc("A");

FM
@mafelix
Jun 16 2016 02:11
function checkBooleanValue(){ arr.forEach(function(value){ //your conditionals here }) }
Coy Sanders
@coymeetsworld
Jun 16 2016 02:11
first thing is look at the card, and modify the count variable as appropriate. That is done through case/switch
then, after that you look at the count variable and determine what to return
Chipi
@Chipsta
Jun 16 2016 02:11
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"
FM
@mafelix
Jun 16 2016 02:12
or better yet
Coy Sanders
@coymeetsworld
Jun 16 2016 02:12
you could use an if/else statement for that
@Chipsta 3,7,Q,8,A is actually 5 separate calls to the cc function
FM
@mafelix
Jun 16 2016 02:13
I'll tell my general thoughts on this problem.
take it for what it is.
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:13
@mafelix thank you
CamperBot
@camperbot
Jun 16 2016 02:13
indirashrestha sends brownie points to @mafelix :sparkles: :thumbsup: :sparkles:
:cookie: 281 | @mafelix |http://www.freecodecamp.com/mafelix
Chipi
@Chipsta
Jun 16 2016 02:13
i tried the if/else statements the code was not showing after the first if statement, & stopped showing on else if statements.
James S.
@Mrblue27
Jun 16 2016 02:13
This message was deleted
Coy Sanders
@coymeetsworld
Jun 16 2016 02:13
cc(3) would make count = 1, cc(7) keeps count at 1, cc(Q) subtracts one from the count so its now 0, cc(8) keeps count at 0, cc(A) subtracts one from the count so now count would equal -1
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:14
I am still trying to understand what you said :point_up: June 15, 2016 10:08 PM
any feedback is great
and much appreciated
FM
@mafelix
Jun 16 2016 02:14
you have an function bouncer(arr) <---- that takes an array of w/e
you have to make sure every element of that arr passes certain checks <--- more specifically falsy values in javascript checks
then you return the array with those values removed
you can use filter
Eden Coleman
@nede36
Jun 16 2016 02:15
Yupp I got that, I just can't figure out how to get it to display the count as well as Hold or Bet
FM
@mafelix
Jun 16 2016 02:15
you can use map
you can use forEach to make these checks
Chris Cullen
@123xylem
Jun 16 2016 02:15
I have just completed Symmetric Differences... BUT I Had to CHEAT. And I dont understand some of f this code... Is there something that can help me understand it. my comments are my understanding of it.. How correct are they?
function sym(args) {

  var argz = Array.prototype.slice.call(arguments);

  // Return the symmetric difference of 2 arrays
  var getDiff = function(arr1, arr2) {

//Creates function that Returns items in arr1 != arr2
    function filterFunction(arr1, arr2) {
      return arr1.filter(function(item) {
        return arr2.indexOf(item) === -1;
      });
    }
//Now it uses that filterFunction on both arrays and joins them
return filterFunction(arr1,arr2).concat(filterFunction(arr2,arr1));
    };

//Here we actually START the function on argz. we reduce argz with getDiff function and an empty array.
 var symArray= argz.reduce(getDiff,[]);

  //So far it only works for 2 args so
  //here we filter the array returning the index of a num in array
 //if its the first instance of this. index=== num in arr means first instance of num in arr return that index value.
  var answer=symArray.filter(function(num,index,arr){
    return index===arr.indexOf(num);
  });

  return answer;

}

sym([1, 2, 3], [5, 2, 1, 4]);
Jonathan Mitchell
@Vanhealen
Jun 16 2016 02:16
is it bad practice to use a loop inside a conditional?
ie if I use a for loop inside of an if statement???
would it be better to use the loop on the outside and the if statement on the inside?
Tim Crockett
@BoboMunkee
Jun 16 2016 02:19
@Vanhealen It depends, do you need to check the if statement every time the loop executes? or do you only need to check it once and the outcome determines if the loop executes.
FM
@mafelix
Jun 16 2016 02:19
@IndiraShrestha
return arr.filter(function(element){ if(element !== false && element !== null && element !== NaN && element !== "" && element !== undefined){ return element; } });
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:21
@mafelix thank you but i guess i need to re-read the material about boolean
CamperBot
@camperbot
Jun 16 2016 02:21
indirashrestha sends brownie points to @mafelix :sparkles: :thumbsup: :sparkles:
:warning: indirashrestha already gave mafelix points
Jonathan Mitchell
@Vanhealen
Jun 16 2016 02:22
@BoboMunkee check it once
IndiraShrestha
@IndiraShrestha
Jun 16 2016 02:22
@mafelix I think it has be simpler than that
Jonathan Mitchell
@Vanhealen
Jun 16 2016 02:22
@BoboMunkee it doesnt matter, both work. I just put the if statement on the outside because I didn't want to go into the for loop if I didn't need to
FM
@mafelix
Jun 16 2016 02:24
@IndiraShrestha you can definitely modify the code. to learn more about how javascript sees things. if I'm testing to see if it's NOT falsy values
see if you can test for TRUTHY values and just return that instead
@IndiraShrestha then you don't need that long if conditional statement
Carlo Gonzales
@gonyolac
Jun 16 2016 02:25
hey everyone can someone explain to me what this block of code means?
var cur, memo = memo || [];
FM
@mafelix
Jun 16 2016 02:26
@gonyolac you're defining two variables
var cur = memo || []; var memo = memo || [];
so if memo is not defined it equals an empty array
Tim Crockett
@BoboMunkee
Jun 16 2016 02:27
@Vanhealen It may work in certain situations, but they do very different things. A loop in an if statement means the if always get checked once, but the loop may not ever execute. An if within a loop means the if will get checked everytime it loops.
Christian Hansen
@ChrisWcs
Jun 16 2016 02:29

function bouncer(arr) {

arr = arr.filter(isntFalsy);

return arr;
}
function isntFalsy(value){

var bol = true;

if(value === false){
bol = false;
}else if(value === 0){
bol = false;
}else if(value === null){
bol = false;
}else if(value === ""){
bol = false;
}else if(value === undefined){
bol = false;
}else if(isNaN(value)){
bol = false;
}
return bol;
}

bouncer([7, "ate", "", false, 9]);

FM
@mafelix
Jun 16 2016 02:29
@gonyolac loop up how || statements are evaluated.
Christian Hansen
@ChrisWcs
Jun 16 2016 02:29
so my code up above deletes all strings and I am not sure why....?
Carlo Gonzales
@gonyolac
Jun 16 2016 02:29
@mafelix Thanks! Couldn't think of any search keyword for this
CamperBot
@camperbot
Jun 16 2016 02:29
gonyolac sends brownie points to @mafelix :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @mafelix |http://www.freecodecamp.com/mafelix
Alvin Li
@ShadowInkLee
Jun 16 2016 02:31
windows user
FM
@mafelix
Jun 16 2016 02:31
@ChrisWcs you're having the same problems as @IndiraShrestha
you're passing arr.filter a function that takes a parameter
I'm not entirely sure if you can or cannot do that.
where is value defined?
javascript doesn't care if you pass in the right amount of parameters in your functions
if you pass in too many it ignores them
if you don't pass in enough it will still try to run the function
so I think you two are trying to be too fancy without understanding the fundamentals
Christian Hansen
@ChrisWcs
Jun 16 2016 02:33
Thanks, I will look in to this and read more
FM
@mafelix
Jun 16 2016 02:36

function test(oneparameter){
return oneparameter;
}

test('hello world');
test();
test('hell','o','a','a','a');

these calls all run
javascript doesn't throw errors if you call functions without the appropriate parameters
troyc12
@troyc12
Jun 16 2016 02:40
hello, I was wondering if someone could helpwith why my code isnt working? It is the Record Collection challenge
```
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

   if (prop == "tracks" && value !== ""){
    collection[id][prop].push(value);
    } else if (value !==""){
     collection[id][prop] = value;
       } else if (value === ""){
         delete collection[id][prop];
       } 

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Arsalan Savand
@ArsalanSavand
Jun 16 2016 02:43
Hi everyone
i have a small problem here
so can anyone help me with this>

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

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

// Test your code by modifying these values
checkObj("gift");
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
i did anything but it seems little bit idk
can anyone help ??
FM
@mafelix
Jun 16 2016 02:45
@ChrisWcs

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  function test(obj){
    if(obj){
      return obj;
    }
  }

  return arr.filter(test);
}

bouncer([7, "ate", "", false, 9]);
Micah Bales
@micahbales
Jun 16 2016 02:46
Quick question: Any idea why the jquery in lines 106 and 109 isn't turning the #strict button red? http://codepen.io/micahbales/pen/MegRqm?editors=0010
FM
@mafelix
Jun 16 2016 02:46
@ChrisWcs @IndiraShrestha you may pass functions into filter without defining the parameters. it runs that function and passes every element of array into that function as the parameter.
Eden Coleman
@nede36
Jun 16 2016 02:46
@Chipsta Did you get your card counter to work properly?
James S.
@Mrblue27
Jun 16 2016 02:47
How do I so a screen shot instead of using my browser
Eden Coleman
@nede36
Jun 16 2016 02:48
Was wondering the same thing @Mrblue27
David Halls
@DavidHalls
Jun 16 2016 02:49
@Mrblue27 what have you got so far
Tyler Moeller
@TylerMoeller
Jun 16 2016 02:49
@ArsalanSavand when accessing data from a JSON object with a variable, you have to use bracket notation: return myObj[checkProp]. More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors
David Halls
@DavidHalls
Jun 16 2016 02:50
help js
CamperBot
@camperbot
Jun 16 2016 02:50

:point_right: challenge accessing nested arrays in json [wiki]

Challenge Accessing Nested Arrays in JSON

As we have seen in earlier examples, JSON objects can contain both nested objects and nested arrays. Similar to accessing nested objects, Array bracket notation can be chained to access nested arrays.

Here is an example of how to access a nested array:

```javascript
var ourPets = {
"cats": [
"Meowzer",
"Fluffy",
"Kit-Cat"
],
"dogs": [
"Spot",
"Bowser",
"Frankie"
]
};
ourPets.cats1; // "Fluffy"
:pencil: read more about challenge accessing nested arrays in json on the FCC Wiki

FM
@mafelix
Jun 16 2016 02:50
@Mrblue27 look up modulus javascript on google
@Mrblue27 or you could write your own code for the remainder. I suggest you reread the instructions.
Arsalan Savand
@ArsalanSavand
Jun 16 2016 02:52
@TylerMoeller thanks alot!
CamperBot
@camperbot
Jun 16 2016 02:52
arsalansavand sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:cookie: 594 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
David Halls
@DavidHalls
Jun 16 2016 02:52
@Mrblue27 Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
Tyler Moeller
@TylerMoeller
Jun 16 2016 02:56
@micahbales Remove the dot . from the class name: $(this).addClass('red-button');
Micah Bales
@micahbales
Jun 16 2016 03:04
@TylerMoeller thank you!
CamperBot
@camperbot
Jun 16 2016 03:04
micahbales sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:cookie: 595 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
Christian Hansen
@ChrisWcs
Jun 16 2016 03:09
@mafelix Thanks for your help!
CamperBot
@camperbot
Jun 16 2016 03:09
chriswcs sends brownie points to @mafelix :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @mafelix |http://www.freecodecamp.com/mafelix
James S.
@Mrblue27
Jun 16 2016 03:09
@Byzgig 11 % 3; ?
David Halls
@DavidHalls
Jun 16 2016 03:10
@mrblue yup, assign that to remainder
James S.
@Mrblue27
Jun 16 2016 03:12
@Byzgig I keep getting unexpected number
David Halls
@DavidHalls
Jun 16 2016 03:13
@mrblue how are you assigning it to remainder?
Chipi
@Chipsta
Jun 16 2016 03:13
@nede36 No im still lost
James S.
@Mrblue27
Jun 16 2016 03:14
@Byzgig not following
David Halls
@DavidHalls
Jun 16 2016 03:15
@Mrblue27 if you want remainder to = 2; how would you do that?
James S.
@Mrblue27
Jun 16 2016 03:16
2 % 3
David Halls
@DavidHalls
Jun 16 2016 03:16
@Mrblue27 does that make remainder 2?
James S.
@Mrblue27
Jun 16 2016 03:16
@Byzgig no
David Halls
@DavidHalls
Jun 16 2016 03:17
@Mrblue27 so, how would you make remainder = 2?
James S.
@Mrblue27
Jun 16 2016 03:17
2 % 1
apbowe
@apbowe
Jun 16 2016 03:18
function titleCase(str) {

  var newArray = str.split(" ");
  var finArray =[];

  for (var x = 0; x < newArray.length; x++) {

    for (var y = 0; y < newArray[x].length; y++) {

      if (y === 0) {
        finArray.push(newArray[x][y].toUpperCase());
      } else {
        finArray.push(newArray[x][y].toLowerCase());
      }
    } finArray.push(" ");       
  }

  return finArray.join("");
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Title Sentence case - my code performs the function but only passes one test. What am I missing?
Should I have used regular expressions?
David Halls
@DavidHalls
Jun 16 2016 03:19
@Mrblue27 ok, it wants you to assign remainder 11 % 3; how would you assign remainder 11 % 3?
James S.
@Mrblue27
Jun 16 2016 03:22
@Byzgig the remainder would be 2
David Halls
@DavidHalls
Jun 16 2016 03:23
@Mrblue27 yes
James S.
@Mrblue27
Jun 16 2016 03:25
@Byzgig I get that and when I enter 2 % 1 it not correct. I thought I could use that value to equal two but I was wrong
Chipi
@Chipsta
Jun 16 2016 03:25

var count = 0;

function cc(card) {
// Only change code below this line
count = [-1,0,+1];
switch (card) {
case 2,3,4,5,6:
return "5 Bet" ;
break ;
case 7,8,9 :
return "0 Hold";
break;
case 10,"J","Q","K","A" :
return "-5 Hold" ;
break;
case 7,8,9 :
return "-1 Hold" ;
break ;
case 2,2,10 :
return "1 Bet" ;
break ;
case 2,"J",9,2,7:
return "1 Bet" ;
break ;
case 3,2,"A", 10,"K":
return "-1 Hold" ;
break ;
}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(10); cc("J"); cc("Q"); cc("K"); cc("A");

David Halls
@DavidHalls
Jun 16 2016 03:26
@Mrblue27 your doing more than you need, over complicating it
Chipi
@Chipsta
Jun 16 2016 03:26
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"
apbowe
@apbowe
Jun 16 2016 03:28
Sentence Title Case - My codes executes the function but only passes one test. What am I missing?
function titleCase(str) {

  var newArray = str.split(" ");
  var finArray =[];

  for (var x = 0; x < newArray.length; x++) {

    for (var y = 0; y < newArray[x].length; y++) {

      if (y === 0) {
        finArray.push(newArray[x][y].toUpperCase());
      } else {
        finArray.push(newArray[x][y].toLowerCase());
      }
    } finArray.push(" ");       
  }

  return finArray.join("");
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Josef Saltz
@JosefSaltz
Jun 16 2016 03:38
Doing the ROT13 excercise, my if statement won't isolate non-alphanumeric when using regular expressions
Joseph
@revisualize
Jun 16 2016 03:38
@inkuplex What are you doing?
Josef Saltz
@JosefSaltz
Jun 16 2016 03:39
Testing if character about to go numeric conversion is a non-alphanumeric character
Joseph
@revisualize
Jun 16 2016 03:39
@Chipsta That isn't correct. You should be modifying the global variable.
James S.
@Mrblue27
Jun 16 2016 03:39
@Byzgig I am a bone head lol. Thanks I got it I over thought the question Time to hit the bed lol
CamperBot
@camperbot
Jun 16 2016 03:39
mrblue27 sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 324 | @byzgig |http://www.freecodecamp.com/byzgig
Josef Saltz
@JosefSaltz
Jun 16 2016 03:40
IDK how to pass my code into the chat
Juan Cortes
@jcortes0309
Jun 16 2016 03:40
@Chipsta first of all the count should not be an array as you stated with count = [-1,0,+1]; The instructions mention that count should increase by 1 (+1), remain the same (0) or decrease by 1 (-1). Also when you do a return, this return should provide the current count and either Hold or Bet
Joseph
@revisualize
Jun 16 2016 03:41
@Chipsta Your switch shouldn't be returning anything you should be evaluating the global then returning something.
help format
CamperBot
@camperbot
Jun 16 2016 03:41

: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 thecode`.

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

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

Joseph
@revisualize
Jun 16 2016 03:41
```js [SHIFT+ENTER]
// your code here
```[CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
apbowe
@apbowe
Jun 16 2016 03:41
Sentence Title Case - My code does what it is supposed to but it only passes one test. Am I supposed to solve it a particular way?
function titleCase(str) {

  var newArray = str.split(" ");
  var finArray =[];

  for (var x = 0; x < newArray.length; x++) {

    for (var y = 0; y < newArray[x].length; y++) {

      if (y === 0) {
        finArray.push(newArray[x][y].toUpperCase());
      } else {
        finArray.push(newArray[x][y].toLowerCase());
      }
    } finArray.push(" ");       
  }

  return finArray.join("");
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Josef Saltz
@JosefSaltz
Jun 16 2016 03:42
function rot13(str) { // LBH QVQ VG!
  var decoded = "";
  var thatChar;
  for (var i = 0; i < str.length; i++) {
    var thatCharCode = str.charCodeAt(i);
    if (str[i] == /[^A-Z]/) { //DETERMINE IF CHARACTER TO BE CONVERTED IS NON-ALPHANUM
      if (thatCharCode - 13 >= 65) { //MAKE SURE SHIFTING BACKWARDS DOESN'T PASS A
        thatChar = String.fromCharCode(thatCharCode - 13);
      } else { //SHIFT FORWARD IF SHIFTING BACK PASSES A
        thatChar = String.fromCharCode(thatCharCode + 13);
      } decoded += thatChar;
    } else {
      decoded += str[i];
    }

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

// Change the inputs below to test
rot13("SERR PBQR PNZC");
apbowe
@apbowe
Jun 16 2016 03:42
Was I supposed to use regular expressions?
Joseph
@revisualize
Jun 16 2016 03:42
@inkuplex That won't evaluate.
@inkuplex Yeah... You can't do regex like that.
Josef Saltz
@JosefSaltz
Jun 16 2016 03:43
why?
Joseph
@revisualize
Jun 16 2016 03:43
Because JS isn't built to do that.
Josef Saltz
@JosefSaltz
Jun 16 2016 03:44
guess that explains why it decodes with != " "
but how can I specify non-alphanum text otherwise?
Chipi
@Chipsta
Jun 16 2016 03:45
@jcortes0309 im trying to put it in if/else statements and it is also not working
Juan Cortes
@jcortes0309
Jun 16 2016 03:50
@Chipsta it will work with the switch; however there are a couple of things that are not working for you. First you need to run through all the cards that are given to you before you do the return. Also the return should be inside an if statement. If the count > 0 then you Bet, otherwise you Hold.
Juwdohr
@Juwdohr
Jun 16 2016 03:50
Are these equivalant?
B[i] === B[i + 1] === B[i + 2]
B[i] === B[i + 1] && B[i + 1] == B[i + 2]
apbowe
@apbowe
Jun 16 2016 03:51
This code works on all the tests, but it doesn't pass the test. Why?
function titleCase(str) {

  var newArray = str.split(" ");
  var finArray =[];

  for (var x = 0; x < newArray.length; x++) {

    for (var y = 0; y < newArray[x].length; y++) {

      if (y === 0) {
        finArray.push(newArray[x][y].toUpperCase());
      } else {
        finArray.push(newArray[x][y].toLowerCase());
      }
    }  finArray.push(" ");     
  }

  return finArray.join("");
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Juan Cortes
@jcortes0309
Jun 16 2016 03:53

@Chipsta also I wouldn't do

case 2, 3, 4, 5, 6:

but would do

    case 2:
    case 3:
    case 4:
    case 5:
    case 6:

because it's easier to read, but I believe your way will work.

GideonCahill
@GideonCahill
Jun 16 2016 03:57
Can someone help me with exercise "Target the same element with multiple jQuery Selectors"?

'''

<script>
$(document).ready(function() {
$("button").addClass("animated animated");
$(".btn").addClass("shake");
$("#target1").addClass("animated shake .btn-primary");
});
</script>

<div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3>
<div class="row">
<div class="col-xs-6">
<h4>#left-well</h4>
<div class="well" id="left-well">
<button class="btn btn-default target" id="target1">#target1</button>
<button class="btn btn-default target" id="target2">#target2</button>
<button class="btn btn-default target" id="target3">#target3</button>
</div>
</div>
<div class="col-xs-6">
<h4>#right-well</h4>
<div class="well" id="right-well">
<button class="btn btn-default target" id="target4">#target4</button>
<button class="btn btn-default target" id="target5">#target5</button>
<button class="btn btn-default target" id="target6">#target6</button>
</div>
</div>
</div>
</div>
'''

CamperBot
@camperbot
Jun 16 2016 03:58
:bulb: to format code use backticks! ``` more info
Ian Arsenault
@ianarsenault
Jun 16 2016 03:58
This message was deleted
apbowe
@apbowe
Jun 16 2016 03:58
Nevermind. I think there is an extra space after the last word. Might be throwing it off.
GideonCahill
@GideonCahill
Jun 16 2016 03:58

<script>
  $(document).ready(function() {
    $("button").addClass("animated animated");
    $(".btn").addClass("shake");
    $("#target1").addClass("animated shake .btn-primary");
  });
</script>

<!-- Only change code above this line. -->

<div class="container-fluid">
  <h3 class="text-primary text-center">jQuery Playground</h3>
  <div class="row">
    <div class="col-xs-6">
      <h4>#left-well</h4>
      <div class="well" id="left-well">
        <button class="btn btn-default target" id="target1">#target1</button>
        <button class="btn btn-default target" id="target2">#target2</button>
        <button class="btn btn-default target" id="target3">#target3</button>
      </div>
    </div>
    <div class="col-xs-6">
      <h4>#right-well</h4>
      <div class="well" id="right-well">
        <button class="btn btn-default target" id="target4">#target4</button>
        <button class="btn btn-default target" id="target5">#target5</button>
        <button class="btn btn-default target" id="target6">#target6</button>
      </div>
    </div>
  </div>
</div>
there
Sam Marshall
@srolandmarshall
Jun 16 2016 03:59
Is anyone here familiar with the weather widget objectives
Ian Arsenault
@ianarsenault
Jun 16 2016 04:00
@GideonCahill what's the problem/ what are you trying to do?
Quang-Vinh
@quangvinh2080
Jun 16 2016 04:00
@GideonCahill the link to your excercise ?
GideonCahill
@GideonCahill
Jun 16 2016 04:00
So in the exercise, it saids I should have one class for each jquery element
https://www.freecodecamp.com/challenges/target-the-same-element-with-multiple-jquery-selectors#?solution=%0Afccss%0A%20%20%24(document).ready(function()%20%7B%0A%20%20%20%20%24(%22button%22).addClass(%22animated%22)%3B%0A%20%20%20%20%24(%22.btn%22).addClass(%22shake%22)%3B%0A%20%20%20%20%24(%22%23target1%22).addClass(%22animated%20shake%20.btn-primary%22)%3B%0A%20%20%7D)%3B%0Afcces%0A%0A%3C!--%20Only%20change%20code%20above%20this%20line.%20--%3E%0A%0A%3Cdiv%20class%3D%22container-fluid%22%3E%0A%20%20%3Ch3%20class%3D%22text-primary%20text-center%22%3EjQuery%20Playground%3C%2Fh3%3E%0A%20%20%3Cdiv%20class%3D%22row%22%3E%0A%20%20%20%20%3Cdiv%20class%3D%22col-xs-6%22%3E%0A%20%20%20%20%20%20%3Ch4%3E%23left-well%3C%2Fh4%3E%0A%20%20%20%20%20%20%3Cdiv%20class%3D%22well%22%20id%3D%22left-well%22%3E%0A%20%20%20%20%20%20%20%20%3Cbutton%20class%3D%22btn%20btn-default%20target%22%20id%3D%22target1%22%3E%23target1%3C%2Fbutton%3E%0A%20%20%20%20%20%20%20%20%3Cbutton%20class%3D%22btn%20btn-default%20target%22%20id%3D%22target2%22%3E%23target2%3C%2Fbutton%3E%0A%20%20%20%20%20%20%20%20%3Cbutton%20class%3D%22btn%20btn-default%20target%22%20id%3D%22target3%22%3E%23target3%3C%2Fbutton%3E%0A%20%20%20%20%20%20%3C%2Fdiv%3E%0A%20%20%20%20%3C%2Fdiv%3E%0A%20%20%20%20%3Cdiv%20class%3D%22col-xs-6%22%3E%0A%20%20%20%20%20%20%3Ch4%3E%23right-well%3C%2Fh4%3E%0A%20%20%20%20%20%20%3Cdiv%20class%3D%22well%22%20id%3D%22right-well%22%3E%0A%20%20%20%20%20%20%20%20%3Cbutton%20class%3D%22btn%20btn-default%20target%22%20id%3D%22target4%22%3E%23target4%3C%2Fbutton%3E%0A%20%20%20%20%20%20%20%20%3Cbutton%20class%3D%22btn%20btn-default%20target%22%20id%3D%22target5%22%3E%23target5%3C%2Fbutton%3E%0A%20%20%20%20%20%20%20%20%3Cbutton%20class%3D%22btn%20btn-default%20target%22%20id%3D%22target6%22%3E%23target6%3C%2Fbutton%3E%0A%20%20%20%20%20%20%3C%2Fdiv%3E%0A%20%20%20%20%3C%2Fdiv%3E%0A%20%20%3C%2Fdiv%3E%0A%3C%2Fdiv%3E%0A
Ian Arsenault
@ianarsenault
Jun 16 2016 04:01
ok give me a second
GideonCahill
@GideonCahill
Jun 16 2016 04:01
alright
Rahul Nayak
@pragyes31
Jun 16 2016 04:01
Hello People
any hint for Ceaser's cipher exercise? Struggling there.
Ian Arsenault
@ianarsenault
Jun 16 2016 04:02
@GideonCahill get rid of the second animated in button selector
$(document).ready(function() {
    $("button").addClass("animated");
    $(".btn").addClass("shake");
    $("#target1").addClass("animated shake .btn-primary");
  });
</script>
GideonCahill
@GideonCahill
Jun 16 2016 04:02
ok let me see
apbowe
@apbowe
Jun 16 2016 04:02
Yes, it was the extra space. Solved that exercise.
GideonCahill
@GideonCahill
Jun 16 2016 04:03
<script>
  $(document).ready(function() {
    $("button").addClass("animated");
    $(".btn").addClass("shake");
    $("#target1").addClass("animated shake .btn-primary");
  });
</script>
like that?
Ian Arsenault
@ianarsenault
Jun 16 2016 04:03
Yeah, but that doesn't solve the problem still
GideonCahill
@GideonCahill
Jun 16 2016 04:03
yea it doesnt solve it
Ian Arsenault
@ianarsenault
Jun 16 2016 04:03
Yeah one more sec
Juan Cortes
@jcortes0309
Jun 16 2016 04:04
@Chipsta any luck with your challenge?
Sam Marshall
@srolandmarshall
Jun 16 2016 04:05
can anyone here help with the weather widget challenge?
Quang-Vinh
@quangvinh2080
Jun 16 2016 04:05
<script>
$(document).ready(function() {
$("button").addClass("animated");
$(".btn").addClass("shake");
$("#target1").addClass("btn-primary");
});
</script>
<script>
  $(document).ready(function() {
    $("button").addClass("animated");
    $(".btn").addClass("shake");
    $("#target1").addClass("btn-primary");
  });
</script>
GideonCahill
@GideonCahill
Jun 16 2016 04:05
@quangvinh2080 that works thanks!
CamperBot
@camperbot
Jun 16 2016 04:05
gideoncahill sends brownie points to @quangvinh2080 :sparkles: :thumbsup: :sparkles:
:cookie: 8 | @quangvinh2080 |http://www.freecodecamp.com/quangvinh2080
Quang-Vinh
@quangvinh2080
Jun 16 2016 04:06
@GideonCahill your welcome ! :)
Ian Arsenault
@ianarsenault
Jun 16 2016 04:06
@GideonCahill get rid of the animated and shake in target1 selector
oh alright @quangvinh2080 got it
GideonCahill
@GideonCahill
Jun 16 2016 04:07
@GorgonsMaze I got it working! Thank you for your help!
CamperBot
@camperbot
Jun 16 2016 04:07
gideoncahill sends brownie points to @gorgonsmaze :sparkles: :thumbsup: :sparkles:
:cookie: 254 | @gorgonsmaze |http://www.freecodecamp.com/gorgonsmaze
Juan Cortes
@jcortes0309
Jun 16 2016 04:07
@GideonCahill do you understand the why your answer wasn't working?
Miguel Benevento
@KSMOknot
Jun 16 2016 04:08
js
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  {
  var albumId = id;
  var changeProp = collection[albumId];

if (value !== "" && prop !== "tracks")
  {
    changeProp[prop] = value;
  }
else if (prop == "tracks" && value !== "")
  {
    changeProp[prop].push(value);
  }
  else {
    delete changeProp[prop];
  }
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "Tracks", "Take a Chance on Me");
I need help with this one. The only thing I need checked off says
" After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element."
Sam Marshall
@srolandmarshall
Jun 16 2016 04:11
you're using a capital T at the bottom, but I don't think that matters.
let me look at my code for a second
UtkarshShukla7
@UtkarshShukla7
Jun 16 2016 04:11
@KSMOknot it is because in the collection object the object with id 5439 doesn't have tracks property predefined .So when you try to push into the tracks property (which is undefined currently for this object) ,the push operation cannot be performed as it is only defined for arrays.
so you can check for if the property is present in that object .If yes ,then push in it else you have to define tracks as an array and then push in it @KSMOknot
jiawang
@hectoraaphrodite
Jun 16 2016 04:13
i have a problem with english..
"ready go" or "ready to go",which is correct?
UtkarshShukla7
@UtkarshShukla7
Jun 16 2016 04:14
@hectoraaphrodite ready to go
Tyler
@TychoCRD
Jun 16 2016 04:15
inputStack = [2, "add", 8, "div", 4, "div", 2];

//stack map functions
function divMult(val, index){
  if( val === "div" || val === "mult"){
    var answer = calc[val](inputStack[index-1],inputStack[index+1]);
    inputStack.splice(index-1, 3, answer);
  }
}
console.log(inputStack);
inputStack.map(divMult);
console.log(inputStack);
this function results in var inputStack = [2, "add", 2, "div", 2];
what I expect is for the map/loop (tested both) to continue running and solve the second "div" in the arr as well
background is calc.div and calc.mult are functions that do division/multiplication operations and return answer
jiawang
@hectoraaphrodite
Jun 16 2016 04:15
thanks @UtkarshShukla7
CamperBot
@camperbot
Jun 16 2016 04:15
hectoraaphrodite sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 641 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
UtkarshShukla7
@UtkarshShukla7
Jun 16 2016 04:16
@hectoraaphrodite np
ALMY91
@ALMY91
Jun 16 2016 04:18
hi guys
am i doing smth wrong here?
"use strict";
var rect= {
width:4,
height:5,

setSize: function(width,height) {

this.result=this.width * this.height;
}
};




console.log(rect.setSize(width,height)); //A method invocation to compute 4*5
console.log(rect.result);
David Halls
@DavidHalls
Jun 16 2016 04:19
@ALMY91 what are you trying to do
ALMY91
@ALMY91
Jun 16 2016 04:19
@Byzgig get the results using method invocation
David Halls
@DavidHalls
Jun 16 2016 04:20
@ALMY91 what challenge is it
ALMY91
@ALMY91
Jun 16 2016 04:21
@Byzgig its not a challenge basically my book provided this line rect.setSize(width,height) as one of the method-invocation syntax so i came up with the rest of the code to see if it worked
Tyler
@TychoCRD
Jun 16 2016 04:24
@ALMY91 in your function, "width" and "parameter" are arguments, they are not linked to the object properties above them
ALMY91
@ALMY91
Jun 16 2016 04:24
@TychoCRD how do i have them linked?
Tyler
@TychoCRD
Jun 16 2016 04:24
so when you call the function, it should be rect.setSize(this.width, this.height));
or rect.setSize(rect.width, rect.height)); if that is clearer
ALMY91
@ALMY91
Jun 16 2016 04:25
@TychoCRD okay what if i want to keep this line as it is rect.setSize(width,height) how do i modify the rest of my code?
Tyler
@TychoCRD
Jun 16 2016 04:25
I don't think it can work that way
you have to build the function and set parameters (w, h). only when you call the function can you give it the arguments for those parameters (rect.width, rect.height)
also the function body shouldn't use "this"
should be return width*function;
Alex T.
@lx-t
Jun 16 2016 04:28
@ALMY91 put var width = 4, height = 5; before first console.log
Tyler
@TychoCRD
Jun 16 2016 04:28
"result" is inside the scope of the setSize function, so you can refer to it as rect.result
Alex T.
@lx-t
Jun 16 2016 04:29
@ALMY91 You're calling the setSize function with undefined variables as arguments
Tyler
@TychoCRD
Jun 16 2016 04:29
if he does that, there's point in putting the width and height inside the rect object
there's no point*
or having an object at all
ALMY91
@ALMY91
Jun 16 2016 04:30
@lx-t @TychoCRD yeah that was what i was thinking, is there a more sophisticated way of doing this?
Tyler
@TychoCRD
Jun 16 2016 04:30
ah, I see now
in the function remove the parameters competely
Alex T.
@lx-t
Jun 16 2016 04:30
@ALMY91 Anyway, your setSize does not set size
Tyler
@TychoCRD
Jun 16 2016 04:30
setsize: function(){ ....
ALMY91
@ALMY91
Jun 16 2016 04:31
@TychoCRD hmm what do u mean?
Tyler
@TychoCRD
Jun 16 2016 04:31
setSize: function(){ return this.width*this.height;}
then console.log(rect.setSize()); will call the function and return the area
ALMY91
@ALMY91
Jun 16 2016 04:31
@TychoCRD remove them completely?
Alex T.
@lx-t
Jun 16 2016 04:32
@ALMY91 I guess this would look more practical:
function(width, height) {
this.width = width;
this.height = height;
this.result = this.width * this.height;
}
Tyler
@TychoCRD
Jun 16 2016 04:32
ah, yes
if you needed a more complicated function that used the object's properties, though, that is how you would do it
ALMY91
@ALMY91
Jun 16 2016 04:32
@lx-t would this be considered a method invocation or function invocation?
Tyler
@TychoCRD
Jun 16 2016 04:33
I don't understand how you would use that in practice
David Halls
@DavidHalls
Jun 16 2016 04:35
@lx-t wouldnt this be better function(width, height) {
this.result = this.width * this.height;
}
Alex T.
@lx-t
Jun 16 2016 04:35
setSize is a function defined in rect object as a method. I guess calling setSize method of your rect object is method invocation.
ALMY91
@ALMY91
Jun 16 2016 04:36
@lx-t i got it ! thanks :)
CamperBot
@camperbot
Jun 16 2016 04:36
almy91 sends brownie points to @lx-t :sparkles: :thumbsup: :sparkles:
:cookie: 334 | @lx-t |http://www.freecodecamp.com/lx-t
Alex T.
@lx-t
Jun 16 2016 04:36
@Byzgig I wouldn't call it setSize. I would call it calculateSize
Tyler
@TychoCRD
Jun 16 2016 04:37
var rect= {
width:4,
height:5,

setSize: function() {

 return this.width * this.height;
}
};

console.log(rect.setSize());
Alex T.
@lx-t
Jun 16 2016 04:37
@Byzgig And what's the point of width and height arguments if they're not used in that method?
Tyler
@TychoCRD
Jun 16 2016 04:37
That's how it would work
Alex T.
@lx-t
Jun 16 2016 04:38
@TychoCRD I'd call that method getSize :)
Tyler
@TychoCRD
Jun 16 2016 04:38
I'm just using his properties
Sam Marshall
@srolandmarshall
Jun 16 2016 04:39
can someone help me with objects and return statements, i'm going a little crazy
Alex T.
@lx-t
Jun 16 2016 04:39
@TychoCRD Yeah, I know. Thanks for helping.
CamperBot
@camperbot
Jun 16 2016 04:39
lx-t sends brownie points to @tychocrd :sparkles: :thumbsup: :sparkles:
:cookie: 309 | @tychocrd |http://www.freecodecamp.com/tychocrd
NixonRichard
@NixonRichard
Jun 16 2016 04:40
function reverseString(str) {
  var array = str.split('');
  array.reverse('');array=arr.join(''); 
  return arr;
}

reverseString("hello");
hi what s wrong with my code ?
David Halls
@DavidHalls
Jun 16 2016 04:40
@NixonRichard arr is never declared for one
Tyler
@TychoCRD
Jun 16 2016 04:41
np~
anyone have any ideas how I can make my splicing .map/loop continue iterating through the entire array?
inputStack = [2, "add", 8, "div", 4, "div", 2];

//stack map functions
function divMult(val, index){
  if( val === "div" || val === "mult"){
    var answer = calc[val](inputStack[index-1],inputStack[index+1]);
    inputStack.splice(index-1, 3, answer);
  }
}
console.log(inputStack);
inputStack.map(divMult);
console.log(inputStack);
this function results in var inputStack = [2, "add", 2, "div", 2];
what I expect is for the map/loop (tested both) to continue running and solve the second "div" in the arr as well
background is calc.div and calc.mult are functions that do division/multiplication operations and return answer
UtkarshShukla7
@UtkarshShukla7
Jun 16 2016 04:45
@TychoCRD you should not modify the same array you are using in map
Tyler
@TychoCRD
Jun 16 2016 04:46
yeah, just did some console.logging and found the index count is messed up by the splice
Coy Sanders
@coymeetsworld
Jun 16 2016 04:46
@TychoCRD you're not returning anything in your divMult function
UtkarshShukla7
@UtkarshShukla7
Jun 16 2016 04:46
@TychoCRD exactly
Coy Sanders
@coymeetsworld
Jun 16 2016 04:46
either
if you need to modify the array you should look at the reduce function instead of map
Sam Marshall
@srolandmarshall
Jun 16 2016 04:49
This message was deleted
oops wrong one
Tyler
@TychoCRD
Jun 16 2016 04:50
I find reduce hard to understand where it's appropriate to use and how best to use it in general, not sure how to apply it here
if not mapping, my second thought is it If conditional for div/mult, splice, then recursively call the function until no more div/mult
if conditional for indexOf div/mult*
NixonRichard
@NixonRichard
Jun 16 2016 04:54
hi
my iq s 80 can i learn to coidng ?
*coding
Coy Sanders
@coymeetsworld
Jun 16 2016 04:57
just have to remember what those functions are for @TychoCRD, you could theoretically do the calculation with our without any of them
Don't believe I used any of them to get my solution done, but that doesn't mean you shouldn't try because they are really useful
Tyler
@TychoCRD
Jun 16 2016 04:58
you mean the array methods?
yeah, now I'm thinking a recursive function with a switchcase for the whole solution might be right...
Coy Sanders
@coymeetsworld
Jun 16 2016 05:00
yes, array methods
Tyler
@TychoCRD
Jun 16 2016 05:00
rather than dividing order of operations into separate methods
Coy Sanders
@coymeetsworld
Jun 16 2016 05:00
doesn't have to be recursive either
you just need to go through the array a few times so you make sure order of ops is correct
Tyler
@TychoCRD
Jun 16 2016 05:01
ah, yes, a while loop could do that...
Coy Sanders
@coymeetsworld
Jun 16 2016 05:03
yeah
or look at eval function
Tyler
@TychoCRD
Jun 16 2016 05:05
Feel like I tend to overthink these now. I started with the idea of converting an inputStack into an array of calc functions that would reduce one into another and return b(a)...building that second stack was the problem
Chris Cullen
@123xylem
Jun 16 2016 05:05
@NixonRichard possibly if u do css and web based stuff
@NixonRichard javascript is tough.. But IQ is strange.. Ur IQ maybe suited to coding
NixonRichard
@NixonRichard
Jun 16 2016 05:07
oh thx u that helped alot
(=
Tyler
@TychoCRD
Jun 16 2016 05:08
ah man, is it really that simple?
thanks @coymeetsworld , I'm taking a close look at eval now
CamperBot
@camperbot
Jun 16 2016 05:08
tychocrd sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1157 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 16 2016 05:09
idk, i didn't use it, heard about it after I finished lol
like a few days after
but I am going through my projects again and will look over refactoring it if it works
Tyler
@TychoCRD
Jun 16 2016 05:09
haha. I've just encountered a lot of ominous commentary on eval and generally avoided looking into it further
Coy Sanders
@coymeetsworld
Jun 16 2016 05:14
seems like its worth looking into
keep your code shorter thats for sure lol
Tyler
@TychoCRD
Jun 16 2016 05:15
yeah hah
TanYiXun
@TanYiXun
Jun 16 2016 05:30

Can someone help me with caesar cipher challenge?

function rot13(str) { // LBH QVQ VG!
  str=str.split("");
  var letters=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T",
               "U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M"];

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

       for(var j=0;j<letters.length;j++){ 

      if(str[i]===letters[j]){
        str[i]=letters[j+13]; 

            }
      }     
  }
  return str;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

i keep getting [null,null,null,null," ",null,null,null,null," ",null,null,null,null] as my answers
Appreciate it

Eric Crescioni
@ecam900
Jun 16 2016 05:31
I too need help. This is returning "No Such Contact" even though the contact "Harry" exists.

//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 lookUpProfile(firstName, prop){
// Only change code below this line

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

      if ( (contacts[i].firstName == firstName) && (contacts[i].hasOwnProperty(prop))){
        return contacts[i][prop];
    } else {
        return "No such contact";
        }
  }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "likes");
any insight would be very appreciated
been stuck here for 3 days
Markus Kiili
@Masd925
Jun 16 2016 05:32
@ecam900 You should return no such contact when you have checked all the contacts.
Eric Crescioni
@ecam900
Jun 16 2016 05:32
aaaaaaaaaaah it's only checking the first on
one*
Markus Kiili
@Masd925
Jun 16 2016 05:32
Two nested if's is the simplest structure.
Eric Crescioni
@ecam900
Jun 16 2016 05:33
Markus, you've helped me once again. Thank you so much.
Thanks @Masd925
CamperBot
@camperbot
Jun 16 2016 05:33
ecam900 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
api offline
Markus Kiili
@Masd925
Jun 16 2016 05:34
@ecam900 You're wellcome.
bitgrower
@bitgrower
Jun 16 2016 05:34
@ecam900 so sorry you spent so long on Profile Lookup ...
Eric Crescioni
@ecam900
Jun 16 2016 05:36
@bitgrower It seems longer than it was, I probably spent 15~20 minutes on it each day
I'm not discouraged at all, these discovery / "aha!" moments are worth every minute of struggle
bitgrower
@bitgrower
Jun 16 2016 05:45
and that, sir, is an attitude which will serve you well, and bodes EXTREMELY well, imnsho, in your success with this program!
...and 15-20 minutes/day...considering that you would have to refresh your brain with what you were working on ... is even less time ...
onward and upward!
Coy Sanders
@coymeetsworld
Jun 16 2016 05:49
@TanYiXun figured out your issue
if you implement it this way you need a way to exit out of the 2nd for loop after you find the match, or else it will keep going to the end
it will go through all the letters and eventually you're setting str[i] to letters.length+13
Eric Crescioni
@ecam900
Jun 16 2016 05:51
@bitgrower Thank you for the encouragement :)
CamperBot
@camperbot
Jun 16 2016 05:51
ecam900 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1103 | @bitgrower |http://www.freecodecamp.com/bitgrower
Coy Sanders
@coymeetsworld
Jun 16 2016 05:51
which is not a defined value which is where your nulls come from
I would suggest using the functions they recommend: charCodeAt and fromCharCode
bitgrower
@bitgrower
Jun 16 2016 05:51
@coymeetsworld -- but then he is missing one of the major points of that exercise, which is to learn about charAt & charFrom (imnsho)
Coy Sanders
@coymeetsworld
Jun 16 2016 05:52
right, which is why I suggested to do it :)
bitgrower
@bitgrower
Jun 16 2016 05:52
yeah, i was busy writing before your posting came thru ...
:)
Coy Sanders
@coymeetsworld
Jun 16 2016 05:53
you wouldn't need to keep an array of letters, you wouldn't have a n squared function, etc
well actually i guess not n squared, letters is fixed
but still wouldn't need 2 for loops
lol
bitgrower
@bitgrower
Jun 16 2016 05:53
I tried running it on pythontutor and pythontutor coughed because it took over 1000 steps ... I'm pretty sure that's not because it was an endless loop ... but just a very slow algo...
it's def a different approach ...
Coy Sanders
@coymeetsworld
Jun 16 2016 05:54
theres no break statement in the inner loop @bitgrower
so it processes each value in the letters array
bitgrower
@bitgrower
Jun 16 2016 05:55
yeah ...
Coy Sanders
@coymeetsworld
Jun 16 2016 05:55
which is what length 39? times 14 characters, 2 of which shouldn't be modified at all and don't need to be processed (the spaces)
I doubt its slow by any functioning computers standards but yeah could be refactored a bit
bitgrower
@bitgrower
Jun 16 2016 05:56
that's still not 1000 steps ... hmmmm ...
Coy Sanders
@coymeetsworld
Jun 16 2016 05:56
you sure?
oh it isn't yeah hmm
bitgrower
@bitgrower
Jun 16 2016 05:56
39 * 14 ?
Coy Sanders
@coymeetsworld
Jun 16 2016 05:56
did you run the function more than once?
RakeshNerkar
@Rakesh18754
Jun 16 2016 05:56
do i need to have a server to run angular routes on my local machine?
bitgrower
@bitgrower
Jun 16 2016 05:56
don't think so ...
that's to @coymeetsworld
I dunno about angular ... haven't run angular before ...
Markus Kiili
@Masd925
Jun 16 2016 06:03
@deepakpatil007 I don't think you need. The browser always has the same angular code, even if there was a server.
Ethan Rose
@ethanrose
Jun 16 2016 06:04
hi all! just wondering why do my variables = 0 when I use console.log OUTSIDE of the JSON api call, but the variables = what they are supposed to inside the call..
//All Variables
var currentTemp = 0;
 var tempMin = 0;
var tempMax = 0;
var humidity = 0;
var windSpeed = 0;
var weather = "";


//API call and assigning values to variables
$.getJSON("http://api.openweathermap.org/data/2.5/weather?q=Phoenix&type=like?id=524901&APPID=047667fad5d1973f37bc119e3581da10", function(json){
  currentTemp = json["main"]["temp"];
  tempMin = json["main"]["temp_min"];
  tempMax = json["main"]["temp_max"];
  humidity = json["main"]["humidity"];
  windSpeed = json["wind"]["speed"];
  weather = json["weather"][0]["main"];
});


console.log("currentTemp = " +
  currentTemp +
            "tempMin = " +
  tempMin +
            "tempMax = " +
  tempMax +
            "humidity = " +
  humidity +
            "windSpeed = " +
  windSpeed +
            "weather = " +
  weather
  );
does it make sense / best practice what I'm trying to do here?
:D
Markus Kiili
@Masd925
Jun 16 2016 06:06
This message was deleted
Juan Carlos Teso
@jcarlosteso
Jun 16 2016 06:06
@deepakpatil007 you always need an http server running locally if you want to test a web app. Take a look at this
RakeshNerkar
@Rakesh18754
Jun 16 2016 06:06
@Masd925 because in chrome i am getting cross origin error but runs perfectly on firefox
Leo
@Leodhy
Jun 16 2016 06:06
does anyone know how to find the attribute of an object according to the value?
Ethan Rose
@ethanrose
Jun 16 2016 06:07
like right now my console.log returns 0 for everything! if I moved the "console.log" to the INSIDE of the .getJSON brackets, then it returns the new values
Leo
@Leodhy
Jun 16 2016 06:07
i'm doing the part of "Accessing Objects Properties with Variables"
RakeshNerkar
@Rakesh18754
Jun 16 2016 06:08
@jcarlosteso @Masd925 because in chrome i am getting cross origin error but runs perfectly on firefox
Leo
@Leodhy
Jun 16 2016 06:08

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber; // Change this Line
var player = testObj; // Change this Line

Markus Kiili
@Masd925
Jun 16 2016 06:08
@deepakpatil007 Probably would run on Chrome too with local files.
Leo
@Leodhy
Jun 16 2016 06:08
how to find the number 16 in the object
Coy Sanders
@coymeetsworld
Jun 16 2016 06:08
you need to use bracket notation @Leodhy
and you need to set playerNumber to that number
RakeshNerkar
@Rakesh18754
Jun 16 2016 06:09
@Masd925 OK thanks!!
CamperBot
@camperbot
Jun 16 2016 06:09
deepakpatil007 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1877 | @masd925 |http://www.freecodecamp.com/masd925
Leo
@Leodhy
Jun 16 2016 06:10
thx, i misunderstood this question
shariquemaaz
@shariquemaaz
Jun 16 2016 06:24

Hey guys ., For Open weather app, am not able to use geolocatioon to fetch user's location as it is restricted in unsecure origins in chrome. i need to add 'https' in the address bar to make it work. if i do so, openweather api doesn't work due to mismatch in the protocols..

please suggest me an alternate way to get user location, maybe another api which fetches the location details of user..

Coy Sanders
@coymeetsworld
Jun 16 2016 06:25
try http://ip-api.com/json @shariquemaaz
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 06:30
need help
guys
kirbyedy
@kirbyedy
Jun 16 2016 06:30
@rahulchaurasia01 and what is the problem ?
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 06:31
i m unable to solve this
kirbyedy
@kirbyedy
Jun 16 2016 06:32
can we see your code
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 06:32
yaa
i have taken a screen shot but how to send it ??
Markus Kiili
@Masd925
Jun 16 2016 06:33
explain format
CamperBot
@camperbot
Jun 16 2016 06:33

: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 thecode`.

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

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

Markus Kiili
@Masd925
Jun 16 2016 06:33
@rahulchaurasia01 Use copy/paste.
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 06:34
@kirbyedy i have written two codes, one with if/else n other one with switch
@kirbyedy if (card === 2){
count++;
return (count);
}
else if (card === 3) {
count ++;
}
else if (card === 4){
count++;
}
else if (card === 5) {
count ++;
}
else if (card === 6) {
count++;
return (count + " Bet");
}
else if (card === 7) {
count = 0;
return (count + " Hold");
}
else if (card === 8) {
count = 0;
}
else if (card === 9) {
count =0;
return (count + " Hold");
}
else if (card === 10) {
count = count - 1;
}
else if (card === 'J') {
count--;
}
else if (card === 'Q') {
count = count - 1;
}
else if (card === 'K') {
count = count - 1;
return (count);
}
else if (card === 'A') {
count = count - 1;
return (count + " Hold");
}
archan6le
@archan6le
Jun 16 2016 06:35
hey guys.. trying to solve for factorizing a number but dont seem to have it quite right:
function factorialize(num) {
 var testNum = 1;
  for(i = 0; i <= num; i++){
    if(i > 0 ){
     testNum = num * testNum;
    }

  }
  return testNum;

  //return newNum;
}

factorialize(5);
Markus Kiili
@Masd925
Jun 16 2016 06:36
@archan6le testNum *= i;
Umair
@umairbalani
Jun 16 2016 06:36

function golfScore(par, strokes) {
  // Only change code below this line
  if (par == 4 && strokes == 1) {
    return "Hole-in-one!";
  }
  else if (par >= 4 && strokes >= 2) {
    return "Eagle";
  }
  else if (par >= 5  && strokes >= 2) {
    return "Eagle";
  }
  else if (par === 4  && strokes === 3) {
    return "Birdie";
  }

  else {
  return "Change Me";
  }
  // Only change code above this line
}

// Change these values to test
golfScore(4, 1);
golfScore(4, 2);
golfScore(5, 2);
golfScore(4, 3);
golfScore(4, 4);
golfScore(1, 1);
golfScore(5, 5);
golfScore(4, 5);
golfScore(4, 6);
golfScore(4, 7);
golfScore(5, 9);
Markus Kiili
@Masd925
Jun 16 2016 06:36
@umairbalani Where is Go home!
Umair
@umairbalani
Jun 16 2016 06:37
Your function will be passed par and strokes arguments. Return the correct string according to this table which lists the strokes in order of priority; top (highest) to bottom (lowest):
What I'm doing wrong here.
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 06:37
@Masd925 can u tell me this 1 how to solve ?
Coy Sanders
@coymeetsworld
Jun 16 2016 06:37
@umairbalani you don't want to hardcode your test cases like that
Coy Sanders
@coymeetsworld
Jun 16 2016 06:37
your score is relative to par and strokes
Markus Kiili
@Masd925
Jun 16 2016 06:38
@rahulchaurasia01 Test the card and change count accordingly. Then figure out the return value from count (not card).
Coy Sanders
@coymeetsworld
Jun 16 2016 06:38
for instance on a par-5 hole if you get 7 strokes you have a double bogey
but also par-4 with 6 strokes, par-3 with 5, etc. It would be alot of code to check each of those pairs of numbers individually
you're better off comparing strokes to par, not strokes to a number and par to another number
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 06:39
@Masd925 see this
if (card === 2){
count++;
return (count);
}
else if (card === 3) {
count ++;
}
else if (card === 4){
count++;
}
else if (card === 5) {
count ++;
}
else if (card === 6) {
count++;
return (count + " Bet");
}
else if (card === 7) {
count = 0;
return (count + " Hold");
}
else if (card === 8) {
count = 0;
}
else if (card === 9) {
count =0;
return (count + " Hold");
}
else if (card === 10) {
count = count - 1;
}
else if (card === 'J') {
count--;
}
else if (card === 'Q') {
count = count - 1;
}
else if (card === 'K') {
count = count - 1;
return (count);
}
else if (card === 'A') {
count = count - 1;
return (count + " Hold");
}
Umair
@umairbalani
Jun 16 2016 06:40
ok I'll try
Coy Sanders
@coymeetsworld
Jun 16 2016 06:40
also hole-in-one is always when you have one stroke, regardless of par
Markus Kiili
@Masd925
Jun 16 2016 06:42
@rahulchaurasia01 Card value should only change value of count (no returns based on card). After checking the card, you should figure out what to return based on count (not card). The count is a global variable that can change on each function call, so the return value is not based on just one card.
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 06:45
i m still not understand :(
Markus Kiili
@Masd925
Jun 16 2016 06:47
@rahulchaurasia01 Try to read the instructions. The value of passed card changes value of count. Count determines the return value.
Leo
@Leodhy
Jun 16 2016 06:47

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

// Only change code below this line

var gloveBoxContents = "maps"; // Change this line

myStorage.car.inside["glove box"];

who can tell me where the mistake is in the last line?
Markus Kiili
@Masd925
Jun 16 2016 06:48
@Leodhy Assign the value from object access to the variable.
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 06:48
W8 i think i understand little bit, i'll do some changes n come to u again @Masd925
Leo
@Leodhy
Jun 16 2016 06:49
what's that mean? @Masd925
Markus Kiili
@Masd925
Jun 16 2016 06:50
@Leodhy Your last code line gets the property value. Assign it to var gloveBoxContents on the previous line -> // Change this line
Leo
@Leodhy
Jun 16 2016 06:51
got it! thanks
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 06:52
@Masd925 now look this
if (card === 2){
count++;
}
else if (card === 3) {
count ++;
}
else if (card === 4){
count++;
}
else if (card === 5) {
count ++;
}
else if (card === 6) {
count++;
}
else if (card === 7) {
count = 0;
}
else if (card === 8) {
count = 0;
}
else if (card === 9) {
count =0;
}
else if (card === 10) {
count = count - 1;
}
else if (card === 'J') {
count--;
}
else if (card === 'Q') {
count = count - 1;
}
else if (card === 'K') {
count = count - 1;
}
else if (card === 'A') {
count = count - 1;
}
if (count > 0) {
return (count + " Bet");
}
else {
return (count + " Hold");
}
James Dui
@jamesMD
Jun 16 2016 06:52
LOL i was about to ask the glove box question
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 06:52
but it still give 1 error
remaining 6 is successful
Markus Kiili
@Masd925
Jun 16 2016 06:53
@rahulchaurasia01 Logic is right now.
@rahulchaurasia01 count = 0; is wrong.
James Dui
@jamesMD
Jun 16 2016 06:53

but I still don't get the answer right though

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

// Only change code below this line

var gloveBoxContents = "myStorage.car.inside["glove box"]";

Markus Kiili
@Masd925
Jun 16 2016 06:54
@jamesMD Remove the quotes "myStorage.car.inside["glove box"]". You are not supposed to assign that string.
James Dui
@jamesMD
Jun 16 2016 06:54
@Masd925 thanks that fixed it
CamperBot
@camperbot
Jun 16 2016 06:54
jamesmd sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1879 | @masd925 |http://www.freecodecamp.com/masd925
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 06:55
@Masd925 DonE :D
Markus Kiili
@Masd925
Jun 16 2016 06:56
@rahulchaurasia01 Nice.
Anush Reddy
@anushreddy
Jun 16 2016 06:57
Write a function which takes an id, a property (prop), and a value.
Marian Menschig
@mmenschig
Jun 16 2016 07:00
Go for it @anush6533 ! :)
function myFunction(id, prop, val)  {
    // do_something;
};
something like that perhaps?
Anush Reddy
@anushreddy
Jun 16 2016 07:01

For the given id in collection:

If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop.

for(id in collection){
if(value !== "" && prop != "tracks"){
prop=value;
id.set(prop);
}
is this code correct
Marian Menschig
@mmenschig
Jun 16 2016 07:02
please format the code with three back ticks (first line and last line) `
Markus Kiili
@Masd925
Jun 16 2016 07:03
@anush6533 You don't need a loop, because you know the property key.
explain format
CamperBot
@camperbot
Jun 16 2016 07:03

: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 thecode`.

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

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

Anush Reddy
@anushreddy
Jun 16 2016 07:04
for(id in collection){
    if(value !== "" && prop != "tracks"){
      prop=value;
      id.set(prop);
    }
Markus Kiili
@Masd925
Jun 16 2016 07:06
@anush6533 No need for a loop. Just 2 or 3 checks on value and prop and then access collection as asked.
juw3lstar
@juw3lstar
Jun 16 2016 07:07
oh, hi masd :)
Markus Kiili
@Masd925
Jun 16 2016 07:07
@juw3lstar Hello.
juw3lstar
@juw3lstar
Jun 16 2016 07:07
back at it again with the help for the noobs :)
if i want to get the length of characters, in lets say an article, is adding /\s+/g + /\S/g a good possibility?
xu hongbin
@mnixu
Jun 16 2016 07:11

var myVar = 87;

// Only change code below this line
myVar = ++ myVar ;

what's wrong
juw3lstar
@juw3lstar
Jun 16 2016 07:12
you can do myVar++; and that will do it
that will increase myVar by 1
xu hongbin
@mnixu
Jun 16 2016 07:13
but myVar should equal 88
juw3lstar
@juw3lstar
Jun 16 2016 07:13
what is the title of the tutorial
Markus Kiili
@Masd925
Jun 16 2016 07:13
@juw3lstar Maybe regexp and str.match() is good.
xu hongbin
@mnixu
Jun 16 2016 07:14
Increment a Number with JavaScript
juw3lstar
@juw3lstar
Jun 16 2016 07:14
@Masd925 i didnt have that yet, but theoretically my way would work right?
Markus Kiili
@Masd925
Jun 16 2016 07:15
@juw3lstar Yes, built the regexp according to what characters you like to count.
juw3lstar
@juw3lstar
Jun 16 2016 07:15
@mnixu look at the code above, there stand var myVar = 87;
@mnixu so if you increment it by one myVar gets 88 :)
@Masd925 thanks
CamperBot
@camperbot
Jun 16 2016 07:16
juw3lstar sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1880 | @masd925 |http://www.freecodecamp.com/masd925
xu hongbin
@mnixu
Jun 16 2016 07:17
but must Use the ++ operator
juw3lstar
@juw3lstar
Jun 16 2016 07:18
@mnixu ye, your variable, myVar is already defined and set to 87. if you increase it by one the way it is written on the left, you get 88
xu hongbin
@mnixu
Jun 16 2016 07:19
ye
but is wrong
so i don't how to solve
RakeshNerkar
@Rakesh18754
Jun 16 2016 07:20

in my node server i have this

app.use(express.static(__dirname + "/public"));

so thus the public folder require ONLY a file with name index.html file
because if i change the file name it throws an error cannot GET.

juw3lstar
@juw3lstar
Jun 16 2016 07:21
@mnixu i wrote how it's right, instead of using ur code of line just use myVar++;
Umair
@umairbalani
Jun 16 2016 07:22

function golfScore(par, strokes) {
  // Only change code below this line
if (strokes === 1 && par >= 3) {
    return "Hole-in-one!";
}
else if (strokes === 2 && par >= 4) {
    return "Eagle";
}
else if (strokes === 3 && par >= 3) {
    return "Birdie";
}
else if (strokes === 4 && par >= 3) {
    return "Par";
}else if (strokes === 1 && par >= 1) {
    return "Hole-in-one!";
}else if (strokes == 5 && par >= 4) {
    return "Par";
}else if (strokes == 5 ) {
    return "Bogey";
}else if (strokes == 6 ) {
    return "Double Bogey";
}else if (strokes == 7 ) {
    return "Go Home!";
}else if (strokes == 9 ) {
    return "Go Home!";
}

  else {
  return "Change Me";
  }
  // Only change code above this line
}

// Change these values to test
golfScore(4, 5);
golfScore(4, 5) should return "Bogey"
Couldn't get it pass for bogey what I'm doing wrong here?
xu hongbin
@mnixu
Jun 16 2016 07:23
@juw3lstar Can you copy the entire code?
juw3lstar
@juw3lstar
Jun 16 2016 07:23
@mnixu that is the entire code!
Norberto
@nortocode
Jun 16 2016 07:24
@umairbalani
else if (strokes === 4 && par >= 3) {
return "Par";
this doesn't look right
Sanzhar Askaruly
@askaruly
Jun 16 2016 07:24
hi guys
juw3lstar
@juw3lstar
Jun 16 2016 07:24
This message was deleted
Umair
@umairbalani
Jun 16 2016 07:25
@nortocode issue isn't with "Par" I'm stuck at golfScore(4, 5) should return "Bogey"
Norberto
@nortocode
Jun 16 2016 07:25
one line can lead to the fail in another
Norvin Burrus
@ndburrus
Jun 16 2016 07:26
@umairbalani is this logic accurate? if (strokes === 1 && par >= 3) :) overall comment: review/check the logic per the Strokes/Return table/chart... hint: simply start at the top of the table/chart, and work your way down to the end. the logic should flow nicely/smoothly...
Norberto
@nortocode
Jun 16 2016 07:26
else if (strokes === 3 && par >= 3) {
return "Birdie";
}
this one doesn't look either
juw3lstar
@juw3lstar
Jun 16 2016 07:26
This message was deleted
Norberto
@nortocode
Jun 16 2016 07:26
if strokes === 3 and par is 3 that's not a birdie
Sanzhar Askaruly
@askaruly
Jun 16 2016 07:27
can't figure out

function truncateString(str, num) {
if (num >= str.length && num>3) {
return str;
}

else if (num < str.legnth && num > 3) {
str = str.substr(0,num-3);
str = str.concat("...");
return str;
}

else if (num < str.legnth && num <= 3) {
str = str.substr(0,num);
str = str.concat("...");
return str;
}

else {
return 0;
}
}

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

Truncate a string
juw3lstar
@juw3lstar
Jun 16 2016 07:27
@mnixu

var myVar = 87;

// Only change code below this line
myVar++;
Sanzhar Askaruly
@askaruly
Jun 16 2016 07:27
why it cannot enter else if (num < str.legnth && num > 3) statement
xu hongbin
@mnixu
Jun 16 2016 07:28
@juw3lstar oh thanks
CamperBot
@camperbot
Jun 16 2016 07:28
mnixu sends brownie points to @juw3lstar :sparkles: :thumbsup: :sparkles:
:cookie: 232 | @juw3lstar |http://www.freecodecamp.com/juw3lstar
Norberto
@nortocode
Jun 16 2016 07:28
@askaruly misspeleed length
and I misspelled misspeleed :)
Sanzhar Askaruly
@askaruly
Jun 16 2016 07:29
haha @nortocode thank you
CamperBot
@camperbot
Jun 16 2016 07:29
askaruly sends brownie points to @nortocode :sparkles: :thumbsup: :sparkles:
:cookie: 319 | @nortocode |http://www.freecodecamp.com/nortocode
Sanzhar Askaruly
@askaruly
Jun 16 2016 07:29
just noticed that
byronsj
@byronsj
Jun 16 2016 07:30
so i did the "return largest numbers in arrays" chalange today, and i used both "while and for" but i realised I could probably have used one or the other.
Is there a difrence between them and how do i know which one i should be useing.
Is this something i should be worrying about?
Sanzhar Askaruly
@askaruly
Jun 16 2016 07:30
one more question
how do you compile something to see the result of your code?
it says console.log in Dev Tools of your browser
but when I try in Chrome some weird staff
Norberto
@nortocode
Jun 16 2016 07:32
@askaruly yes, console.log( truncateString('xxxx', 3)); should work
as the last line in your code
byronsj
@byronsj
Jun 16 2016 07:33

this is how i did the chalange
```function largestOfFour(arr) {
// You can do this!
var result = [];
var lrg = 0;
var n = 0;

while (n < arr.length){
for (var i = 0; i < arr[n].length; i++){
if(arr[n][i] > lrg){
lrg = arr[n][i];
}
}
n++;
result.push(lrg);
lrg = 0;
}
return result;
}

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

Norvin Burrus
@ndburrus
Jun 16 2016 07:33
@askaruly ...or you could use an external repl: http://replit.com/ :)
Markus Kiili
@Masd925
Jun 16 2016 07:33
@byronsj For is good for looping over incremented numbers. Anything more complicated than that, use while. Any for can be done with while and vice versa, but the logic of while is trivial to see and the logic of for is hidden.
Alex T.
@lx-t
Jun 16 2016 07:35
@askaruly You can test you code in codepen, there's console in there too.
Sanzhar Askaruly
@askaruly
Jun 16 2016 07:43
@ndburrus liked http://repl.it tool! Nice one. Codepen also works fine @lx-t Thank you guys :)
CamperBot
@camperbot
Jun 16 2016 07:43
askaruly sends brownie points to @ndburrus and @lx-t :sparkles: :thumbsup: :sparkles:
:cookie: 562 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 335 | @lx-t |http://www.freecodecamp.com/lx-t
Norvin Burrus
@ndburrus
Jun 16 2016 07:45
@askaruly you're welcome :smile: in my opinion, it helps to get some quick code result feedback.. :+1:
byronsj
@byronsj
Jun 16 2016 07:46
@Masd925 do you mean that the variables and whatever else inside the () of a "for", are hidden globaly?
Anush Reddy
@anushreddy
Jun 16 2016 07:47
can anyone help me with Record Collection challenge
Markus Kiili
@Masd925
Jun 16 2016 07:48
@byronsj No. I mean that if you add more complicated logic to a for loop than just a condition and incrementing the loop index, it is easy to make errors in the logic. For loop doesn't tell you what those three parts actually mean. While loop does.
byronsj
@byronsj
Jun 16 2016 07:49
ah yes, ok thanks @Masd925
CamperBot
@camperbot
Jun 16 2016 07:49
byronsj sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1881 | @masd925 |http://www.freecodecamp.com/masd925
Harshil Agrawal
@harshil1712
Jun 16 2016 07:51

hello. I need a little help in the Title Case a Sentence. Below is my code
``` function titleCase(str) {
var b = "";
str = str.toLowerCase();
var a = str.split(" ");
for(var i = 0; i<a.length; i++)
{

   b = a[i].charAt(0).toUpperCase();
}

console.log(b);
}

titleCase("sHoRt AnD sToUt"); ```

Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 07:52
@Masd925 need help in this

var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank",
};
result = lookup.alpha;
result = lookup.bravo;
result = lookup.charlie;
result = lookup.delta;
result = lookup.echo;
result = lookup.foxtrot;

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

Markus Kiili
@Masd925
Jun 16 2016 07:52
@harshil1712 Add the rest of the string too to a[i].charAt(0).toUpperCase().
Markus Kiili
@Masd925
Jun 16 2016 07:53
@harshil1712 Maybe a[i]=a[i].charAt... is better. Then join a at the end.
Akshat
@Akshatkumar4433
Jun 16 2016 07:53

function golfScore(par, strokes) {
// Only change code below this line
if (strokes == 1)
{
return "Hole-in-one!";

}
if (strokes <= par-1)
return "Change Me";
// Only change code above this line
}
if (strokes > par-1)
{
return "Birdie";
}
if (strokes > par+1) {
return "Bogey";
}
if (strokes > par+2) {
return "Double Bogey";
}
if (strokes >= par+3) {
return "Go Home!";
}
// Change these values to test
golfScore(5, 4);

Harshil Agrawal
@harshil1712
Jun 16 2016 07:54
@Masd925 this is what i did b += " " +a[i].charAt(0).toUpperCase() + a[i].slice(!0);
Markus Kiili
@Masd925
Jun 16 2016 07:55
@harshil1712 What is this? !0
@harshil1712 Adding to a result string is ok way to do it.
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 07:56
@Masd925 see my
val = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank",
};
result = lookup.alpha;
result = lookup.bravo;
result = lookup.charlie;
result = lookup.delta;
result = lookup.echo;
result = val.foxtrot;
Markus Kiili
@Masd925
Jun 16 2016 07:56
@Akshatkumar4433 // Only change code above this line
Norvin Burrus
@ndburrus
Jun 16 2016 07:56
@Akshatkumar4433 carefully review/check the Strokes values in the Strokes/Return table/chart against the code values... :)
udaypathak
@udaypathak
Jun 16 2016 07:57

var Bike = function() {

// Only change code below this line.
var gear = 4;
//these are public methods

this.getGear = function(change){
gear += change;
};

this.setGear = function(){
gear -= 1;
};

this.getGear = function(){
return gear;
};
};

Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 07:57
@Masd925 ??
Harshil Agrawal
@harshil1712
Jun 16 2016 07:57
@Masd925 let me try
udaypathak
@udaypathak
Jun 16 2016 07:57
myBike.getGear() should return 4 after calling myBike.setGear(4).
myBike.getGear() should return 3 after calling myBike.setGear(3).
Akshat
@Akshatkumar4433
Jun 16 2016 07:57
i don't know about game of golf
Bookerhooker101
@Bookerhooker101
Jun 16 2016 07:57
hello, can someone tell me how to skip this CSS course so I can do other coding?
Norvin Burrus
@ndburrus
Jun 16 2016 07:57
@rahulchaurasia01 review the assignment to val. is this accurate?
@udaypathak which exercise is this?
juw3lstar
@juw3lstar
Jun 16 2016 07:58
@Bookerhooker101 you can go to the map and choose which tutorial you'd like to do
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 07:58
@ndburrus no it is not accurate
Harshil Agrawal
@harshil1712
Jun 16 2016 07:59
@Masd925 the problem is with the spacing.
Norvin Burrus
@ndburrus
Jun 16 2016 07:59
@Akshatkumar4433 ...no specialized information about eh game of golf is necessary. we just need the information in the table/chart to allow converting the strokes/par values.. :+1:
Markus Kiili
@Masd925
Jun 16 2016 08:00
@harshil1712 Just add suitable spaces, and possibly .trim() the result string.
Norvin Burrus
@ndburrus
Jun 16 2016 08:00
@rahulchaurasia01 ok, take a look here: Convert the switch statement into a lookup table called lookup. have we accomplished this? hint: note the name given...
Akshat
@Akshatkumar4433
Jun 16 2016 08:00
syntax error is coming
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:00
@ndburrus first tell me how to convert into lookup table
Norvin Burrus
@ndburrus
Jun 16 2016 08:02
@rahulchaurasia01 simply reference the example code (lookup table) in the pink background on the left (right above "Instructions").... this would be the format/organization... see it?
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:03
ok
@ndburrus like this
var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank",
};
result = lookup.alpha;
result = lookup.bravo;
result = lookup.charlie;
result = lookup.delta;
result = lookup.echo;
result = lookup.foxtrot;
Anton Bright
@OrthantBing
Jun 16 2016 08:05
Hi
Norvin Burrus
@ndburrus
Jun 16 2016 08:05
@Bookerhooker101 i believe you can just click on the exercises that you would like to go to... :+1:
ssm34
@ssm34
Jun 16 2016 08:05
Online places to learn JS ? I'm sick of every course teaching how to do maths with JS
Anton Bright
@OrthantBing
Jun 16 2016 08:06

I am at,
https://www.freecodecamp.com/challenges/arguments-optional
This is the working solution i came up with,

function addTogether() {
  var array = Array.prototype.slice.call(arguments);

  if (!array.every(function(k){
      return  Number.isInteger(k); 
    })){
    return undefined;
  }
  if(array.length > 1){
    return array.reduce(function(prev,next){
      return prev+next;
    });
  }

  else{
    return function(val){
      if (!Number.isInteger(val)){
        return undefined;
      }else{
        return array[0]+val;
      }
    };
  }
 }

A better solution?

Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:06
@Masd925 tell something >>??
ssm34
@ssm34
Jun 16 2016 08:07
Online places to learn JS ? I'm sick of every course teaching how to do maths with JS
Norvin Burrus
@ndburrus
Jun 16 2016 08:07
@rahulchaurasia01 ok, now, we need to use (or reference) the lookup table to get the desired return (or result) values.... check how to do this in the code example... here: (note how the table name is used, along with the key to reference a desired value )
alpha[2]; // "Y"
alpha[24]; // "C"

var value = 2;
alpha[value]; // "Y"
Markus Kiili
@Masd925
Jun 16 2016 08:08
@OrthantBing JS functions return undefined automatically if no return is made. Therefore you can forget returning undefined and just make two positive test cases for one and two valid arguments. Code gets clearer and shorter.
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:08
@ndburrus ok
Anton Bright
@OrthantBing
Jun 16 2016 08:08
@Masd925 Oh!! Okay.. I didnt know that, thanks for the info.
CamperBot
@camperbot
Jun 16 2016 08:08
orthantbing sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1882 | @masd925 |http://www.freecodecamp.com/masd925
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:10
@ndburrus this way
lookup[alpha];
Harshil Agrawal
@harshil1712
Jun 16 2016 08:10
@Masd925 thanks
CamperBot
@camperbot
Jun 16 2016 08:10
harshil1712 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1883 | @masd925 |http://www.freecodecamp.com/masd925
Norvin Burrus
@ndburrus
Jun 16 2016 08:10
@ssm34 this may be useful: The 50 Best Websites to Learn JavaScript :)
guys help
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:13
yOoooO oHO anyONE ????????
Norvin Burrus
@ndburrus
Jun 16 2016 08:13
@rahulchaurasia01 alright... almost... notice exactly what is/are being used. it looks like the table name is used, along with what? hint: see the bottom two lines of example code... :+1: here:
var value = 2;
alpha[value]; // "Y"
mos
@sophizo
Jun 16 2016 08:14
 switch (val) {
  case 'alpha':
console.log('do this');    
      break;

      case "beta":
console.log("beta");    break;

      case "gamma":
    console.log("gamma");
    break;

      case "delta":
console.log("delta");    break;
  }
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:16
@ndburrus not working :(
Norvin Burrus
@ndburrus
Jun 16 2016 08:17
@rahulchaurasia01 can you post what you've got?
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:17

@ndburrus var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank",
};

lookup.alpha;
var value = "alpha";
lookup[value];

Norvin Burrus
@ndburrus
Jun 16 2016 08:18
@rahulchaurasia01 ok... 2 questions: a) what is the appropriate variable (hint: function input) name?, and b) where do you want your desired output to go (or be placed)? :sparkles:
mos
@sophizo
Jun 16 2016 08:19
guys
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:19
output to go to "result"
Norvin Burrus
@ndburrus
Jun 16 2016 08:19
@rahulchaurasia01 ok, super... and the variable name should be? ok, outstanding - can you adjust the code?
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:20
val
maybe
@ndburrus i cant :(
Norvin Burrus
@ndburrus
Jun 16 2016 08:23
@rahulchaurasia01 ...sure you can :) ... we're going to need an assignment to result - because that's where you said you want the output to go? ...and we also need to use val, because you mentioned that is the appropriate variable name to use? so, we can just re-organize the information in those last 3 code lines... you can actually complete it with one code line...
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:25
@ndburrus i not getting it, totally consfuse
Norvin Burrus
@ndburrus
Jun 16 2016 08:27
@rahulchaurasia01 ok, let's get rid of the last 3 code lines. how can we make an assignment to our return variable?
Arun Kumar A
@alarun555
Jun 16 2016 08:27
@HeumO You shouldn't do it that way. You should check for the numerical value of the input and correspondingly print outputs. Like, if 1 is the input alpha should be printed and so on
Vladimir Oscolcov
@dmduelist
Jun 16 2016 08:27
hey guys, I have a problem with the Twitch.tv assignment. When I use the target='_blank' on the links that point out to the channel, the new window of twitch opens, but it never finishes to load.
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:28
@ndburrus dont knw :(
Arun Kumar A
@alarun555
Jun 16 2016 08:28
@HeumO So it must be like case 1: console.log('alpha'); break; and so on
Norvin Burrus
@ndburrus
Jun 16 2016 08:28
@rahulchaurasia01 come on... relax... what is the return variable?
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:28
result
Norvin Burrus
@ndburrus
Jun 16 2016 08:29
@rahulchaurasia01 ...and how do we make an assignment to it?
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:29
result = something
Norvin Burrus
@ndburrus
Jun 16 2016 08:29
@rahulchaurasia01 great! ... and that something needs to look like: alpha[value];, right? note: in the example, alpha is the table name, and value is a variable, see that?
Scott Leivesley
@scottlevos
Jun 16 2016 08:30
Thanks so much @ndburrus - was struggling with this at exactly the same time!
CamperBot
@camperbot
Jun 16 2016 08:30
scottlevos sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 563 | @ndburrus |http://www.freecodecamp.com/ndburrus
Joseph Jordan
@Garousen
Jun 16 2016 08:31
Hey all. having a small issue with a lesson, I can wait if you're busy though.
Norvin Burrus
@ndburrus
Jun 16 2016 08:31
@scottlevos you're very welcome! glad to help... nice work... :+1:
@Garousen which exercise?
@rahulchaurasia01 how are we doing?
Joseph Jordan
@Garousen
Jun 16 2016 08:32
Assignment with a Returned Value...it's telling me that processed should equal 2, which it does, but I think I messed the code as it's not showing the value as assigned
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:32
@ndburrus bad

var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank",
};

lookup.alpha;
lookup.bravo;
var value = "alpha";
lookup[value];

mos
@sophizo
Jun 16 2016 08:33
@alarun555 no luck still
  switch (val) {
      case 1:
console.log("alpha");    
      break;

      case 2:
console.log("beta");    break;

      case 3:
    console.log("gamma");
    break;

      case 4:
console.log("delta");    break;
  }
Joseph Jordan
@Garousen
Jun 16 2016 08:33

var processed = 0;

function processArg(num) {
return (num + 5) / 5;
}
This is what I have for the exercise

Norvin Burrus
@ndburrus
Jun 16 2016 08:33
@rahulchaurasia01 ok, these lines can disappear : (we need the result = we were working with)
lookup.alpha;
lookup.bravo;
var value = "alpha";
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:34
@ndburrus removed now ?
Norvin Burrus
@ndburrus
Jun 16 2016 08:35
@Garousen is this accurate? num + 5 :)
Arun Kumar A
@alarun555
Jun 16 2016 08:35
@HeumO it should not be like that actually, you must set "answer" equal to the corresponding strings in each cases like "alpha" for case 1 "beta" for case2 and so on and finally return the answer
mos
@sophizo
Jun 16 2016 08:36
got it
thanks
Joseph Jordan
@Garousen
Jun 16 2016 08:36
@ndburrus how do you mean?
mos
@sophizo
Jun 16 2016 08:36
@alarun555
thanks
Arun Kumar A
@alarun555
Jun 16 2016 08:37
@HeumO yeah thats ok :)
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:37
@ndburrus how to send code like that ??
mos
@sophizo
Jun 16 2016 08:38
by typing ``` above & below the code
Norvin Burrus
@ndburrus
Jun 16 2016 08:38
help format @rahulchaurasia01
CamperBot
@camperbot
Jun 16 2016 08: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 thecode`.

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

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

Thomas M
@TMORGANT
Jun 16 2016 08:39
Hey guys, can someone explain me where i'm wrong in this code ?
function lookUpProfile(firstName, prop){
// Only change code below this line
  var res = "";
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i]["firstName"] == firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];      
    } else if (contacts[i]["firstName"] != firstName) {
      res = "No such contact";
    } else if (!contacts[i].hasOwnProperty(prop)) {
      res = "No such property";
    }
  }

  return res;
// Only change code above this line
}
I can't get how to solve the last request of the test ...
Norvin Burrus
@ndburrus
Jun 16 2016 08:41
@Garousen can you post your code after this line: // Only change code below this line?
Joseph Jordan
@Garousen
Jun 16 2016 08:41

@ndburrus
var processed = 0;

function processArg(num) {
return (num + 5) / 5;

there is a } that I missed pasting
Norvin Burrus
@ndburrus
Jun 16 2016 08:42
@Garousen ok, do we understand these instructions: Call the processArg function with an argument of 7 and assign its return value to the variable processed.? brb...
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:43
@ndburrus ttell mine wht to do next ??
help me
CamperBot
@camperbot
Jun 16 2016 08:45

:point_right: adding environment variables [wiki]

Adding Envirioment Variables in Windows

Via GUI

  1. Download Varpanel.
  2. Open Varpanel.
  3. In PATH variable, add the relevant path (for example).

Via Command Line

Refer to this answer on Super User.

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

phugogang
@phugogang
Jun 16 2016 08:46
I learn: declare-string-variables (javascript). But my code not pass
Instructions
Create two new string variables: myFirstName and myLastName and assign them the values of your first and last name, respectively.
Joseph Jordan
@Garousen
Jun 16 2016 08:46
thatnks @ndburrus
phugogang
@phugogang
Jun 16 2016 08:46
My solution: var myFirstName = "Alan";
var myLastname = "Turing";
Khaleel Syed
@khaleelsyed
Jun 16 2016 08:49

Hey guys, I'm struggling with a small javascript challenge:
" myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces. "

var myStr='\ \t \t \r \n';

My output is: https://gmkr.io/s/576267e5bcef1657248ef000/0

Bank5z0rSqt
@Bank5z0rSqt
Jun 16 2016 08:49

Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr.

multiplyAll([1,2,[3]]); should return 6

what is "product" for?
Thomas M
@TMORGANT
Jun 16 2016 08:51
to store the result ?
Bank5z0rSqt
@Bank5z0rSqt
Jun 16 2016 08:51
k...and this...
multiplyAll([[1,2],[3,4],[5,6,7]]);
Thomas M
@TMORGANT
Jun 16 2016 08:51
= 20
or not
Bank5z0rSqt
@Bank5z0rSqt
Jun 16 2016 08:51
no..
SaltyAir
@SaltyAir
Jun 16 2016 08:51
@phugogang "Use the var keyword to create a variable called myName.“ —> var myName;
Bank5z0rSqt
@Bank5z0rSqt
Jun 16 2016 08:51
5040
Thomas M
@TMORGANT
Jun 16 2016 08:52
= 1 x 2 x 3 x 4 x 5 x 6 x 7
Bank5z0rSqt
@Bank5z0rSqt
Jun 16 2016 08:52
multiplyAll([[1,2],[3,4],[5,6,7]]) should return 5040
Alexander Køpke
@alexanderkopke
Jun 16 2016 08:52
@khaleelsyed I think to escape backlash you do \\
SaltyAir
@SaltyAir
Jun 16 2016 08:52
whoops. string variables, sorry
Bank5z0rSqt
@Bank5z0rSqt
Jun 16 2016 08:53
y its that...but how should i use "product" in 1x2x3x4x5...
Vladimir Oscolcov
@dmduelist
Jun 16 2016 08:53
if I click on the link, the page doesn't load, if I middle-mouse-click, the page opens in new tab and it works
Norvin Burrus
@ndburrus
Jun 16 2016 08:54
@Garousen were you able to resolve it?
Khaleel Syed
@khaleelsyed
Jun 16 2016 08:54
@alexanderkopke thanks that did the job!
CamperBot
@camperbot
Jun 16 2016 08:54
khaleelsyed sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:cookie: 672 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:54
@ndburrus mine ??
SaltyAir
@SaltyAir
Jun 16 2016 08:54
@phugogang Your „myLastname“ variable is not CamelCase
Norvin Burrus
@ndburrus
Jun 16 2016 08:55
@rahulchaurasia01 ok, have you figured out what to assign to result?
Thomas M
@TMORGANT
Jun 16 2016 08:55
@Bank5z0rSqt can you give me the name of the test ?
Norvin Burrus
@ndburrus
Jun 16 2016 08:55
@Bank5z0rSqt which exercise?
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:55
'''j result = lookup[value]; '''
CamperBot
@camperbot
Jun 16 2016 08:55
:bulb: to format code use backticks! ``` more info
Kashif Mohammed
@Spyreo
Jun 16 2016 08:56
Hello
Alex T.
@lx-t
Jun 16 2016 08:56
@dmduelist try using target="_blank" attribute in a tags
Norvin Burrus
@ndburrus
Jun 16 2016 08:56
@rahulchaurasia01 alright - where did that "j" come from? and also, what is the right var/iable name? you're almost there! :) hint: the correct var/iable name is also the same as the function input (which is the same as the test function call varaiable)
phugogang
@phugogang
Jun 16 2016 08:57
Thanks @SaltyAir
CamperBot
@camperbot
Jun 16 2016 08:57
phugogang sends brownie points to @saltyair :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @saltyair |http://www.freecodecamp.com/saltyair
Kashif Mohammed
@Spyreo
Jun 16 2016 08:57

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

// Only change code below this line

var gloveBoxContents = "maps"; // Change this line
myStorage.car.inside["glove box"];
myStorage.outside.trunk;
Can anyone help me wtih this?
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:57
@ndburrus j is nthing
phugogang
@phugogang
Jun 16 2016 08:58
@khaleelsyed : var myStr='\ \t \t \r \n'; ==> DOUBLE QUOTE not Single quote
Thomas M
@TMORGANT
Jun 16 2016 08:58
@Bank5z0rSqt For this exercise, you have to use 2 loop, and then watch the exemple on the left (instead of console.log, use a multiply)
SaltyAir
@SaltyAir
Jun 16 2016 08:58
@phugogang :)
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 08:58

@ndburrus
'''j var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank",
};

var value = "alpha";
result = lookup[value];
// Only change code above this line
return result;
}
'''

CamperBot
@camperbot
Jun 16 2016 08:58
:bulb: to format code use backticks! ``` more info
Vladimir Oscolcov
@dmduelist
Jun 16 2016 08:58
@lx-t tried, it opens a new twitch tab, but the page is loading-loop, it simply doesn't load.
@lx-t is in*
Thomas M
@TMORGANT
Jun 16 2016 08:58
@ndburrus have you any idea about where am i wrong in this code ?
function lookUpProfile(firstName, prop){
// Only change code below this line
  var res = "";
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i]["firstName"] == firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];      
    } else if (contacts[i]["firstName"] != firstName) {
      res = "No such contact";
    } else if (!contacts[i].hasOwnProperty(prop)) {
      res = "No such property";
    }
  }

  return res;
// Only change code above this line
}
RakeshNerkar
@Rakesh18754
Jun 16 2016 09:00
can i have multiple multiple module in angular js
Norvin Burrus
@ndburrus
Jun 16 2016 09:00
@rahulchaurasia01 it may be time for a break. you should calmly review the sample exercise code to ensure that all of the names (ie table, variables) are accurate... :+1:
Rahul Chaurasia
@rahulchaurasia01
Jun 16 2016 09:00
@ndburrus

'''js
var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank",
};

var value = "alpha";
result = lookup[value];
// Only change code above this line
return result;
}

CamperBot
@camperbot
Jun 16 2016 09:00
:bulb: to format code use backticks! ``` more info
Norvin Burrus
@ndburrus
Jun 16 2016 09:02
@TMORGANT "firstName" is a variable, so it shouldn't have quotes :)
Kashif Mohammed
@Spyreo
Jun 16 2016 09:02
Can anyone help me
Norvin Burrus
@ndburrus
Jun 16 2016 09:02
@Spyreo which challenge?
Thomas M
@TMORGANT
Jun 16 2016 09:02
it's also in my json
Kashif Mohammed
@Spyreo
Jun 16 2016 09:03
Accessing Nested Objects in JSON
:(
Thomas M
@TMORGANT
Jun 16 2016 09:03
var contacts = [
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];
Yannick Dongo
@yannick77
Jun 16 2016 09:03

'''
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
'''

help with this exercise would be apreciated, cant exactly figure out what is required,

For the given id in collection:

If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

CamperBot
@camperbot
Jun 16 2016 09:03
:bulb: to format code use backticks! ``` more info
James Dui
@jamesMD
Jun 16 2016 09:04
@yannick77 i was about to ask the same question, found answer online, but still don't understand it
Norvin Burrus
@ndburrus
Jun 16 2016 09:04
@Spyreo this code can be eliminated: myStorage.outside.trunk;, along with this "maps" piece the remaining code together and youve got it~ have to go now..
Kashif Mohammed
@Spyreo
Jun 16 2016 09:04
Use dot and bracket notation to access myStorage
I get this error then
Yannick Dongo
@yannick77
Jun 16 2016 09:05
@jamesMD i was wondering if(collection.id.prop =="tracks" && collection.id.propvalue!== ""){
collection.id.prop.tracks.push(value);
}
Kashif Mohammed
@Spyreo
Jun 16 2016 09:05
I'm using the dot and bracket notation
myStorage.car.inside["glove box"];
How do i get acces to myStorage using dot and bracket notation?
Leslie Lee
@leslie5803
Jun 16 2016 09:07
function getData(){}
Kashif Mohammed
@Spyreo
Jun 16 2016 09:07
I'm trying to do same thing what he did in the example problem
Wilmer Rodriguez
@wilmerRodriguez
Jun 16 2016 09:09
Hello world
CamperBot
@camperbot
Jun 16 2016 09:09

welcome to FreeCodeCamp @wilmerRodriguez!

Kashif Mohammed
@Spyreo
Jun 16 2016 09:09
Hello sir
Yannick Dongo
@yannick77
Jun 16 2016 09:09
@Spyreo Var gloveBpxContents= myStorage.car.inside["glove box"]
Alex T.
@lx-t
Jun 16 2016 09:10
@dmduelist The problem is in the a tag content. When I chenge your JS to populate a tag only with a stream's title, it works.
"<div class='col-md-4 col-sm-6 col-xs-12 offline'>
  <div class='channel'>
    <a href='" + url + "' class='link' target='_blank'>" + title + ". " + text + "
    </a>
  </div>
</div>"
Kashif Mohammed
@Spyreo
Jun 16 2016 09:10
Thank you @yannick77
CamperBot
@camperbot
Jun 16 2016 09:10
spyreo sends brownie points to @yannick77 :sparkles: :thumbsup: :sparkles:
:cookie: 166 | @yannick77 |http://www.freecodecamp.com/yannick77
Kashif Mohammed
@Spyreo
Jun 16 2016 09:11
I got it know
Yannick Dongo
@yannick77
Jun 16 2016 09:11
can anyone help with the "Record Collection" exercise
Vladimir Oscolcov
@dmduelist
Jun 16 2016 09:11
@TMORGANT try using contacts[i].firstName instead of contacts[i]["firstName"]
Kashif Mohammed
@Spyreo
Jun 16 2016 09:14
I'm doing the same exercise
i will hit you up, after i solve it @yannick77
Thomas M
@TMORGANT
Jun 16 2016 09:14
@dmduelist I'm on it
function lookUpProfile(firstName, prop){
// Only change code below this line
  var res = "";
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
      res = contacts[i][prop];
    } else if (contacts[i].firstName != firstName) {
      res = "No such contact";
    } else if (!contacts[i].hasOwnProperty(prop)) {
      res = "No such property";
    }
  }

  return res;
// Only change code above this line
}
Still a bad result :/
Krishna
@krishnakumar360
Jun 16 2016 09:15

Counting Cards(javascript)
getting errors

Need Help

var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2:

case 3:
case 4:
case 5:
case 6:
  count++;
  break;

case 7:
case 8:
case 9:
  count=count+0;
 break;

case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
  count--;
  break;

}

if(count<=0)
{
console.log(count+=" Hold");

}

else{
console.log(count+=" bet");

}

Vladimir Oscolcov
@dmduelist
Jun 16 2016 09:15
@TMORGANT I did it but "if - nesting"
@TMORGANT by*
Yannick Dongo
@yannick77
Jun 16 2016 09:16
@Spyreo would be appreciated
Kashif Mohammed
@Spyreo
Jun 16 2016 09:16
Krishna
count = count + 1;
count = count + 0;
count = count - 1;
Thomas M
@TMORGANT
Jun 16 2016 09:17
@dmduelist like this ?
function lookUpProfile(firstName, prop){
// Only change code below this line
  var res = "";
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName) {
      if (contacts[i].hasOwnProperty(prop))
        res = contacts[i][prop];
    } else if (contacts[i].firstName != firstName) {
      res = "No such contact";
    } else if (!contacts[i].hasOwnProperty(prop)) {
      res = "No such property";
    }
  }

  return res;
// Only change code above this line
}
Kashif Mohammed
@Spyreo
Jun 16 2016 09:17
That thing sure works "++" but as you are beginning start with +1
And there should be a if
Krishna
@krishnakumar360
Jun 16 2016 09:18
@Spyreo Still getting the errors
Vladimir Oscolcov
@dmduelist
Jun 16 2016 09:18
@TMORGANT yes, but I can advise you ditch the whole "var res" you can return the result straight from the if check
Kashif Mohammed
@Spyreo
Jun 16 2016 09:19
there should
If
after
count = count - 1;
break;
Get it?
Markus Kiili
@Masd925
Jun 16 2016 09:20
@TMORGANT You only need the first two if's. Elses are optional. No such contact should be returned after checking all the contacts.
Kashif Mohammed
@Spyreo
Jun 16 2016 09:20
Hi @Masd925
Vladimir Oscolcov
@dmduelist
Jun 16 2016 09:20
@TMORGANT put the last else if inside the first if
Markus Kiili
@Masd925
Jun 16 2016 09:20
@Spyreo Hello.
DaX
@daxdax89
Jun 16 2016 09:20
someone give me solution for Word Blanks chllenge i am stucked and it's probably somethign stupid
Krishna
@krishnakumar360
Jun 16 2016 09:21

@Spyreo i also tried this way but got error switch(card){
case 2:

case 3:
case 4:
case 5:
case 6:
  count=count+1;
  if(count<=0)
{
  return count+=" Hold";
  //console.log(count+" Hold");
}

else{
return count+=" Bet";
//console.log(count+" Bet");
}
break;

case 7:
case 8:
case 9:
  count=count+0;
  if(count<=0)
{
  return count+=" Hold";
  //console.log(count+" Hold");
}

else{
return count+=" Bet";
//console.log(count+" Bet");
}
break;

case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
  count=count-1;
  if(count<=0)
{
  return count+=" Hold";
  //console.log(count+" Hold");
}

else{
return count+=" Bet";
//console.log(count+" Bet");
}
break;
}

Kashif Mohammed
@Spyreo
Jun 16 2016 09:23
Do the if part in the end
More convinent
Thomas M
@TMORGANT
Jun 16 2016 09:24
@Masd925 @dmduelist is this better ```
DaX
@daxdax89
Jun 16 2016 09:24
come on guys help me
Thomas M
@TMORGANT
Jun 16 2016 09:24
function lookUpProfile(firstName, prop){
// Only change code below this line
  var res = "";
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName) {
      if (contacts[i].hasOwnProperty(prop))
        res = contacts[i][prop];
      else if (!contacts[i].hasOwnProperty(prop)) {
        res = "No such property";
      }
    }
    res = "No such contact";
  }

  return res;
// Only change code above this line
}
Kashif Mohammed
@Spyreo
Jun 16 2016 09:24
@krishnakumar360 ``` if (count>0){
return count+ ' Bet';
}
else {
return count+ ' Hold';
}
``
Markus Kiili
@Masd925
Jun 16 2016 09:24
This message was deleted
@TMORGANT It is better if you remove the res variable and just return when you know the return value.
Vladimir Oscolcov
@dmduelist
Jun 16 2016 09:26
@lx-t thanks, it didn't help though.
CamperBot
@camperbot
Jun 16 2016 09:26
dmduelist sends brownie points to @lx-t :sparkles: :thumbsup: :sparkles:
:cookie: 337 | @lx-t |http://www.freecodecamp.com/lx-t
Kashif Mohammed
@Spyreo
Jun 16 2016 09:26

// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
What i have to do here? I can't really figure it out @Masd925
Vladimir Oscolcov
@dmduelist
Jun 16 2016 09:27
@lx-t I added target _blank (I already did that before) same result unfortunately ;(
Markus Kiili
@Masd925
Jun 16 2016 09:27
@Spyreo Make checks for value and prop according to task. On if blocks access collection as asked.
Vladimir Oscolcov
@dmduelist
Jun 16 2016 09:27
@TMORGANT I solved my problem a bit simpler, so i'm trying to adapt it to your solution to see what's not working
Thomas M
@TMORGANT
Jun 16 2016 09:28
@Masd925 this ?
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName) {
      if (contacts[i].hasOwnProperty(prop))
        return contacts[i][prop];
      else if (!contacts[i].hasOwnProperty(prop)) {
        return "No such property";
      }
    }
    return "No such contact";
  }
// Only change code above this line
}
@dmduelist If you want you can guide me to simplify it ?
Markus Kiili
@Masd925
Jun 16 2016 09:28
@TMORGANT Move the last return slightly down.
Alex T.
@lx-t
Jun 16 2016 09:28
@dmduelist Hm. It works for me in Firefox. It opens twitch stream in new tab.
Markus Kiili
@Masd925
Jun 16 2016 09:29
@TMORGANT The third if is redundant. You only need the two if's and the returns.
Alex T.
@lx-t
Jun 16 2016 09:30
@dmduelist Or did you mean it opens a new tab for you too but twitch is trying to load content and hangs with a spinning icon in the middle of the screen?
Thomas M
@TMORGANT
Jun 16 2016 09:31
@Masd925 Yes you are obviously right about the redundant if ... my mistake. Well, it works, but can't figure out why :/
So, thanks @Masd925 @dmduelist
CamperBot
@camperbot
Jun 16 2016 09:31
tmorgant sends brownie points to @masd925 and @dmduelist :sparkles: :thumbsup: :sparkles:
:cookie: 293 | @dmduelist |http://www.freecodecamp.com/dmduelist
:star2: 1884 | @masd925 |http://www.freecodecamp.com/masd925
Thomas M
@TMORGANT
Jun 16 2016 09:32
OMG i understand it !
Ok i'm going far far far away ...
DaX
@daxdax89
Jun 16 2016 09:33
Word Blanks challenge, could anyone help?
Vladimir Oscolcov
@dmduelist
Jun 16 2016 09:34
@lx-t yes- exactply, it opens but it hangs
@lx-t but when I use middle-mouse-button, it works fine, opens in new tab and loads perfectly
Alex T.
@lx-t
Jun 16 2016 09:35
@dmduelist I see. Now, it's getting interesting. :)
Krishna
@krishnakumar360
Jun 16 2016 09:35

getting errors in

counting cards

var count = 0;

function cc(card) {
// Only change code below this line

switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count=count+1;
break;
case 7:
case 8:
case 9:
count=count+0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count=count-1;
break;
}
if(count<=0)
{
return (count+" Hold");

}

else{
return (count+" bet");

}
return "count";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Vladimir Oscolcov
@dmduelist
Jun 16 2016 09:36
@TMORGANT you are very close :)
@lx-t and this is when I though it's gonna be easy to fix it before finishing the buttons' functionality ))
Alex T.
@lx-t
Jun 16 2016 09:37
@dmduelist You know, it even loads pages differently. When I middle click links it shows twitch logo in the middle of the opened page. It doesn't do that when I left click a link.
Vladimir Oscolcov
@dmduelist
Jun 16 2016 09:38
@lx-t for me, the opening of the page is the same
mos
@sophizo
Jun 16 2016 09:41
can someone help me in card counting ?
Adeel Ahmed
@Adeel992
Jun 16 2016 09:42
why myStr notmhave a value of This is the first sentence. This is the second sentence.using += operator
Zena Jose
@zena-08
Jun 16 2016 09:42

Can someone tell me what's wrong in my code? I ge the desired output but it isn't accepting my code.

var count = 0;

function cc(card) {
// Only change code below this line
switch(card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count = count +1;
break;

case 7:
case 8:
case 9:
  count = count;
  break;

case 10:
case "J":
case "K":
case "Q":
case "A":
  count--;
  break;

}

if(count > 0){
return count + " bet";
}
return count + " hold";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

96street
@96street
Jun 16 2016 09:43
Hey i'm doing the Quote Generator challenge. Can someone tell me why it's not working ? http://codepen.io/kingdezz/pen/mEJPLN
Alexander Køpke
@alexanderkopke
Jun 16 2016 09:43
@zena-08 just guessing but bet and hold should be Bet and Hold?
mos
@sophizo
Jun 16 2016 09:43
add else
Zena Jose
@zena-08
Jun 16 2016 09:44
@alexanderkopke thanks :). That worked.
CamperBot
@camperbot
Jun 16 2016 09:44
zena-08 sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:cookie: 673 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Alexander Køpke
@alexanderkopke
Jun 16 2016 09:44
@zena-08 det var så lidt ;)
Krishna
@krishnakumar360
Jun 16 2016 09:46
@Spyreo thanks bro
CamperBot
@camperbot
Jun 16 2016 09:46
krishnakumar360 sends brownie points to @spyreo :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @spyreo |http://www.freecodecamp.com/spyreo
Yannick Dongo
@yannick77
Jun 16 2016 09:46
@Spyreo any luck?
Alex T.
@lx-t
Jun 16 2016 09:49
@dmduelist Even if I remove all HTML, CSS and JS code and place this into HTML editor panel: <a href='https://www.twitch.tv/ogamingsc2' class='link' target='_blank'>oGamingSC2</a> it behaves the same. I guess it's twitch's problem. Also I guess twitch might respond this way because it sees codepen.com as a referrer in HTML request.
Eli
@elisspace
Jun 16 2016 09:49
Hey folks. Working on the wikipedia viewer. I've run into an issue. I want my div's with the search results to be clickable links, but I think the event.preventDefault(); is stopping the links from working. However if I remove it then the search box doesn't work. Here's the code:
$('#searchbox').submit(function(event) {
  event.preventDefault();
  //console.log('input: '+$('input').val());
  $.getJSON(wikiEndpoint + $('input').val() + '&callback=?', function() {
      console.log("success");

    })
    .done(function(data) {
      //For testing purposes
      console.log("second success");

      //Clear any current results
      $("#results").html('');

      $.each(data.query.search, function(index, value) {
      console.log('index:'+index+" this.title:"+ encodeURI(this.title));

      $("<br><a href='http://en.wikipedia.org/wiki/" + encodeURI(this.title) + "'><div class='indiv-result well col-md-offset-2 col-md-8'>" + "<a href='http://en.wikipedia.org/wiki/" + encodeURI(this.title) + "'>"+ this.title + "</a>" + " - " + this.snippet + "</div>" + "</a>")
        .appendTo("#results");  


      });
    })
    .fail(function() {
      console.log("error");
    })
    .always(function() {
      console.log("complete");
    });
});
mos
@sophizo
Jun 16 2016 09:50
@alexanderkopke can we do that exercise without switch statement ?
Leo
@Leodhy
Jun 16 2016 09:50

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

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

var Bike = function(setGear,getGear) {

var gear;
this.setGear=setGear;
getGear=this.setGear;
};

var myCar = new Car();

var myBike = new Bike(setGear,getGear);

mos
@sophizo
Jun 16 2016 09:50
card counting i mean
Alexander Køpke
@alexanderkopke
Jun 16 2016 09:50
@HeumO yes but I think it is required to use the switch if I recall correctly
mos
@sophizo
Jun 16 2016 09:51
no it isnt mentioned
Krishna
@krishnakumar360
Jun 16 2016 09:51
@HeumO just completed it
Alexander Køpke
@alexanderkopke
Jun 16 2016 09:51
I'll have a look
mos
@sophizo
Jun 16 2016 09:51
i was trying with "if" but just saw her code it was in swithc
Leo
@Leodhy
Jun 16 2016 09:52
?
mos
@sophizo
Jun 16 2016 09:52
@krishnakumar360 with if else ?
Krishna
@krishnakumar360
Jun 16 2016 09:52

var count = 0;

function cc(card) {
// Only change code below this line

switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count=count+1;
break;
case 7:
case 8:
case 9:
count=count+0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count=count-1;
break;
}
if(count<=0)
{
return (count+" Hold");

}

else{
return (count+" Bet");

}
// return "count";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Alex T.
@lx-t
Jun 16 2016 09:52
@dmduelist Even FreeCodeCamp's TwitchTV API example won't work. :(
Leo
@Leodhy
Jun 16 2016 09:52
how can tell me the problem about my code
it's a program about "Make Object Properties Private"
Krishna
@krishnakumar360
Jun 16 2016 09:53
@HeumO with switch and if condition
mos
@sophizo
Jun 16 2016 09:53
no , i was talking about just if else
not switch
Alexander Køpke
@alexanderkopke
Jun 16 2016 09:53
@HeumO you're right, there is no switch requirement.
Krishna
@krishnakumar360
Jun 16 2016 09:54
@HeumO ya it can be done but it will get much bigger
Markus Kiili
@Masd925