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

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

return 10<=15;

returning boolean on function
rphares
@rphares
May 18 2016 00:01 UTC
just use a and b,
Norvin Burrus
@ndburrus
May 18 2016 00:01 UTC
@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 UTC
and just less than, not less than or equal to ;)
Jason Shoemaker
@kutsuya1
May 18 2016 00:01 UTC
@ndburrus It's cheaten' :))
heh
eduwin7
@eduwin7
May 18 2016 00:02 UTC

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

return 10<15;

rphares
@rphares
May 18 2016 00:02 UTC
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 UTC
@kutsuya1 ...hmmm, that code is in the challenge.
Maury
@MBNWeb1
May 18 2016 00:05 UTC
@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 UTC
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 UTC
@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 UTC
@michaeldiegogil the math of it?
Norvin Burrus
@ndburrus
May 18 2016 00:06 UTC
help format @MBNWeb1
CamperBot
@camperbot
May 18 2016 00:06 UTC

# 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

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

@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 UTC
the temp in fahrenheit is the temp in celsius times 9/5 plus 32
Michael
@michaeldiegogil
May 18 2016 00:08 UTC
32?
Maury
@MBNWeb1
May 18 2016 00:08 UTC
@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 UTC
@michaeldiegogil ok, just use the conversion formula information given to generate a fahrenheit value
rphares
@rphares
May 18 2016 00:09 UTC

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 UTC
@michaeldiegogil in the API url query
rphares
@rphares
May 18 2016 00:09 UTC
@MBNWeb1 , dont think he is on the pen yet,
a waypoint, i believe...
Norvin Burrus
@ndburrus
May 18 2016 00:10 UTC
@eduwin7 ...how are you doing?
Maury
@MBNWeb1
May 18 2016 00:10 UTC
@rphares Oh, well, now he knows for later haha
rphares
@rphares
May 18 2016 00:10 UTC
indeed :blush:
Maury
@MBNWeb1
May 18 2016 00:11 UTC
@rphares any chance you know how to enable ES6 in FCC?
rphares
@rphares
May 18 2016 00:12 UTC
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 UTC
THANK YOU @rphares
CamperBot
@camperbot
May 18 2016 00:14 UTC
michaeldiegogil sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4666 | @rphares |http://www.freecodecamp.com/rphares
rphares
@rphares
May 18 2016 00:18 UTC
@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 UTC

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 UTC
@rphares Thanks, I'll try that out! I appreciate it!
CamperBot
@camperbot
May 18 2016 00:23 UTC
mbnweb1 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4667 | @rphares |http://www.freecodecamp.com/rphares
rphares
@rphares
May 18 2016 00:24 UTC
Anytime~ I didn't do much, i didn't know, lol, but happy to help :blush:
Ryan Park
@rpark4
May 18 2016 00:24 UTC
anyone know what to do when the code you wrote works, but doesn't pass the test?
Maury
@MBNWeb1
May 18 2016 00:25 UTC
@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 UTC
@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 UTC
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 UTC
im not good enough-- calling the wise people who were here earlier-- anyone wanna de-bug?
Ryan Park
@rpark4
May 18 2016 00:29 UTC
thanks anyways @rphares
CamperBot
@camperbot
May 18 2016 00:29 UTC
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 UTC
your killing it with the brownie points
rphares
@rphares
May 18 2016 00:29 UTC
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 UTC
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 UTC
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 UTC
@rpark4 what is the name of the assignment you're doing?
rphares
@rphares
May 18 2016 00:33 UTC
Title Case a Sentence
Peter Weinberg
@no-stack-dub-sack
May 18 2016 00:34 UTC
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 UTC
yep
rphares
@rphares
May 18 2016 00:34 UTC
yep!
Peter Weinberg
@no-stack-dub-sack
May 18 2016 00:34 UTC
@eeflores is that yep directed towards me?
rphares
@rphares
May 18 2016 00:34 UTC
yep~ @no-stack-dub-sack :blush:
Peter Weinberg
@no-stack-dub-sack
May 18 2016 00:35 UTC
Ok, thanks! That's good
eeflores
@eeflores
May 18 2016 00:35 UTC
yep - there is a loop in Profile Lookup
Maury
@MBNWeb1
May 18 2016 00:35 UTC
@rphares Okay, give me a minute to check it out
rphares
@rphares
May 18 2016 00:35 UTC
( :blush: :blush: :blush: @eeflores !! :) )
eeflores
@eeflores
May 18 2016 00:35 UTC
hullo @rphares !
Peter Weinberg
@no-stack-dub-sack
May 18 2016 00:35 UTC
I may come back if I get stuck, but just wanted to make sure. Thanks @eeflores @rphares!
CamperBot
@camperbot
May 18 2016 00:35 UTC
no-stack-dub-sack sends brownie points to @eeflores and @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4669 | @rphares |http://www.freecodecamp.com/rphares
Ryan Park
@rpark4
May 18 2016 00:37 UTC
@MBNWeb1 Title Case a Sentence
oh thanks again @rphares .
CamperBot
@camperbot
May 18 2016 00:37 UTC
rpark4 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:warning: rpark4 already gave rphares points
rphares
@rphares
May 18 2016 00:38 UTC
lol, sure thing-- now you have good people trying to help, hopefully that'll sort it :blush:
Ghost
@ghost~56beb80de610378809c138b0
May 18 2016 00:41 UTC
help sum all primes
CamperBot
@camperbot
May 18 2016 00:41 UTC

# 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.

Ryan Park
@rpark4
May 18 2016 00:42 UTC
we all good people
hehe
ok. I think I might have accidentally broken the internet
my baf
rphares
@rphares
May 18 2016 00:44 UTC
lol, uhoh--
Ryan Park
@rpark4
May 18 2016 00:45 UTC
yeah, but not in a loop. it just says //testing challenge...
Maury
@MBNWeb1
May 18 2016 00:45 UTC
@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 UTC
and never returns anything
Rémi Fortier
@mizujin
May 18 2016 00:45 UTC
exceeding call stack maybe
can we see code ?
Ryan Park
@rpark4
May 18 2016 00:46 UTC

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 UTC
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
rphares
@rphares
May 18 2016 00:48 UTC
Enjoy classe!
Jordan Shackelford
@JordanShackelford
May 18 2016 00:49 UTC
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 UTC
Can anyone help me with the jQuery .animate() function?
Jordan Shackelford
@JordanShackelford
May 18 2016 00:51 UTC
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 UTC
is there a tiles var?
Jordan Shackelford
@JordanShackelford
May 18 2016 00:52 UTC
context.drawImage(grass,0,0,100,100); but not context.drawImage(tiles.grass,0,0,100,100);
eeflores
@eeflores
May 18 2016 00:52 UTC
oh yeah there it is
this.grass = new Tile()
Jordan Shackelford
@JordanShackelford
May 18 2016 00:52 UTC
I'm calling it outside the Tile function though
eduwin7
@eduwin7
May 18 2016 00:53 UTC
need help guys
on the counting cards
buckshot307
@buckshot307
May 18 2016 00:53 UTC
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 UTC
@JordanShackelford whats context.drawImage ?? from canvas ?
eeflores
@eeflores
May 18 2016 00:54 UTC
@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 UTC
I would think not since tiles is an object
Rémi Fortier
@mizujin
May 18 2016 00:55 UTC
@rpark4 Your code returns "I\'m A Little Teapot"
eeflores
@eeflores
May 18 2016 00:55 UTC
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 UTC
@rpark4 check that, maybe "I'm" is considered as a single word ?
buckshot307
@buckshot307
May 18 2016 00:56 UTC
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 UTC
wait ... that's not quite right ...
Moisés Man
@moigithub
May 18 2016 00:57 UTC
@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 UTC
@moigithub Hmmm
Karan Bhandari
@karanbhandari
May 18 2016 00:59 UTC
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 UTC
It's weird that it lets me draw it by just calling it grass though
Moisés Man
@moigithub
May 18 2016 00:59 UTC
probably on ur code u have another variable named grass only
else grass will be undefined....
Jordan Shackelford
@JordanShackelford
May 18 2016 01:01 UTC
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 UTC
syntax
ctx.drawImage(image, dx, dy);
ctx.drawImage(image, dx, dy, dWidth, dHeight);
Jordan Shackelford
@JordanShackelford
May 18 2016 01:04 UTC
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 UTC
dx and dy whre on the screen it gonna be draw
Rémi Fortier
@mizujin
May 18 2016 01:06 UTC
it's drawing 10 tiles exactly at the same spot
Jordan Shackelford
@JordanShackelford
May 18 2016 01:07 UTC
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 UTC

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 UTC
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 UTC
modify the for loop
ERWIN JOHN T. CARPIO, MD, FPCR
May 18 2016 01:13 UTC
This message was deleted
Rémi Fortier
@mizujin
May 18 2016 01:14 UTC
@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 UTC
@JordanShackelford why u cant have variables.. how u doing ?? did u try the code exactly ?
bitgrower
@bitgrower
May 18 2016 01:18 UTC
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 UTC
internet went out. im back
eduwin7
@eduwin7
May 18 2016 01:19 UTC
i am on the counting cards section
ERWIN JOHN T. CARPIO, MD, FPCR
May 18 2016 01:19 UTC
hmm... it's not appearing in "code" i already used 
Moisés Man
@moigithub
May 18 2016 01:19 UTC
@RadEdje backticks must be on its own line
ERWIN JOHN T. CARPIO, MD, FPCR
May 18 2016 01:20 UTC
@moigithub oh thanks...
eduwin7
@eduwin7
May 18 2016 01:20 UTC
?
bitgrower
@bitgrower
May 18 2016 01:21 UTC
@eduwin7 think I've seen you around before ... so, can you post your code ?
Rémi Fortier
@mizujin
May 18 2016 01:21 UTC
@eduwin7 maybe I can help ?
ERWIN JOHN T. CARPIO, MD, FPCR
May 18 2016 01:23 UTC
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 UTC
 <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 UTC
Good evening everyone. Can anyone tell me what the red dot symbolizes in the black results box?
eduwin7
@eduwin7
May 18 2016 01:25 UTC

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
May 18 2016 01:26 UTC
@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 UTC 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 UTC @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 UTC oops sorry I meant $(".twitter-share-button").attr("data-text", html);
Rémi Fortier
@mizujin
May 18 2016 01:27 UTC
Frank XC
@tenkdayz
May 18 2016 01:28 UTC
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
May 18 2016 01:29 UTC
@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 UTC
@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;
fjs.parentNode.insertBefore(js, fjs);

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

return t;
}(document, "script", "twitter-wjs"));
this twttr function accepts parameter (code)
something like
twttr.widgets.createShareButton(
"-",
{
size: "large",
count: "none"
}
);
ERWIN JOHN T. CARPIO, MD, FPCR
May 18 2016 01:31 UTC
@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 UTC
radedje sends brownie points to @mizujin :sparkles: :thumbsup: :sparkles:
Rémi Fortier
@mizujin
May 18 2016 01:32 UTC
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 UTC

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 UTC
you should use switch for this exercise @eduwin7
rphares
@rphares
May 18 2016 01:34 UTC
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 UTC
@RadEdje r u working on codepen ?
rphares
@rphares
May 18 2016 01:34 UTC
you need if for those cards, incrementing count
Stephen James
@sjames1958gm
May 18 2016 01:34 UTC
@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 UTC
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 UTC
@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
May 18 2016 01:35 UTC
@moigithub no... I'm working on local files first before uploading to codepen.
eduwin7
@eduwin7
May 18 2016 01:36 UTC
okay let me try switch
Moisés Man
@moigithub
May 18 2016 01:37 UTC
@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 UTC
Hi .. I am not able to solve "Record Collection"
can anyone help ??
ERWIN JOHN T. CARPIO, MD, FPCR
May 18 2016 01:38 UTC
@moigithub wow Thanks! I'll try that.
CamperBot
@camperbot
May 18 2016 01:38 UTC
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 UTC
@RadEdje that code above create that script tag with src
bitgrower
@bitgrower
May 18 2016 01:39 UTC
@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 UTC
thanks @moigithub I didn't knew the widget code was hosted somewhere
CamperBot
@camperbot
May 18 2016 01:39 UTC
mizujin sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1170 | @moigithub |http://www.freecodecamp.com/moigithub
bitgrower
@bitgrower
May 18 2016 01:39 UTC
many of us have helped folks with record collection innumerable times ...
Stephen James
@sjames1958gm
May 18 2016 01:40 UTC
@subhsamal Use brackets when the property is stored in a variable
ERWIN JOHN T. CARPIO, MD, FPCR
May 18 2016 01:45 UTC
@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 UTC
radedje sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
Subh Samal
@subhsamal
May 18 2016 01:46 UTC

@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 UTC

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 UTC
my coding may be aweful
eduwin7
@eduwin7
May 18 2016 01:46 UTC
it is telling me J is not defined
Stephen James
@sjames1958gm
May 18 2016 01:46 UTC
@subhsamal Don't use literal values in your code
bitgrower
@bitgrower
May 18 2016 01:46 UTC
@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 UTC
@subhsamal You have to use delete not pop for value===""
Moisés Man
@moigithub
May 18 2016 01:48 UTC
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 UTC
@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 UTC
@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 UTC
AWESOME
ERWIN JOHN T. CARPIO, MD, FPCR
May 18 2016 01:48 UTC
@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 UTC
thanks @bitgrower
CamperBot
@camperbot
May 18 2016 01:48 UTC
eduwin7 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1055 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
May 18 2016 01:49 UTC
@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 UTC
@bitgrower to proceed for only those ids .
bitgrower
@bitgrower
May 18 2016 01:50 UTC
well ... I don't think that' necessary for the challenge ...
ERWIN JOHN T. CARPIO, MD, FPCR
May 18 2016 01:50 UTC
@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 UTC
@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 UTC
@sjames1958gm I am not able to use two variables prob and value together!!
Stephen James
@sjames1958gm
May 18 2016 01:53 UTC
yes you can
@subhsamal can you post your code.
Subh Samal
@subhsamal
May 18 2016 01:54 UTC

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 UTC
need to see collection
Stephen James
@sjames1958gm
May 18 2016 01:54 UTC
@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 UTC

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

Hello
Stephen James
@sjames1958gm
May 18 2016 01:58 UTC
Close, your delete doesn't need .value
@J-Mari hello
ERWIN JOHN T. CARPIO, MD, FPCR
May 18 2016 01:59 UTC
@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 UTC
@sjames1958gm aah...!! it worked.. :blush: it was the toiling one for me so far.
Stephen James
@sjames1958gm
May 18 2016 02:00 UTC
@subhsamal Study the code and make sure you understand each part of it.
eduwin7
@eduwin7
May 18 2016 02:00 UTC

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 UTC
@sjames1958gm except the delete statement.
Moisés Man
@moigithub
May 18 2016 02:01 UTC
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'
}
);
eduwin7
@eduwin7
May 18 2016 02:01 UTC
i am stuck on return -5 hold
the rest of the codes are good
Subh Samal
@subhsamal
May 18 2016 02:02 UTC
@sjames1958gm for delete to work object.property is sufficient to work! Hence no need of value ??
Stephen James
@sjames1958gm
May 18 2016 02:05 UTC
@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 UTC
@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 UTC
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 UTC
what is the expected return value ?
Subh Samal
@subhsamal
May 18 2016 02:12 UTC
hmm.. true means if will execute .is it what you mean ? @mizujin
if(true) !
mrcsscco
@marcussacco
May 18 2016 02:13 UTC
The expected return value is the reversed string. [7,6,5,4,3,2,1]
Subh Samal
@subhsamal
May 18 2016 02:13 UTC
next code inside the block executes.
Rémi Fortier
@mizujin
May 18 2016 02:13 UTC
@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 UTC
oh, you weren't talking to me
Rémi Fortier
@mizujin
May 18 2016 02:14 UTC
@marcussacco I was :-D your code works in repl.it and returns the correct array
Subh Samal
@subhsamal
May 18 2016 02:14 UTC
got it clearly .. thank you @mizujin @sjames1958gm
CamperBot
@camperbot
May 18 2016 02:14 UTC
subhsamal sends brownie points to @mizujin and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1140 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 18 2016 02:14 UTC
@marcussacco Do it in one line I think.
Subh Samal
@subhsamal
May 18 2016 02:15 UTC
How can I post screen shots here ? @mizujin
Rémi Fortier
@mizujin
May 18 2016 02:15 UTC
@subhsamal no problem :)
mrcsscco
@marcussacco
May 18 2016 02:15 UTC
like, newArray = array.reverse(); ? That doesn't work either
rphares
@rphares
May 18 2016 02:15 UTC
explain format
CamperBot
@camperbot
May 18 2016 02:15 UTC

# 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

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

@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 UTC
Wow, refreshing my browser worked.
Thanks
Stephen James
@sjames1958gm
May 18 2016 02:16 UTC
@marcussacco :(
Rémi Fortier
@mizujin
May 18 2016 02:17 UTC
@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 UTC
@rphares okay..will try it
Rémi Fortier
@mizujin
May 18 2016 02:17 UTC
@marcussacco oh haha, nvm then
mrcsscco
@marcussacco
May 18 2016 02:17 UTC
@mizujin that was the first thing i tried
Wendy Medeiros
@wendyr21
May 18 2016 02:18 UTC
what was the code to check your answer against what freeCodeCamp has
help Make Object Properties Private
CamperBot
@camperbot
May 18 2016 02:19 UTC

# 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
return value + "KM/H";
}

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

};
Wendy Medeiros
@wendyr21
May 18 2016 02:19 UTC
found it
mrcsscco
@marcussacco
May 18 2016 02:19 UTC
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 UTC
@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 UTC
@ndburrus thanks, didn't know about that. was using devtools console
CamperBot
@camperbot
May 18 2016 02:21 UTC
marcussacco sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
May 18 2016 02:21 UTC
@marcussacco devtools console is a REPL
Rémi Fortier
@mizujin
May 18 2016 02:22 UTC
@marcussacco I highly recommend repl.it
Norvin Burrus
@ndburrus
May 18 2016 02:23 UTC
@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 UTC
@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 UTC
@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 UTC
hey guys i have a quick question what is jquery playground?
jgoldverg
@jgoldverg
May 18 2016 02:35 UTC
ahh okay so its pretty much a test site before implementation.
thanks
Norvin Burrus
@ndburrus
May 18 2016 02:36 UTC
@jgoldverg anytime... :sparkles:
Wendy Medeiros
@wendyr21
May 18 2016 02:36 UTC
help Condense arrays with reduce
CamperBot
@camperbot
May 18 2016 02:36 UTC

# 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;

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

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 UTC
@eduwin7 did the issue get resolved?
rphares
@rphares
May 18 2016 02:40 UTC
@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 UTC
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 UTC
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 UTC
@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 UTC
also you can choose a different regex too @rjmelville
OneRandomJamie
@OneRandomJamie
May 18 2016 02:44 UTC
Can someone help me with the Word Blank challenge?
Coy Sanders
@coymeetsworld
May 18 2016 02:45 UTC
sure @OneRandomJamie
what do you need help with?
Norvin Burrus
@ndburrus
May 18 2016 02:46 UTC
@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 UTC

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 UTC
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 UTC

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 UTC
thin your 1st elseif needs to be fixed
pinecrest515
@pinecrest515
May 18 2016 02:50 UTC
same issue after committing out the first elseif
Coy Sanders
@coymeetsworld
May 18 2016 02:50 UTC
collection.id[prop] = value;
pinecrest515
@pinecrest515
May 18 2016 02:50 UTC
**commeting
Coy Sanders
@coymeetsworld
May 18 2016 02:50 UTC
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 UTC
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 UTC
like this? collection[id].prop = value; I cannot do double brackets
James Alton
@TwoKind
May 18 2016 02:53 UTC
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Coy Sanders
@coymeetsworld
May 18 2016 02:54 UTC
why can't you do double brackets?
rphares
@rphares
May 18 2016 02:54 UTC
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 UTC
@TwoKind which exercise number?
James Alton
@TwoKind
May 18 2016 02:54 UTC
Wont work wants two single and four double
rphares
@rphares
May 18 2016 02:54 UTC
show us what that looks like? @TwoKind
DwayneCode
@DwayneCode
May 18 2016 02:54 UTC
should be var myStr = '<a href="http://www.example.com" target="_blank">Link</a>'
Norvin Burrus
@ndburrus
May 18 2016 02:54 UTC

@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 UTC
One sec
DwayneCode
@DwayneCode
May 18 2016 02:54 UTC
i think
James Alton
@TwoKind
May 18 2016 02:55 UTC
@DwayneCode Nope
pinecrest515
@pinecrest515
May 18 2016 02:55 UTC
@coymeetsworld you mean collection[id[prop]]= value;?
James Alton
@TwoKind
May 18 2016 02:55 UTC
That what I thoguh
rphares
@rphares
May 18 2016 02:55 UTC
erm-- yes... usually we try not to paste answers, though
James Alton
@TwoKind
May 18 2016 02:55 UTC
Its Quoting Strings with Single Quotes
Coy Sanders
@coymeetsworld
May 18 2016 02:55 UTC
no, collection[id][prop] @pinecrest515
DwayneCode
@DwayneCode
May 18 2016 02:55 UTC
sorry
Rachel Melville
@rjmelville
May 18 2016 02:55 UTC
@coymeetsworld Thanks for the pointers.
CamperBot
@camperbot
May 18 2016 02:55 UTC
rjmelville sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 18 2016 02:55 UTC
np @rjmelville
James Alton
@TwoKind
May 18 2016 02:56 UTC
Anyone else?
rphares
@rphares
May 18 2016 02:56 UTC
@TwoKind ,try again--
pinecrest515
@pinecrest515
May 18 2016 02:56 UTC
@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 UTC
pinecrest515 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
rphares
@rphares
May 18 2016 02:57 UTC
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 UTC
I tied for like 15m every posiblility. And I use js for like 4 months now
Coy Sanders
@coymeetsworld
May 18 2016 02:57 UTC
depends on what you're trying to do and what information you have @pinecrest515 but np
rphares
@rphares
May 18 2016 02:58 UTC
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 UTC
Sure :P
pinecrest515
@pinecrest515
May 18 2016 02:58 UTC
@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 UTC
Ok I have a conundrum. It says to remove all backslashes but wants two double quotes
rphares
@rphares
May 18 2016 02:59 UTC
(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 UTC
Ok
Coy Sanders
@coymeetsworld
May 18 2016 02:59 UTC
yeah
@pinecrest515
pinecrest515
@pinecrest515
May 18 2016 03:00 UTC
hmmm....it gives me an error when I try collection[id][prop].push(value)
buckshot307
@buckshot307
May 18 2016 03:00 UTC
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 UTC
@pinecrest515 need semilcolon at end
James Alton
@TwoKind
May 18 2016 03:01 UTC
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 UTC
okay so opposite--
single quotes the outside
double quotes inside
James Alton
@TwoKind
May 18 2016 03:01 UTC
Oh make a second strign?
rphares
@rphares
May 18 2016 03:01 UTC
no
James Alton
@TwoKind
May 18 2016 03:01 UTC
???
pinecrest515
@pinecrest515
May 18 2016 03:01 UTC
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 UTC
pinecrest515 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: pinecrest515 already gave coymeetsworld points
rphares
@rphares
May 18 2016 03:02 UTC
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 UTC
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 UTC
@TwoKind If you tell me the exercise # I can go back and search for the solution
DwayneCode
@DwayneCode
May 18 2016 03:02 UTC
single quote entire string, double inside
James Alton
@TwoKind
May 18 2016 03:02 UTC
@rphares Thank you!
CamperBot
@camperbot
May 18 2016 03:02 UTC
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 UTC
@rphares You are bae
@DwayneCode Thank you
CamperBot
@camperbot
May 18 2016 03:03 UTC
twokind sends brownie points to @dwaynecode :sparkles: :thumbsup: :sparkles:
rphares
@rphares
May 18 2016 03:03 UTC
oh, yay! i was scratching my head making an example, lol-- congrats and happy coding! :blush:
DwayneCode
@DwayneCode
May 18 2016 03:03 UTC
np
James Alton
@TwoKind
May 18 2016 03:03 UTC
@rphares I worked 8h today a bit slow :P
TO simple
rphares
@rphares
May 18 2016 03:03 UTC
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 UTC
I need pointers on the Word Blanks challenge.
rphares
@rphares
May 18 2016 03:04 UTC
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 UTC
Do i assign my own strings to the variables? I don't think i've tried that
rphares
@rphares
May 18 2016 03:06 UTC
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 UTC
@DwayneCode ...using string operator/s...
DwayneCode
@DwayneCode
May 18 2016 03:07 UTC
wow, i really over think that one
rphares
@rphares
May 18 2016 03:08 UTC
sighs someday ill be able to say smart things like @ndburrus :blush:
DwayneCode
@DwayneCode
May 18 2016 03:08 UTC
thanks @ndburrus @rphares
CamperBot
@camperbot
May 18 2016 03:08 UTC
dwaynecode sends brownie points to @ndburrus and @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4675 | @rphares |http://www.freecodecamp.com/rphares
rphares
@rphares
May 18 2016 03:08 UTC
Anytime~
Norvin Burrus
@ndburrus
May 18 2016 03:08 UTC
@rphares your too kind... i think....
rphares
@rphares
May 18 2016 03:09 UTC
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 UTC
@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 UTC
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 UTC
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
May 18 2016 03:22 UTC
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 UTC
@teeGTee which challenge? what is your code to assign the contents of a to b?
DwayneCode
@DwayneCode
May 18 2016 03:23 UTC
@teeGTee and how are you writing it?
Tee Stoddard
@teeGTee
May 18 2016 03:23 UTC
@ndburrus Storing Valus with the assignment operator
Norvin Burrus
@ndburrus
May 18 2016 03:24 UTC
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 UTC

// 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 UTC
@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 UTC

http://thomasnguyen.co/weather/

^^ i need help with my weather app

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

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 UTC
@coymeetsworld i do have jquery imported at the bottom
Tee Stoddard
@teeGTee
May 18 2016 03:31 UTC
@coymeetsworld @ndburrus @DwayneCode thanks so much I was over thinking it
CamperBot
@camperbot
May 18 2016 03:31 UTC
teegtee sends brownie points to @coymeetsworld and @ndburrus and @dwaynecode :sparkles: :thumbsup: :sparkles:
Norvin Burrus
@ndburrus
May 18 2016 03:32 UTC
@teeGTee kudos to you!! :fire:
Coy Sanders
@coymeetsworld
May 18 2016 03:32 UTC
@toshiru is it declared before bootstrap?
bootstrap js requires jquery to be in first
Thomas Nguyen
@thomasnguyen
May 18 2016 03:33 UTC
no it isnt
Coy Sanders
@coymeetsworld
May 18 2016 03:33 UTC
yeah @teeGTee no worries you're just learning the language
Thomas Nguyen
@thomasnguyen
May 18 2016 03:34 UTC
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 UTC 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 UTC Anyone? DwayneCode @DwayneCode May 18 2016 03:57 UTC 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: Ghost @ghost~56beb80de610378809c138b0 May 18 2016 03:59 UTC 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 UTC I need help with the Word Blank challenge. rphares @rphares May 18 2016 04:03 UTC @OneRandomJamie , can you paste what you are trying? Wellington Nadson @DrNadson May 18 2016 04:03 UTC 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 UTC @DrNadson , yep! use the chart to make that code. for example, backslash would be \\ :blush: Wellington Nadson @DrNadson May 18 2016 04:05 UTC @rphares Thanks ;) CamperBot @camperbot May 18 2016 04:05 UTC drnadson sends brownie points to @rphares :sparkles: :thumbsup: :sparkles: :star2: 4679 | @rphares |http://www.freecodecamp.com/rphares rphares @rphares May 18 2016 04:06 UTC sure thing~ happy coding! Hi, could anyone please help me with a basic explanation for "Stand in Line" Aleksander Gębicki @Takumar May 18 2016 04:09 UTC @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 UTC @Takumar hi, you are early :) Aleksander Gębicki @Takumar May 18 2016 04:10 UTC Hello @rphares kirbyedy @kirbyedy May 18 2016 04:10 UTC and long time no see ;) Aleksander Gębicki @Takumar May 18 2016 04:10 UTC Hi @kirbyedy I entered here for a moment, and now I am leaving to work :-) rphares @rphares May 18 2016 04:11 UTC hiya, @Takumar ! :blush: Aleksander Gębicki @Takumar May 18 2016 04:11 UTC @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 UTC nice hahaha is that in poland? Aleksander Gębicki @Takumar May 18 2016 04:12 UTC yes, in Poland, (Łódź city) rphares @rphares May 18 2016 04:13 UTC lol, free food is always a good thing :blush: Aleksander Gębicki @Takumar May 18 2016 04:13 UTC 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 UTC hey @Takumar I've been to Poznan, Poland i like it :+1: kirbyedy @kirbyedy May 18 2016 04:13 UTC you too :wave: @Takumar OneRandomJamie @OneRandomJamie May 18 2016 04:13 UTC Can someone help me with the Word Blank challenge? kirbyedy @kirbyedy May 18 2016 04:14 UTC we can try DwayneCode @DwayneCode May 18 2016 04:14 UTC @OneRandomJamie what kind of help do you need? rphares @rphares May 18 2016 04:14 UTC @OneRandomJamie , sure- could you paste your code, please? @Takumar Attempting it now, thought it might've been push and/or pop. OneRandomJamie @OneRandomJamie May 18 2016 04:17 UTC @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 UTC start with result = instead of var Str rphares @rphares May 18 2016 04:18 UTC 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 UTC 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 UTC 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 UTC @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 UTC 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 UTC @rphares Thank you. All that needed to be changed was the myStr to result. CamperBot @camperbot May 18 2016 04:23 UTC onerandomjamie sends brownie points to @rphares :sparkles: :thumbsup: :sparkles: :star2: 4680 | @rphares |http://www.freecodecamp.com/rphares DwayneCode @DwayneCode May 18 2016 04:23 UTC that's what i said :) rphares @rphares May 18 2016 04:23 UTC 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 UTC @rphares @OneRandomJamie thanks it was an extra space CamperBot @camperbot May 18 2016 04:24 UTC 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 UTC sweet~ Congrats and happy coding ~ OneRandomJamie @OneRandomJamie May 18 2016 04:24 UTC @DwayneCode Thank you CamperBot @camperbot May 18 2016 04:24 UTC onerandomjamie sends brownie points to @dwaynecode :sparkles: :thumbsup: :sparkles: :cookie: 179 | @dwaynecode |http://www.freecodecamp.com/dwaynecode Rex @RexChip May 18 2016 04:28 UTC 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 :) 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 UTC 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 UTC @Woodywoodruff3 What did you put down? :) EODjugornot @EODjugornot May 18 2016 04:37 UTC 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 UTC @EODjugornot What's the task name? EODjugornot @EODjugornot May 18 2016 04:38 UTC @kutsuya1 Escape Sequences in Strings Ross @Woodywoodruff3 May 18 2016 04:38 UTC 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 UTC @Woodywoodruff3 how about "The " + myAdjective + ' ' + ........ @EODjugornot It looks some like "// /t /n" EODjugornot @EODjugornot May 18 2016 04:40 UTC 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 UTC @EODjugornot the examples usually just need a little change to pass the task @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 UTC @Woodywoodruff3 .... ran is a verb, big is a adjective EODjugornot @EODjugornot May 18 2016 04:42 UTC nope that didnt work. i dont get it :worried: Ross @Woodywoodruff3 May 18 2016 04:42 UTC Haha...I knew I messed that up Rex @RexChip May 18 2016 04:43 UTC 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 UTC @EODjugornot var myStr = "\ \t \t \r \n" ; // Change this line Jason Shoemaker @kutsuya1 May 18 2016 04:44 UTC @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 UTC @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 UTC opps backslash EODjugornot @EODjugornot May 18 2016 04:44 UTC oh holy cow. i didnt put the quotes.... youre the best! Jason Shoemaker @kutsuya1 May 18 2016 04:45 UTC @EODjugornot I used foreslash though... heh EODjugornot @EODjugornot May 18 2016 04:45 UTC @kutsuya1 youre a life saver! i was losing my mind! many thanks! CamperBot @camperbot May 18 2016 04:45 UTC eodjugornot sends brownie points to @kutsuya1 :sparkles: :thumbsup: :sparkles: :cookie: 259 | @kutsuya1 |http://www.freecodecamp.com/kutsuya1 Greg @GregJacoby May 18 2016 04:45 UTC 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 UTC @EODjugornot The escapes only work in "" and not '' Greg @GregJacoby May 18 2016 04:45 UTC 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 why do you have 3x = Jason Shoemaker @kutsuya1 May 18 2016 04:46 UTC @EODjugornot glad could help if(arr[i] == false){ ? * Greg @GregJacoby May 18 2016 04:47 UTC @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 UTC many thanks @subhsamal and @kutsuya1 CamperBot @camperbot May 18 2016 04:48 UTC 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 UTC I tried replacing that line with if(arr[i] == false || arr[i] === false) but it didn't change anything in your for loop do you need to have "var" in front of i? Jason Shoemaker @kutsuya1 May 18 2016 04:49 UTC @Woodywoodruff3 glad I could help some @J-Mari if no var, then it becomes global? Greg @GregJacoby May 18 2016 04:50 UTC @J-Mari it's not necessary but it doesn't matter in this situation 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 UTC no ideas? :( I'm not sure, sorry! Currently stuck on something really basic myself. :( Robert Richey @0x0936 May 18 2016 04:55 UTC @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 UTC @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 UTC 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 UTC @GregJacoby try if ( !arr[i] ) {...} instead of === false or == false Greg @GregJacoby May 18 2016 04:58 UTC @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 UTC gregjacoby sends brownie points to @duaraghav8 :sparkles: :thumbsup: :sparkles: :cookie: 6 | @duaraghav8 |http://www.freecodecamp.com/duaraghav8 Richard @richao03 May 18 2016 05:00 UTC Hello, i have a quick question regarding Regex can some one help me? =) Robert Richey @0x0936 May 18 2016 05:01 UTC @richao03 possibly Richard @richao03 May 18 2016 05:02 UTC 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 UTC @richao03 have you tried a regex sandbox to test your patterns? https://regex101.com/ is one Richard @richao03 May 18 2016 05:04 UTC 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 UTC @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 UTC 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 UTC @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 UTC gregjacoby sends brownie points to @duaraghav8 :sparkles: :thumbsup: :sparkles: :warning: gregjacoby already gave duaraghav8 points Robert Richey @0x0936 May 18 2016 05:08 UTC 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 UTC just solved it Robert Richey @0x0936 May 18 2016 05:13 UTC 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 UTC with while (oldnum.length !== newNum.length){ newNum = "0"+newNum } =D thanks @0x0936 CamperBot @camperbot May 18 2016 05:13 UTC :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 UTC 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 UTC 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 UTC @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 UTC ohhh that makes perfect sense @duaraghav8 /bows Raghav Dua @duaraghav8 May 18 2016 05:17 UTC @GregJacoby haha happy to help Aryan @aryandua May 18 2016 05:20 UTC 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 UTC
hii frds i get stuck in escape sequence in string.
can anyone plz help me
anthonyjl92
@anthonyjl92
May 18 2016 05:23 UTC
<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 UTC
$(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 UTC
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 UTC
@Pujachaubey , they gave you a sequence,
Puja
@Pujachaubey
May 18 2016 05:38 UTC
yes
rphares
@rphares
May 18 2016 05:38 UTC
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 UTC
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 UTC
yes i wrote like that var myStr = "\ \t \t \r \n";
Rex
@RexChip
May 18 2016 05:41 UTC
This message was deleted
CamperBot
@camperbot
May 18 2016 05:41 UTC
no wiki entry for: pagination
rphares
@rphares
May 18 2016 05:41 UTC
that should be fine, except--
do you have one space or two in-between those, @Pujachaubey ?
Puja
@Pujachaubey
May 18 2016 05:41 UTC
one space
rphares
@rphares
May 18 2016 05:42 UTC
hmm, refesh and run tests again, ill check my answer, that looks okay?
Puja
@Pujachaubey
May 18 2016 05:43 UTC
yes i got it.
thanks
rphares
@rphares
May 18 2016 05:44 UTC
sweet! Congrats and happy coding, @Pujachaubey ~
Rex
@RexChip
May 18 2016 05:48 UTC
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 UTC
(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 UTC
@RexChip Have you considered using Bootstrap's pagination?
@rphares Good morning.
rphares
@rphares
May 18 2016 05:50 UTC
morning, @Masd925 ~
Markus Kiili
@Masd925
May 18 2016 05:51 UTC
@rphares Or maybe not that great morning. I have to study php.
rphares
@rphares
May 18 2016 05:51 UTC
Oooh, what for?
Markus Kiili
@Masd925
May 18 2016 05:52 UTC
@rphares Work.
rphares
@rphares
May 18 2016 05:52 UTC
Well-- it'll be something new? Thats always exciting...?
jorgon1022
@jorgon1022
May 18 2016 05:53 UTC
hi guys
im looking for a little bit of help and guidance in the right direction
Markus Kiili
@Masd925
May 18 2016 05:54 UTC
@rphares Yes, all programming is nice, but if I could choose, I would pick some other language.
jorgon1022
@jorgon1022
May 18 2016 05:54 UTC
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 UTC
You have to catch your button by document.getElementById () and then you need to create function onclick
Rex
@RexChip
May 18 2016 05:56 UTC
@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 UTC
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 UTC
@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 UTC
Otherwise i have no idea what may be wrong with your codes
jorgon1022
@jorgon1022
May 18 2016 05:57 UTC
 <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>
<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 UTC
And show me myFunction()
jorgon1022
@jorgon1022
May 18 2016 05:58 UTC
so the first one is my html and the second is my function
Grzegorz
@bluznierca1
May 18 2016 05:58 UTC
No , no...
You can not use innerHTML
jorgon1022
@jorgon1022
May 18 2016 05:59 UTC
hmm
Grzegorz
@bluznierca1
May 18 2016 05:59 UTC
Inner*
jorgon1022
@jorgon1022
May 18 2016 05:59 UTC
so I need to read up more on innerHTML
Grzegorz
@bluznierca1
May 18 2016 05:59 UTC
InnerHTML is for changing content of chosen element
jorgon1022
@jorgon1022
May 18 2016 06:00 UTC
@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 UTC
jorgon1022 sends brownie points to @bluznierca1 :sparkles: :thumbsup: :sparkles:
Grzegorz
@bluznierca1
May 18 2016 06:00 UTC
There is no point of giving an answer :)
jorgon1022
@jorgon1022
May 18 2016 06:01 UTC
thank you again @bluznierca1
CamperBot
@camperbot
May 18 2016 06:01 UTC
jorgon1022 sends brownie points to @bluznierca1 :sparkles: :thumbsup: :sparkles:
:warning: jorgon1022 already gave bluznierca1 points
Grzegorz
@bluznierca1
May 18 2016 06:02 UTC
Welcome ;)
redixhumayun
@redixhumayun
May 18 2016 06:15 UTC
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 UTC
@redixhumayun maybe this will help...
check the image
lyett
@lyett
May 18 2016 06:23 UTC
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 UTC
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 UTC
@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 UTC
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 UTC
what have you got so far @wcski ?
William Coleman
@wcski
May 18 2016 06:28 UTC
  // Only change code below this line
var val = {

"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 UTC
@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 UTC
here's the full context
// Setup
function phoneticLookup(val) {
var result = "";

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

"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 UTC
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 UTC
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 UTC
all you need to do is rename your table, then use tablename[val] to grab the result corresponding to the input val
Darth Skywalker
May 18 2016 06:31 UTC
@wcski : Rename your var val = {to var lookup = {
And then
result = lookup[val];
return result;
Keone Martin
@Athaman
May 18 2016 06:31 UTC
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 UTC
so i'm pretty sure my object should be titled lookup
ohh
Keone Martin
@Athaman
May 18 2016 06:31 UTC
the table should be called lookup according to the challenge
Chris Cullen
@123xylem
May 18 2016 06:31 UTC
@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 UTC
obviously you can actually call it whatever you want in the realworld
Rohan Gayen
@WapmasterRohan
May 18 2016 06:31 UTC
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
May 18 2016 06:32 UTC
@123xylem : Demons in your dreams seem to have fucked it up overnight :P
William Coleman
@wcski
May 18 2016 06:33 UTC
CamperBot
@camperbot
May 18 2016 06:33 UTC
wcski sends brownie points to @adityaparab and @athaman :sparkles: :thumbsup: :sparkles:
Markus Kiili
@Masd925
May 18 2016 06:34 UTC
@WapmasterRohan The default sort is unicode sort, so not numerical sort.
Keone Martin
@Athaman
May 18 2016 06:34 UTC
@wcski no worries bud, enjoy your sleep... or one last challenge ;)
Rohan Gayen
@WapmasterRohan
May 18 2016 06:36 UTC
unicode sort means?
Ghost
@ghost~56a552d0e610378809be0124
May 18 2016 06:36 UTC
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 UTC
means crazy and unpredictable... ok, so probably predictable when you get used to JS
Darth Skywalker
May 18 2016 06:36 UTC
@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 UTC
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 UTC
where am i wrong?
Keone Martin
@Athaman
May 18 2016 06:37 UTC
@Myuuks you need to add a space to the start of the third string
lyett
@lyett
May 18 2016 06:38 UTC
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 UTC
@Athaman var myStr = myName + "Thomas " + "and i am swell!"; on this line ?
Keone Martin
@Athaman
May 18 2016 06:39 UTC
yeah @Myuuks you need to have " and i am swell"
Chris Cullen
@123xylem
May 18 2016 06:39 UTC
@adityaparab ha.. Did you see what the demons did?
Samuel Plumppu
@Greenheart
May 18 2016 06:39 UTC
@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 UTC
@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 UTC
@Athaman i just understand what's wrong, that wasnt that ^^ but thanks
CamperBot
@camperbot
May 18 2016 06:39 UTC
myuuks sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
Keone Martin
@Athaman
May 18 2016 06:40 UTC
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 UTC
@WapmasterRohan Unicode sort would sort numbers like this:
Darth Skywalker
May 18 2016 06:40 UTC

@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 UTC
[15,4,2,33,12,9].sort(); // [ 12, 15, 2, 33, 4, 9 ]
Darth Skywalker
May 18 2016 06:40 UTC
@123xylem : I am glad I did not :P :P
Rohan Gayen
@WapmasterRohan
May 18 2016 06:40 UTC
CamperBot
@camperbot
May 18 2016 06:40 UTC
wapmasterrohan sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
Myuuks
@Myuuks
May 18 2016 06:40 UTC
@Athaman the exercice want me to do + anyvariable + stuff
CamperBot
@camperbot
May 18 2016 06:40 UTC
Myuuks
@Myuuks
May 18 2016 06:41 UTC
@Myuuks that's why its didnt work ^^
Keone Martin
@Athaman
May 18 2016 06:41 UTC
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 UTC
but what is unicode sorting?? @Masd925
lyett
@lyett
May 18 2016 06:41 UTC
many thank Keone Martin, can't believe I missed that...
Keone Martin
@Athaman
May 18 2016 06:41 UTC
sorts things alphabetically @WapmasterRohan instead of by integer value
@lyett it happens ;)
Markus Kiili
@Masd925
May 18 2016 06:42 UTC
@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 UTC
I have doubt in record collection. Though my code is working I have some doubt .
Rohan Gayen
@WapmasterRohan
May 18 2016 06:44 UTC
thanks @Masd925
CamperBot
@camperbot
May 18 2016 06:44 UTC
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 UTC
@WapmasterRohan And all characters have unicode values between 0 and 65535.
Keone Martin
@Athaman
May 18 2016 06:46 UTC
Subh Samal
@subhsamal
May 18 2016 06:46 UTC

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

Darth Skywalker
May 18 2016 06:46 UTC

@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 UTC
@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 UTC
collection[id][prop] = value; @Athaman How can I use push here
Keone Martin
@Athaman
May 18 2016 06:48 UTC
@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 UTC
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 UTC
@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 UTC
what if I have to use variable prop which stores track? Any idea? @Athaman
Keone Martin
@Athaman
May 18 2016 06:52 UTC
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 UTC

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 UTC
:bulb: to format code use backticks!  more info
Subh Samal
@subhsamal
May 18 2016 06:55 UTC
@Athaman I did it. Not able to get first condition corect.
Correct *
Keone Martin
@Athaman
May 18 2016 06:56 UTC
it's not the pop line causing troubles
Markus Kiili
@Masd925
May 18 2016 06:56 UTC
@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 UTC
oh, yeah, everything except for tracks is not an array so push won't work on them
which test is failing?
Subh Samal
@subhsamal
May 18 2016 06:59 UTC
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 UTC
CP
@lubere0102
May 18 2016 07:01 UTC
could you guys help me with Word Blanks from Basic JavaScript?
Keone Martin
@Athaman
May 18 2016 07:01 UTC
sure thing bud, what's up?
Subh Samal
@subhsamal
May 18 2016 07:02 UTC
thanks guys @Athaman @Masd925
CamperBot
@camperbot
May 18 2016 07:02 UTC
subhsamal sends brownie points to @athaman and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1527 | @masd925 |http://www.freecodecamp.com/masd925
CP
@lubere0102
May 18 2016 07:02 UTC
i have no idea how i should start questioning

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 UTC
CP
@lubere0102
May 18 2016 07:03 UTC
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 UTC
@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 UTC
how to solve Profile Lookup problem
Keone Martin
@Athaman
May 18 2016 07:04 UTC
you need to stick them together into 1 string called result
CP
@lubere0102
May 18 2016 07:04 UTC
ok
Keone Martin
@Athaman
May 18 2016 07:04 UTC
you can join strings together using the + operator
CP
@lubere0102
May 18 2016 07:04 UTC
ah
Keone Martin
@Athaman
May 18 2016 07:05 UTC
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 UTC
how do you capture like that?
Keone Martin
@Athaman
May 18 2016 07:06 UTC
help format
CamperBot
@camperbot
May 18 2016 07:06 UTC

# 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

Keone Martin
@Athaman
May 18 2016 07:07 UTC
@parihars which part is confusing you?
Subh Samal
@subhsamal
May 18 2016 07:07 UTC
var result = "my " + myAdjective +" "+ myNoun +" " + myVerb+" " + myAdverb; @lubere0102 try like this
Keone Martin
@Athaman
May 18 2016 07:08 UTC
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 UTC
CP
@lubere0102
May 18 2016 07:10 UTC
thank you i just didn't get what i was supposed to do
Keone Martin
@Athaman
May 18 2016 07:10 UTC
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 UTC
yes you sound correct buddy
Keone Martin
@Athaman
May 18 2016 07:11 UTC
:)
Subh Samal
@subhsamal
May 18 2016 07:11 UTC
:blush:
Keone Martin
@Athaman
May 18 2016 07:12 UTC
sorry also if i sound high and mighty.
Subh Samal
@subhsamal
May 18 2016 07:12 UTC
np
CP
@lubere0102
May 18 2016 07:12 UTC
thank you all
sdf
Keone Martin
@Athaman
May 18 2016 07:12 UTC
no problem @lubere0102 :) enjoy the challenges
CP
@lubere0102
May 18 2016 07:13 UTC
thank you for that capturing method too

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 UTC
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 UTC
very good
Michael
@michaelpautov
May 18 2016 07:16 UTC

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 UTC
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 UTC
++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 UTC
oh right, i didn't think JS had increment first in it sorry...
Michael
@michaelpautov
May 18 2016 07:20 UTC
thank
Keone Martin
@Athaman
May 18 2016 07:20 UTC
you're welcome
Myuuks
@Myuuks
May 18 2016 07:20 UTC
@Athaman i dont understand what's asked for the exercice called "Woord Blanks"
-o
Blauelf
@Blauelf
May 18 2016 07:21 UTC
You are meant to return a sentence containing all those words passed to your function.
Myuuks
@Myuuks
May 18 2016 07:21 UTC
Keone Martin
@Athaman
May 18 2016 07:22 UTC
similar to before when you used your name + another string
Blauelf
@Blauelf
May 18 2016 07:22 UTC
@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 UTC
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 UTC
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 UTC
i just need to do like : myNoun + myAdjective + myVerb etc.. ?
Keone Martin
@Athaman
May 18 2016 07:24 UTC
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 UTC
@Myuuks That would lead to "dogbigranquickly", the words have to remain separate.
Myuuks
@Myuuks
May 18 2016 07:24 UTC
yeah yeah i see
alright thanks
Keone Martin
@Athaman
May 18 2016 07:25 UTC
np
Markus Kiili
@Masd925
May 18 2016 07:26 UTC
@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 UTC
@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 UTC
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 UTC
what i dont understand is why we dont put our text into : var result
Markus Kiili
@Masd925
May 18 2016 07:29 UTC
@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 UTC
thanks @Masd925 @Blauelf
CamperBot
@camperbot
May 18 2016 07:30 UTC
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 UTC
@Masd925 I have to make a loop inside function
Markus Kiili
@Masd925
May 18 2016 07:31 UTC
@parihars Yes.
Ajith
@ajithvallabai
May 18 2016 07:31 UTC
@Blauelf @Masd925 which loop is better to use
Markus Kiili
@Masd925
May 18 2016 07:31 UTC
@parihars For loop is fine.
Myuuks
@Myuuks
May 18 2016 07:32 UTC
@Blauelf @Athaman can you check my text ^^
pls :)
Darth Skywalker
May 18 2016 07:32 UTC

@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 UTC
@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 UTC
@Masd925 I am not getting can you please explain me
Blauelf
@Blauelf
May 18 2016 07:33 UTC
@Myuuks Can you post your code?
help format
CamperBot
@camperbot
May 18 2016 07:33 UTC

# 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

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

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 UTC
@Myuuks That's not code, it's a screenshot.
Myuuks
@Myuuks
May 18 2016 07:34 UTC
yeah how can i do ?

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 UTC
Copy/Paste, format according to :point_up: 18. Mai 2016 09:33
Myuuks
@Myuuks
May 18 2016 07:35 UTC
looks wierd like this on my screen
Blauelf
@Blauelf
May 18 2016 07:35 UTC
@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 UTC
Kelvin-penang
@Kelvin-penang
May 18 2016 07:36 UTC
This message was deleted
Myuuks
@Myuuks
May 18 2016 07:36 UTC

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 UTC
@Kelvin-penang You can type  without it being interpreted by using \ as an escape character.
Saurabh Parihar
@parihars
May 18 2016 07:37 UTC
Blauelf
@Blauelf
May 18 2016 07:37 UTC
@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 UTC
@parihars contacts is an array. Make a standard for loop over array indices.
Kelvin-penang
@Kelvin-penang
May 18 2016 07:38 UTC
ok thanks @Blauelf I need help on my splitting exercise tho..:sweat_smile:
CamperBot
@camperbot
May 18 2016 07:38 UTC
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 UTC
Kelvin-penang
@Kelvin-penang
May 18 2016 07:38 UTC
can anybody help me in the splitting inception?
Myuuks
@Myuuks
May 18 2016 07:38 UTC
@Blauelf my english is not great sorry xD
Blauelf
@Blauelf
May 18 2016 07:39 UTC
@parihars Why don't you post the code here on chat?
Saurabh Parihar
@parihars
May 18 2016 07:39 UTC

//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 UTC
hello,i am new here
Markus Kiili
@Masd925
May 18 2016 07:40 UTC
@parihars It is contacts.
Saurabh Parihar
@parihars
May 18 2016 07:40 UTC
@Masd925 yeah i m changing it
Markus Kiili
@Masd925
May 18 2016 07:40 UTC
@parihars Then figure out how to access one contact inside the array of contacts.
Blauelf
@Blauelf
May 18 2016 07:41 UTC
@Myuuks
js
function yourCode(arg1) {
var foo;
return "bar";
}

becomes
function yourCode(arg1) {
var foo;
return "bar";
}
Myuuks
@Myuuks
May 18 2016 07:41 UTC
allright thanks
Keone Martin
@Athaman
May 18 2016 07:41 UTC
sorry, wandered off for a bit
Myuuks
@Myuuks
May 18 2016 07:42 UTC
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 UTC
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
May 18 2016 07:43 UTC
@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 UTC

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 UTC
there is also else condition
Darth Skywalker
May 18 2016 07:44 UTC
@parihars : Sorry I don't know the problem statement. I just fixed syntax and semantic errors.
Myuuks
@Myuuks
May 18 2016 07:45 UTC
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 UTC
CamperBot
@camperbot
May 18 2016 07:45 UTC
parihars sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
Myuuks
@Myuuks
May 18 2016 07:45 UTC
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 UTC
"" is no space " " is a space
Myuuks
@Myuuks
May 18 2016 07:46 UTC
ok :)
Keone Martin
@Athaman
May 18 2016 07:46 UTC
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 UTC
Can anyone help me? D:
Myuuks
@Myuuks
May 18 2016 07:47 UTC
yeah it's xD
Keone Martin
@Athaman
May 18 2016 07:48 UTC
@cnj1987 what do you need?
Rex
@RexChip
May 18 2016 07:48 UTC
<div id="wrapper">

<table id="records">
<tr>
<th class="long-cell">Input</th>
<th class="long-cell">E-Mail</th>
</tr>
<tfoot>
<tr>
<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 UTC

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 UTC
cnj1987 sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
Rohan Gayen
@WapmasterRohan
May 18 2016 07:48 UTC
can anyone help me??
Rex
@RexChip
May 18 2016 07:48 UTC
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 UTC
@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 UTC
@cnj1987 which challenge is it?
cnj1987
@cnj1987
May 18 2016 07:50 UTC
Assignment with a Returned Value
Keone Martin
@Athaman
May 18 2016 07:50 UTC
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 UTC
AH!
Divyam Bhagchandani
@divyambhagchandani
May 18 2016 07:52 UTC

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
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Keone Martin
@Athaman
May 18 2016 07:53 UTC
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 UTC
@divyambhag return count+" Bet"; etc
cnj1987
@cnj1987
May 18 2016 07:53 UTC
That makes so much more sense. Thanks @Athaman, I passed it now. :D
CamperBot
@camperbot
May 18 2016 07:53 UTC
cnj1987 sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:warning: cnj1987 already gave athaman points
Keone Martin
@Athaman
May 18 2016 07:53 UTC
cnj1987
@cnj1987
May 18 2016 07:54 UTC
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 UTC
oh thanks @Masd925
CamperBot
@camperbot
May 18 2016 07:55 UTC
divyambhag sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1529 | @masd925 |http://www.freecodecamp.com/masd925
CodeNeophyte
@CodeNeophyte
May 18 2016 08:00 UTC
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 UTC
Darth Skywalker
May 18 2016 08:01 UTC
@parihars : Whats up?
Saurabh Parihar
@parihars
May 18 2016 08:01 UTC

//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

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

## :point_right: adding snippets to sublime text [wiki]

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:

Saurabh Parihar
@parihars
May 18 2016 08:05 UTC
Blauelf
@Blauelf
May 18 2016 08:05 UTC
@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 UTC

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 UTC
@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 UTC
@Blauelf How do i check if prop exists in contact list or not
Blauelf
@Blauelf
May 18 2016 08:08 UTC
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 UTC
@Blauelf https://coderpad.io/R3ERDJ79 join here to help me
Blauelf
@Blauelf
May 18 2016 08:09 UTC
@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.
cnj1987
@cnj1987
May 18 2016 08:09 UTC
Okay, I don't even have a clue what I'm doing with this next one. :/
Saurabh Parihar
@parihars
May 18 2016 08:09 UTC
thats not spam
here you just edit my code
Keone Martin
@Athaman
May 18 2016 08:10 UTC
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 UTC
wtf
Keone Martin
@Athaman
May 18 2016 08:10 UTC
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 UTC
@parihars chill, keep it friendly
Saurabh Parihar
@parihars
May 18 2016 08:11 UTC
@Athaman go in freecode camp chat
this is chat room for help
@ush19 yeah bro
Blauelf
@Blauelf
May 18 2016 08:11 UTC
I want to help here, not on external website.
Susheel Palakurthi
@ush19
May 18 2016 08:11 UTC
@Blauelf alrightty, i think i get it, thanks!
CamperBot
@camperbot
May 18 2016 08:11 UTC
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 UTC
@Blauelf so just said this i will not ask you again
Keone Martin
@Athaman
May 18 2016 08:12 UTC
... i chill in this room because i regularly help people with inquiries
Saurabh Parihar
@parihars
May 18 2016 08:12 UTC
Do anybody wants to help me
Blauelf
@Blauelf
May 18 2016 08:13 UTC
Sure, but only here on chat, not on external website.
Saurabh Parihar
@parihars
May 18 2016 08:13 UTC
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