These are chat archives for FreeCodeCamp/HelpJavaScript

18th
May 2016
eduwin7
@eduwin7
May 18 2016 00:00

function isLess(a, b) {
// Fix this code

return 10<=15;

returning boolean on function
rphares
@rphares
May 18 2016 00:01
just use a and b,
Norvin Burrus
@ndburrus
May 18 2016 00:01
@MBNWeb1 it's helpful to follow the format of the sample code :)
var arr = [
  [1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
    console.log(arr[i][j]);
  }
}
rphares
@rphares
May 18 2016 00:01
and just less than, not less than or equal to ;)
Jason Shoemaker
@kutsuya1
May 18 2016 00:01
@ndburrus It's cheaten' :))
heh
eduwin7
@eduwin7
May 18 2016 00:02

this is what i have
function isLess(a, b) {
// Fix this code

return 10<15;

rphares
@rphares
May 18 2016 00:02
now the bottom is almost right, but
dont hard code 10 and 15
just use a and b
Norvin Burrus
@ndburrus
May 18 2016 00:02
@kutsuya1 ...hmmm, that code is in the challenge.
Maury
@MBNWeb1
May 18 2016 00:05
@ndburrus I haven't figured out how to send code in the black frame there, so I just sent the link
Michael
@michaeldiegogil
May 18 2016 00:05
can anyone explain Convert Celsius to Fahrenheit
to me? i can not understand for the life of me
Norvin Burrus
@ndburrus
May 18 2016 00:05
@eduwin7 it may be helpful to review the operators w3chools, JavaScript Comparison and Logical Operators {ref: http://www.w3schools.com/js/js_comparisons.asp }
Operator    Description    Comparing    Returns    Try it
==    equal to    x == 8    false    Try it »
x == 5    true    Try it »
x == "5"    true    Try it »
===    equal value and equal type    x === 5    true    Try it »
x === "5"    false    Try it »
!=    not equal    x != 8    true    Try it »
!==    not equal value or not equal type    x !== 5    false    Try it »
x !== "5"    true    Try it »
x !== 8    true    Try it »
>    greater than    x > 8    false    Try it »
<    less than    x < 8    true    Try it »
>=    greater than or equal to    x >= 8    false    Try it »
<=    less than or equal to    x <= 8    true
Maury
@MBNWeb1
May 18 2016 00:05
@michaeldiegogil the math of it?
Norvin Burrus
@ndburrus
May 18 2016 00:06
help format @MBNWeb1
CamperBot
@camperbot
May 18 2016 00:06

: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

rphares
@rphares
May 18 2016 00:07
@michaeldiegogil , you just need to turn the formal they gave you into code
Michael
@michaeldiegogil
May 18 2016 00:07

@MBNWeb1 To test your learning, you will create a solution "from scratch". Place your code between the indicated lines and it will be tested against multiple test cases.

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

You are given a variable celsius representing a temperature in Celsius. Create a variable fahrenheit and apply the algorithm to assign it the corresponding temperature in Fahrenheit.

what formal
rphares
@rphares
May 18 2016 00:07
the temp in fahrenheit is the temp in celsius times 9/5 plus 32
Michael
@michaeldiegogil
May 18 2016 00:08
32?
Maury
@MBNWeb1
May 18 2016 00:08
@michaeldiegogil technically, you don't need to do the math. The API returns either F or C when you give it a units=imperial or units=metric
Norvin Burrus
@ndburrus
May 18 2016 00:09
@michaeldiegogil ok, just use the conversion formula information given to generate a fahrenheit value
rphares
@rphares
May 18 2016 00:09

declare the var fahrenheit and use the operators = , * , and + to write

the temp in fahrenheit is the temp in celsius times 9/5 plus 32
in code. @michaeldiegogil

Maury
@MBNWeb1
May 18 2016 00:09
@michaeldiegogil in the API url query
rphares
@rphares
May 18 2016 00:09
@MBNWeb1 , dont think he is on the pen yet,
a waypoint, i believe...
Norvin Burrus
@ndburrus
May 18 2016 00:10
@eduwin7 ...how are you doing?
Maury
@MBNWeb1
May 18 2016 00:10
@rphares Oh, well, now he knows for later haha
rphares
@rphares
May 18 2016 00:10
indeed :blush:
Maury
@MBNWeb1
May 18 2016 00:11
@rphares any chance you know how to enable ES6 in FCC?
rphares
@rphares
May 18 2016 00:12
no-- I've seen people talk about it, i know its doable-- something about its supported, depends on your browser, and ... babel? could be making that up though, I'm a newbie and only half pay attention to things way above my level--
give me a minute or two to see if i can find a convo on it with some possibly useful info
Michael
@michaeldiegogil
May 18 2016 00:14
THANK YOU @rphares
CamperBot
@camperbot
May 18 2016 00:14
michaeldiegogil sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4666 | @rphares |http://www.freecodecamp.com/rphares
rphares
@rphares
May 18 2016 00:18
@michaeldiegogil -- read the first few replies and feel free to ask follow-ups-- its a good, helpful group :point_up: May 17, 2016 5:16 PM :blush:
this one is super relevant, i think :point_up: May 17, 2016 5:18 PM @michaeldiegogil
Ryan Park
@rpark4
May 18 2016 00:21

function titleCase(str) {

str = str.toLowerCase();
str = str.split(' ');
sroo="";
for (i=0;i<str.length;i++)
{
j = str[i][0].toUpperCase();
k = str[i];
k = k.slice(1,k.length);
sroo += j.concat(k, " ");
}
sroo = sroo.slice(0,-1);
j='"';
sroo = j.concat(sroo, j);
return sroo;

}

titleCase("sHoRt AnD sToUt");

hey guys, I can't figure out why this doesn't pass
it seems to work
Maury
@MBNWeb1
May 18 2016 00:23
@rphares Thanks, I'll try that out! I appreciate it!
CamperBot
@camperbot
May 18 2016 00:23
mbnweb1 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4667 | @rphares |http://www.freecodecamp.com/rphares
rphares
@rphares
May 18 2016 00:24
Anytime~ I didn't do much, i didn't know, lol, but happy to help :blush:
Ryan Park
@rpark4
May 18 2016 00:24
anyone know what to do when the code you wrote works, but doesn't pass the test?
Maury
@MBNWeb1
May 18 2016 00:25
@rphares For sure. I just find it funny that FCC recommends learning ES6 but doesnt make it easy to use for the assignments
rphares
@rphares
May 18 2016 00:26
@rpark4 , paste it and get feedback in the help or main chat rooms, depending on where people will look through it with you :blush:
Ryan Park
@rpark4
May 18 2016 00:27
This message was deleted

function titleCase(str) {

str = str.toLowerCase();
str = str.split(' ');
sroo="";
for (i=0;i<str.length;i++)
{
j = str[i][0].toUpperCase();
k = str[i];
k = k.slice(1,k.length);
sroo += j.concat(k, " ");
}
sroo = sroo.slice(0,-1);
j='"';
sroo = j.concat(sroo, j);
sroo.toString();
return sroo;

}

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

This message was deleted
it works
rphares
@rphares
May 18 2016 00:28
im not good enough-- calling the wise people who were here earlier-- anyone wanna de-bug?
Ryan Park
@rpark4
May 18 2016 00:29
thanks anyways @rphares
CamperBot
@camperbot
May 18 2016 00:29
rpark4 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4668 | @rphares |http://www.freecodecamp.com/rphares
Ryan Park
@rpark4
May 18 2016 00:29
your killing it with the brownie points
rphares
@rphares
May 18 2016 00:29
lol, sorry-- the only i notice is you dont seem to be using var ...?
lol, yeah, I'm a lazy slow learner who spends too much time on gitter :blush:
Ryan Park
@rpark4
May 18 2016 00:30
yeah, that is best practices. I'll go through and see if that helps somehow
still didn't pass, but it looks more professional.
rphares
@rphares
May 18 2016 00:32
lol, sorry! I'm trying to compare it to my soln... but part of why I'm barely moving forward is to get to a point where i can look at others algos and not be utterly useless... :pensive:
you might also try pasting it in the main chat with a 'my code works, but won't pass, anyone see anything?'
there are loads more people out there atm than in here... though it is general chat, and thy may not feel helpful ... shrug
Maury
@MBNWeb1
May 18 2016 00:33
@rpark4 what is the name of the assignment you're doing?
rphares
@rphares
May 18 2016 00:33
Title Case a Sentence
Peter Weinberg
@no-stack-dub-sack
May 18 2016 00:34
JS waypoint: Profile Lookup. Het guys, not looking for specific help on this, but can someone who's completed this waypoint before let me know if the solution includes a loop? It came right after the loop section, so it's stands to reason that it would, but it seems to be a little different than previous examples so just trying to make sure I'm on the right track. Thanks in advance.
eeflores
@eeflores
May 18 2016 00:34
yep
rphares
@rphares
May 18 2016 00:34
yep!
Peter Weinberg
@no-stack-dub-sack
May 18 2016 00:34
@eeflores is that yep directed towards me?
rphares
@rphares
May 18 2016 00:34
yep~ @no-stack-dub-sack :blush:
Peter Weinberg
@no-stack-dub-sack
May 18 2016 00:35
Ok, thanks! That's good
eeflores
@eeflores
May 18 2016 00:35
yep - there is a loop in Profile Lookup
Maury
@MBNWeb1
May 18 2016 00:35
@rphares Okay, give me a minute to check it out
rphares
@rphares
May 18 2016 00:35
( :blush: :blush: :blush: @eeflores !! :) )
eeflores
@eeflores
May 18 2016 00:35
hullo @rphares !
Peter Weinberg
@no-stack-dub-sack
May 18 2016 00:35
I may come back if I get stuck, but just wanted to make sure. Thanks @eeflores @rphares!
CamperBot
@camperbot
May 18 2016 00:35
no-stack-dub-sack sends brownie points to @eeflores and @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4669 | @rphares |http://www.freecodecamp.com/rphares
:cookie: 720 | @eeflores |http://www.freecodecamp.com/eeflores
Ryan Park
@rpark4
May 18 2016 00:37
@MBNWeb1 Title Case a Sentence
oh thanks again @rphares .
CamperBot
@camperbot
May 18 2016 00:37
rpark4 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:warning: rpark4 already gave rphares points
rphares
@rphares
May 18 2016 00:38
lol, sure thing-- now you have good people trying to help, hopefully that'll sort it :blush:
Mike Olo
@michaelolo24
May 18 2016 00:41
help sum all primes
CamperBot
@camperbot
May 18 2016 00:41

:point_right: algorithm sum all primes [wiki]

Algorithm Sum All Primes

Explanation:

The explanation for this problem is very simple. You will generate a list of prime numbers up to the number you are given as a parameter. Then you need to add them all up and return that value. The tricky part is on generating the list of prime numbers. I suggest you find a code or a good math algorithm that you can turn into code.

:pencil: read more about algorithm sum all primes on the FCC Wiki

Ryan Park
@rpark4
May 18 2016 00:42
we all good people
hehe
ok. I think I might have accidentally broken the internet
my baf
bad
rphares
@rphares
May 18 2016 00:44
lol, uhoh--
did your code get stuck?
Ryan Park
@rpark4
May 18 2016 00:45
yeah, but not in a loop. it just says //testing challenge...
Maury
@MBNWeb1
May 18 2016 00:45
@rphares that's odd. It does work for their test strings. Not sure why it doesn't pass
Ryan Park
@rpark4
May 18 2016 00:45
and never returns anything
Rémi Fortier
@mizujin
May 18 2016 00:45
exceeding call stack maybe
can we see code ?
Ryan Park
@rpark4
May 18 2016 00:46

function titleCase(str) {

str = str.toLowerCase();
str = str.split(' ');
sroo="";
for (i=0;i<str.length;i++)
{
j = str[i][0].toUpperCase();
k = str[i];
k = k.slice(1,k.length);
sroo += j.concat(k, " ");
}
sroo = sroo.slice(0,-1);
j='"';
sroo = j.concat(sroo, j);
sroo.toString();
return sroo;

}

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

I'll check back later. Have to get to class. Thanks @mizujin @MBNWeb1 @rphares for the help.
CamperBot
@camperbot
May 18 2016 00:47
rpark4 sends brownie points to @mizujin and @mbnweb1 and @rphares :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for mbnweb1
:warning: rpark4 already gave rphares points
:cookie: 347 | @mizujin |http://www.freecodecamp.com/mizujin
rphares
@rphares
May 18 2016 00:48
Enjoy classe!
Jordan Shackelford
@JordanShackelford
May 18 2016 00:49
Hey, so I'm working on a little 2d tile-based game to practice javascript. I have the different types of tiles stored in a "tiles" object.
function Tile(width,height,image){
        this.width = screen.tileWidth * width;
        this.height = screen.tileHeight * height;
        this.image = new Image();
        this.image.src = image;
    }

var tiles = {
        grass:new Tile(1,1,"grass.jpg"),
        water:new Tile(1,1,"water.jpg"),
        tree1:new Tile(2,5,"tree1.png"),
        tree2:new Tile(2,5,"tree2.png")
    };
buckshot307
@buckshot307
May 18 2016 00:51
Can anyone help me with the jQuery .animate() function?
Jordan Shackelford
@JordanShackelford
May 18 2016 00:51
When I try to draw a tile to the screen with tiles.grass it doesn't work, but if I just call it grass it does
eeflores
@eeflores
May 18 2016 00:52
is there a tiles var?
Jordan Shackelford
@JordanShackelford
May 18 2016 00:52
context.drawImage(grass,0,0,100,100); but not context.drawImage(tiles.grass,0,0,100,100);
eeflores
@eeflores
May 18 2016 00:52
oh yeah there it is
this.grass = new Tile()
Jordan Shackelford
@JordanShackelford
May 18 2016 00:52
I'm calling it outside the Tile function though
eduwin7
@eduwin7
May 18 2016 00:53
need help guys
on the counting cards
buckshot307
@buckshot307
May 18 2016 00:53
for (var i = 0; i < game.count; i++) {
              $('#button' + game.genSequence[i]).animate({
                  opacity: 0.6
                }, {
                duration: 50,
                  complete: function() {
                    $('#button' + game.genSequence[i]).stop().animate({
                      opacity: 1
                    }, 1000);
I've got this on a simon says game, but it only works like 1/4 of the time. Sometimes it just changes the opacity and doesn't change it back, and sometimes it doesn't work at all.
Moisés Man
@moigithub
May 18 2016 00:53
@JordanShackelford whats context.drawImage ?? from canvas ?
eeflores
@eeflores
May 18 2016 00:54
@JordanShackelford to make something private you declare it as var something
at the moment, grass is a global
or is it?
Jordan Shackelford
@JordanShackelford
May 18 2016 00:55
I would think not since tiles is an object
Rémi Fortier
@mizujin
May 18 2016 00:55
@rpark4 Your code returns "I\'m A Little Teapot"
eeflores
@eeflores
May 18 2016 00:55
tiles is declared with braces like object - maybe use square brackets to declare as array @JordanShackelford
Rémi Fortier
@mizujin
May 18 2016 00:56
@rpark4 check that, maybe "I'm" is considered as a single word ?
buckshot307
@buckshot307
May 18 2016 00:56
and if I change the duration at duration: 50 or at the end, the 1000, sometimes it just stops working.
eeflores
@eeflores
May 18 2016 00:56
wait ... that's not quite right ...
Moisés Man
@moigithub
May 18 2016 00:57
@JordanShackelford https://developer.mozilla.org/es/docs/Web/API/CanvasRenderingContext2D/drawImage
drawImage requires an image.. but tiles.grass is an object
context.drawImage(tiles.grass.image,0,0,100,100);
Jordan Shackelford
@JordanShackelford
May 18 2016 00:59
@moigithub Hmmm
Karan Bhandari
@karanbhandari
May 18 2016 00:59
Hi Guys, does anyone know if we could use jquery to call json inside a react.js website???
Jordan Shackelford
@JordanShackelford
May 18 2016 00:59
It's weird that it lets me draw it by just calling it grass though
Moisés Man
@moigithub
May 18 2016 00:59
probably on ur code u have another variable named grass only
else grass will be undefined....
Jordan Shackelford
@JordanShackelford
May 18 2016 01:01
Well another issue I'm having is that it will only draw the tile once
for(var i = 0; i < 10; i++){
            context.drawImage(tiles.grass.image,pixelX,pixelY,100,100);
            pixelX += screen.tileWidth;
        }
Moisés Man
@moigithub
May 18 2016 01:02
syntax
ctx.drawImage(image, dx, dy);
ctx.drawImage(image, dx, dy, dWidth, dHeight);
Jordan Shackelford
@JordanShackelford
May 18 2016 01:04
oh it has something to do with where I'm storing the width and the height of my tiles
because it doesn't draw anything at all when I do context.drawImage(tiles.grass.image,pixelX,pixelY,screen.tileWidth,screen.tileHeight);
Moisés Man
@moigithub
May 18 2016 01:05
dx and dy whre on the screen it gonna be draw
Rémi Fortier
@mizujin
May 18 2016 01:06
it's drawing 10 tiles exactly at the same spot
Jordan Shackelford
@JordanShackelford
May 18 2016 01:07
yeah it's my screen object
var screen = {
        offsetX: 0,
        offsetY: 0,
        numRows:25,
        numColumns:25,
        mouseCanvasCoords:[0,0],
        selectionBoxCoords:[0,0],
        tileWidth: a_canvas.width / this.numColumns,
        tileHeight: a_canvas.height / this.numRows,
        tileX: 0,
        tileY: 0,
    };
Moisés Man
@moigithub
May 18 2016 01:10

for(var i = 0; i < 10; i++){
            context.drawImage(tiles.grass.image,   
                     tiles.grass.width*i  ,  
                     tiles.grass.height*i ,
                    tiles.grass.width, 
                    tiles.grass.height);
        }
probably...
Jordan Shackelford
@JordanShackelford
May 18 2016 01:11
apparently I can't have variables inside an object refer to other variables inside that same object
Rémi Fortier
@mizujin
May 18 2016 01:11
modify the for loop
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:13
This message was deleted
Rémi Fortier
@mizujin
May 18 2016 01:14
@JordanShackelford var i could be your tiles width, i < number of tiles, i + tiles width
that way you get coordinates out of your loop
and I suppose that would be a nested for loop, for rows and columns
Moisés Man
@moigithub
May 18 2016 01:16
@JordanShackelford why u cant have variables.. how u doing ?? did u try the code exactly ?
bitgrower
@bitgrower
May 18 2016 01:18
I agree with @moigithub -- there's something not quite right about what you're doing ... the only time you would have difficulty is if you are defining a parameter within a function call ... but then you wouldn't be using object notation in that case ... but if you have a variable, you should be able to use an arithmetic expression with a variable as the value passed as a parameter ...
Jordan Shackelford
@JordanShackelford
May 18 2016 01:19
internet went out. im back
eduwin7
@eduwin7
May 18 2016 01:19
can some one please help
i am on the counting cards section
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:19
hmm... it's not appearing in "code" i already used ```
Moisés Man
@moigithub
May 18 2016 01:19
@RadEdje backticks must be on its own line
shift enter to add newlines
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:20
@moigithub oh thanks...
eduwin7
@eduwin7
May 18 2016 01:20
?
bitgrower
@bitgrower
May 18 2016 01:21
@eduwin7 think I've seen you around before ... so, can you post your code ?
Rémi Fortier
@mizujin
May 18 2016 01:21
@eduwin7 maybe I can help ?
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:23
Hi still working on my random quote generator. Stuck on the tweet button. When I use the usual
``` <a class="twitter-share-button" href="https://twitter.com/intent/tweet">Tweet</a>```

and then use

``` $("twitter-share-button").attr("href", 'https://twitter.com/intent/tweet?text=' + html);```

to prepopulate it with the quote it works but I lose the nice formatting for the twitter widget button so I tried the twitter script for the button and uses this instead

```<a href="https://twitter.com/share" class="twitter-share-button" data-text="REPLACE ME">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>```

and I reused the

``` $("twitter-share-button").attr("data-text", html);```

but this doesn't work so i figured the twitter script was the problem. After I little digging... I found that the twitter widget had to be reload? Any suggestions or more elegant solution? thanks
Rémi Fortier
@mizujin
May 18 2016 01:24
 <a class="twitter-share-button" href="https://twitter.com/intent/tweet">Tweet</a>

and then use

 $("twitter-share-button").attr("href", 'https://twitter.com/intent/tweet?text=' + html);

to prepopulate it with the quote it works but I lose the nice formatting for the twitter widget button so I tried the twitter script for the button and uses this instead

<a href="https://twitter.com/share" class="twitter-share-button" data-text="REPLACE ME">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

and I reused the

 $("twitter-share-button").attr("data-text", 'html);

but this doesn't work so i figured the twitter script was the problem. After I little digging... I found that the twitter widget had to be reload? Any suggestions or more elegant solution? thanks

=> $("twitter-share-button") is invalid, put a suffix there $(".twitter-share-button")
shaunski11
@shaunski11
May 18 2016 01:25
Good evening everyone. Can anyone tell me what the red dot symbolizes in the black results box?
eduwin7
@eduwin7
May 18 2016 01:25

var count = 0;

function cc(card) {
// Only change code below this line
if (card==2||card==3||card 4||card==5||card==6)
return count ++;

if Count<0{return count+"hold";}

i have no idea what to do
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:26
@mizujin oh thanks for making my cocde mor readable. Oh about that I put the dot in the original code it was $("twitter-share-button").attr("data-text", html);
CamperBot
@camperbot
May 18 2016 01:26
radedje sends brownie points to @mizujin :sparkles: :thumbsup: :sparkles:
:cookie: 348 | @mizujin |http://www.freecodecamp.com/mizujin
Jordan Shackelford
@JordanShackelford
May 18 2016 01:26
@eduwin7 put 3 backticks above your code and 3 backticks below
it's the key above tab
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:27
oops sorry I meant $(".twitter-share-button").attr("data-text", html);
Rémi Fortier
@mizujin
May 18 2016 01:27
@RadEdje twitter script is working, but it needs to be different in your code
Frank XC
@tenkdayz
May 18 2016 01:28
trying to make an object shoot a laser. but every time I create a new laser object the previous one disappears. how can I fix this.
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:29
@mizujin Oh? i read somewhere that I have to "RELOAD" the twitter widget since it only runs once so the moment the document is "ready" it alrady asigns "REPLACE ME" and clicking the button for the random quote doesn't reload the twitter widget so it doesn't repopulate with the new quote....
Rémi Fortier
@mizujin
May 18 2016 01:29
@RadEdje my script code (html) looks like this :
window.twttr = (function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0],
    t = window.twttr || {};
  if (d.getElementById(id)) return t;
  js = d.createElement(s);
  js.id = id;
  js.src = "https://platform.twitter.com/widgets.js";
  fjs.parentNode.insertBefore(js, fjs);

  t._e = [];
  t.ready = function(f) {
    t._e.push(f);
  };

  return t;
}(document, "script", "twitter-wjs"));
this twttr function accepts parameter (code)
something like
twttr.widgets.createShareButton(
              "-",
              document.getElementById("twitter-button"),
              {
                size: "large",
                text: your html variable here,
                count: "none"
              }
            );
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:31
@mizujin Oh thanks... I'll study that for a while.... so your script skips the problem of having to reload the twitter widget? thanks it might take me some time... kinda new to this....
CamperBot
@camperbot
May 18 2016 01:31
radedje sends brownie points to @mizujin :sparkles: :thumbsup: :sparkles:
:warning: radedje already gave mizujin points
Rémi Fortier
@mizujin
May 18 2016 01:32
yes, this script needs to be put in the bottom of your html page, it appends a button with correct parameters
eduwin7
@eduwin7
May 18 2016 01:32

var count = 0;

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

if (card==2||card==3||card 4||card==5||card==6)
return " 5 bet";

how can i fix this code
Arvilyn Ong
@arvilyn
May 18 2016 01:33
you should use switch for this exercise @eduwin7
rphares
@rphares
May 18 2016 01:34
if is also okay, but...
@eduwin7 , you dont always return "5 bet"
you will get five cards,
if you are using if/else,
Moisés Man
@moigithub
May 18 2016 01:34
@RadEdje r u working on codepen ?
rphares
@rphares
May 18 2016 01:34
you need if for those cards, incrementing count
Stephen James
@sjames1958gm
May 18 2016 01:34
@eduwin7 You are supposed to adjust count based on the card number and then return a value based on count
rphares
@rphares
May 18 2016 01:34
and another for the other cards, decrementing count
then another if/else, to return count and the appropriate string (" Bet" or " Hold")
depending on if count is above or below 0
bitgrower
@bitgrower
May 18 2016 01:35
@eduwin7 -- you can start down that path, but you neeed to account for all the rest of the numbers ... there are TWO parts to this card count challenge ...
  1. determine whether to add or subtract 1 from the count, or nothing at all
  2. look at the value of count to determine whether you should send a bet or hold message
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:35
@moigithub no... I'm working on local files first before uploading to codepen.
eduwin7
@eduwin7
May 18 2016 01:36
okay let me try switch
Moisés Man
@moigithub
May 18 2016 01:37
@RadEdje cuz.. instead of writing all the code above.. u can just append to ur code a script tag n point to https://platform.twitter.com/widgets.js
<script src = "https://platform.twitter.com/widgets.js" />
instead of this :point_up: May 17, 2016 8:29 PM
@RadEdje then u can twttr.widgets.createShareButton( ... etc
Subh Samal
@subhsamal
May 18 2016 01:38
Hi .. I am not able to solve "Record Collection"
can anyone help ??
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:38
@moigithub wow Thanks! I'll try that.
CamperBot
@camperbot
May 18 2016 01:38
radedje sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1169 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
May 18 2016 01:38
@RadEdje that code above create that script tag with src
bitgrower
@bitgrower
May 18 2016 01:39
@subhsamal --- getting help is aided significantly if you post the code showing what you've tried ...
Rémi Fortier
@mizujin
May 18 2016 01:39
thanks @moigithub I didn't knew the widget code was hosted somewhere
CamperBot
@camperbot
May 18 2016 01:39
mizujin sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1170 | @moigithub |http://www.freecodecamp.com/moigithub
bitgrower
@bitgrower
May 18 2016 01:39
many of us have helped folks with record collection innumerable times ...
Stephen James
@sjames1958gm
May 18 2016 01:40
@subhsamal Use brackets when the property is stored in a variable
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:45
@moigithub unfortunately adding <script src = "https://platform.twitter.com/widgets.js" /> messes up my website... I'm already using material design js and css from google. I'll study this a bit more. still... thanks for the help.
CamperBot
@camperbot
May 18 2016 01:45
radedje sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: radedje already gave moigithub points
Subh Samal
@subhsamal
May 18 2016 01:46

@bitgrower @sjames1958gm function updateRecords(id, prop, value) {
if (id == 2548 || id == 2468 || id == 1245 || id == 5439) {
if(value !== "" && prop !== "tracks"){
collection[id].artist = value;
}

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

}}

return collection;

eduwin7
@eduwin7
May 18 2016 01:46

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

switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:

return "5 Bet";
break;
case 7:
case 8:
case 9:

  return "0 Hold";
  break;

case 10:
case J:
case Q:
case K:
case A:
  return "-5 Hold";
  break;

}

Subh Samal
@subhsamal
May 18 2016 01:46
my coding may be aweful
eduwin7
@eduwin7
May 18 2016 01:46
it is telling me J is not defined
Stephen James
@sjames1958gm
May 18 2016 01:46
@subhsamal Don't use literal values in your code
bitgrower
@bitgrower
May 18 2016 01:46
@eduwin7 yes, you have to put letters in quotes .... otherwise it considers them to be a variable
Stephen James
@sjames1958gm
May 18 2016 01:47
@subhsamal You have to use delete not pop for value===""
Moisés Man
@moigithub
May 18 2016 01:48
@RadEdje mess.. it shouldnt
try like this
<script src="https://platform.twitter.com/widgets.js"> </script>
or
<script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script>
Stephen James
@sjames1958gm
May 18 2016 01:48
@eduwin7 The instructions are to modify count based on the card number - also A, K, Q, J are strings.
bitgrower
@bitgrower
May 18 2016 01:48
@subhsamal -- yeah, I don't get your first line of code at all ... what's it's purpose ?
eduwin7
@eduwin7
May 18 2016 01:48
AWESOME
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:48
@moigithub it seems the twitter widget js isn't compatible with bootstrap and the material design js from google. I tried putting the script source below everything (nothing loads), below the material design (all the formating for material design is lost), above bootstrap.... bootstrap formatting is lost....
eduwin7
@eduwin7
May 18 2016 01:48
thanks @bitgrower
CamperBot
@camperbot
May 18 2016 01:48
eduwin7 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1055 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
May 18 2016 01:49
@eduwin7 -- yes as I mentioned earlier ... there are 2 separate and distinct things you need to do in this challenge ... the first is to determine how to adjust the count value, the 2nd is to actually use the count value and output a message based on the value ...
yw @eduwin7
Subh Samal
@subhsamal
May 18 2016 01:50
@bitgrower to proceed for only those ids .
bitgrower
@bitgrower
May 18 2016 01:50
well ... I don't think that' necessary for the challenge ...
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:50
@moigithub Okay... I'll give that a try. No time left anymore. I have to go back to "to my Other Job" hehe... really wish I could keep asking you for advice on this topic when I get back to freeCodeCamp...
Moisés Man
@moigithub
May 18 2016 01:50
@RadEdje first code posted above..used a self closing tag
but on documentation... it shows opentag + closingtag
<script src="..."></script> should be correct
Subh Samal
@subhsamal
May 18 2016 01:51
@sjames1958gm I am not able to use two variables prob and value together!!
Stephen James
@sjames1958gm
May 18 2016 01:53
yes you can
@subhsamal can you post your code.
Subh Samal
@subhsamal
May 18 2016 01:54

function updateRecords(id, prop, value) {
if (id == 2548 || id == 2468 || id == 1245 || id == 5439) {
if(value !== "" && prop !== "tracks"){
collection[id].artist = value;
}

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

}}

return collection;
}

Rémi Fortier
@mizujin
May 18 2016 01:54
full code please
need to see collection
Stephen James
@sjames1958gm
May 18 2016 01:54
@subhsamal Drop the code with id ==2548 etc.
@subhsamal Don't use literals like artist. use [prop]
The idea behind having a function is that the code is generic and shouldn't refer to literal values, in this case "tracks" is an exception because it is an array.
Subh Samal
@subhsamal
May 18 2016 01:57

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(value !== "" && prop !== "tracks"){
collection[id][prop] = value;
}

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

}

return collection;
}

// Alter values below to test your code
updateRecords(2548, "tracks", "Addicted to Love");

J
@J-Mari
May 18 2016 01:58
Hello
Stephen James
@sjames1958gm
May 18 2016 01:58
Close, your delete doesn't need .value
@J-Mari hello
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
May 18 2016 01:59
@moigithub I couldn't resist... I had to try your suggestion first before I left... It doesn't mess with my other script src's anymore but the twttr.widgets.createShareButton( "-", document.getElementById("twitter-button"), { size: "large", text: html, count: "none" } );
still doesn't work
btw is use html as the variable per codecamp's example... so it's defined as var html = "" I'll just study your suggestions for a while .
Subh Samal
@subhsamal
May 18 2016 01:59
@sjames1958gm aah...!! it worked.. :blush: it was the toiling one for me so far.
Stephen James
@sjames1958gm
May 18 2016 02:00
@subhsamal Study the code and make sure you understand each part of it.
eduwin7
@eduwin7
May 18 2016 02:00

switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:

return "5 Bet";
break;
case 7:
case 8:
case 9:

  return "0 Hold";
  break;

case 10:
case "J":
case "Q":
case "K":
case "A":

  return "-5 Hold";
  break;
case 3:
case 7:
case "Q":
case 8:
case "A":
  return "-1 Hold";
Subh Samal
@subhsamal
May 18 2016 02:00
@sjames1958gm except the delete statement.
Moisés Man
@moigithub
May 18 2016 02:01
twttr.widgets.createShareButton(
  'https://dev.twitter.com/',   // u can leave blank this ''
  document.getElementById('container'),    // ur html should hve a placeholder.. like <div id="container"></div>
  {
    text: 'Hello World'
  }
);
@RadEdje
eduwin7
@eduwin7
May 18 2016 02:01
i am stuck on return -5 hold
the rest of the codes are good
Subh Samal
@subhsamal
May 18 2016 02:02
@sjames1958gm for delete to work object.property is sufficient to work! Hence no need of value ??
Stephen James
@sjames1958gm
May 18 2016 02:05
@subhsamal Correct, anyway value is "" in this case.
@eduwin7 Your code is not correct, you are coding to the tests, not the instructions. The instructions are to increment count for 2-6 and decrement for 10-A and then return count + a string based on the value of count.
Rémi Fortier
@mizujin
May 18 2016 02:09
@subhsamal if I can add, and it's only a preference but
if (value !== "")  // if value is not false 
// is the same as saying 
if(value)
mrcsscco
@marcussacco
May 18 2016 02:10
I need help. My task: Use reverse to reverse the array variable and assign it to newArray.

var array = [1,2,3,4,5,6,7];
var newArray = [];

// Only change code below this line.
array.reverse();
newArray = array;

Doesn't work.
This code does work in my browsers JS console, however.
Rémi Fortier
@mizujin
May 18 2016 02:12
what is the expected return value ?
Subh Samal
@subhsamal
May 18 2016 02:12
hmm.. true means if will execute .is it what you mean ? @mizujin
if(true) !
mrcsscco
@marcussacco
May 18 2016 02:13
The expected return value is the reversed string. [7,6,5,4,3,2,1]
Subh Samal
@subhsamal
May 18 2016 02:13
next code inside the block executes.
Rémi Fortier
@mizujin
May 18 2016 02:13
@subhsamal when you say if(value) , a coercion effect is applied and so the value is tested to be true or false. an empty string is false so you can only test the value to be true
mrcsscco
@marcussacco
May 18 2016 02:13
oh, you weren't talking to me
Rémi Fortier
@mizujin
May 18 2016 02:14
@marcussacco I was :-D your code works in repl.it and returns the correct array
Subh Samal
@subhsamal
May 18 2016 02:14
got it clearly .. thank you @mizujin @sjames1958gm
CamperBot
@camperbot
May 18 2016 02:14
subhsamal sends brownie points to @mizujin and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 349 | @mizujin |http://www.freecodecamp.com/mizujin
:star2: 1140 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 18 2016 02:14
@marcussacco Do it in one line I think.
Subh Samal
@subhsamal
May 18 2016 02:15
How can I post screen shots here ? @mizujin
Rémi Fortier
@mizujin
May 18 2016 02:15
@subhsamal no problem :)
mrcsscco
@marcussacco
May 18 2016 02:15
like, newArray = array.reverse(); ? That doesn't work either
rphares
@rphares
May 18 2016 02:15
explain format
CamperBot
@camperbot
May 18 2016 02:15

: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

rphares
@rphares
May 18 2016 02:15
@subhsamal :point_up_2:
Stephen James
@sjames1958gm
May 18 2016 02:15
@marcussacco Maybe refresh browser?
Rémi Fortier
@mizujin
May 18 2016 02:16

@marcussacco this :


var array = [1,2,3,4,5,6,7];
var newArray = [];

// Only change code below this line.

newArray = array.reverse();

Works in FCC, can you test ?

mrcsscco
@marcussacco
May 18 2016 02:16
Wow, refreshing my browser worked.
Thanks
Stephen James
@sjames1958gm
May 18 2016 02:16
@marcussacco :(
Rémi Fortier
@mizujin
May 18 2016 02:17
@marcussacco I think the errors comes from the tests expecting you to use chain commands directly on newArray
Subh Samal
@subhsamal
May 18 2016 02:17
@rphares okay..will try it
Rémi Fortier
@mizujin
May 18 2016 02:17
@marcussacco oh haha, nvm then
mrcsscco
@marcussacco
May 18 2016 02:17
@mizujin that was the first thing i tried
Wendy Medeiros
@wendyr21
May 18 2016 02:18
what was the code to check your answer against what freeCodeCamp has
help Make Object Properties Private
CamperBot
@camperbot
May 18 2016 02:19

:point_right: challenge make object properties private [wiki]

Challenge Make Object Properties Private

Objects have their own attributes, called properties_, and their own functions, called _methods.

You can use the this keyword to reference public properties and methods of the current objects. However, when You need to create private ones so they are not accessible from the outside of the object you just remove the keyword this from the object property or method declaration and declare it with var so that it is private outside its scope.

var Bike = function() {
  var speed = 100; // private
  function addUnit(value) { // private
    return value + "KM/H";
  }

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

};

:pencil: read more about challenge make object properties private on the FCC Wiki

Wendy Medeiros
@wendyr21
May 18 2016 02:19
found it
mrcsscco
@marcussacco
May 18 2016 02:19
I thought maybe I couldn't assign a reverse method to a variable via a chain command
Norvin Burrus
@ndburrus
May 18 2016 02:20
@marcussacco ...it may be useful to check your code (in these situations) using a repl (read-evaluate-print-loop) :)
mrcsscco
@marcussacco
May 18 2016 02:21
@ndburrus thanks, didn't know about that. was using devtools console
CamperBot
@camperbot
May 18 2016 02:21
:cookie: 371 | @ndburrus |http://www.freecodecamp.com/ndburrus
marcussacco sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
May 18 2016 02:21
@marcussacco devtools console is a REPL
Rémi Fortier
@mizujin
May 18 2016 02:22
@marcussacco I highly recommend repl.it
Norvin Burrus
@ndburrus
May 18 2016 02:23
@marcussacco ... try replit (google it). then you can determine that the code is valid, thus isolating the issue to be somewhere else (in this case - the browser) :sparkles:
mrcsscco
@marcussacco
May 18 2016 02:23
@sjames1958gm it seems cumbersome testing multi-line code in the devtools console
@sjames1958gm nvm. looks like it takes copy/paste!
Norvin Burrus
@ndburrus
May 18 2016 02:24
@marcussacco i find i can test code faster outside of the browser.... to each thier own... :) well, js code anyway (for now)
jgoldverg
@jgoldverg
May 18 2016 02:31
hey guys i have a quick question what is jquery playground?
jgoldverg
@jgoldverg
May 18 2016 02:35
ahh okay so its pretty much a test site before implementation.
thanks
Norvin Burrus
@ndburrus
May 18 2016 02:36
@jgoldverg anytime... :sparkles:
Wendy Medeiros
@wendyr21
May 18 2016 02:36
help Condense arrays with reduce
CamperBot
@camperbot
May 18 2016 02:36

:point_right: challenge condense arrays with reduce [wiki]

Challenge Condense Arrays with Reduce

Reduce can be useful for condensing an array of numbers into one value.

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

var singleVal = array.reduce(function(previousVal, currentVal){

  return previousVal+currentVal;

});

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

Jesus Vega
@ParagonChuy
May 18 2016 02:37
Who here has completed the Steamroller algorithm challenge?
pinecrest515
@pinecrest515
May 18 2016 02:40

Hi, I was stuck on freecodecamp exercise 227, getting an error: TypeError: Attempted to write to read only property. Anyone have pointers? Thanks! Here is my code for that exercise:

// Only change code below this line
function updateRecords(id, prop, value) {
if ((value !== "")&&(prop !== "tracks")){
collection.id.prop = value;
}
else if ((value !== "")&&(tracks !== "")){
collection.id.prop.push(value);
}
else if (value === ""){
delete collection.id.prop;
}

return collection;
}

Norvin Burrus
@ndburrus
May 18 2016 02:40
@eduwin7 did the issue get resolved?
rphares
@rphares
May 18 2016 02:40
@pinecrest515 , use bracket, not dot--
im not good at explaining why... this article helped me with it https://medium.com/@prufrock123/js-dot-notation-vs-bracket-notation-797c4e34f01d#.klo1nz8b3
Rachel Melville
@rjmelville
May 18 2016 02:41
Anyone have any suggestions on how to clean up my solution for 'Check for Palindromes'?
function palindrome(str) {
  if (str.toLowerCase().split('').join('').replace(/[' ',.;':'_/\-')']/g, '') === str.toLowerCase().split('').reverse().join('').replace(/[' ',.;':'_/\-')']/g, '')) {// Good luck!
  return true;
  }
  else {
    return false;
  }
}
Coy Sanders
@coymeetsworld
May 18 2016 02:43
you could just return that entire line instead of putting it in an if/else statement @rjmelville
Norvin Burrus
@ndburrus
May 18 2016 02:43
@pinecrest515 ... basicaly, you can use variables with bracket notation, whereas you cannot with dot notation. bracket notation allows more flexibility...
Coy Sanders
@coymeetsworld
May 18 2016 02:44
also you can choose a different regex too @rjmelville
OneRandomJamie
@OneRandomJamie
May 18 2016 02:44
Can someone help me with the Word Blank challenge?
Coy Sanders
@coymeetsworld
May 18 2016 02:45
sure @OneRandomJamie
what do you need help with?
Norvin Burrus
@ndburrus
May 18 2016 02:46
@OneRandomJamie ok, basically we're trying to build a result string that is a sentence with the four components given... (noun, adjective, etc) have you identified a sentence (madlib) yet? once you have a sentence - we will use the result var/iable (which has already been declared) to construct/build the complete sentence.... :)
pinecrest515
@pinecrest515
May 18 2016 02:47

Thanks guys, but still getting same error, updated code: // Only change code below this line
function updateRecords(id, prop, value) {
if ((value !== "")&&(prop !== "tracks")){
collection.id["prop"] = value;
}
else if ((value !== "")&&(tracks !== "")){
collection.id["prop"].push(value);
}
else if (value === ""){
delete collection.id["prop"];
}

return collection;
}

Coy Sanders
@coymeetsworld
May 18 2016 02:47
prop shouldn't be in quotation marks
or else it will look for the property named "prop" not what's inside the variable prop
pinecrest515
@pinecrest515
May 18 2016 02:48

Good catch, I dropped the quotation marks for prop, still same error: // Only change code below this line
function updateRecords(id, prop, value) {
if ((value !== "")&&(prop !== "tracks")){
collection.id[prop] = value;
}
else if ((value !== "")&&(tracks !== "")){
collection.id[prop].push(value);
}
else if (value === ""){
delete collection.id[prop];
}

return collection;
}

Coy Sanders
@coymeetsworld
May 18 2016 02:49
thin your 1st elseif needs to be fixed
pinecrest515
@pinecrest515
May 18 2016 02:50
same issue after committing out the first elseif
Coy Sanders
@coymeetsworld
May 18 2016 02:50
collection.id[prop] = value;
pinecrest515
@pinecrest515
May 18 2016 02:50
**commeting
Coy Sanders
@coymeetsworld
May 18 2016 02:50
no you need something there
This message was deleted
i mean notation
for any of the 3 actually
try using bracket notation for id also
James Alton
@TwoKind
May 18 2016 02:53
Ok guys I flew thought the fist 19 lessions in 15 seconds each
This one has me just brain dead
pinecrest515
@pinecrest515
May 18 2016 02:53
like this? collection[id].prop = value; I cannot do double brackets
James Alton
@TwoKind
May 18 2016 02:53
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Coy Sanders
@coymeetsworld
May 18 2016 02:54
why can't you do double brackets?
rphares
@rphares
May 18 2016 02:54
wants you to put the string in single quotes, and remove the escaping on the doubles, if i recall, @TwoKind
pinecrest515
@pinecrest515
May 18 2016 02:54
@TwoKind which exercise number?
James Alton
@TwoKind
May 18 2016 02:54
Wont work wants two single and four double
rphares
@rphares
May 18 2016 02:54
show us what that looks like? @TwoKind
DwayneCode
@DwayneCode
May 18 2016 02:54
should be var myStr = '<a href="http://www.example.com" target="_blank">Link</a>'
Norvin Burrus
@ndburrus
May 18 2016 02:54

@OneRandomJamie this may be useful: MDN, String operators String operators {ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators }
In addition to the comparison operators, which can be used on string values, the concatenation operator (+) concatenates two string values together, returning another string that is the union of the two operand strings.

For example,

console.log("my " + "string"); // console logs the string "my string".
The shorthand assignment operator += can also be used to concatenate strings.

For example,

var mystring = "alpha";
mystring += "bet"; // evaluates to "alphabet" and assigns this value to

James Alton
@TwoKind
May 18 2016 02:54
One sec
DwayneCode
@DwayneCode
May 18 2016 02:54
i think
James Alton
@TwoKind
May 18 2016 02:55
@DwayneCode Nope
pinecrest515
@pinecrest515
May 18 2016 02:55
@coymeetsworld you mean collection[id[prop]]= value;?
James Alton
@TwoKind
May 18 2016 02:55
That what I thoguh
rphares
@rphares
May 18 2016 02:55
erm-- yes... usually we try not to paste answers, though
James Alton
@TwoKind
May 18 2016 02:55
Its Quoting Strings with Single Quotes
Coy Sanders
@coymeetsworld
May 18 2016 02:55
no, collection[id][prop] @pinecrest515
DwayneCode
@DwayneCode
May 18 2016 02:55
sorry
Rachel Melville
@rjmelville
May 18 2016 02:55
@coymeetsworld Thanks for the pointers.
CamperBot
@camperbot
May 18 2016 02:55
rjmelville sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 884 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 18 2016 02:55
np @rjmelville
James Alton
@TwoKind
May 18 2016 02:56
Anyone else?
rphares
@rphares
May 18 2016 02:56
@TwoKind ,try again--
pinecrest515
@pinecrest515
May 18 2016 02:56
@coymeetsworld ok thanks for the tip, appreciate it! This was different from the demo and previous two JSON exercises, where we use either periods or one period + one bracket to denote
CamperBot
@camperbot
May 18 2016 02:56
pinecrest515 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 885 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
rphares
@rphares
May 18 2016 02:57
essentially, on Quoting Strings with Single Quotes , all you need are two singles and 4 doubles,
just like he said @TwoKind .... must have been some minor error
James Alton
@TwoKind
May 18 2016 02:57
I tied for like 15m every posiblility. And I use js for like 4 months now
Coy Sanders
@coymeetsworld
May 18 2016 02:57
depends on what you're trying to do and what information you have @pinecrest515 but np
rphares
@rphares
May 18 2016 02:58
try once more, paste what you try here, and we'll talk ya though it :blush: @TwoKind
James Alton
@TwoKind
May 18 2016 02:58
Sure :P
pinecrest515
@pinecrest515
May 18 2016 02:58
@coymeetsworld If I want to push a value to the last element, can I do this? collection[id][prop].push(value);
James Alton
@TwoKind
May 18 2016 02:59
Ok I have a conundrum. It says to remove all backslashes but wants two double quotes
rphares
@rphares
May 18 2016 02:59
(also, try refreshing before running tests again... every now and again it gets glitchy... @TwoKind )
remove them
James Alton
@TwoKind
May 18 2016 02:59
Ok
Coy Sanders
@coymeetsworld
May 18 2016 02:59
yeah
@pinecrest515
pinecrest515
@pinecrest515
May 18 2016 03:00
hmmm....it gives me an error when I try collection[id][prop].push(value)
buckshot307
@buckshot307
May 18 2016 03:00
for (var i = 0; i < game.count; i++) {
              $('#button' + game.genSequence[i]).animate({ opacity: 0.6 }, 1000).delay(800)}
              $('#button' + game.genSequence[i]).animate({ opacity: 1 }, 1000)
Why does this only work every now and then? Sometimes it will change the opacity and then change back and sometimes it just changes it the first time.
Coy Sanders
@coymeetsworld
May 18 2016 03:00
@pinecrest515 need semilcolon at end
James Alton
@TwoKind
May 18 2016 03:01
Ok so I tried this does not work. But the instructions make no sense. How am I suposed to havea double quote wihtout backslashes. No logic goes against all the rules I know
var myStr = "<a href='http://www.example.com' target='_blank'>"Link"</a>";
rphares
@rphares
May 18 2016 03:01
okay so opposite--
single quotes the outside
double quotes inside
James Alton
@TwoKind
May 18 2016 03:01
Oh make a second strign?
rphares
@rphares
May 18 2016 03:01
no
James Alton
@TwoKind
May 18 2016 03:01
???
pinecrest515
@pinecrest515
May 18 2016 03:01
Thanks @coymeetsworld the error I just figured out, it had to do with my else if statement, fixed and it worked, the collection[id][prop].push(value); was correct, thanks again, such appreciated!
CamperBot
@camperbot
May 18 2016 03:01
pinecrest515 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: pinecrest515 already gave coymeetsworld points
rphares
@rphares
May 18 2016 03:02
this was the original, yes?
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Coy Sanders
@coymeetsworld
May 18 2016 03:02
np @pinecrest515 yeah i saw a little bit of issues with your if/else statements but i thought it would work
pinecrest515
@pinecrest515
May 18 2016 03:02
@TwoKind If you tell me the exercise # I can go back and search for the solution
DwayneCode
@DwayneCode
May 18 2016 03:02
single quote entire string, double inside
James Alton
@TwoKind
May 18 2016 03:02
@rphares Thank you!
CamperBot
@camperbot
May 18 2016 03:02
twokind sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4674 | @rphares |http://www.freecodecamp.com/rphares
James Alton
@TwoKind
May 18 2016 03:02
@rphares You are bae
@DwayneCode Thank you
CamperBot
@camperbot
May 18 2016 03:03
twokind sends brownie points to @dwaynecode :sparkles: :thumbsup: :sparkles:
:cookie: 167 | @dwaynecode |http://www.freecodecamp.com/dwaynecode
rphares
@rphares
May 18 2016 03:03
oh, yay! i was scratching my head making an example, lol-- congrats and happy coding! :blush:
DwayneCode
@DwayneCode
May 18 2016 03:03
np
James Alton
@TwoKind
May 18 2016 03:03
@rphares I worked 8h today a bit slow :P
TO simple
rphares
@rphares
May 18 2016 03:03
happens all the time,
just was really trying to figure out how to make a clear, learning-useful, not copy-and-paste example for that one :wink2:
DwayneCode
@DwayneCode
May 18 2016 03:04
I need pointers on the Word Blanks challenge.
rphares
@rphares
May 18 2016 03:04
Sure thing--
you are meant to build a sentence
you can do so by concatenating all the parameters together,
with at least some non-word characters in between them (i suggest spaces)
(you may also add other words in-between if you like, to make it funnier)
be sure to concatenate in the spaces, as you do not want the output to be bigdogranquickly ;)
DwayneCode
@DwayneCode
May 18 2016 03:06
Do i assign my own strings to the variables? I don't think i've tried that
rphares
@rphares
May 18 2016 03:06
you only need the var they gave you,
up top, they gave you result = ""
so just reassign result,
no need to include any new var
Norvin Burrus
@ndburrus
May 18 2016 03:06
@DwayneCode ...using string operator/s...
DwayneCode
@DwayneCode
May 18 2016 03:07
wow, i really over think that one
rphares
@rphares
May 18 2016 03:08
sighs someday ill be able to say smart things like @ndburrus :blush:
DwayneCode
@DwayneCode
May 18 2016 03:08
thanks @ndburrus @rphares
CamperBot
@camperbot
May 18 2016 03:08
dwaynecode sends brownie points to @ndburrus and @rphares :sparkles: :thumbsup: :sparkles:
:cookie: 372 | @ndburrus |http://www.freecodecamp.com/ndburrus
:star2: 4675 | @rphares |http://www.freecodecamp.com/rphares
rphares
@rphares
May 18 2016 03:08
Anytime~
Norvin Burrus
@ndburrus
May 18 2016 03:08
@rphares your too kind... i think....
rphares
@rphares
May 18 2016 03:09
oooh, there was no sarcasm in that
i meant it, lol
(I'm terrible at using terms, and cant even begin to explain concepts. i was most definitely being sincere! 0
Norvin Burrus
@ndburrus
May 18 2016 03:10
@rphares i should have received only a cookie crumb for that contribution.... :smile: thank you :) {... wow, 4600+ cookies - that's a lot of dough...}
buckshot307
@buckshot307
May 18 2016 03:17
for (var i = 0; i < game.count; i++) {
              $('#button' + game.genSequence[i]).animate({ opacity: 0.5 }, 200, function() {
                console.log("First and ...")
              }).delay(800)
              $('#button' + game.genSequence[i]).stop().animate({ opacity: 1 }, 1000, function(){
                console.log("Done!")
              })
I added some console.log() things and it's not logging the first one at all now.. with or without the .delay(800)
unless I just completely remove the second animation
Tee Stoddard
@teeGTee
May 18 2016 03:22
I am working on assigning the vars so far i have var a =7; var b =7; but i am getting an error when trying to assign the contents of a to b
Chris Saunders
@canadianchris
May 18 2016 03:22
hey Campers! I finished the Mutations challenge just now. I took some time away from FCC so I'm trying to clear out some cobwebs. My code works, but I feel like this could have been much simpler with nested functions.. any suggestions ?
function mutation(arr) {

  for (i = 0; i < arr[1].length; i++){

    if (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase()) == -1){
      return false;
    }
  }
  return true;
}
Norvin Burrus
@ndburrus
May 18 2016 03:23
@teeGTee which challenge? what is your code to assign the contents of a to b?
DwayneCode
@DwayneCode
May 18 2016 03:23
@teeGTee and how are you writing it?
Tee Stoddard
@teeGTee
May 18 2016 03:23
@ndburrus Storing Valus with the assignment operator
Norvin Burrus
@ndburrus
May 18 2016 03:24
ok, you're not changing code above the comment line are you? (you mentioned var b = 7. var b = 2; is given information)
Tee Stoddard
@teeGTee
May 18 2016 03:25

// Setup
var a;
var b = 2;

// Only change code below this line

var a = 7;
var b = 7;

Norvin Burrus
@ndburrus
May 18 2016 03:26
@teeGTee let's carefully examine the (instruction) statement: "Assign the contents of a to variable b." we want to set the value of variable b to the value of variable a. make sense? a already has the value we need. we just need to transfer it into var/iable b....
Thomas Nguyen
@thomasnguyen
May 18 2016 03:27

http://thomasnguyen.co/weather/

^^ i need help with my weather app

i want to add jquery fadeIn but it wont work
DwayneCode
@DwayneCode
May 18 2016 03:28
@ndburrus that
Coy Sanders
@coymeetsworld
May 18 2016 03:29
@teeGTee you can't define the same variable twice
DwayneCode
@DwayneCode
May 18 2016 03:29
that's not me
Coy Sanders
@coymeetsworld
May 18 2016 03:29
also you dont reassign b to 7
you assign it the value of a
Tee Stoddard
@teeGTee
May 18 2016 03:29
@ndburrus @coymeetsworld @DwayneCode ok changing somethings around
Norvin Burrus
@ndburrus
May 18 2016 03:30
@DwayneCode sorry... updated...
Coy Sanders
@coymeetsworld
May 18 2016 03:31
@toshiru you need to import jquery
Diwakar Serala
@diwpro007
May 18 2016 03:31

Hello friends!! I need a small help in the challenge Exact Change
https://www.freecodecamp.com/challenges/exact-change
it says

checkCashRegister(19.50, 20.00, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1.00], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]) should return "Insufficient Funds".

But it shouldn't be insufficient funds, should It?

Thomas Nguyen
@thomasnguyen
May 18 2016 03:31
@coymeetsworld i do have jquery imported at the bottom
Tee Stoddard
@teeGTee
May 18 2016 03:31
@coymeetsworld @ndburrus @DwayneCode thanks so much I was over thinking it
CamperBot
@camperbot
May 18 2016 03:31
teegtee sends brownie points to @coymeetsworld and @ndburrus and @dwaynecode :sparkles: :thumbsup: :sparkles:
:cookie: 373 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 173 | @dwaynecode |http://www.freecodecamp.com/dwaynecode
:cookie: 886 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Norvin Burrus
@ndburrus
May 18 2016 03:32
@teeGTee kudos to you!! :fire:
Coy Sanders
@coymeetsworld
May 18 2016 03:32
@toshiru is it declared before bootstrap?
bootstrap js requires jquery to be in first
Thomas Nguyen
@thomasnguyen
May 18 2016 03:33
no it isnt
Coy Sanders
@coymeetsworld
May 18 2016 03:33
yeah @teeGTee no worries you're just learning the language
Thomas Nguyen
@thomasnguyen
May 18 2016 03:34
I just putted it in and nothing seemed to do anything

anyways is there any reason why

$("#location").html(city).fadeIn("slow");

may not work?

nvm i got it I have to put .hide() first!
robertky
@robertky
May 18 2016 03:48

If I am trying to make a word in an array upper case, wouldn't this do it?:

newTitleArr[i]=newTitleArr[i].charAt(0).toUpperCase();

If that was in a for loop?
It wont capitalize any of the words in the array, running it through a for loop for some reason.
robertky
@robertky
May 18 2016 03:55
Anyone?
DwayneCode
@DwayneCode
May 18 2016 03:57
hello again, where can i read more about Access MultiDimensional Arrays With Indexes?
I got the answer to the challenge, but i guessed, I don't why my answer is correct :worried:
Mike Olo
@michaelolo24
May 18 2016 03:59
can someone please help me figure out how to make my code for smallest common multiple more efficient?

function smallestCommons(arr) {
  var newArr=[];

  if(arr[0] < arr[1]){
    for(i=arr[0]; i<=arr[1]; i++) newArr.push(i);
  } else{
    for(i=arr[1]; i<=arr[0]; i++) newArr.push(i);
  }


  function lowestCommon(myArr, common){
    var found;
    if(!common) common = myArr[myArr.length-1]; //if a common multiple is not set, set it to largest number
    var final = myArr[myArr.length-1]; //set final number in array to variable final

    for(i=0; i<myArr.length; i++){  //loop through all the elements of your array...the factors
      if(common % myArr[i] !== 0) { // if your common number is not divisible by an array element
        var newCommon = common+final;
        return lowestCommon(myArr, newCommon);
      }
      else found = common; 

    }   

    return found;
  }

 return lowestCommon(newArr);
}


smallestCommons([1,10]);
I'm trying to use recursion here, but as soon as I look into [1,13] it says maximum stack size used
exceeded* rather
OneRandomJamie
@OneRandomJamie
May 18 2016 04:02
I need help with the Word Blank challenge.
rphares
@rphares
May 18 2016 04:03
@OneRandomJamie , can you paste what you are trying?
Wellington Nadson
@DrNadson
May 18 2016 04:03
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
rphares
@rphares
May 18 2016 04:04
@DrNadson , yep! use the chart to make that code. for example, backslash would be \\ :blush:
Wellington Nadson
@DrNadson
May 18 2016 04:05
@rphares Thanks ;)
CamperBot
@camperbot
May 18 2016 04:05
drnadson sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4679 | @rphares |http://www.freecodecamp.com/rphares
rphares
@rphares
May 18 2016 04:06
sure thing~ happy coding!
J
@J-Mari
May 18 2016 04:07
Hi, could anyone please help me with a basic explanation for "Stand in Line"
Aleksander Gębicki
@Takumar
May 18 2016 04:09
@J-Mari you have to do three things:
  • add item to the arr array
  • remove first element from your arr array
  • return from your function removed element
@J-Mari for sure you know methods push() and shift() because you used them earlier, think how to solve this challenge with only these two methods.
kirbyedy
@kirbyedy
May 18 2016 04:10
@Takumar hi, you are early :)
Aleksander Gębicki
@Takumar
May 18 2016 04:10
Hello @rphares
kirbyedy
@kirbyedy
May 18 2016 04:10
and long time no see ;)
Aleksander Gębicki
@Takumar
May 18 2016 04:10
Hi @kirbyedy I entered here for a moment, and now I am leaving to work :-)
rphares
@rphares
May 18 2016 04:11
hiya, @Takumar ! :blush:
Aleksander Gębicki
@Takumar
May 18 2016 04:11
@kirbyedy yesterday I was on a "MeetJS" meetup, and I didn't understand a thing. They were talking about Flux, React and migration from Angular 1 to Ang2 using NGUpgrade
@rphares @kirbyedy but I got a free coca cola, cake and sandwich - that was a good meeting ;-)
kirbyedy
@kirbyedy
May 18 2016 04:12
nice
hahaha
is that in poland?
Aleksander Gębicki
@Takumar
May 18 2016 04:12
yes, in Poland, (Łódź city)
rphares
@rphares
May 18 2016 04:13
lol, free food is always a good thing :blush:
Aleksander Gębicki
@Takumar
May 18 2016 04:13
I am sorry I wish I could stay here longer but I have to leave
Have a nice day! :wave:
DwayneCode
@DwayneCode
May 18 2016 04:13
hey @Takumar I've been to Poznan, Poland i like it :+1:
kirbyedy
@kirbyedy
May 18 2016 04:13
you too :wave: @Takumar
OneRandomJamie
@OneRandomJamie
May 18 2016 04:13
Can someone help me with the Word Blank challenge?
kirbyedy
@kirbyedy
May 18 2016 04:14
we can try
DwayneCode
@DwayneCode
May 18 2016 04:14
@OneRandomJamie what kind of help do you need?
rphares
@rphares
May 18 2016 04:14
@OneRandomJamie , sure- could you paste your code, please?
J
@J-Mari
May 18 2016 04:17
@Takumar Attempting it now, thought it might've been push and/or pop.
OneRandomJamie
@OneRandomJamie
May 18 2016 04:17
@DwayneCode @rphares This is what I have. var Str = "The" + " " + myAdjective + " " + myNoun + " " + "ran" + " " + myAdverb + " " + "across the street and" + " " + myVerb + " " + "the dog.";
I asked someone for help last night and I tool their advice but i still have it wrong.
took not tool
DwayneCode
@DwayneCode
May 18 2016 04:18
start with result = instead of var Str
rphares
@rphares
May 18 2016 04:18
yep=- should be result, and
if i recall, the editor gets mad when you concatenate two stings in a row,
so when you have things like "The" + " " +
turn those into "The " + myAd...
for example
Tee Stoddard
@teeGTee
May 18 2016 04:20
ok so I am working on the Escaping literal Quotes in a String Challenge
var myStr = " I am a \"double quoted\" string inside \"double quotes\"";
that is what i have so far it looks right but I am still missing something
rphares
@rphares
May 18 2016 04:21
do you have an extra space, at the beginning of the string?
hard to tell without formatting, but if so, try deleting that...
OneRandomJamie
@OneRandomJamie
May 18 2016 04:22
@rphares The person who helped me yesterday said that i needed to put the " " because it put spaces between the words. "The" + "dog" was Thedog and that "The" + " " + "dog" would make The dog.
rphares
@rphares
May 18 2016 04:22
yes, thats true
but on this exercise, it doesn't like two strings net to each other--
so in-between the parameters you would need to use + " " +
for example, myNoun + " " + myAdjective
OneRandomJamie
@OneRandomJamie
May 18 2016 04:23
@rphares Thank you. All that needed to be changed was the myStr to result.
CamperBot
@camperbot
May 18 2016 04:23
onerandomjamie sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4680 | @rphares |http://www.freecodecamp.com/rphares
DwayneCode
@DwayneCode
May 18 2016 04:23
that's what i said :)
rphares
@rphares
May 18 2016 04:23
interesting, I've seen a few people fail with the spaces... but cool cool, glad it worked! :blush:
Tee Stoddard
@teeGTee
May 18 2016 04:24
@rphares @OneRandomJamie thanks it was an extra space
CamperBot
@camperbot
May 18 2016 04:24
teegtee sends brownie points to @rphares and @onerandomjamie :sparkles: :thumbsup: :sparkles:
:cookie: 178 | @onerandomjamie |http://www.freecodecamp.com/onerandomjamie
:star2: 4681 | @rphares |http://www.freecodecamp.com/rphares
rphares
@rphares
May 18 2016 04:24
sweet~ Congrats and happy coding ~
OneRandomJamie
@OneRandomJamie
May 18 2016 04:24
@DwayneCode Thank you
CamperBot
@camperbot
May 18 2016 04:24
onerandomjamie sends brownie points to @dwaynecode :sparkles: :thumbsup: :sparkles:
:cookie: 179 | @dwaynecode |http://www.freecodecamp.com/dwaynecode
Rex
@RexChip
May 18 2016 04:28
Hi all, I'm javascript beginner, but because the professor need i make a pagination, i found a method, http://paginationjs.com/ , but i dont know how to use this, i try and try but get nothing help :( can some body help me? thank u very much :)
J
@J-Mari
May 18 2016 04:33
I'm still not sure what I'm doing... I wrote one line which marks off 2/4 things I need to be doing, am stuck.
@Takumar Are you still here?
Ross
@Woodywoodruff3
May 18 2016 04:35
Can anyone look at their Challenge 167 - "Word Blanks" and let me know what they put down?
Jason Shoemaker
@kutsuya1
May 18 2016 04:37
@Woodywoodruff3 What did you put down? :)
EODjugornot
@EODjugornot
May 18 2016 04:37
no idea what im supposed to do for challenge 155. i know how to escape and everything but what the heck are they trying to get out of me?!
Jason Shoemaker
@kutsuya1
May 18 2016 04:37
@EODjugornot What's the task name?
EODjugornot
@EODjugornot
May 18 2016 04:38
@kutsuya1 Escape Sequences in Strings
Ross
@Woodywoodruff3
May 18 2016 04:38

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
myNoun = "dog";
myAdjective = "ran";
myVerb = "big";
myAdverb = "quickly";

results = "The "myVerb" wussy "myNoun" "myAdjective" "myAdverb" so his nuts wont get cut off";

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "ran", "quickly", "big");

i am so lost on what they are asking me to do
Jason Shoemaker
@kutsuya1
May 18 2016 04:38
@Woodywoodruff3 how about "The " + myAdjective + ' ' + ........
@EODjugornot It looks some like "// /t /n"
EODjugornot
@EODjugornot
May 18 2016 04:40
i tried that. maybe because im doing my / the other way? matching what is in the sample it is . ill try it! thank you!
Jason Shoemaker
@kutsuya1
May 18 2016 04:41
@EODjugornot the examples usually just need a little change to pass the task
J
@J-Mari
May 18 2016 04:41
@kutsuya1 Hi, I'm stuck on "Stand in Line". Would I be able to ask for help with this task?
Jason Shoemaker
@kutsuya1
May 18 2016 04:42
@Woodywoodruff3 .... ran is a verb, big is a adjective
EODjugornot
@EODjugornot
May 18 2016 04:42
nope that didnt work. i dont get it :worried:
Ross
@Woodywoodruff3
May 18 2016 04:42
Haha...I knew I messed that up
Rex
@RexChip
May 18 2016 04:43
Hi all, I'm javascript beginner, because the professor need i make a pagination, i found a method, http://paginationjs.com/ , but i dont know how to use this, i try and try but get nothing help... i'm stuck in three weeks, someone can help me? thank u very much .
Ross
@Woodywoodruff3
May 18 2016 04:43
@EODjugornot var myStr = "\ \t \t \r \n" ; // Change this line
Jason Shoemaker
@kutsuya1
May 18 2016 04:44
@EODjugornot they give you a list of codes...above the instructions....
It gives you the list they want you to encode: backslash tab tab .... var myStr = "// /t /t....
Subh Samal
@subhsamal
May 18 2016 04:44
@Woodywoodruff3 @EODjugornot @kutsuya1 this is my solution:

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

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Jason Shoemaker
@kutsuya1
May 18 2016 04:44
opps backslash
EODjugornot
@EODjugornot
May 18 2016 04:44
oh holy cow. i didnt put the quotes.... youre the best!
Jason Shoemaker
@kutsuya1
May 18 2016 04:45
@EODjugornot I used foreslash though... heh
EODjugornot
@EODjugornot
May 18 2016 04:45
@kutsuya1 youre a life saver! i was losing my mind! many thanks!
CamperBot
@camperbot
May 18 2016 04:45
eodjugornot sends brownie points to @kutsuya1 :sparkles: :thumbsup: :sparkles:
:cookie: 259 | @kutsuya1 |http://www.freecodecamp.com/kutsuya1
Greg
@GregJacoby
May 18 2016 04:45
why is this code not having the intended effect? (falsy bouncer)

function bouncer(arr) {
  var index;
  for(var i = 0; i < arr.length; i++) {
    if(arr[i] === false) {
      index = arr.indexOf(arr[i]);
      arr.splice(index, 1);
    }
  }
  // Don't show a false ID to this bouncer.
  return arr;
}
Jason Shoemaker
@kutsuya1
May 18 2016 04:45
@EODjugornot The escapes only work in "" and not ''
Greg
@GregJacoby
May 18 2016 04:45
shouldn't it remove every single false value the way i've set it up?
but it seems like it's only removing one
oh wait
hm
yeah idk
J
@J-Mari
May 18 2016 04:46
why do you have 3x =
Jason Shoemaker
@kutsuya1
May 18 2016 04:46
@EODjugornot glad could help
J
@J-Mari
May 18 2016 04:47
if(arr[i] == false){ ? *
Greg
@GregJacoby
May 18 2016 04:47
@J-Mari yeah I'm playing with that right now, but if I use 2 ==s, then it doesn't remove "false", and if i do 3, then it doesn't remove ""
Ross
@Woodywoodruff3
May 18 2016 04:48
many thanks @subhsamal and @kutsuya1
CamperBot
@camperbot
May 18 2016 04:48
woodywoodruff3 sends brownie points to @subhsamal and @kutsuya1 :sparkles: :thumbsup: :sparkles:
:cookie: 260 | @kutsuya1 |http://www.freecodecamp.com/kutsuya1
:cookie: 221 | @subhsamal |http://www.freecodecamp.com/subhsamal
Greg
@GregJacoby
May 18 2016 04:48
I tried replacing that line with if(arr[i] == false || arr[i] === false)
but it didn't change anything
J
@J-Mari
May 18 2016 04:49
in your for loop do you need to have "var" in front of i?
Jason Shoemaker
@kutsuya1
May 18 2016 04:49
@Woodywoodruff3 glad I could help some
@J-Mari if no var, then it becomes global?
Greg
@GregJacoby
May 18 2016 04:50
@J-Mari it's not necessary but it doesn't matter in this situation
J
@J-Mari
May 18 2016 04:50
shouldn't become global when it's inside the function
if it doesn't change anything then that's cool
Greg
@GregJacoby
May 18 2016 04:54
no ideas? :(
J
@J-Mari
May 18 2016 04:54
I'm not sure, sorry! Currently stuck on something really basic myself. :(
Robert Richey
@0x0936
May 18 2016 04:55
@GregJacoby == is correct to coerce a value into truthy or falsy. For example, "false" is truthy, because it's not an empty string. Also, in your loop, splicing arr will affect the length of arr. To fix this, when arr[i] is falsy and arr is spliced, decrement i by one.
Greg
@GregJacoby
May 18 2016 04:55
@0x0936 ! thank you so much!!! let me give it a shot and i'll let you know how it goes
CamperBot
@camperbot
May 18 2016 04:55
gregjacoby sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1316 | @0x0936 |http://www.freecodecamp.com/0x0936
Raghav Dua
@duaraghav8
May 18 2016 04:57
@GregJacoby try if ( !arr[i] ) {...} instead of === false or == false
Greg
@GregJacoby
May 18 2016 04:58
@duaraghav8 okay - so without the !arr[i] bouncer([false, null, 0, NaN, undefined, ""]) returned [null, null, null] why is that??? and using !arr[i] fixed that, but it's still not completely working. but why did that null thing happen?
@duaraghav8 thank you, btw
CamperBot
@camperbot
May 18 2016 04:58
gregjacoby sends brownie points to @duaraghav8 :sparkles: :thumbsup: :sparkles:
:cookie: 6 | @duaraghav8 |http://www.freecodecamp.com/duaraghav8
Richard
@richao03
May 18 2016 05:00
Hello, i have a quick question regarding Regex
can some one help me? =)
Robert Richey
@0x0936
May 18 2016 05:01
@richao03 possibly
Richard
@richao03
May 18 2016 05:02
sooo... im trying to take the number at the end of a string and adding 1 to it
ie: hello0999 ----> hello1000
hello0099 ---> hello0100
I have
var digits = /\d.*/.exec(str)[0] return str.replace(digits, parseInt(digits,10)+1) }
Robert Richey
@0x0936
May 18 2016 05:04
@richao03 have you tried a regex sandbox to test your patterns? https://regex101.com/ is one
Richard
@richao03
May 18 2016 05:04
yes..
im having trouble keeping the leading zeroes when i change it from string to number
in the parseInt ()
Raghav Dua
@duaraghav8
May 18 2016 05:05
@GregJacoby I remember reading the mechanics of the ! operator in JS. I don't remember the exact detail, but ! simply evaluates all the NaN, undefined, false values to True
You're welcome :)
Also let me know what the problem is even after you use the !arr [i]
Diar
@Diarselimi
May 18 2016 05:05
can someone explain me the Smallest Common Multiple i don't get it why the result should be 60 of the 1 and 5 ?
Greg
@GregJacoby
May 18 2016 05:07
@duaraghav8 well, when i pass through bouncer([1, null, NaN, 2, undefined]) it only returns [1] instead of [1, 2] and thank you so much again. i just read about how it works and i understand it a lot better. i also looked at the solution code, which is one line using filter, but i wanted to figure it out without using that first. but yeah, i dont understand what's going wrong here!
CamperBot
@camperbot
May 18 2016 05:07
gregjacoby sends brownie points to @duaraghav8 :sparkles: :thumbsup: :sparkles:
:warning: gregjacoby already gave duaraghav8 points
Robert Richey
@0x0936
May 18 2016 05:08
left padding a number is a separate issue from adding one after a regex match. turn number into a string, determine it's length, prefix some zeros and concatenate.
Richard
@richao03
May 18 2016 05:13
just solved it
Robert Richey
@0x0936
May 18 2016 05:13
function prefixer(str, n) {
  if (str.length >= n) { return str }
  return '0' + prefixer(str, n - 1)
}
@richao03 :+1: :)
Richard
@richao03
May 18 2016 05:13
with
while (oldnum.length !== newNum.length){
newNum = "0"+newNum
}
=D
thanks @0x0936
CamperBot
@camperbot
May 18 2016 05:13
:star2: 1317 | @0x0936 |http://www.freecodecamp.com/0x0936
richao03 sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
Raghav Dua
@duaraghav8
May 18 2016 05:13
ok @GregJacoby a couple of things:
  1. the statement index = arr.indexOf(arr[i]); seems redundant to me
    try directly: arr.splice (i, 1);
Greg
@GregJacoby
May 18 2016 05:14
oh, because i is already the index of arr
okay
@duaraghav8 that solved it - but what was causing the problem?
Raghav Dua
@duaraghav8
May 18 2016 05:16
@GregJacoby its how indexOf works
say I have an array [10, 20, 50, 30, 20]
Your intension was to use indexOf to get the index of the LAST 20, but it ends up returning index of the first 20 it encounter => 1
Try relating it with that
ALso, yes even I though the most elegant solution was simply filter () but I think now you'll be more careful
*thought
Greg
@GregJacoby
May 18 2016 05:17
ohhh
that makes perfect sense
@duaraghav8 /bows
Raghav Dua
@duaraghav8
May 18 2016 05:17
@GregJacoby haha happy to help
Aryan
@aryandua
May 18 2016 05:20
var arr = [
"freecodecamp", "storbeck", "terakilobyte", "habathcx", "RobotCaleb", "thomasballinger", "noobs2ninjas", "beohoff", "ESL_SC2", "OgamingSC2", "cretetion"
];
var onOrof = [];
var whatStream = [];
for (i = 0; i < arr.length; i++) {
name = arr[i];
$.getJSON('https://api.twitch.tv/kraken/streams/' + name, function(data) {
if (data["stream"] === null) {
onOrof.push("offline");
whatStream.push("");
}
else {
onOrof.push("online");
whatStream.push(data['stream']['game']);
}
});
console.log(onOrof);
}
why does my console.log() show []?
Puja
@Pujachaubey
May 18 2016 05:20
hii frds i get stuck in escape sequence in string.
can anyone plz help me
anthonyjl92
@anthonyjl92
May 18 2016 05:23
<div id="standard_container" style="width:160px;height:600px;"></div>
<script type="text/javascript">
(function(d) {
var ttx_iframe = d.createElement('iframe');
ttx_iframe.id = 'iframecontainer';
ttx_iframe.style = "margin: 0px; padding: 0px; border: 0px none; width: 160px; height: 600px; overflow: hidden;";
var container = document.getElementById('standard_container');
container.appendChild(ttx_iframe);
var doc = ttx_iframe.contentDocument ? ttx_iframe.contentDocument : ttx_iframe.contentWindow.document;
var script = "<scr"+"ipt type='text/javascript' src='cdn.angular'</scr"+"ipt>";
doc.open();
doc.write(script);
 doc.close();
})(document);</script>
How do I rewrite this using appendChild or innerHTML? Do i just replace doc.write(script) with doc.body.appendChild(script) or doc.innerHTML(script)?
Lemmy
@imnotlammy
May 18 2016 05:28
$(document).ready(function() {
  var api = "https://en.wikipedia.org/w/api.php?action=opensearch&search=pikachu";

  $.getJSON(api, function(data) {
    console.log(data);
  });
})
can someone tell why this doesn't work?
Puja
@Pujachaubey
May 18 2016 05:32
var myStr; // Change this line
how can i solve this
plz tell me any one
this is aproblem of escape sequence in string
rphares
@rphares
May 18 2016 05:38
@Pujachaubey , they gave you a sequence,
Puja
@Pujachaubey
May 18 2016 05:38
yes
rphares
@rphares
May 18 2016 05:38
something like backslash tab tab newline carriage return
you use the chart to turn that into code
for example, the backslash would be \\
you sort that line of code as a string in the var they give you,
var myStr; // Change this line
that one-- assign the coded sequence there :blush:
christianws
@christianws
May 18 2016 05:39
Yo I'm on the Quote Machine zipline can anyone point me in the right direction of how to use an API with codepen?
Puja
@Pujachaubey
May 18 2016 05:40
yes i wrote like that var myStr = "\ \t \t \r \n";
Rex
@RexChip
May 18 2016 05:41
This message was deleted
CamperBot
@camperbot
May 18 2016 05:41
no wiki entry for: pagination
rphares
@rphares
May 18 2016 05:41
that should be fine, except--
do you have one space or two in-between those, @Pujachaubey ?
Puja
@Pujachaubey
May 18 2016 05:41
one space
rphares
@rphares
May 18 2016 05:42
hmm, refesh and run tests again, ill check my answer, that looks okay?
Puja
@Pujachaubey
May 18 2016 05:43
yes i got it.
thanks
rphares
@rphares
May 18 2016 05:44
sweet! Congrats and happy coding, @Pujachaubey ~
Rex
@RexChip
May 18 2016 05:48
Hey guys, I'm javascript beginner, the professor need i make a pagination, i found a method, http://paginationjs.com/ , but i dont know how to use this, i try and try but get nothing help... i'm stuck in three weeks, someone can help me? thank u very much .
rphares
@rphares
May 18 2016 05:49
(just so you know,I'm not ignoring your Q, i've seen it many times... i just dont know anything about it, sorry! @RexChip :pensive: )
Markus Kiili
@Masd925
May 18 2016 05:50
@RexChip Have you considered using Bootstrap's pagination?
@rphares Good morning.
rphares
@rphares
May 18 2016 05:50
morning, @Masd925 ~
Markus Kiili
@Masd925
May 18 2016 05:51
@rphares Or maybe not that great morning. I have to study php.
rphares
@rphares
May 18 2016 05:51
Oooh, what for?
Markus Kiili
@Masd925
May 18 2016 05:52
@rphares Work.
rphares
@rphares
May 18 2016 05:52
Well-- it'll be something new? Thats always exciting...?
jorgon1022
@jorgon1022
May 18 2016 05:53
hi guys
im looking for a little bit of help and guidance in the right direction
Markus Kiili
@Masd925
May 18 2016 05:54
@rphares Yes, all programming is nice, but if I could choose, I would pick some other language.
jorgon1022
@jorgon1022
May 18 2016 05:54
function myFunction() {
    var quoteArr=['Too weird to live, too rare to die!','Sex is kicking death in the ass while singing.','Life is but a dream for the dead.'];
    var quoteAuthor=['-Hunter S.Thompson','-Charles Bukowski','-Gerard Way']
    var index=Math.floor(Math.random()*quoteArr.length);
    var hex = Math.floor(Math.random() * 0xFFFFFF);
    var hex = Math.floor(Math.random() * 0xFFFFFF);
    document.getElementById('demo').innerHTML=quoteArr[index]+'<br>'+quoteAuthor[index]
    document.getElementById('color').innerHTML= "#" + ("000000" + hex.toString(16)).substr(-6);

}
I am trying to get my background color to change on the click of a button, but so far I have had no success. What exactly am I doing wrong?
Grzegorz
@bluznierca1
May 18 2016 05:55
You have to catch your button by document.getElementById () and then you need to create function onclick
Rex
@RexChip
May 18 2016 05:56
@rphares thank your reply @Masd925 yes, but i don't know how to add to Bootstrap Pagination, i can make button, but when i click button, button its not work
CamperBot
@camperbot
May 18 2016 05:56
rexchip sends brownie points to @rphares and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1525 | @masd925 |http://www.freecodecamp.com/masd925
:star2: 4683 | @rphares |http://www.freecodecamp.com/rphares
jorgon1022
@jorgon1022
May 18 2016 05:57
@bluznierca1 whats weird is that the random quote part is working when I click the button, but the color doesnt change
Grzegorz
@bluznierca1
May 18 2016 05:57
Show me your codes; )
Otherwise i have no idea what may be wrong with your codes
jorgon1022
@jorgon1022
May 18 2016 05:57
 <script src="js/plugins.js"></script>
        <script src="js/main.js"></script>

        <div id="color">
            <p>Click on the button to display a random number</p>
            <button onclick='myFunction()'>Click Here for Random Number</button>
            <h1 id="demo"></h1>

        </div >
function myFunction() {
    var quoteArr=['Too weird to live, too rare to die!','Sex is kicking death in the ass while singing.','Life is but a dream for the dead.'];
    var quoteAuthor=['-Hunter S.Thompson','-Charles Bukowski','-Gerard Way']
    var index=Math.floor(Math.random()*quoteArr.length);
    var hex = Math.floor(Math.random() * 0xFFFFFF);
    var hex = Math.floor(Math.random() * 0xFFFFFF);
    document.getElementById('demo').innerHTML=quoteArr[index]+'<br>'+quoteAuthor[index]
    document.getElementById('color').innerHTML= "#" + ("000000" + hex.toString(16)).substr(-6);

}
Grzegorz
@bluznierca1
May 18 2016 05:58
And show me myFunction()
jorgon1022
@jorgon1022
May 18 2016 05:58
so the first one is my html and the second is my function
Grzegorz
@bluznierca1
May 18 2016 05:58
No , no...
You can not use innerHTML
Type addClass
jorgon1022
@jorgon1022
May 18 2016 05:59
hmm
Grzegorz
@bluznierca1
May 18 2016 05:59
Instead of inne
Inner*
jorgon1022
@jorgon1022
May 18 2016 05:59
so I need to read up more on innerHTML
Grzegorz
@bluznierca1
May 18 2016 05:59
InnerHTML is for changing content of chosen element
Read about addClass; )
jorgon1022
@jorgon1022
May 18 2016 06:00
@bluznierca1 thank you . Also I honestly appreciate you not giving me the answer. That way I can research this
CamperBot
@camperbot
May 18 2016 06:00
jorgon1022 sends brownie points to @bluznierca1 :sparkles: :thumbsup: :sparkles:
:cookie: 135 | @bluznierca1 |http://www.freecodecamp.com/bluznierca1
Grzegorz
@bluznierca1
May 18 2016 06:00
document.getElementById ("#").addClass
Read abt that :)
There is no point of giving an answer :)
jorgon1022
@jorgon1022
May 18 2016 06:01
thank you again @bluznierca1
CamperBot
@camperbot
May 18 2016 06:01
jorgon1022 sends brownie points to @bluznierca1 :sparkles: :thumbsup: :sparkles:
:warning: jorgon1022 already gave bluznierca1 points
Grzegorz
@bluznierca1
May 18 2016 06:02
Welcome ;)
redixhumayun
@redixhumayun
May 18 2016 06:15
For the Title Case a Sentence code, I have the following algorithm.

function titleCase(str) {
var words = str.toLowerCase().split(" ");
var new_word = 0;
var sentence = 0;
var letters = 0;
for(var i = 0; i < words.length; i++){
new_word = words[i].charAt(0).toUpperCase();
letters = new_word.split('');
for(var j = 0; j < letters.length; j++){
sentence = sentence + " " + new_word + words[i].slice(j+1);
}
}
return sentence;
}

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

But for some reason I get my result for the above code as 0 I'm A Little Tea Pot. Can somebody please tell me where the 0 is coming from?
kirbyedy
@kirbyedy
May 18 2016 06:17
@redixhumayun maybe this will help...
check the image
Screen Shot 2016-05-18 at 09.17.16.png
lyett
@lyett
May 18 2016 06:23
Hi, for the following nesting loop I get "TypeError : Cannot read property 'length' of undefined. Any help?

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < multiplyAll.length ; i++)
{
for (var j=0; j < multiplyAll[i].length; j++)
{
console.log(arr[i][j]);
product *= multiplyAll[i];
}
}

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Chris Cullen
@123xylem
May 18 2016 06:23
This was workinhg yesterday and today its not> Any idea why?
http://codepen.io/123xylem/pen/aNxREJ?editors=1011
Samuel Plumppu
@Greenheart
May 18 2016 06:24
@123xylem Seems to be some problem with your $.ajax-call
I'll check it out more closely in a sec :blush:
William Coleman
@wcski
May 18 2016 06:27
Last challenge before bed (i always say that) and I'm stuck
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.
Keone Martin
@Athaman
May 18 2016 06:28
what have you got so far @wcski ?
William Coleman
@wcski
May 18 2016 06:28
  // Only change code below this line
  var val = {

    "alpha": "Adams",

    "bravo": "Boston",

    "charlie": "Chicago",

    "delta": "Denver",

    "echo": "Easy",

   "foxtrot": "Frank",
  };

  // Only change code above this line
  return result;
}
Markus Kiili
@Masd925
May 18 2016 06:28
@redixhumayun Easier would be to just do words[i]=words[i].charAt(0).toUpperCase()+... <- rest of words[i] here
William Coleman
@wcski
May 18 2016 06:29
here's the full context
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var val = {

    "alpha": "Adams",

    "bravo": "Boston",

    "charlie": "Chicago",

    "delta": "Denver",

    "echo": "Easy",

   "foxtrot": "Frank",
  };

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

// Change this value to test
phoneticLookup("charlie");
Keone Martin
@Athaman
May 18 2016 06:29
ok, so val is being passed into the function here, but you're redefining it as being the label for your lookup table
William Coleman
@wcski
May 18 2016 06:30
I've tried it with js var lookup = etc etc
sorry the formatting on gitter always eludes me
Keone Martin
@Athaman
May 18 2016 06:30
all you need to do is rename your table, then use tablename[val] to grab the result corresponding to the input val
Darth Skywalker
@adityaparab
May 18 2016 06:31
@wcski : Rename your var val = {to var lookup = {
And then
result = lookup[val];
return result;
Keone Martin
@Athaman
May 18 2016 06:31
the table acts as a dictionary or map sort of (if you know those from another language) and val acts as the key
William Coleman
@wcski
May 18 2016 06:31
so i'm pretty sure my object should be titled lookup
ohh
Keone Martin
@Athaman
May 18 2016 06:31
the table should be called lookup according to the challenge
Chris Cullen
@123xylem
May 18 2016 06:31
@Greenheart please do :) I cant see whats wrong and it was working before I went to bed yesterday
Keone Martin
@Athaman
May 18 2016 06:31
obviously you can actually call it whatever you want in the realworld
Rohan Gayen
@WapmasterRohan
May 18 2016 06:31
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  newArr=arr.sort();
  for(var i=0; i<newArr.length;i++) {
    if(num<=newArr[i]) return i;
    //else if(num === newArr[i]) return i;
  }
  return newArr.length;
}

getIndexToIns([5, 3, 20, 3], 5);
return the lowest index at which a value should be inserted into an array once it has been sorted.
what is wrong with this program??
Darth Skywalker
@adityaparab
May 18 2016 06:32
@123xylem : Demons in your dreams seem to have fucked it up overnight :P
William Coleman
@wcski
May 18 2016 06:33
thanks @adityaparab and @Athaman
CamperBot
@camperbot
May 18 2016 06:33
wcski sends brownie points to @adityaparab and @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 404 | @athaman |http://www.freecodecamp.com/athaman
:cookie: 256 | @adityaparab |http://www.freecodecamp.com/adityaparab
Markus Kiili
@Masd925
May 18 2016 06:34
@WapmasterRohan The default sort is unicode sort, so not numerical sort.
Keone Martin
@Athaman
May 18 2016 06:34
@wcski no worries bud, enjoy your sleep... or one last challenge ;)
Rohan Gayen
@WapmasterRohan
May 18 2016 06:36
unicode sort means?
Ghost
@ghost~56a552d0e610378809be0124
May 18 2016 06:36
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i].prop;
    }
  }
  for (var j = 0; j < contacts.length; j++) {
    if(contacts[i][firstName] == firstName) {
      noContact = false;
      propPresent = contacts[i].hasOwnProperty(prop);
    }
  }
  if (noContact) {
    return "No such contact";
  } else if (propPresent) {
    return "No such property";
  }

// Only change code above this line
}
Keone Martin
@Athaman
May 18 2016 06:36
means crazy and unpredictable... ok, so probably predictable when you get used to JS
Darth Skywalker
@adityaparab
May 18 2016 06:36
@WapmasterRohan : You're not sorting array correctly. :) The Array.prototype.sort function takes a function as argument. This function should implement the logic that determines sorting method. So to sort the array in ascending order, you do something like
arr.sort(function(a,b){
   return a-b;
});
Myuuks
@Myuuks
May 18 2016 06:37
hi , i dont understand why my code isnt right : http://pastebin.com/PRdXTxty (java) it says : Use two + operators to build myStr with myName inside it, but i did it :/
Ghost
@ghost~56a552d0e610378809be0124
May 18 2016 06:37
where am i wrong?
Keone Martin
@Athaman
May 18 2016 06:37
@Myuuks you need to add a space to the start of the third string
lyett
@lyett
May 18 2016 06:38
Hi, for the following nesting loop I get "TypeError : Cannot read property 'length' of undefined". Any help?
Hi, for the following nesting loop I get "TypeError : Cannot read property 'length' of undefined. Any help?

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < multiplyAll.length ; i++)
{
for (var j=0; j < multiplyAll[i].length; j++)
{
console.log(arr[i][j]);
product *= multiplyAll[i];
}
}

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Myuuks
@Myuuks
May 18 2016 06:38
@Athaman var myStr = myName + "Thomas " + "and i am swell!"; on this line ?
Keone Martin
@Athaman
May 18 2016 06:39
yeah @Myuuks you need to have " and i am swell"
Chris Cullen
@123xylem
May 18 2016 06:39
@adityaparab ha.. Did you see what the demons did?
Samuel Plumppu
@Greenheart
May 18 2016 06:39
@123xylem There could be two errors: Either the wikipedia-API-url or the ajax-call. I'm afraid I don't have time to help anymore but I recomend you to go through the documentation for jQuery.ajax() and the Wikipedia Search API one more time and verify that you're using the right values :)
Keone Martin
@Athaman
May 18 2016 06:39
@lyett mulitplyAll is the name of the function, arr is the name of the array. need to change multiplyAll.length to arr.length
Myuuks
@Myuuks
May 18 2016 06:39
@Athaman i just understand what's wrong, that wasnt that ^^ but thanks
CamperBot
@camperbot
May 18 2016 06:39
myuuks sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 405 | @athaman |http://www.freecodecamp.com/athaman
Keone Martin
@Athaman
May 18 2016 06:40
oh wow, @ myuuks, sorry you're right, you have one after thomas... it's probably worth copy pasting the code here in the formatted code for ease of reading
Markus Kiili
@Masd925
May 18 2016 06:40
@WapmasterRohan Unicode sort would sort numbers like this:
Darth Skywalker
@adityaparab
May 18 2016 06:40

@WapmasterRohan : Secondly, if you want to find if particular element exists in array, you don't need to iterate through the array. Array.prototype has a method called indexOf to check if the element exists in the array.

You can just do

arr.sort(function(a,b){
   return a-b;
});
return arr.indexOf(num) > -1 ? arr.indexOf(num) : arr.length;

Note: `indexOf function returns -1 if the element is not present in the array.

Markus Kiili
@Masd925
May 18 2016 06:40
[15,4,2,33,12,9].sort(); // [ 12, 15, 2, 33, 4, 9 ]
Darth Skywalker
@adityaparab
May 18 2016 06:40
@123xylem : I am glad I did not :P :P
Rohan Gayen
@WapmasterRohan
May 18 2016 06:40
thanks @adityaparab
CamperBot
@camperbot
May 18 2016 06:40
wapmasterrohan sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
Myuuks
@Myuuks
May 18 2016 06:40
@Athaman the exercice want me to do + anyvariable + stuff
CamperBot
@camperbot
May 18 2016 06:40
:cookie: 257 | @adityaparab |http://www.freecodecamp.com/adityaparab
Myuuks
@Myuuks
May 18 2016 06:41
@Myuuks that's why its didnt work ^^
Keone Martin
@Athaman
May 18 2016 06:41
yeah :) i had another look and see it now
i'm just used to most string concatenation being broken by spaces
Rohan Gayen
@WapmasterRohan
May 18 2016 06:41
but what is unicode sorting?? @Masd925
lyett
@lyett
May 18 2016 06:41
many thank Keone Martin, can't believe I missed that...
Keone Martin
@Athaman
May 18 2016 06:41
sorts things alphabetically @WapmasterRohan instead of by integer value
@lyett it happens ;)
Markus Kiili
@Masd925
May 18 2016 06:42
@WapmasterRohan MDN: If compareFunction is not supplied, elements are sorted by converting them to strings and comparing strings in Unicode code point order. For example, "Banana" comes before "cherry". In a numeric sort, 9 comes before 80, but because numbers are converted to strings, "80" comes before "9" in Unicode order.
Subh Samal
@subhsamal
May 18 2016 06:44
I have doubt in record collection. Though my code is working I have some doubt .
Rohan Gayen
@WapmasterRohan
May 18 2016 06:44
thanks @Masd925
CamperBot
@camperbot
May 18 2016 06:44
wapmasterrohan sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1526 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
May 18 2016 06:45
@WapmasterRohan And all characters have unicode values between 0 and 65535.
Keone Martin
@Athaman
May 18 2016 06:46
@subhsamal paste your code?
Subh Samal
@subhsamal
May 18 2016 06:46

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(value && prop !== "tracks"){ // if (value !== " ") is same as if (value)
collection[id][prop] = value;
}

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

}

return collection;
}

// Alter values below to test your code
updateRecords(2548, "tracks", "Addicted to Love");

Darth Skywalker
@adityaparab
May 18 2016 06:46

@WapmasterRohan : Every character you see on the screen is encoded in a way that the computer can understand.
There are various methods of character encoding. Earlier, it used to be ASCII now we support various characters from other languages like Hindi, Chinene, ASCII is no longer sufficient to encompass all the characters. So other standards were developed.

One of those standards is Unicode. It comes in variations like UTF-8, UTF-16 etc.

So when you have a character W, it is represented with a unicode encoding in memory. So when they say unicode sorting or ASCII sorting what they mean is that the characters are compared based on the code that represents that character based on the encoding scheme in use. Not necessarily ASCII.

V Arun Kumar
@arunvkumr
May 18 2016 06:46
@lyett multiplyAll is function name... use arr instead. and product *= multiplyAll[i](if multiplyAll is assumed to be the array) then this represents sub array so you are multipling subarray with product, i don't think it works that way.. try using both i and j
Subh Samal
@subhsamal
May 18 2016 06:47
collection[id][prop] = value; @Athaman How can I use push here
Keone Martin
@Athaman
May 18 2016 06:48
@subhsamal since you check if (prop === "tracks") you can just refer to tracks directly in your code at that stage
collection[id].tracks.push(value);
is how i wrote it, seems legit to me
Subh Samal
@subhsamal
May 18 2016 06:50
yeah I could know problem in my code, was not able to use variable instead of literal. will try this @Athaman
V Arun Kumar
@arunvkumr
May 18 2016 06:50
@ShashiDwivedi have you defined both noContact and propPresent? in the if condition of j loop gets false and both vars are not defined then, they are undefined variables, which if takes as false.
Subh Samal
@subhsamal
May 18 2016 06:51
what if I have to use variable prop which stores track? Any idea? @Athaman
Keone Martin
@Athaman
May 18 2016 06:52
yeah you can just use collection[id][prop].push(value);
at least i just rewrote mine and it worked.
Subh Samal
@subhsamal
May 18 2016 06:55

function updateRecords(id, prop, value) {

if(value && prop !== "tracks"){ // if (value !== " ") is same as if (value)
collection[id][prop].push(value);
}

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

}

return collection;
}'''

CamperBot
@camperbot
May 18 2016 06:55
:bulb: to format code use backticks! ``` more info
Subh Samal
@subhsamal
May 18 2016 06:55
@Athaman I did it. Not able to get first condition corect.
Correct *
Keone Martin
@Athaman
May 18 2016 06:56
it's not the pop line causing troubles
Markus Kiili
@Masd925
May 18 2016 06:56
@subhsamal On the first test, set the property value instead of pushing. (you only push to tracks which is an array)
Keone Martin
@Athaman
May 18 2016 06:57
oh, yeah, everything except for tracks is not an array so push won't work on them
which test is failing?
i though you were talking about your tracks test failing
Subh Samal
@subhsamal
May 18 2016 06:59
oh...I had done it using assignment which worked for me. but I was not clear with usages. so I tried doing it using push. Now it makes sense to me. @Athaman @Masd925
Keone Martin
@Athaman
May 18 2016 06:59
glad it worked out
CP
@lubere0102
May 18 2016 07:01
could you guys help me with Word Blanks from Basic JavaScript?
Keone Martin
@Athaman
May 18 2016 07:01
sure thing bud, what's up?
Subh Samal
@subhsamal
May 18 2016 07:02
thanks guys @Athaman @Masd925
CamperBot
@camperbot
May 18 2016 07:02
subhsamal sends brownie points to @athaman and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1527 | @masd925 |http://www.freecodecamp.com/masd925
:cookie: 406 | @athaman |http://www.freecodecamp.com/athaman
CP
@lubere0102
May 18 2016 07:02
i have no idea how i should start questioning

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

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

You will also need to provide additional strings, which will not change, in between the provided words.

We have provided a framework for testing your results with different words. The tests will run your function with several different inputs to make sure all of the provided words appear in the output, as well as your extra strings.

Subh Samal
@subhsamal
May 18 2016 07:03
paste your code and mention your problem
CP
@lubere0102
May 18 2016 07:03
wordBlanks("","","","") should return a string.
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
Keone Martin
@Athaman
May 18 2016 07:04
@lubere0102 so the challenge gives you a function call with a bunch of words called myNoun, myAdjective, myVerb, myAdverb.
Saurabh Parihar
@parihars
May 18 2016 07:04
how to solve Profile Lookup problem
Keone Martin
@Athaman
May 18 2016 07:04
you need to stick them together into 1 string called result
CP
@lubere0102
May 18 2016 07:04
ok
Keone Martin
@Athaman
May 18 2016 07:04
you can join strings together using the + operator
CP
@lubere0102
May 18 2016 07:04
ah
Keone Martin
@Athaman
May 18 2016 07:05
var oneWord = "whargarbl";
var anotherWord = "blargh";
var together = oneWord + anotherWord // together now = "whargarblblargh" <-- notice that no space was added between the words
CP
@lubere0102
May 18 2016 07:06
how do you capture like that?
Keone Martin
@Athaman
May 18 2016 07:06
help format
CamperBot
@camperbot
May 18 2016 07:06

: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

Keone Martin
@Athaman
May 18 2016 07:07
@parihars which part is confusing you?
Subh Samal
@subhsamal
May 18 2016 07:07
var result = "my " + myAdjective +" "+ myNoun +" " + myVerb+" " + myAdverb; @lubere0102 try like this
Keone Martin
@Athaman
May 18 2016 07:08
bro, if you give people the answer directly like that it doesn't really give them a chance to learn the content
also in the challenge var result = ""; has already been set... so you just want result = ... :P
Subh Samal
@subhsamal
May 18 2016 07:09
my bad :P
CP
@lubere0102
May 18 2016 07:10
thank you i just didn't get what i was supposed to do
Keone Martin
@Athaman
May 18 2016 07:10
no problem :) sorry if i sounded hostile, i'm struggling to find the right words but it's a common thing on the channel to just give the answers which i think isn't the best solution
sometimes if someones obviously got the logic and just has a typoe, or uses the wrong variable somewhere or something it makes sense to just tell them where it's wrong and pass the solution, but normally i start off with clues and analogies.
Subh Samal
@subhsamal
May 18 2016 07:11
yes you sound correct buddy
Keone Martin
@Athaman
May 18 2016 07:11
:)
Subh Samal
@subhsamal
May 18 2016 07:11
:blush:
Keone Martin
@Athaman
May 18 2016 07:12
sorry also if i sound high and mighty.
Subh Samal
@subhsamal
May 18 2016 07:12
np
CP
@lubere0102
May 18 2016 07:12
thank you all
sdf
Keone Martin
@Athaman
May 18 2016 07:12
no problem @lubere0102 :) enjoy the challenges
CP
@lubere0102
May 18 2016 07:13
thank you for that capturing method too

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

    var result = "my " + myAdjective +" "+ myNoun +" " + myVerb+" " + myAdverb; 
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Keone Martin
@Athaman
May 18 2016 07:13
no worries, it's good to know. much easier to help people when the code is all pretty and formatted
CP
@lubere0102
May 18 2016 07:13
very good
Michael
@michaelpautov
May 18 2016 07:16

hello
var myVar = 87;

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

dont' working ex myVar = myVar should be changed
Keone Martin
@Athaman
May 18 2016 07:17
myVar = myVar; won't do anything, all it does is tell myVar to be itself
like 5 = 5;
the increment by one shorthand needs to be on the end of the variable like myVar++;
but it doesn't need to be reassigned because that's part of the short hand
so myVar = myVar++; is the same as myVar = myVar = MyVar + 1;
Blauelf
@Blauelf
May 18 2016 07:19
++myVar first increments myVar, then evaluates to the incremented value (in contrast to myVar++, which also increments myVar, but evaluates to the old value), so myVar = ++myVar; should be same as ++myVar;
Keone Martin
@Athaman
May 18 2016 07:19
oh right, i didn't think JS had increment first in it sorry...
Michael
@michaelpautov
May 18 2016 07:20
thank
Keone Martin
@Athaman
May 18 2016 07:20
you're welcome
Myuuks
@Myuuks
May 18 2016 07:20
@Athaman i dont understand what's asked for the exercice called "Woord Blanks"
-o
Blauelf
@Blauelf
May 18 2016 07:21
You are meant to return a sentence containing all those words passed to your function.
Keone Martin
@Athaman
May 18 2016 07:22
similar to before when you used your name + another string
Blauelf
@Blauelf
May 18 2016 07:22
@Myuuks So for "big","dog","ran","quickly" it might return something like "When I saw a big dog, I ran quickly."
Ajith
@ajithvallabai
May 18 2016 07:22
diff btwn two arrays .there is a mistake in if loop but i dnt know to recify it

function diffArray(arr1, arr2) {
  var newArr = [];
  var oldArr=[];
  // Same, same; but different.
  for(var i=0;i<arr1.length;i++)
    {
      for(var j=0;j<arr2.length;j++)
      {  
      if(arr1[i]==arr2[j])

      newArr.push(arr2[j]);
        else
          oldArr.push(arr2[j]);

      }

    }

  return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Keone Martin
@Athaman
May 18 2016 07:22
you just need to do it for the variables passed into the function, called myNoun, myVerb, and the other 2
Myuuks
@Myuuks
May 18 2016 07:23
i just need to do like : myNoun + myAdjective + myVerb etc.. ?
Keone Martin
@Athaman
May 18 2016 07:24
but remember spaces
so myNoun + " " + myAdjective
and you can put in your own words too like @Blauelf said if you want to be creative
Blauelf
@Blauelf
May 18 2016 07:24
@Myuuks That would lead to "dogbigranquickly", the words have to remain separate.
Myuuks
@Myuuks
May 18 2016 07:24
yeah yeah i see
alright thanks
Keone Martin
@Athaman
May 18 2016 07:25
np
Markus Kiili
@Masd925
May 18 2016 07:26
@ajithvallabai You are pushing if there is an element on the other array that differs from it. You should push if the element differs from all the elements on the other array?
Blauelf
@Blauelf
May 18 2016 07:26
@ajithvallabai You cannot decide whether to include something based on a single match, you would have to make sure the element is not anywhere in the whole other array before you push it to the result array.
Saurabh Parihar
@parihars
May 18 2016 07:28
How to solve Profile Lookup Problem

//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
if(contacts.hasOwnProperty(firstName) && contacts.hasOwnProperty(prop))
return contacts[prop];
else if(contacts.hasOwnProperty(firstName))
return "No such contact";

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

Myuuks
@Myuuks
May 18 2016 07:29
what i dont understand is why we dont put our text into : var result
Markus Kiili
@Masd925
May 18 2016 07:29
@parihars First you need to loop or iterate through the contacts array.
@parihars Then figure out how to access one contact.
Ajith
@ajithvallabai
May 18 2016 07:30
thanks @Masd925 @Blauelf
CamperBot
@camperbot
May 18 2016 07:30
ajithvallabai sends brownie points to @masd925 and @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1528 | @masd925 |http://www.freecodecamp.com/masd925
:star2: 1825 | @blauelf |http://www.freecodecamp.com/blauelf
Saurabh Parihar
@parihars
May 18 2016 07:30
@Masd925 I have to make a loop inside function
Markus Kiili
@Masd925
May 18 2016 07:31
@parihars Yes.
Ajith
@ajithvallabai
May 18 2016 07:31
@Blauelf @Masd925 which loop is better to use
Markus Kiili
@Masd925
May 18 2016 07:31
@parihars For loop is fine.
Myuuks
@Myuuks
May 18 2016 07:32
@Blauelf @Athaman can you check my text ^^
pls :)
Darth Skywalker
@adityaparab
May 18 2016 07:32

@ajithvallabai :smile:

For loop in case of small number of iterations. Like in multiples of 1000s
While loop (iterating backwards) in case of millions of records. ;)

Blauelf
@Blauelf
May 18 2016 07:32
@ajithvallabai I think I used implicit loops, filter for cleaning from duplicates, and indexOf for finding out whether an element is in the other array.
Saurabh Parihar
@parihars
May 18 2016 07:33
@Masd925 I am not getting can you please explain me
Blauelf
@Blauelf
May 18 2016 07:33
@Myuuks Can you post your code?
help format
CamperBot
@camperbot
May 18 2016 07: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

ah, how can i do ?.
Kelvin-penang
@Kelvin-penang
May 18 2016 07:33

Hi all, I'm trying to split each word of a string into seperate arrays of alphabets, within a larger array of the whole string. What I'm looking for is this ["I","'","m"] ["a"]["l","i","t","t","l","e"]...you get the point,

but I'm stumped on how to split the words, can anybody help?

```


function titleCase(str) {
  var splitOnce = str.split(" ");

 for (var i=0; i <splitOnce.length; i++){
  var splitTwice = splitOnce[[i][i]].split("");

  return splitTwice;
}
}
titleCase("I'm a little tea pot");
Blauelf
@Blauelf
May 18 2016 07:34
@Myuuks That's not code, it's a screenshot.
Myuuks
@Myuuks
May 18 2016 07:34
yeah how can i do ?

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

"when i saw a " + myAdjective + myNoun + "i " + myVerb + myAdverb;

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Blauelf
@Blauelf
May 18 2016 07:34
Copy/Paste, format according to :point_up: 18. Mai 2016 09:33
Myuuks
@Myuuks
May 18 2016 07:35
looks wierd like this on my screen
Blauelf
@Blauelf
May 18 2016 07:35
@Myuuks You should probably use result = in front of your string. Also, the words are not all separate.
Saurabh Parihar
@parihars
May 18 2016 07:35
https://coderpad.io/R3ERDJ79 join here and please help me in solving this problem
Kelvin-penang
@Kelvin-penang
May 18 2016 07:36
This message was deleted
Myuuks
@Myuuks
May 18 2016 07:36

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

result = "when i saw a " + myAdjective + myNoun + "i " + myVerb + myAdverb;

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog ", "big ", "ran ", "quickly ");

Blauelf
@Blauelf
May 18 2016 07:37
@Kelvin-penang You can type ``` without it being interpreted by using \ as an escape character.
Saurabh Parihar
@parihars
May 18 2016 07:37
Blauelf
@Blauelf
May 18 2016 07:37
@Myuuks Please put a line of triple backticks in front of your code, and one below, add line breaks using Shift+Return.
Markus Kiili
@Masd925
May 18 2016 07:38
@parihars contacts is an array. Make a standard for loop over array indices.
Kelvin-penang
@Kelvin-penang
May 18 2016 07:38
ok thanks @Blauelf I need help on my splitting exercise tho..:sweat_smile:
CamperBot
@camperbot
May 18 2016 07:38
kelvin-penang sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1826 | @blauelf |http://www.freecodecamp.com/blauelf
Saurabh Parihar
@parihars
May 18 2016 07:38
@Masd925 please join on that link and help me
Kelvin-penang
@Kelvin-penang
May 18 2016 07:38
can anybody help me in the splitting inception?
Myuuks
@Myuuks
May 18 2016 07:38
@Blauelf my english is not great sorry xD
Blauelf
@Blauelf
May 18 2016 07:39
@parihars Why don't you post the code here on chat?
Saurabh Parihar
@parihars
May 18 2016 07:39

//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<contact.length;i++)

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

zhangx007
@zhangx007
May 18 2016 07:40
hello,i am new here
Markus Kiili
@Masd925
May 18 2016 07:40
@parihars It is contacts.
Saurabh Parihar
@parihars
May 18 2016 07:40
@Masd925 yeah i m changing it
Markus Kiili
@Masd925
May 18 2016 07:40
@parihars Then figure out how to access one contact inside the array of contacts.
Blauelf
@Blauelf
May 18 2016 07:41
@Myuuks
```js
function yourCode(arg1) {
var foo;
return "bar";
}
```
becomes
function yourCode(arg1) {
  var foo;
  return "bar";
}
Myuuks
@Myuuks
May 18 2016 07:41
allright thanks
Keone Martin
@Athaman
May 18 2016 07:41
sorry, wandered off for a bit
Myuuks
@Myuuks
May 18 2016 07:42
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

 result = "when i saw a " + myAdjective  + myNoun + "i " + myVerb + myAdverb;

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog ", "big ", "ran ", "quickly ");
it works but
Keone Martin
@Athaman
May 18 2016 07:43
remember myuuks if you take "one word" + "another word" you get "one wordanother word" so when you add two words together which are stored as variables, like myAdjective and myNoun, you need to use myAdjective + " " + myNoun
Darth Skywalker
@adityaparab
May 18 2016 07:43
@parihars :smile:
for(var i=0;i<contacts.length;i++) {
       if(firstName == contacts[i].firstName){
             return contacts[i][prop];
       }
}
Rohan Gayen
@WapmasterRohan
May 18 2016 07:43

Caesars cipher

function rot13(str) { // LBH QVQ VG!
  for(var i=0;i<str.length;i++) {
    if(str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 90) {
      if(str.charCodeAt(i) < 78) {
        str[i] = String.fromCharCode(str.charCodeAt(i) + 13);
      }
      else {
        str[i] = String.fromCharCode(str.charCodeAt(i) - 13);
      }
    }
  }
  return str;
}

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

what is the problem?
TypeError: Cannot assign to read only property '0' of string 'SERR PBQR PNZC'

Saurabh Parihar
@parihars
May 18 2016 07:44
there is also else condition
@adityaparab
Darth Skywalker
@adityaparab
May 18 2016 07:44
@parihars : Sorry I don't know the problem statement. I just fixed syntax and semantic errors.
Myuuks
@Myuuks
May 18 2016 07:45
is that better @Athaman :
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

 result = "when i saw a " + myAdjective+ "" + myNoun + "i " + myVerb + "" + myAdverb;

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Saurabh Parihar
@parihars
May 18 2016 07:45
@adityaparab No problem buddy Thanks!!
CamperBot
@camperbot
May 18 2016 07:45
parihars sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 258 | @adityaparab |http://www.freecodecamp.com/adityaparab
Myuuks
@Myuuks
May 18 2016 07:45
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

 result = "when i saw a " + myAdjective + "" + myNoun + "i " + myVerb + "" + myAdverb;

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Keone Martin
@Athaman
May 18 2016 07:45
"" is no space " " is a space
Myuuks
@Myuuks
May 18 2016 07:46
ok :)
Keone Martin
@Athaman
May 18 2016 07:46
also you'll need a space in front of i so " i "
this challenge is just to make people aware of how annoying joining strings can be :D
cnj1987
@cnj1987
May 18 2016 07:46
Can anyone help me? D:
Myuuks
@Myuuks
May 18 2016 07:47
yeah it's xD
Keone Martin
@Athaman
May 18 2016 07:48
@cnj1987 what do you need?
Rex
@RexChip
May 18 2016 07:48
<div id="wrapper">

<table id="records">
<thead>
<tr>
<th class="long-cell">Input</th>
<th class="long-cell">E-Mail</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3" style="padding:10px;">
<button type="button" onclick="Normalizer.clear();">Clear all history</button>
</td>
<td><div id="pagination">test</div></td>
</tr>
</tfoot>
<tbody></tbody>
</table>
<footer>
</footer>
</div>
cnj1987
@cnj1987
May 18 2016 07:48

Thanks @Athaman :)

Call the processArg function with an argument of 7 and assign its return value to the variable processed.

// Example
var changed = 0;

function change(num) {
  return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 0;

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

// Only change code below this line


processArg(7);
return processed;
CamperBot
@camperbot
May 18 2016 07:48
cnj1987 sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 407 | @athaman |http://www.freecodecamp.com/athaman
Rohan Gayen
@WapmasterRohan
May 18 2016 07:48
can anyone help me??
Rex
@RexChip
May 18 2016 07:48
this is my code, it will make some data like : test at gmail com -> test@gmail.com , in tbody, i don't know how to add to pagination
can anyone tell me how to add to pagination ? thank you
Myuuks
@Myuuks
May 18 2016 07:50
@Athaman on this site we only use var when i tryed to learn we used : String , char & others stuffs, that's why i'm a bit lost
Keone Martin
@Athaman
May 18 2016 07:50
@cnj1987 which challenge is it?
cnj1987
@cnj1987
May 18 2016 07:50
Assignment with a Returned Value
Keone Martin
@Athaman
May 18 2016 07:50
yeah, having not fixed data types is a brave new world for me too @Myuuks
@cnj1987 ok so the challenge is pointing out how returns work. when you call a function it will send back a piece of information in the return statement. but if you don't do anything to capture that information it just gets lost. so here they want you to declare a variable next to the processArg(7) line like var processed = processArg(7);
cnj1987
@cnj1987
May 18 2016 07:52
AH!
Divyam Bhagchandani
@divyambhagchandani
May 18 2016 07:52

guys ! help me with counting cards problem !

var count = 0;

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

if(card==2,3,4,5,6){
count++;
}
if(card==10,'J','Q','K','A'){
count--;

}
if(count>0){
return count "Bet" ;

}
if(count<0){

return count "Hold";

}

return "Change Me";
// 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');

Keone Martin
@Athaman
May 18 2016 07:53
so that when processArg(num) is run it sends back (num + 3) /5 which gets stored in the new variable... so in this case it will send back 2 and processed will be set to 2
Markus Kiili
@Masd925
May 18 2016 07:53
@divyambhag return count+" Bet"; etc
cnj1987
@cnj1987
May 18 2016 07:53
That makes so much more sense. Thanks @Athaman, I passed it now. :D
CamperBot
@camperbot
May 18 2016 07:53
cnj1987 sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:warning: cnj1987 already gave athaman points
Keone Martin
@Athaman
May 18 2016 07:53
glad to help :)
cnj1987
@cnj1987
May 18 2016 07:54
I really struggle with functions, still. It seems like pretty much every time I see one, I'm lost
Divyam Bhagchandani
@divyambhagchandani
May 18 2016 07:55
oh thanks @Masd925
CamperBot
@camperbot
May 18 2016 07:55
divyambhag sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1529 | @masd925 |http://www.freecodecamp.com/masd925
CodeNeophyte
@CodeNeophyte
May 18 2016 08:00
hello all. I'm having some trouble with my twitch zipline. I'm not sure why from the two channels that are supposed to give me an error only one is coming through. Any help would be greatly appreciated. http://codepen.io/TheCodeNeophyte/pen/yOWQzV?editors=0010
Saurabh Parihar
@parihars
May 18 2016 08:00
@adityaparab are you here
Darth Skywalker
@adityaparab
May 18 2016 08:01
@parihars : Whats up?
Saurabh Parihar
@parihars
May 18 2016 08:01
come to codepad

//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"]
}
];

//still showing error
function lookUpProfile(firstName, prop){
// Only change code below this line
var j=0;
var k=0;
for(var i=0;i<contacts.length;i++)
{
if(firstName == contacts[i].firstName){
return contacts[i][prop];
}
if(firstName!==contacts[i].firstName)
j++;
if(!contacts[i].hasOwnProperty(prop))
k++;
}
if(j==contacts.length)
return "No such contact";
if(k==contacts.length)
return "No such property";
// Only change code above this line
}

// Change these values to test your function

(lookUpProfile("Akira", "address"));

how to return No such property
Help me
CamperBot
@camperbot
May 18 2016 08:04

:point_right: adding snippets to sublime text [wiki]

Adding Snippets To Your Sublime Text Installation

If you are a user of sublime text (I hope you are, it kicks ass. You can get it here), then you may have already noticed some of the tab completion capabilities. For example, when you are opening an html tag such as <p>, it automatically closes the tag as soon as you type /. You can get similar functionality for pieces of code you end up re-writing over and over, and it's surprisingly easy!

Here's an example, which activates after typing div and then tab:

alt text

:pencil: read more about adding snippets to sublime text on the FCC Wiki

Saurabh Parihar
@parihars
May 18 2016 08:05
Blauelf
@Blauelf
May 18 2016 08:05
@parihars You return the property without checking it is there. Instead, you could simply nest some additional if with if(contacts[i].hasOwnProperty(prop)), also, I do not see any use of j and k.
Susheel Palakurthi
@ush19
May 18 2016 08:06

So I'm having a bit of trouble with my program

Why does it work with the id being in [] brackets instead of .. dot notation? Doesn't [] bracket notation use zero indexed? So if it's [123] it'd be accessing thr 124th element?


// 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) {
/*
 *  if value is non blank and prop is not tracks, then update or set the value for the prop
 *  if prop is tracks and value is non blank, push value onto end of tracks array
 *  if value is blank, delete that prop
 */

  if ((value !== "") && (prop !== "tracks"))
    {
      //update or set the value for the prop
      collection[id][prop] = value;
    }

  if ((prop === "tracks") && (value !== ""))
    {
      //push value onto end of tracks array
      collection[id].tracks.push(value);
    }

  if (value == "")
    {
      //delete prop

    }


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Blauelf
@Blauelf
May 18 2016 08:07
@ush19 [] notation is also used for accessing properties. You can use dot notation only if the property name is a valid identifier name and it is static, as collection.id would equal collection["id"], which has nothing to do with variable id.
Saurabh Parihar
@parihars
May 18 2016 08:08
@Blauelf How do i check if prop exists in contact list or not
Blauelf
@Blauelf
May 18 2016 08:08
And passing non-strings for property name will implicitly convert them to string, so 5439 is treated like "5439".
Saurabh Parihar
@parihars
May 18 2016 08:09
@Blauelf https://coderpad.io/R3ERDJ79 join here to help me
Blauelf
@Blauelf
May 18 2016 08:09
@parihars You have your check. Just put that in the place where you return the property and return the property or "No such property" depending on the outcome.
@parihars Stop spamming that link.
cnj1987
@cnj1987
May 18 2016 08:09
Okay, I don't even have a clue what I'm doing with this next one. :/
Saurabh Parihar
@parihars
May 18 2016 08:09
thats not spam
here you just edit my code
Keone Martin
@Athaman
May 18 2016 08:10
i haven't even been in this room but if @Blauelf says it's spam it's spam, he's telling you not to repeat it
Saurabh Parihar
@parihars
May 18 2016 08:10
wtf
Keone Martin
@Athaman
May 18 2016 08:10
if you ask for help we'll help, but there's no point in repeating a request, if we ignore it it's because it's not something we want to do at the moment for whatever reason
Susheel Palakurthi
@ush19
May 18 2016 08:11
@parihars chill, keep it friendly
Saurabh Parihar
@parihars
May 18 2016 08:11
@Athaman go in freecode camp chat
this is chat room for help
@ush19 yeah bro
Blauelf
@Blauelf
May 18 2016 08:11
I want to help here, not on external website.
Susheel Palakurthi
@ush19
May 18 2016 08:11
@Blauelf alrightty, i think i get it, thanks!
CamperBot
@camperbot
May 18 2016 08:11
ush19 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1827 | @blauelf |http://www.freecodecamp.com/blauelf
Saurabh Parihar
@parihars
May 18 2016 08:12
@Blauelf so just said this i will not ask you again
Keone Martin
@Athaman
May 18 2016 08:12
... i chill in this room because i regularly help people with inquiries
Saurabh Parihar
@parihars
May 18 2016 08:12
Do anybody wants to help me
Blauelf
@Blauelf
May 18 2016 08:13
Sure, but only here on chat, not on external website.
Saurabh Parihar
@parihars
May 18 2016 08:13
ok

//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"]
}
];

//still showing error
function lookUpProfile(firstName, prop){
// Only change code below this line
var j=0;
var k=0;
for(var i=0;i<contacts.length;i++)
{
if(firstName == contacts[i].firstName){
return contacts[i][prop];
}
if(firstName!==contacts[i].firstName)
j++;
if(contacts[i].hasOwnProperty(prop))
k++;
}
if(j==contacts.length)
return "No such contact";
if(k==contacts.length)
return "No such property";
// Only change code above this line
}

// Change these values to test your function

(lookUpProfile("Akira", "address"));

cnj1987
@cnj1987
May 18 2016 08:13
Can confirm. @Athaman has been helping me a lot
Keone Martin
@Athaman
May 18 2016 08:13
@cnj1987 thanks :) also what's the next challenge? i can give you some starters maybe
CamperBot
@camperbot
May 18 2016 08:13
athaman sends brownie points to @cnj1987 :sparkles: :thumbsup: :sparkles:
:cookie: 188 | @cnj1987 |http://www.freecodecamp.com/cnj1987
Saurabh Parihar
@parihars
May 18 2016 08:14
@Athaman help me
Myuuks
@Myuuks
May 18 2016 08:14
@Blauelf can you help on the shopping list exercise ? :)
Saurabh Parihar
@parihars
May 18 2016 08:14
Address is not in contact list how do i return No such propert