12th
Aug 2016
abtak mustapha
@mustapha88
Aug 12 2016 00:00
@MrBoggyice yah i know i just write that way
John Magee
@jemagee
Aug 12 2016 00:00
@sjames1958gm and converting this to an array and a nested loop to me is way off in terms of 'programtic thinking' - it's not like he's adding an extra bit or two - he's overly complicating the problem - the fundamental understanding is flawed
llamatarianism
@llamatarianism
Aug 12 2016 00:00
besides, if you care that much about performance, try using a faster language.
fortune ikechukwu ekeruo
@MrBoggyice
Aug 12 2016 00:00
ok
John Magee
@jemagee
Aug 12 2016 00:00
@llamatarianism it's fundamental understanding of the problem and for loops
if he thinks he needs to break it down into an array it shows me a flaw in understanding for loops
llamatarianism
@llamatarianism
Aug 12 2016 00:00
@jemagee in what way is it massively overcomplicating the problem? it only looks overly complex because JS has no range builtin.
Stephen James
@sjames1958gm
Aug 12 2016 00:00
@jemagee The tendency here to create arrays seems to be high.
John Magee
@jemagee
Aug 12 2016 00:01
@sjames1958gm yes - and it isn't always needed - and that should be made clear
llamatarianism
@llamatarianism
Aug 12 2016 00:01
in languages with some builtin to create a range of numbers, the equivalent code is much nicer.
BeefHazard
@BeefHazard
Aug 12 2016 00:01
Beautiful arrays aren't ugly!
Ujjwal Nambiar
@UjjwalNambiar
Aug 12 2016 00:01
@jemagee @sjames1958gm So do you recommend I reset and simplify the loop, or continue?
John Magee
@jemagee
Aug 12 2016 00:01
@UjjwalNambiar that's up to you
you can do it without any arrays and in one loop :)
fortune ikechukwu ekeruo
@MrBoggyice
Aug 12 2016 00:01
yes languages like python has a built in range function @llamatarianism
John Magee
@jemagee
Aug 12 2016 00:01
@llamatarianism creating an array and two nested loops with a reduce function - it has nothing to do with 'ranges'
it has to do with understanding you can just 'loop' through the numbers on their own :)
llamatarianism
@llamatarianism
Aug 12 2016 00:02
return reduce(lambda acc, x: acc*x, range(2, n+1))
John Magee
@jemagee
Aug 12 2016 00:02
i think it's fundamental to understand for loops
Stephen James
@sjames1958gm
Aug 12 2016 00:02
@UjjwalNambiar The thing is that you create an array when at that point you might as well calculate the value.
llamatarianism
@llamatarianism
Aug 12 2016 00:02
foldl (*) 1 [1..n]
abtak mustapha
@mustapha88
Aug 12 2016 00:02
@UjjwalNambiar i just give almost answer
fortune ikechukwu ekeruo
@MrBoggyice
Aug 12 2016 00:03
help where do i belong
CamperBot
@camperbot
Aug 12 2016 00:03

# Algorithm Where do I Belong

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

### :checkered_flag: Problem Explanation:

This can be a tricky problem to understand. You need to find where in the array a number should be inserted by order, and return the index where it should go.

Ujjwal Nambiar
@UjjwalNambiar
Aug 12 2016 00:03
@mustapha88 Yes, I tested it and it worked. I didn't look it at thoroughly as I want to try to code this on my own.
John Magee
@jemagee
Aug 12 2016 00:03
@UjjwalNambiar I just feel it's important you understand you do not need an array to go through it
in the grand scheme ofprocessing power no it's not going to make much difference
in the grand scheme of some day i want to be an efficient coder it can make a difference
Ujjwal Nambiar
@UjjwalNambiar
Aug 12 2016 00:04
@jemagee @sjames1958gm @mustapha88 OK. I'll review and refine my understanding of 'For Loops' and come back to this challenge later.
llamatarianism
@llamatarianism
Aug 12 2016 00:04
if we step a little further out of the realm of "programming"
Ujjwal Nambiar
@UjjwalNambiar
Aug 12 2016 00:04
This message was deleted
llamatarianism
@llamatarianism
Aug 12 2016 00:04
and a little further into the realm of "computer science"
a for loop and reducing over an array are pretty much the same
Ujjwal Nambiar
@UjjwalNambiar
Aug 12 2016 00:04
@jemagee @sjames1958gm @mustapha88 Thank you all for your help.
CamperBot
@camperbot
Aug 12 2016 00:04
ujjwalnambiar sends brownie points to @jemagee and @sjames1958gm and @mustapha88 :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @jemagee |http://www.freecodecamp.com/jemagee
:cookie: 335 | @mustapha88 |http://www.freecodecamp.com/mustapha88
:star2: 2523 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 12 2016 00:04
@UjjwalNambiar :+1:
abtak mustapha
@mustapha88
Aug 12 2016 00:04
@UjjwalNambiar it's exaclty like your the main diff is i assign val 1 to fact to avoid error in case of 0! that equal to 1
llamatarianism
@llamatarianism
Aug 12 2016 00:04
also like I said
if you care that much about efficiency
write C
also
$O(2n) = O(n)$
John Magee
@jemagee
Aug 12 2016 00:05
@llamatarianism If you give someone this questoin in a job interview and they forego the for loop simple solution for the complicated array nested for loop - are you going to give them points or take them away?
llamatarianism
@llamatarianism
Aug 12 2016 00:05
there's no nesting
Stephen James
@sjames1958gm
Aug 12 2016 00:05
@UjjwalNambiar So you did get it to pass?
llamatarianism
@llamatarianism
Aug 12 2016 00:05
if there was a nested for loop it'd be $O(n^2)$ and I'd agree with you
Ujjwal Nambiar
@UjjwalNambiar
Aug 12 2016 00:05
@sjames1958gm Not for 0!. All other cases passed though!
John Magee
@jemagee
Aug 12 2016 00:06
it's a pointless discussion - i explained why i felt he should re do it - you disagree - fine - moving on
Stephen James
@sjames1958gm
Aug 12 2016 00:06
@UjjwalNambiar There is a second parameter to reduce (after the function) that establishes the initial value for previous. If the array is empty then that is the result of the reduce.
llamatarianism
@llamatarianism
Aug 12 2016 00:06
if it's a pointless discussion
why did you bring it up
BeefHazard
@BeefHazard
Aug 12 2016 00:06
lol @llamatarianism
Stephen James
@sjames1958gm
Aug 12 2016 00:07
So @BeefHazard hows that ciphering going :)
llamatarianism
@llamatarianism
Aug 12 2016 00:07
$O(2n) = O(n)$
2 loops vs 1 loop, it really doesn't make a huge difference
BeefHazard
@BeefHazard
Aug 12 2016 00:07
@sjames1958gm having a hard time concentrating well... Need to find a way to actually replace the characters
John Magee
@jemagee
Aug 12 2016 00:07
@BeefHazard regular expressions
BeefHazard
@BeefHazard
Aug 12 2016 00:07
nooooooooo not regex please not regex
Stephen James
@sjames1958gm
Aug 12 2016 00:08
@jemagee Interesting. . .
llamatarianism
@llamatarianism
Aug 12 2016 00:08
@jemagee he's doing the caesar cipher thing
BeefHazard
@BeefHazard
Aug 12 2016 00:09
@llamatarianism @sjames1958gm looking for something to replace a character with code X by a character with code X + 13
llamatarianism
@llamatarianism
Aug 12 2016 00:10
@BeefHazard I just used map
Santiago Gómez
@Sperkajugglite
Aug 12 2016 00:10
@llamatarianism hola :P
llamatarianism
@llamatarianism
Aug 12 2016 00:10
str.split("").map(function(char) {
var code = String.fromCharCode(char);
// do stuff with code here
});
@Sperkajugglite donde esta?
Santiago Gómez
@Sperkajugglite
Aug 12 2016 00:10
en casa :P
llamatarianism
@llamatarianism
Aug 12 2016 00:10
ah si
muy bien
Santiago Gómez
@Sperkajugglite
Aug 12 2016 00:11
:D
guys, do you know how can i "require" react in codepen?
like assign it to a variable
e.g: var React = require("react")
BeefHazard
@BeefHazard
Aug 12 2016 00:11
This message was deleted
llamatarianism
@llamatarianism
Aug 12 2016 00:11
nah
bitgrower
@bitgrower
Aug 12 2016 00:11
@llamatarianism nice looking code there, sir ...
llamatarianism
@llamatarianism
Aug 12 2016 00:11
not really any more efficient than just using a loop
Brandon
@Brandons42
Aug 12 2016 00:12
@Sperkajugglite Perdón, pero no sé.
Santiago Gómez
@Sperkajugglite
Aug 12 2016 00:12
ok, thanks @Brandons42 :P
CamperBot
@camperbot
Aug 12 2016 00:12
sperkajugglite sends brownie points to @brandons42 :sparkles: :thumbsup: :sparkles:
:cookie: 261 | @brandons42 |http://www.freecodecamp.com/brandons42
llamatarianism
@llamatarianism
Aug 12 2016 00:12
@Sperkajugglite you can add libraries in the codepen settings
BeefHazard
@BeefHazard
Aug 12 2016 00:12
I initialized that char var a little later than I wrote the loop, let me fix the DRY
bitgrower
@bitgrower
Aug 12 2016 00:12
but compact, easy to read & understand -- that counts for something @llamatarianism
BeefHazard
@BeefHazard
Aug 12 2016 00:13

function rot13(str) { // LBH QVQ VG!
str = str.split("");
var result = [];
for (var i = 0; i < str.length; i++){
var char = str[i].charCodeAt(0);
if(char >= 65 && char <= 78){

}
else if(char > 78 && char <= 95){

}
return result;
}
}

// Change the inputs below to test
llamatarianism
@llamatarianism
Aug 12 2016 00:13
also @BeefHazard , somewhat related:
if you have an array of char codes - for example, one that your for loop or map creates -
you can turn it into a string like so
String.fromCharCode(...arr);
or in the ES5 way
String.fromCharCode.apply(String, arr);
BeefHazard
@BeefHazard
Aug 12 2016 00:14
yeah
but that wouldn't get the spaces and such in there
llamatarianism
@llamatarianism
Aug 12 2016 00:14
yeah it would
as long as there are spaces in the array
not literal spaces of course, just the number 32
BeefHazard
@BeefHazard
Aug 12 2016 00:15
oooohh
I forgot those have a number too
mind blown
now in my looping, getting those charcodes into the right place would be quite a hassle...
or arr[i] = char of course
Stephen James
@sjames1958gm
Aug 12 2016 00:18
@Sperkajugglite You don't require react you had react to the libraries and React is available
BeefHazard
@BeefHazard
Aug 12 2016 00:18
nah that won't work, it's stupid
llamatarianism
@llamatarianism
Aug 12 2016 00:20
nah you can just do
str.split("").map(function(x) {
return x.charCodeAt(0) // rotate it somewhere in here
});
or with a for loop
var result = [];
for (var i = 0; i < arr.length; i++) result.push(str.charCodeAt(i));
BeefHazard
@BeefHazard
Aug 12 2016 00:23
@llamatarianism and then iterate over result, change 'em up and turn it back into a string... might be a damn good idea
llamatarianism
@llamatarianism
Aug 12 2016 00:23
nah
you can do it all in one loop
BeefHazard
@BeefHazard
Aug 12 2016 00:25
@llamatarianism think i'm gonna go and not do that to keep things simple
llamatarianism
@llamatarianism
Aug 12 2016 00:26
it's not like it'd make it that much more complex
Moisés Man
@moigithub
Aug 12 2016 00:26

function rot13 (str){
var code ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var decipher = "NOPQRSTUVWXYZABCDEFGHIJKLM";
var result = "";
for(var i=0;i<str.length;i++){
var idx = code.indexOf(str[i]);
result += idx>0 ? decipher[idx]: str[i]
}
return result;
}

rot13("SERR PBQR PNZC")
:D
Stephen James
@sjames1958gm
Aug 12 2016 00:26
Ha regex - I did it :)
function rot13(str) {

var output = ""
str.replace(/(\s)|([A-M])|([N-Z])/g, function(x, a, b, c) {
if (a) output += a;
if (b) output += String.fromCharCode(b.charCodeAt(0) + 13);
if (c) output += String.fromCharCode(c.charCodeAt(0) - 13);
});
return output;
}
@BeefHazard Since you weren't doing regex :)
BeefHazard
@BeefHazard
Aug 12 2016 00:27
@sjames1958gm regex is made by satan himself
Moisés Man
@moigithub
Aug 12 2016 00:27
function rot13 (str){
return str.replace(/[A-Z]/g, function(char){
return String.fromCharCode((char.charCodeAt(0)-65+13) %26+65);
});
}
with regex and remainder
Stephen James
@sjames1958gm
Aug 12 2016 00:28
:santa: Could it be satan
@moigithub What about spaces.
Moisés Man
@moigithub
Aug 12 2016 00:29
it wont be replaced :)
"hello".replace(/l/g, "x") <--- hexxo
Stephen James
@sjames1958gm
Aug 12 2016 00:30
@moigithub ah. sure - do'h

@moigithub Coole

function rot13(str) {

return str.replace(/([A-M])|([N-Z])/g, function(x, a, b) {
if (a) return String.fromCharCode(a.charCodeAt(0) + 13);
if (b) return String.fromCharCode(b.charCodeAt(0) - 13);
});
}

Me no like remainder solution :(

And I wonder why I didn't have a girl friend in high school -
Nick Neuman
@neecholaus
Aug 12 2016 00:35
hey guys can anyone tell me why my array is returning vertical? and how i can make it return it horizontal?
function rot13(str) { // LBH QVQ VG!

var abc = "abcdefghijklmnopqrstuvwxyz";
a = abc.split("");
console.log(a);

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Kev
@ngynkvn
Aug 12 2016 00:36
Hey, having an issue with jquery onclick not working with mobile devices, specifically my ios device. Clicks won't register, anyone know why?
DJ
@qualitymanifest
Aug 12 2016 00:39
@ngynkvn onclick isn't jquery, onclick is a vanilla JS method, and [it appears it is deprecated on ios and android](http://stackoverflow.com/questions/35970987/js-onclick-mobile-alternative-onclick-deprecated-on-ios-and-android-too)
.click() is jquery, and i've never had a problem with it on mobile @ngynkvn
nevermind i'm not so sure it's deprecated, i just found that from a quick google. try using jquery's click function and if you're still having issues with it paste a link to your codepen, if you have one
Kev
@ngynkvn
Aug 12 2016 00:43
Sorry for the confusion, .click() is the method I'm using. This is the first time I've had an issue with it not working. It works as expected on desktop too. http://codepen.io/ngynkvn/pen/LkrPxG @qualitymanifest
Yan Kozlovskiy
@YanKozlovskiy
Aug 12 2016 00:44
Would anyone like to pair up and work on the advanced front end projects together?
DJ
@qualitymanifest
Aug 12 2016 00:47
@ngynkvn alright im taking a look at it
Stephen James
@sjames1958gm
Aug 12 2016 00:48
@neecholaus What do you mean by horizontal/vertical?
Nick Neuman
@neecholaus
Aug 12 2016 00:49
like how the result just goes down one by one instead of left to right. @sjames1958gm
Stephen James
@sjames1958gm
Aug 12 2016 00:51
@neecholaus I think that is just a weirdness of the repl tool
Nick Neuman
@neecholaus
Aug 12 2016 00:54
@sjames1958gm okay i was thinking it might be something like that
taq2008
@taq2008
Aug 12 2016 00:55
Hello everybody, I wanna use this to get random quote and show it on the page, why it doesn't work?
$(document).ready(function() {$("#get-another-quote-button").on("click", function() {
$.getJSON("http://quotes.stormconsultancy.co.uk/random.json", function(data) {$("#quote-content").text(data.quote);
$("#quote-title").text(data.author); }); }); }); var code="formatted"; Joseph @revisualize Aug 12 2016 00:59 Hey kids. :P How is everyone? I'm at a Meetup.com event. Kev @ngynkvn Aug 12 2016 01:03 @taq2008 Check your developer console, it's most likely a cross-origins issue, I think you can either use a CORS proxy like crossorigin.me or add ?callback=? to the end of your api link. Alexander Køpke @alexanderkopke Aug 12 2016 01:03 I'm tired and should turn in. How are you? :) Joseph @revisualize Aug 12 2016 01:05 Some slick solutions for ROT13 Alexander Køpke @alexanderkopke Aug 12 2016 01:08 yeah the callback=? does the trick. Couldn't make it work in jsbin but in codepen it worked fine DJ @qualitymanifest Aug 12 2016 01:11 @ngynkvn JS isn't running on mobile at all. try alerting something or changing text. nothing happens. trying to figure out why currently Joseph @revisualize Aug 12 2016 01:11 I'm still trying to understand the solution. function (regex, true, false) ?? That isn't right. Wow.. That code takes a TON of steps. Eddie @Ndaraya Aug 12 2016 01:18 Hello everyone! Is it just me or does the Basic Algorithm Scripting section feel like one is being thrown to the wolves with only a spoon for defense? Kev @ngynkvn Aug 12 2016 01:20 odd. DJ @qualitymanifest Aug 12 2016 01:20 @ngynkvn actually, correction, the JS is running. your clearScreen function is causing it to error out on mobile, i suspect Stephen James @sjames1958gm Aug 12 2016 01:20 @revisualize Probably a lot scanning and one callback per character. Kev @ngynkvn Aug 12 2016 01:20 @qualitymanifest yeah i just noticed the same thing. but why? Jaren Escueta @jarenescueta731 Aug 12 2016 01:20 hello, could someone plz help me figure out how to add a sound effect mp3 file to my pomodoro clock project? i tried putting the mp3 in a public file on my google drive (which works fine for images) but I can't get it to play. is there a better way to do this? Kev @ngynkvn Aug 12 2016 01:21 I think it has something to do with addClass and removeClass actually. Diego Mayer @Chrono79 Aug 12 2016 01:22 @sjames1958gm function rot13(str) { return str.replace(/([A-M])|([N-Z])/g, function(x, a) { return String.fromCharCode(x.charCodeAt(0) + (x == a ? 13 : -13)); }); } DJ @qualitymanifest Aug 12 2016 01:22 @ngynkvn still narrowing it down. its the line with the settimeout specifically Stephen James @sjames1958gm Aug 12 2016 01:22 @Chrono79 Nice Kev @ngynkvn Aug 12 2016 01:23 @qualitymanifest I got it, it was because i was using let instead of var, does is let not supported on mobile? DJ @qualitymanifest Aug 12 2016 01:24 @ngynkvn oh thats funny. no, you just haven't added babel in the js section Nicolas Crumrine @CrumrineCoder Aug 12 2016 01:24 I'm getting an append syntax error which is caused by there being different lines in my append call, but I've escaped the ends of them. http://codepen.io/CrumrineCoder/pen/GqPZpx?editors=0011 I'm not sure why it still gives me the error, the error shows up on line 72 Mike @MikeJSchorah Aug 12 2016 01:24 function mutation(arr) { var haystack = arr[0]; var needles = arr[1]; for (var i = 0; i < arr.length; i++) { arr[0].indexOf(arr[1][i]) !== -1; } } Could someone please give me a hint with Mutations? Joseph @revisualize Aug 12 2016 01:25 @Chrono79 What is a and what is b? DJ @qualitymanifest Aug 12 2016 01:25 @ngynkvn add it in the preprocessor section. i guess the desktop browsers were letting you get away with it for whatever reason. i didn't think anything of it since ive gotten used to seeing es2015 John Magee @jemagee Aug 12 2016 01:25 @Chrono79 I'm reading this and sort of think i get it - but why does b have to be declared if b isn't used? Diego Mayer @Chrono79 Aug 12 2016 01:25 @revisualize that's what I was thinking, but it seems they're the capturing groups Joseph @revisualize Aug 12 2016 01:26 I don't get it.. :| John Magee @jemagee Aug 12 2016 01:27 does it work? Diego Mayer @Chrono79 Aug 12 2016 01:27 @jemagee well, without b it works too Kev @ngynkvn Aug 12 2016 01:27 @qualitymanifest I think I'm just going to remove it entirely, it was an artifact from a previous thing i was trying. Thanks for the help DJ CamperBot @camperbot Aug 12 2016 01:27 ngynkvn sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles: :star2: 1342 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest Joseph @revisualize Aug 12 2016 01:27 I need to learn how to type. John Magee @jemagee Aug 12 2016 01:27 @Chrono79 so b isn't needed and just confuses? Diego Mayer @Chrono79 Aug 12 2016 01:27 @jemagee with the way I did it it's not necessary John Magee @jemagee Aug 12 2016 01:28 @Chrono79 yeah i'm still trying to figure it out but the presence of an argument confuses me :) Nick Neuman @neecholaus Aug 12 2016 01:28 hey can anyone tell me why the A wont show up for an N in the caesars cipher exercise? function rot13(str) { var abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var a = abc.split(""); var newArr = []; for (i = 0; i < str.length; i++) { for (j = 0; j < a.length; j++) { if (str[i] == a[j]) { if (j < 14) { var letter1 = a[j + 13]; newArr.push(letter1); } else if (j > 13) { var letter2 = a[j - 13]; newArr.push(letter2); } } } }console.log(newArr) } rot13("SERR PBQR PNZC"); Diego Mayer @Chrono79 Aug 12 2016 01:28 @MikeJSchorah arr[0].indexOf(arr[1][i]) !== -1 isn't that an if condition? DJ @qualitymanifest Aug 12 2016 01:28 @CrumrineCoder it's got to all be on the same line. and you use parenthesis not curly braces around .append() Nicolas Crumrine @CrumrineCoder Aug 12 2016 01:29 That... would be why .... f*.... Always... always the little things. Thanks @qualitymanifest CamperBot @camperbot Aug 12 2016 01:29 crumrinecoder sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles: :star2: 1343 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest Kelsey Edelstein @kedskeds Aug 12 2016 01:29 anyone know where to find solutions to the algorithm challenges? I thought there used to be a "hint" button. John Magee @jemagee Aug 12 2016 01:30 @kedskeds yeah but the hint button isn't the solution - go to the forum and search the problem you're doing - they have posts with solutions for most of them Stephen James @sjames1958gm Aug 12 2016 01:30 @revisualize For each match the function is called. (In this case it is for every character). The first parameter is the match and the 2nd through nth are the matches inside the (). So if the first parameter matches the second parameter the value is A-M otherwise it is N-Z. Ishan Jain @ishanjain28 Aug 12 2016 01:30 @kedskeds Check @rafase32 on github. He has a repo for it. Wouldn't recommend doing this though Kev @ngynkvn Aug 12 2016 01:30 @kedskeds there's also a freecodecamp wiki Diego Mayer @Chrono79 Aug 12 2016 01:30 @jemagee @revisualize https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter p1, p2, ... The nth parenthesized submatch string, provided the first argument to replace() was a RegExp object. (Corresponds to$1, $2, etc. above.) For example, if /(\a+)(\b+)/, was given, p1 is the match for \a+, and p2 for \b+. Stephen James @sjames1958gm Aug 12 2016 01:32 @MikeJSchorah You should be looping over your needles string not the arr. The hint is to go to jsbin.com or some such site and use console.log to see what the code is doing. It seems like you don't even understand what the challenge is asking. John Magee @jemagee Aug 12 2016 01:32 @sjames1958gm 2nd through nth? how does a become 2nd through nth - that's where i get confused - x is a single letter yes when passed to the second return yes? Kelsey Edelstein @kedskeds Aug 12 2016 01:33 @jemagee @ishanjain28 @ngynkvn thanks all. the FCC wiki hints are exactly what I was looking for. I thought there used to be a "hint" button next to "submit" when you're working through a challenge. CamperBot @camperbot Aug 12 2016 01:33 kedskeds sends brownie points to @jemagee and @ishanjain28 and @ngynkvn :sparkles: :thumbsup: :sparkles: :cookie: 315 | @jemagee |http://www.freecodecamp.com/jemagee :cookie: 291 | @ngynkvn |http://www.freecodecamp.com/ngynkvn :cookie: 321 | @ishanjain28 |http://www.freecodecamp.com/ishanjain28 Stephen James @sjames1958gm Aug 12 2016 01:33 @jemagee For each () there is another parameter added to the function, even if that () isn't matched. John Magee @jemagee Aug 12 2016 01:34 @sjames1958gm yeah - thats' where you lose me well you lose me with what x is as well :) Stephen James @sjames1958gm Aug 12 2016 01:35 @jemagee x is the actual match Whether it is A, B, Y, Z. The next parameter a will only be set if ([A-M]) matches. function rot13(str) { return str.replace(/([A-M])|([N-Z])/g, function(x, a, b) { if (a) return String.fromCharCode(a.charCodeAt(0) + 13); if (b) return String.fromCharCode(b.charCodeAt(0) - 13); }); } John Magee @jemagee Aug 12 2016 01:36 so if the first letter in the string is A x = A and a =? Diego Mayer @Chrono79 Aug 12 2016 01:36 @jemagee a = A Stephen James @sjames1958gm Aug 12 2016 01:36 a is also A If the second letter is N the x is N a is undefined and b is N John Magee @jemagee Aug 12 2016 01:37 and if x = N, a is undefeined and B = N? Stephen James @sjames1958gm Aug 12 2016 01:37 @jemagee Check. Diego Mayer @Chrono79 Aug 12 2016 01:37 b = N, but yes ;) Stephen James @sjames1958gm Aug 12 2016 01:39 @jemagee So my code above uses that undefined to tell which was matched. @Chrono79 improved on it, because if x === a then it is A-M otherwise N-Z. @jemagee Your the one that suggested regex ;) John Magee @jemagee Aug 12 2016 01:40 @sjames1958gm I thought he was referring to a different function :) Sorry i was reading CharCodeAt - i don't use stuff like that often so i had to refresh my memory Ok so now the ternary makes sense I'm just still confused how the a & b knows from the regex - but I figure because that's i'm not great at regex i think using a and b is where i got confused :) Mike @MikeJSchorah Aug 12 2016 01:47 function mutation(arr) { var haystack = arr[0]; var needles = arr[1]; for (var i = 0; i < needles.length; i++) { if (arr[0].indexOf(arr[1][i]) !== -1) { console.log(true); } else { console.log(false); } } } mutation(["hello", "hey"]); @sjames1958gm, when I put this into jsbin.com, I get true true false John Magee @jemagee Aug 12 2016 01:47 that's some deep ass work with replace Stephen James @sjames1958gm Aug 12 2016 01:48 @MikeJSchorah Is that what you expect? Jaymie Rosen @jaymierosen Aug 12 2016 01:52 hi I have a question re: Storing Values with the Assignment Operator Stephen James @sjames1958gm Aug 12 2016 01:52 @jaymierosen ask away Jaymie Rosen @jaymierosen Aug 12 2016 01:52 "a should be assigned to b with =" <-- I typed in: "var a = b;" ...not sure why I'm getting an error. John Magee @jemagee Aug 12 2016 01:53 I am functioning on less than 4 hours sleep and an 8.5 hour work day - just saying :) Stephen James @sjames1958gm Aug 12 2016 01:53 @jaymierosen a assigned to b is the other way b = a (the value of a is assigned to b = means assignement) John Magee @jemagee Aug 12 2016 01:53 @jaymierosen your interpretation of the text is backwards - 'assigned to' is followed by the variable :) var basically says 'assign what ever follows the equals sign to what ever follows me' (I hope that makes sense) in this case David Halls @DavidHalls Aug 12 2016 01:55 help inventory update CamperBot @camperbot Aug 12 2016 01:55 ## :point_right: algorithm inventory update [wiki] # Algorithm Inventory Update :triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil: ### :checkered_flag: Problem Explanation: In this problem, you've to compare and update the inventory stored in a 2D array against a second 2D array of a fresh delivery. Update the current existing inventory item quantities (in arr1). If an item cannot be found, add the new item and quantity into the inventory array. The returned inventory array should be in alphabetical order by item. The current as well as new inventory will be in this format: var newInv = [[2, "Item1 Name"], [3, "Item2 Name"], [67, "Item3 Name"], [7, "Item4 Name"]];. #### Relevant Links Mateusz Szymański @matszym Aug 12 2016 01:55 This message was deleted João Novaes Barreiros @Jon-Nova Aug 12 2016 01:58 Hi How can i send a piece of code ? John Magee @jemagee Aug 12 2016 01:59 help code CamperBot @camperbot Aug 12 2016 01:59 ## :point_right: challenge comment your javascript code [wiki] # Challenge Comment your JavaScript Code Comments are a great way to leave notes to yourself and to other people who will later need to figure out what it does. Any code in it will be ignored. Let's take a look at the two ways you can write comments in JavaScript. • The double-slash comment will comment out the remainder of the text on the current line: // This is a comment. • The slash-star-star-slash comment will comment out everything between the /* and the */ characters: /* This is also a comment */ John Magee @jemagee Aug 12 2016 01:59 ok - that didn't work help post code CamperBot @camperbot Aug 12 2016 01:59 ## :point_right: how to post code [wiki] # How to post code use backticks  John Magee @jemagee Aug 12 2016 01:59 there you go BeefHazard @BeefHazard Aug 12 2016 01:59 don't forget the js help format CamperBot @camperbot Aug 12 2016 01:59 ## :point_right: code formatting [wiki] # Multi line Code js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css) <paste your code here>, then press [shift + enter ⏎]  ⇦ Type 3 backticks, then press [enter ⏎] # Single line Code This an inline <paste code here> code formatting with a single backtick() at _start_ and _end_ around thecode. See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics BeefHazard @BeefHazard Aug 12 2016 01:59 -yes that's right i'm still alive- João Novaes Barreiros @Jon-Nova Aug 12 2016 01:59 thx BeefHazard @BeefHazard Aug 12 2016 02:00 it's 4am though here so i should sleep... probably João Novaes Barreiros @Jon-Nova Aug 12 2016 02:01 is 23:01 in Brazil BeefHazard @BeefHazard Aug 12 2016 02:01 04:00 in Amsterdam :grin: John Magee @jemagee Aug 12 2016 02:01 @Jon-Nova dont' flush the toilet paper João Novaes Barreiros @Jon-Nova Aug 12 2016 02:04 I am having problems whit the "Record Collection" BeefHazard @BeefHazard Aug 12 2016 02:04 everybody does João Novaes Barreiros @Jon-Nova Aug 12 2016 02:05 <function updateRecords(id, prop, value) { if(prop !== "tracks" && value !== ""){ collection.id[prop] = value; }else if(prop == "tracks" && collection.hasOwnProperty("tracks") == false){ collection.id.prop.push(value); }else if(prop == "tracks" && value !== ""){ collection.id[prop].push(value); }else if(value == ""){ delete collection.id[prop]; } return collection; }> sorry John Magee @jemagee Aug 12 2016 02:05 @BeefHazard ahem - not everybody :) BeefHazard @BeefHazard Aug 12 2016 02:06 @jemagee I'm sure you're a very special little snowflake John Magee @jemagee Aug 12 2016 02:06 I had a six hour problem with common multiples though :) Stephen James @sjames1958gm Aug 12 2016 02:06 @Jon-Nova id is a variable - should use [id] @Jon-Nova same with prop João Novaes Barreiros @Jon-Nova Aug 12 2016 02:07 thx Stephen James @sjames1958gm Aug 12 2016 02:08 @Jon-Nova Look a couple of pages back on how to properly post code tw1t611 @tw1t611 Aug 12 2016 02:12 function whatIsInAName(collection, source) { // What's in a name? var arr = []; var key; // Only change code below this line for (key in source) { for (var i = 0; i < collection.length; i++) { if (collection[i].hasOwnProperty(key)) { arr.push(collection[i].key); } } } // Only change code above this line return arr; } whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" }); returns null, key is set right esong7 @esong7 Aug 12 2016 02:14 Hey guys, this might be really simple but I am not understanding what the tutorial wants me to do. How do I get past this? // Setup var myStr = "Jello World"; // Only change code below this line myStrxamarin/xamarin-android@a16673d = "H"; // Fix Me David Halls @DavidHalls Aug 12 2016 02:14 Has anyone completed Inventory Challenge? esong7 @esong7 Aug 12 2016 02:15 should be myStrxamarin/xamarin-android@a16673d tw1t611 @tw1t611 Aug 12 2016 02:15 @esong7 I think you should set the first letter of string to H esong7 @esong7 Aug 12 2016 02:17 Hey Daniel thanks for the response. Changing tI get an error which reads "TypeError: Cannot assign to read only property '0' of string 'Jello World'" The tutorial asks me not to change the string "Jello World" Stephen James @sjames1958gm Aug 12 2016 02:18 @esong7 It is telling you that you cannot change a letter in a string, if you want myStr to be "Hello World" you have to reset the whole string. @nayD93 I think you will be better served to loop over the collection first then the source keys. tw1t611 @tw1t611 Aug 12 2016 02:20 @sjames1958gm i ll try Jaymie Rosen @jaymierosen Aug 12 2016 02:22 @sjames1958gm @jemagee thanks!! CamperBot @camperbot Aug 12 2016 02:22 jaymierosen sends brownie points to @sjames1958gm and @jemagee :sparkles: :thumbsup: :sparkles: :cookie: 316 | @jemagee |http://www.freecodecamp.com/jemagee :star2: 2524 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm tw1t611 @tw1t611 Aug 12 2016 02:22 @sjames1958gm same result, esong7 @esong7 Aug 12 2016 02:23 Got the answer. Thank you guys for your response. Stephen James @sjames1958gm Aug 12 2016 02:23 @nayD93 You are only testing half the requirement not only does it have to exist it has to have the same value @esong7 :+1: Mike @MikeJSchorah Aug 12 2016 02:26 @sjames1958gm I'm not sure what to expect. I don't understand how the website works. Stephen James @sjames1958gm Aug 12 2016 02:27 @MikeJSchorah for the input Hello and Hey would you expect true, true, false for the letters of Hey? @MikeJSchorah h is in hello (true) e is in hello (true) y is not in hello (false). Jaymie Rosen @jaymierosen Aug 12 2016 02:28 Hi, I need help with "Convert Celsius to Fahrenheit" Stephen James @sjames1958gm Aug 12 2016 02:29 @MikeJSchorah if you replace console.log(false) with return false; run the code and see if you pass any tests. @jaymierosen You are given the function structure with the parameter celsius. Also the formula F = C * 9/5 + 32 - replace the F and C in this formula with celsius and the fahrenheit variable given. Jaren Escueta @jarenescueta731 Aug 12 2016 02:35 can anyone help me add an mp3 file i have downloaded to my pomodoro clock project? this is what i have: var audio = new Audio("http://gdriv.es/je_images/Spit_Splat-Mike_Koenig-1170500447.mp3"); ... audio.play(); i suspect the public folder i used to host the file is only good for images. how do i use a sound effect that i downloaded? Jaren Escueta @jarenescueta731 Aug 12 2016 02:43 what can i do differently? John Magee @jemagee Aug 12 2016 02:47 @jarenescueta731 if it's on the server - why do you need an image to it? perhaps this link will give you some guidance Jaren Escueta @jarenescueta731 Aug 12 2016 02:50 @jemagee i still don't understand how to link the server Zachary Taylor @taylorz0917 Aug 12 2016 02:51  function translatePigLatin(str) { var suffix = []; var pigLatinBase = []; var flag, suffixFlag = false; var newStr = str.split(""); for(var i = 0; i < newStr.length; i++){ if((/^[aeiou]$/i).test(newStr[i]) || flag === true){
if(i === 0) suffixFlag = true;
pigLatinBase.push(newStr[i]);
flag = true;
}
else suffix.push(newStr[i]);
}
console.log(newStr[1]);
if(suffixFlag === true) suffix = suffix + "way";
else suffix = suffix + "ay";
pigLatinBase = pigLatinBase.join('');
var finalStr = pigLatinBase + suffix;
return finalStr;
}

translatePigLatin("glove");
Does anyone mind telling me why this is returning "oveg,lay" instead of "oveglay"
Jaren Escueta
@jarenescueta731
Aug 12 2016 02:52
@jemagee how can i make it so that i can just have
var audio = new Audio("Spit_Splat-Mike_Koenig-1110500447.mp3");
Zachary Taylor
@taylorz0917
Aug 12 2016 02:56
I think i see my error.
John Magee
@jemagee
Aug 12 2016 02:56
@jarenescueta731 You can't make it just have that - there needs to be a path - but if it's on the same server that your page is on you just have to use the path to the file...
David Halls
@DavidHalls
Aug 12 2016 02:57
@taylorz0917 is it because you are concatenating arrays?
Jaren Escueta
@jarenescueta731
Aug 12 2016 02:57
@jemagee my project is on codepen
Zachary Taylor
@taylorz0917
Aug 12 2016 02:57
Yes it was
I just used suffix.join("") and everything worked fine
David Halls
@DavidHalls
Aug 12 2016 02:58
nice, i was looking for a comma in your code, but then saw that, cool
Nestor Figliuolo
@Makaan
Aug 12 2016 03:04
Hello guys, can someone help me with "Map the Debris" problem? i can't figure out the ecuation i should use
Jaren Escueta
@jarenescueta731
Aug 12 2016 03:05
@jemagee codepen asset hosting for direct upload is only available for PRO accounts :( is there a free hosting site i can use that also works with audio files?
Joe Farah
@Kangiryanka
Aug 12 2016 03:05
have any of you done a cs degree? and has it helped it you become a better programmer. I'm hesitant if i do a degree or not i nit
silver537
@silver537
Aug 12 2016 03:07
Ha
bitgrower
@bitgrower
Aug 12 2016 03:17
@Kangiryanka you can do a lot of programming ... a lot of GREAT programming ... without a CS degree ... many have (Bill Gates, Mark Zuckerberg, questionably Steve Jobs - who not only don't have a CS degree...they didn't get a degree of ANY kind -- it's kind of a legendary "motif" here in Silicon Valley ...
Joseph
@revisualize
Aug 12 2016 03:17
hello.
bitgrower
@bitgrower
Aug 12 2016 03:20
@revisualize - hi
@revisualize -- save my streak ... I've had about 30-45 minutes sleep in the last 38 hours...(because I spent time in the ER, and then in the hospital)
thank me! :)
Joseph
@revisualize
Aug 12 2016 03:21
Damn. Sorry to hear that.
Done.
Karmen
@klu17
Aug 12 2016 03:22
How do I perform more than one operation in "CONVERT cELSIUS TO fAHRENHEIT?
Joseph
@revisualize
Aug 12 2016 03:22
What do you mean?
Casey
@technomancer408
Aug 12 2016 03:23
on returning Boolean Values from Functions

function isLess(a, b) {
// Fix this code
return a === b;
}

// Change these values to test
isLess(10, 15);

thats my code not sure what to do
bitgrower
@bitgrower
Aug 12 2016 03:23
actually, right now, I feel much better than I have in days ... an interesting combination of 1 side effect to a drug (MAJOR culprit) and the regular effect of another, resulting in bitgrower getting dehydrated ...
Joseph
@revisualize
Aug 12 2016 03:23
@technomancer408 you are doing.. return a equals b;
bitgrower
@bitgrower
Aug 12 2016 03:23
thank you @revisualize
CamperBot
@camperbot
Aug 12 2016 03:23
bitgrower sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1606 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 12 2016 03:24
You need to be doing return a less than b
@bitgrower I got you in the campbotplayground
I didn't want to spam chat. :D
Chat is really slow right now.
silver537
@silver537
Aug 12 2016 03:26




 testing
testing
Tsk.... cant do code blocks on the phone. :/
Joseph
@revisualize
Aug 12 2016 03:27
Yeah, it sucks.
You can't really shift+enter from the mobile app.
silver537
@silver537
Aug 12 2016 03:27
Hmmmm. I wonder...
Joseph
@revisualize
Aug 12 2016 03:28
I really need to solve some more challenges. In FCC. But, I am also two weeks behind on my work.
:(
silver537
@silver537
Aug 12 2016 03:29

ssss
S
Joseph
@revisualize
Aug 12 2016 03:29
You can't even edit posts from the mobile app.
silver537
@silver537
Aug 12 2016 03:29
ss
Joseph
@revisualize
Aug 12 2016 03:30
OH! My :busstop:
:v:
silver537
@silver537
Aug 12 2016 03:30
6
damn not even with the hacker keyboard. :(
Jaren Escueta
@jarenescueta731
Aug 12 2016 03:35
Question: Do people typically stop using codepen by the time they get to the advanced javascript projects? Besides upgrading to PRO to use codepen's asset hosting, I don't know how I can use an mp3 file i downloaded for the pomodoro clock project.
should i just forget trying to add sound effects?
silver537
@silver537
Aug 12 2016 03:36
try 9cloud
IsaiahGz
@IsaiahGz
Aug 12 2016 03:37
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
How do I add a new record? Not sure how to do it
Mateusz Szymański
@matszym
Aug 12 2016 03:37
@jarenescueta731 To me, codepen is like a toy, fun to play witha a hour or two, but I preffer external text editor, not web based
Yogesh Gupta
@yogesh-
Aug 12 2016 03:38
I am having a problem in convert to Fahreinheit
Jaren Escueta
@jarenescueta731
Aug 12 2016 03:38
@matszym is there any such thing as free hosting?
Mateusz Szymański
@matszym
Aug 12 2016 03:39
sure, try heroku

@Maggie9468
Aug 12 2016 03:39
@IsaiahGz me too
how to do it ...
help
CamperBot
@camperbot
Aug 12 2016 03:39

# Accesing the database from your Front End

You must have noticed in main.controller.js how things were retrieved from the database and displayed:

$http.get('/api/things').success(function(awesomeThings){$scope.awesomeThings = awesomeThings;
});

What this does is call the api with a "get" request, which is then routed by /server/api/thing/index.js to the exports.index function in thing.controller.js. You'll also notice in main.controller.js that there are included examples of $http.post and$http.delete functions too! How nice!

silver537
@silver537
Aug 12 2016 03:40
i doubt it
IsaiahGz
@IsaiahGz
Aug 12 2016 03:40
@Maggie9468 I tried doing another pair of {} but it kept saying that the [] were matching up...
Yogesh Gupta
@yogesh-
Aug 12 2016 03:40

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit=convertToF*1.8+32;

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

// Change the inputs below to test your code
convertToF(30);

IsaiahGz
@IsaiahGz
Aug 12 2016 03:40
weren't*
Yogesh Gupta
@yogesh-
Aug 12 2016 03:40
what is the error here ?

@Maggie9468
Aug 12 2016 03:41
I don't understand the meaning of the title.
@IsaiahGz
Yogesh Gupta
@yogesh-
Aug 12 2016 03:41
Convert Celsius to Fahrenheit
silver537
@silver537
Aug 12 2016 03:41
@IsaiahGz you can either enter a new object where the
comment is at
or you can push a new object.
just copy and past the object that is already there into a new object.

@Maggie9468
Aug 12 2016 03:43
What should I add ? @silver537
silver537
@silver537
Aug 12 2016 03:43
myMusic is an array of objects. And should be separated with commas.
Norvin Burrus
@ndburrus
Aug 12 2016 03:43

@yogesh- you're using the function name in the equation... here:
"fahrenheit= convertToF *1.8+32;"

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
we can rewrite the equation/formula to: Fahrenheit is (=) Celsius times() 9/5, plus (+) 32.
which is F = C
9/5 + 32,
or F = C(9/5) + 32.

silver537
@silver537
Aug 12 2016 03:43
It tells you exactly what to add.
IsaiahGz
@IsaiahGz
Aug 12 2016 03:44
When you say object, you mean everything inside the {}? @silver537
Sorry, still new to this
silver537
@silver537
Aug 12 2016 03:45
It wants you to add an object with properties: artist, title, release_year, and formats. Make sure properties and values are in quotes.
Yes.

@Maggie9468
Aug 12 2016 03:46
It's written in itself?
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
scnetsec
@ni234
Aug 12 2016 03:48

CAn someone please put me in the right mindseet to tackle this? Im afraid I dont understand what im supposed to do...

Counting Cards
In the casino game Blackjack, a player can gain an advantage over the house by keeping track of the relative number of high and low cards remaining in the deck. This is called Card Counting.

Having more high cards remaining in the deck favors the player. Each card is assigned a value according to the table below. When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.

Count Change Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K', 'A'
You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.

var count = 0;

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

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
IsaiahGz
@IsaiahGz
Aug 12 2016 03:49
^ How do you make the code come up like that? @ni234
Mateusz Szymański
@matszym
Aug 12 2016 03:49
help format
CamperBot
@camperbot
Aug 12 2016 03:49

# 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

silver537
@silver537
Aug 12 2016 03:49
@Maggie9468
var myMusic = [
{
"artist": "Billy Joel",     //copy
"title": "Piano Man",
"release_year": 1973,
"formats": [   // and
"CS",
"8T",
"LP" ],
"gold": true     //paste
}
// Add record here
];
scnetsec
@ni234
Aug 12 2016 03:50
@IsaiahGz haha right listen close put ur code beetween these guys -----> 
Joel Santos
@St3ps
Aug 12 2016 03:50
Hey, any chance i could get a review of my JS? As in, how readable it is? (I will accept "it's shit", any review will do :) )
http://codepen.io/Steps/pen/zByzZd?editors=0010
scnetsec
@ni234
Aug 12 2016 03:51


sorry I meant double ---> @IsaiahGz
put your code in like a sandwhich
Claudio Restifo
@Marmiz
Aug 12 2016 03:52
@ni234 A simple switch is probably what you're looking for.
If I may give you a pseudo-code, you may want to consider something like:
function cc(card){

switch
// case for when adding my count
// count++

//case for when decrising my count
//count--

if count > requred value --> bet

otherwise not bet
scnetsec
@ni234
Aug 12 2016 03:53
yeah my brain was just bein lazy , I can switch it up for SURE
thanks @Marmiz
CamperBot
@camperbot
Aug 12 2016 03:53
ni234 sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 343 | @marmiz |http://www.freecodecamp.com/marmiz
IsaiahGz
@IsaiahGz
Aug 12 2016 03:53
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
];
@ni234 AH ok thanks
CamperBot
@camperbot
Aug 12 2016 03:54
isaiahgz sends brownie points to @ni234 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for ni234
Claudio Restifo
@Marmiz
Aug 12 2016 03:54
@ni234 sorry pressed enter and send the code not finished. Have it a look :)
IsaiahGz
@IsaiahGz
Aug 12 2016 03:54
@silver537 So whats wrong with this?
silver537
@silver537
Aug 12 2016 03:55
@ni234 since youre going to be checking multiple arguments, you would want a case statement since an if/else will be tedious. Test the card variable and if the value is within the range they provide. Increment, or decrement the count variable. At the end, return counts values and the decision; hold/bet. With the rules they provided.
IsaiahGz
@IsaiahGz
Aug 12 2016 03:55
Ill just try it out in the morning, later
silver537
@silver537
Aug 12 2016 03:56
@IsaiahGz gotta separate objects with commas. Youre missing one.
Joseph
@revisualize
Aug 12 2016 04:02
@IsaiahGz You're missing a , [ { ... } , { ... } ]
silver537
@silver537
Aug 12 2016 04:03
Ha youre on the phone too?
Michael
@davidfutch
Aug 12 2016 04:07

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
case 1:
break;

// Only change code above this line
}

// Change this value to test
caseInSwitch(1);

silver537
@silver537
Aug 12 2016 04:08
Yay you can copy and paste! :)
Michael
@davidfutch
Aug 12 2016 04:09
I am getting the following error "syntaxError: Unexpected token case" and I am not sure why. I have looked at the tutorial, but I am seeing the same setup as the examples
silver537
@silver537
Aug 12 2016 04:10
You have to use the switch keyword. switch (val){...}
Theb input your case conditionals inside the braves.
Braces
Michael
@davidfutch
Aug 12 2016 04:12
what is the switch doing? how is it working as a function?
silver537
@silver537
Aug 12 2016 04:14
The switch is the checker. Says "alright what do we have inside this val variable." And then it brings up some cases you input. "Oh this val variable is exactly 1, and not 'one'. Im gonna assign answer to 'alpha'. "
silver537
@silver537
Aug 12 2016 04:19
@davidfutch this is how it's always written and you cant do anything about it:
switch(variable){
case 1:
// do something here
break;
case 2:
//do something here
break
default://optional
//do something here
}
kelearning
@kelearning
Aug 12 2016 04:25
i am new
silver537
@silver537
Aug 12 2016 04:30
Hi new im silver
@LunyAlex
Aug 12 2016 04:32

if (tempArr.indexOf(arr[1][j] == -1) )

Does this translate to: As long as arr[1][j] doesn't exist in tempArr?

Chris Cullen
@123xylem
Aug 12 2016 04:33
function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;

for(var prop in arr){//go through props in array

var speed= Math.round(2 * Math.PI * Math.sqrt(Math.pow(arr[prop].avgAlt + earthRadius, 3) / GM));  //forumala for orbital period

arr[prop].avgAlt =arr[prop].orbitalPeriod; //change avg alt key name to orbital period

arr[prop].orbitalPeriod=speed; //change key value to the orbital period.

return arr;} //return it all as the answer.
}

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
Why does this return [{"name" : "sputnik","orbital period":6400}] ??? IE why does it put the name etc in quote marks... ??? Its stopping me passing the test
Ken Aguilar
@piq9117
Aug 12 2016 04:35
you want the orbital period as output?
silver537
@silver537
Aug 12 2016 04:37
@LunyAlex no... the ==-1 goes outside the indexOf ()
@LunyAlex
Aug 12 2016 04:38
Didn't catch that. Thanks so much!
Can someone post the solution to this challenge please?
I ran that same code through node, repl, and the chrome dev tools
The output is what the page is asking for
:(
silver537
@silver537
Aug 12 2016 04:41
No links please. Use the markdown format and poste the code here.
Yan Kozlovskiy
@YanKozlovskiy
Aug 12 2016 04:42
var myStr = "FirstLine\n\\SecondLine\\\nThirdLine"; // Change this line
The link is much easier to deal with though
silver537
@silver537
Aug 12 2016 04:42
Youre missing the \r
Carriage return
Yan Kozlovskiy
@YanKozlovskiy
Aug 12 2016 04:43
Thanks
Why would we use a carriage return instead of a new line?
silver537
@silver537
Aug 12 2016 04:44
New line is a hard line break. Carriage return is when someone presses the enter key
Yan Kozlovskiy
@YanKozlovskiy
Aug 12 2016 04:44
So why would we use one over the other?
silver537
@silver537
Aug 12 2016 04:45
Yin that challenge you use both. But the machine language interprets one as input and the other as a function.
Theyre both similar in output.
c0d0er
@c0d0er
Aug 12 2016 05:08
Hi, could anybody help me on this? the picture show the correct answer for the challenge, but i do not understand: the "val" of "result=lookup(val)" was not defined at all, why the answer can directly use this val?
Markus Kiili
@Masd925
Aug 12 2016 05:10
@xiaji1 val is the parameter of the function. It will hold the passed argument, for example "charlie", when the function is executed.
@xiaji1 You use the function input stored in the parameter(s) to produce the result (function return value).
c0d0er
@c0d0er
Aug 12 2016 05:11
@Masd925 but val is the parameter of the function phoneticLookup(val), this is not for the new lookup object
Markus Kiili
@Masd925
Aug 12 2016 05:12
@xiaji1 The string stored in the parameter is used as a key when accessing the lookup object.
c0d0er
@c0d0er
Aug 12 2016 05:13
if you look at this example from the challenge, this example defines the val of the new object alpha first, but the lookup object in the challenge did not define lookup(val) at all
silver537
@silver537
Aug 12 2016 05:14
@xiaji1 the variable lookup is an object. so how do we access object properties?
Markus Kiili
@Masd925
Aug 12 2016 05:15
@xiaji1 In the example the object is accessed with a variable value. Here it is accessed with the function parameter.
silver537
@silver537
Aug 12 2016 05:17
@xiaji1 the dot operator access direct property names. lookup.alpha is = to "Adams" right?
c0d0er
@c0d0er
Aug 12 2016 05:17
yes
silver537
@silver537
Aug 12 2016 05:18
@xiaji1 the downside, we cant use variables in dot notation. lookup.val <--- bad syntax
Taylor
Aug 12 2016 05:19
hi all, I'm working on the "sum all odd fibonacci numbers" challenge and I guess what I'm writing keeps crashing my browser. It's not warning me about infinite loops, and I'm pretty sure I didn't create any infinite loops... got any suggestions?
silver537
@silver537
Aug 12 2016 05:19
because like i said before, the dot operater accesses the direct property name. so in this case, lookup.val val does not exist as a property in the object lookup
Markus Kiili
@Masd925
Aug 12 2016 05:19
@admiraltaylor Post the code here and we can check if there is an infinite loop.
silver537
@silver537
Aug 12 2016 05:20
val is only a place holder for the actual value. which in this case is charlie
c0d0er
@c0d0er
Aug 12 2016 05:20
@silver537 lookup.val is bad syntax because val is not defined in lookup object, but i dont understand what lookup(val) mean?
silver537
@silver537
Aug 12 2016 05:20
hold on im getting there :P
Taylor
Aug 12 2016 05:22

function sumFibs(num) {
var fibs=[];
fibs[0]=1;
fibs[1]=1;
for (var i=2; i<num; i++){
fibs[i]=fibs[i-1]+fibs[i-2];
}
return fibs;
}

sumFibs(4);
silver537
@silver537
Aug 12 2016 05:22
the bracket notation converts any variable or string format as the respective property
@xiaji1
scnetsec
@ni234
Aug 12 2016 05:23
Can someone please help me damnit. I know im close. Im thinking maybe im not using Console.log to output ... idk
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';

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";
break;
}
}
silver537
@silver537
Aug 12 2016 05:23
@xiaji1
so if val = 'charlie' then lookup[val] = lookup['charlie'] = lookup.charlie
c0d0er
@c0d0er
Aug 12 2016 05:23
@silver537 you mean e.g. alpha[value]; // "Y" in the example picture?
scnetsec
@ni234
Aug 12 2016 05:24
Or i dont know if im supposed to be counting or something?

Markus Kiili
@Masd925
Aug 12 2016 05:24
@admiraltaylor You are correct. No infinite loop there.
silver537
@silver537
Aug 12 2016 05:24
@xiaji1 yes exactly
c0d0er
@c0d0er
Aug 12 2016 05:25
@silver537 but here is not lookap[val] but lookup(val)
sorry i was wrong
here is lookup[val]
Taylor
Aug 12 2016 05:25
@ni234 hey! instead of making those cases produce "-1 hold" or something, make them add +5 or -1 or whatever to a variable called "counter" or something. Then in a separate part of your code, say "if score>5" or whatever, "return score + bet" or something
Markus Kiili
@Masd925
Aug 12 2016 05:25
@ni234 Check card and change count accordingly. Then after switch, figure out return value from count, not card.
Taylor
Aug 12 2016 05:25
@Masd925 thanks! Tjat
CamperBot
@camperbot
Aug 12 2016 05:25
:star2: 2279 | @masd925 |http://www.freecodecamp.com/masd925
admiraltaylor sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
silver537
@silver537
Aug 12 2016 05:26
exactly. @xiaji1 because val can be anything. its meant so that the user can lookup the properties. you're just providing the environment.
Taylor
Aug 12 2016 05:26
@Masd925 that's what I thought. I guess I'll... try in another browser? don't know what else to do
... ok crashed chrome as well
this is troublign
c0d0er
@c0d0er
Aug 12 2016 05:26
@silver537 can val in lookup(val) change to any e.g. alpha or bravo or charlie or delta? why val can do this? or this is only the rule?
Markus Kiili
@Masd925
Aug 12 2016 05:26
@admiraltaylor You can also try clearing the browser cache. There was some help file on the camperbot about it.
help browser
CamperBot
@camperbot
Aug 12 2016 05:27

# Store data in web browser's storage

In order to manage data handled by your web application, you do not necessarily need a database. The respective Browser Storage features are supported by Chrome (version 4 and higher), Mozilla Firefox (version 3.5 and higher) and Internet Explorer (version 8 and higher), and a range of other browsers including those of iOS and Android.

There are two main possibilities for browser storage:

silver537
@silver537
Aug 12 2016 05:27
@xiaji1 so basically if your code is correct and if it was combined with html and css. i can go to your website look at the list, and checkout anything i want without the site crashing.
scnetsec
@ni234
Aug 12 2016 05:27
ok t
Taylor
Aug 12 2016 05:27
Thank you, I've actually cleared it several times.. when it crashes it won't re-load freeCodeCamp until i clear it
scnetsec
@ni234
Aug 12 2016 05:27
ok @admiraltaylor should I use console.log or return?
silver537
@silver537
Aug 12 2016 05:28
@xiaji1 because val is the variable. it can change depending on the argument. phoneticLookup("charlie")
which calls the function phoneticLookup(val) where val is "charlie"
c0d0er
@c0d0er
Aug 12 2016 05:29
@silver537 why val can change to anything? is this a rule? if no function phoneticLookup(val) , could i still use lookup(val) with out any val definition e.g. var value =2?
Taylor
Aug 12 2016 05:29
looks like it crashes internet explorer too. Does any of you dare try it on yours?
@ni234 doesn't matter?
silver537
@silver537
Aug 12 2016 05:30
@xiaji1 first, you can't use parenthesis. it has to be square brackets [ ]
c0d0er
@c0d0er
Aug 12 2016 05:30
sorry, i got wrong, must be lookup[val]!
silver537
@silver537
Aug 12 2016 05:30
second, 2 is not a property in the lookup object. so it will return undefined.
luis4flames
@luis4flames
Aug 12 2016 05:31
'' <font-size> ''
c0d0er
@c0d0er
Aug 12 2016 05:31
silver537
@silver537
Aug 12 2016 05:32
oh in the example pic. lol then yea!
c0d0er
@c0d0er
Aug 12 2016 05:32
2 is a property from the challenge example
luis4flames
@luis4flames
Aug 12 2016 05:32

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

function checkObj(checkProp) {
// Your Code Here

if ( myObj.hasOwnProperty("checkProp") === true) {
return myObj[checkProp];
} else {
}

}

// Test your code by modifying these values
checkObj("house"); ANYONE KNOW WHY MY IF STATEMENT WONT RETURN WHEN ITS TRUE

Markus Kiili
@Masd925
Aug 12 2016 05:32
@xiaji1 When the function is called, the engine forms an execution context for the function execution and there the function parameters are variables that have the passed arguments as values. Then the function code is run. Therefore if you call phoneticLookup("charlie"), there will be a variable val with value "charlie" when the code is run.
silver537
@silver537
Aug 12 2016 05:33
@xiaji1 just like when value = 1;... alpha[value] will return 'z'
@luis4flames because you used quotes in your check prop.
checkProp is a variable not a string.
luis4flames
@luis4flames
Aug 12 2016 05:34
@silver537 ahhhh right... Thanks!!!!
CamperBot
@camperbot
Aug 12 2016 05:34
luis4flames sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 480 | @silver537 |http://www.freecodecamp.com/silver537
c0d0er
@c0d0er
Aug 12 2016 05:34
@silver537 @Masd925 so in this challenge, the val of result=lookup[val] is 100% equal to function phoneticLookup(val), and this val can be anything in this function because this val is a variable?
silver537
@silver537
Aug 12 2016 05:35
@xiaji1 YES
c0d0er
@c0d0er
Aug 12 2016 05:36
so if function phoneticLookup(val) change to function phoneticLookup(team), do the solution result=lookup[val] in the challenge must be changed to result=lookup[team]? @silver537 @Masd925
silver537
@silver537
Aug 12 2016 05:37
@xiaji1 YES!
c0d0er
@c0d0er
Aug 12 2016 05:40
@silver537 @Masd925 one think i still dont understand is: why lookup object can use phoneticLookup's val? is this only because lookup object is in the function phoneticLookup(val) {}?
silver537
@silver537
Aug 12 2016 05:40
@xiaji1 YES! lol. you're getting it dude. keep asking!
manusia123
@manusia123
Aug 12 2016 05:42
'''js
CamperBot
@camperbot
Aug 12 2016 05:42
:bulb: to format code use backticks!  more info
Markus Kiili
@Masd925
Aug 12 2016 05:42
@xiaji1 When the function is called, the function parameter val is a variable that holds the passed argument. On the next call, the value might be something different.
manusia123
@manusia123
Aug 12 2016 05:42
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"]
}
];
how to get the first name using a function ?
c0d0er
@c0d0er
Aug 12 2016 05:44
so the val of function phoneticLookup(val) does not need to be defined as a variable in the {} e.g. var val=???, the javascript automatically defines the val as a variable, and this variable val can be directly used in any new object in the function phoneticLookup(val), is this correct?
@silver537 @Masd925 so the val of function phoneticLookup(val) does not need to be defined as a variable in the {} e.g. var val=???, the javascript automatically defines the val as a variable, and this variable val can be directly used in any new object in the function phoneticLookup(val), is this correct?
Taylor
Aug 12 2016 05:44
@Masd925 have you already completed the fibonacci sequence challenge, and if so, do you mind if I see the way you did it? I was told the problem is that one of the test cases is 4,000,000 , and running it that many times is what crashes my browser -_-
Markus Kiili
@Masd925
Aug 12 2016 05:45
@xiaji1 When the engine makes the execution context for the function call, it automatically makes the variables that hold the arguments, so no need to make them yourselves.
silver537
@silver537
Aug 12 2016 05:45
@xiaji1 yes. parameters are predefined variables in respect to its argument.
c0d0er
@c0d0er
Aug 12 2016 05:46
@silver537 @Masd925 i got it completely, HUGE HELP! I really appreciate! THANKS!
CamperBot
@camperbot
Aug 12 2016 05:46
xiaji1 sends brownie points to @silver537 and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 481 | @silver537 |http://www.freecodecamp.com/silver537
:star2: 2280 | @masd925 |http://www.freecodecamp.com/masd925
silver537
@silver537
Aug 12 2016 05:47
@xiaji1 if you do var val = ??? you will override the predefined variable val which is a baaaaad thing
Ken Aguilar
@piq9117
Aug 12 2016 05:47
@manusia123
const firstName = contacts.map(name => name.firstName);
silver537
@silver537
Aug 12 2016 05:47
@xiaji1 anytime man. keep up the coding.
c0d0er
@c0d0er
Aug 12 2016 05:47
:smile: thanks for the bonus learning! @silver537
CamperBot
@camperbot
Aug 12 2016 05:47
xiaji1 sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:warning: xiaji1 already gave silver537 points
silver537
@silver537
Aug 12 2016 05:48
@manusia123 you have to parse this into an actual object. since the object is in json format.
Markus Kiili
@Masd925
Aug 12 2016 05:49
@admiraltaylor One of my solutions is the same as yours but without the array. Just generated a couple of variables and a while loop that generates the next fibo and calculates the sum on the fly. When there is no array that stores the fibos, the code uses much less resources.
Ken Aguilar
@piq9117
Aug 12 2016 05:50
@manusia123 you can also use ramda.
const getFirstName = name => name.firstName;
const firstName = R.map(getFirstName, contacts);
Markus Kiili
@Masd925
Aug 12 2016 05:52
@silver537 contacts is an JS object (array) generated by JS object literal. No parsing needed.
If it was a string holding JSON, parsing would be needed.
Ken Aguilar
@piq9117
Aug 12 2016 05:53
its just a list of objects.. map a function on it and your done..
Markus Kiili
@Masd925
Aug 12 2016 05:54
@manusia123 You need to loop the contacts array and then check the first name of the looped object.
silver537
@silver537
Aug 12 2016 05:55
@Masd925 im not a fan of objects anyway. lol
Ken Aguilar
@piq9117
Aug 12 2016 05:55
I have personally stopped using for loops for a long time..
silver537
@silver537
Aug 12 2016 05:58
especially since most array methods are integrated with a loop.
Rony Vidaur
@RonyVidaur
Aug 12 2016 05:58
@manusia123 do you have that contacts object inside of a function?
Markus Kiili
@Masd925
Aug 12 2016 05:59
@RonyVidaur It is the Profile lookup challenge
silver537
@silver537
Aug 12 2016 05:59
@piq9117 but dude with all due respect, don't input straight solutions in code. you risk them having to copy and paste. they wont learn like that.
Ken Aguilar
@piq9117
Aug 12 2016 05:59
oh.. im sorry
i thought his problem wasnt related to any challenge
DJ
@qualitymanifest
Aug 12 2016 06:00
there's nothing wrong with for loops. but yeah some people overuse them, big time, when there is a better way of accomplishing what they're trying to do
silver537
@silver537
Aug 12 2016 06:00
in any case, they can search the answer with google, we like to advocate a learning environment. it's why FCC is one of the top resources.
Ken Aguilar
@piq9117
Aug 12 2016 06:01
yeah.. i have nothing against them.. i just get confused when i read them.. for loops are marginally faster than recursion but recursion is a lot more readable, at least for me..
@silver537 got it! :thumbsup:
manusia123
@manusia123
Aug 12 2016 06:02
@piq9117 the code said its need es6 or use mozzila extension etc etc.... @silver537 i don't know how to do it, i feel really stupid here @Masd925 i will try it @RonyVidaur no
Ken Aguilar
@piq9117
Aug 12 2016 06:03
yeah.. the code i gave you was es6.. is it complaining about it?
do you know how map functions work?
silver537
@silver537
Aug 12 2016 06:03
this recursion made me understand recursion. lol:
gcd=(x, y)=>{return (y===0)? x : gcd(y, x % y);}
Rony Vidaur
@RonyVidaur
Aug 12 2016 06:03
@manusia123 can you send a link to the challenge or something just to have a little bit of context?
Markus Kiili
@Masd925
Aug 12 2016 06:04
@manusia123 You can also just make a simple for loop through contacts array.
manusia123
@manusia123
Aug 12 2016 06:04
@RonyVidaur its from basic java script challenge called profile lookup
Ken Aguilar
@piq9117
Aug 12 2016 06:04
they way I understand is just is like this. "keep calling the function until it has satisfied a condition"
manusia123
@manusia123
Aug 12 2016 06:05
@manusia123 yeah i am trying it now, don't know how long though
silver537
@silver537
Aug 12 2016 06:05
hmm that makes more sense. and when it satisfies the condition, return the satisfaction. lol
Rony Vidaur
@RonyVidaur
Aug 12 2016 06:05
@manusia123 yeah then you don't want to implement any solution with ES6, rather than help you it will make things really unclear
silver537
@silver537
Aug 12 2016 06:05
@manusia123 which website are you on?
Ken Aguilar
@piq9117
Aug 12 2016 06:06
function somefn (x) {
if (this has been satisfied) return the condition I want;
else return somefn(x);
}
manusia123
@manusia123
Aug 12 2016 06:06
@silver537 freecodecamp ?
Ken Aguilar
@piq9117
Aug 12 2016 06:07
:joy:
silver537
@silver537
Aug 12 2016 06:07
lmao
@manusia123 there's no java challenges 0.o but now i think you meant javascript.
@manusia123 OOOOOOHHHHHH i didn't see script!!! :joy: :joy: :joy: :joy: :joy:
manusia123
@manusia123
Aug 12 2016 06:08
@silver537 hoho
Faisal Zulfiqar
@faisal1337
Aug 12 2016 06:08
http://codepen.io/faisal1337/pen/bZONag I'm trying to make this 'Hero' area responsive. I have a border around the heading and it breaks when the screen size is shrinked. If anyone could help me make it responsive, that'd be a great help :)
Luke
@lukede
Aug 12 2016 06:09

I'm on the seek and destroy challenge. I have gotten the filter to work on two filter parameters, but I'm struggling to make it dynamic (so it could do three or more parameters:


function destroyer(arr) {
// Remove all the values
var a = arguments[1];
var b = arguments[2];

var f = arr.filter(function(value){
for (i=1;i<arr.length; i++){
return value!==arguments[i];
}
//return value!== a && value!== b;
});
return f;
}

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

I was thinking this could be done with a for loop, using the for loop counter to iterate through the parameters.

I'm still not sure if I need a loop, because I read with filter that it automatically loops through an array. So perhaps it loops through the object arguments as well?
Markus Kiili
@Masd925
Aug 12 2016 06:11
@lukede You can store arguments on a variable and loop it inside the callback.
Rony Vidaur
@RonyVidaur
Aug 12 2016 06:12
@faisal1337 what if you nest your text within a div and instead of applying the border to the text itself you apply it to the div element
Markus Kiili
@Masd925
Aug 12 2016 06:12
@lukede Another way is to turn arguments into an array and use indexOf inside the callback.
silver537
@silver537
Aug 12 2016 06:13
@lukede are you familiar with es6 syntax? they came up with the "rest operator" function destroyer(...arr) this splits any argument into an array initially.
Faisal Zulfiqar
@faisal1337
Aug 12 2016 06:13
@RonyVidaur lemme try that.
silver537
@silver537
Aug 12 2016 06:14
that way, you don't have to keep declaring a variable for every argument being passed. all you have to do is declare the testing argument into the variable which is the first one. and work on that while iterating through the rest of the arguments.
Rony Vidaur
@RonyVidaur
Aug 12 2016 06:14
@faisal1337 alright, let me know if it works
Faisal Zulfiqar
@faisal1337
Aug 12 2016 06:17
@RonyVidaur the border doesn't break now. But it doesn't look good either :/ Upon making the screen size smaller it becomes a big box with a single word on each line :/
How can I make it look similar but smaller in size? Some bootstrap grid magic?
Rony Vidaur
@RonyVidaur
Aug 12 2016 06:19
@faisal1337 oh I get you, so you want the text to kinda scale down as the screen does
Faisal Zulfiqar
@faisal1337
Aug 12 2016 06:21
@RonyVidaur exactly
@RonyVidaur I think the problem is with the text size not shrinking down with the screen.
Rony Vidaur
@RonyVidaur
Aug 12 2016 06:22
@faisal1337 yeah it's not doing it, well Im not an expert on bootstrap or CSS but i've read about media queries
also heres some info
Aug 12 2016 06:23
anyone working on Arguments Optional?
silver537
@silver537
Aug 12 2016 06:23
@faisal1337 you can create another style sheet and modulate it so when the screen reaches a certain size, the specific stylesheet activates.
Markus Kiili
@Masd925
Aug 12 2016 06:24
@ahmadabdolsaheb Do you have a problem with it?
Aug 12 2016 06:24
kindda, I was wondering if anyone wants to pair
Ken Aguilar
@piq9117
Aug 12 2016 06:26
what's arguments optional? a challenge? sorry.. i just started freecodecamp..
Markus Kiili
@Masd925
Aug 12 2016 06:27
@piq9117 One tougher challenge that involves closures and higher order function.
Faisal Zulfiqar
@faisal1337
Aug 12 2016 06:27
@RonyVidaur @silver537 I've tried using media queries. I was using blisk to check the output on various devices. And seriously it gets very difficult to handle the size on every screen size :/
Whats the other way of specifying the font-size?
Ken Aguilar
@piq9117
Aug 12 2016 06:28
nice.. i dont think i can pair up @ahmadabdolsaheb but i can help you out..
Rony Vidaur
@RonyVidaur
Aug 12 2016 06:29
@faisal1337 you can do it aparently using vw instead of px or em for your typography can do it too
Markus Kiili
@Masd925
Aug 12 2016 06:30
@ahmadabdolsaheb Do you wan't one tip that doesn't spoil anything?
silver537
@silver537
Aug 12 2016 06:30
there are only few sizes to maintain. all you have to do is copy and paste your code to a new css file and change what you want.
Rony Vidaur
@RonyVidaur
Aug 12 2016 06:30
@silver537 the only issue is that he's working on codepen tho
Faisal Zulfiqar
@faisal1337
Aug 12 2016 06:31
@RonyVidaur no I placed the code of hero area on code pen to ask for suggestions.
Ken Aguilar
@piq9117
Aug 12 2016 06:31
does codepen run transpiled code?
Faisal Zulfiqar
@faisal1337
Aug 12 2016 06:31
I have the code on html files.
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 06:32
Are regexp back references a standard thing? Should I avoid using them.
Rony Vidaur
@RonyVidaur
Aug 12 2016 06:32
@piq9117 yes it does you just need to choose the features that you want
Aug 12 2016 06:32
@Masd925 yes, pls. That's what i am thinking tho.
function addTogether(first, second) {

if (second === undefined){
return function displayName(num) {return num + first;};
}
else
return first+ second;
}

addTogether(2, "3");
Faisal Zulfiqar
@faisal1337
Aug 12 2016 06:32
@silver537 @RonyVidaur tell me how to center a div. Placing in a row and then giving it columns like col-md-4 and then giving col-md-offset-3 works sometimes. But sometimes it doesn't center them.
Broozius
@Brucius
Aug 12 2016 06:32
hi guys
Rony Vidaur
@RonyVidaur
Aug 12 2016 06:33
@faisal1337 try the class center-block
Broozius
@Brucius
Aug 12 2016 06:33
is there a difference between json and jsonp?
Faisal Zulfiqar
@faisal1337
Aug 12 2016 06:33
Alright.
Broozius
@Brucius
Aug 12 2016 06:33
api calling is tough
:/
Markus Kiili
@Masd925
Aug 12 2016 06:33
@ahmadabdolsaheb You should use typeof check on the parameters to check for validity.
Ken Aguilar
@piq9117
Aug 12 2016 06:33
use the new es6 fetch api
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 06:33
I was doing Spinal Tap Case. Only problem is to replace xX with 'x'space'X'. Googled an found a solution with backref
silver537
@silver537
Aug 12 2016 06:33
@faisal1337 can't help you there. im not familiar with bootstrap. i do mine the old fashioned way.
Broozius
@Brucius
Aug 12 2016 06:34
is anyone at random quote generator stage?
Markus Kiili
@Masd925
Aug 12 2016 06:34
@ahmadabdolsaheb You should not add parameters to the function. It is cheating ;)
Faisal Zulfiqar
@faisal1337
Aug 12 2016 06:35
Alright.
Ken Aguilar
@piq9117
Aug 12 2016 06:35
@ahmadabdolsaheb your data needs to be number type..
Markus Kiili
@Masd925
Aug 12 2016 06:35
@ahmadabdolsaheb Remember that JS functions return undefined by default, so you can just make two positive tests for one and two valid arguments, and forget about returning undefined.
Aug 12 2016 06:36
@Masd925 @piq9117 ok let me try that and come back to you guys
Ken Aguilar
@piq9117
Aug 12 2016 06:36
:thumbsup:
Xiao Yang
@xiaopow
Aug 12 2016 06:36
Hey guys, we are on www.codeforx.com right now to help answer javascript questions. Remember to tag FreeCodeCamp so other campers can find your questions.
silver537
@silver537
Aug 12 2016 06:37
@BenjamWondafrash you can try replace second argument syntax. the dollar sign.
Ken Aguilar
@piq9117
Aug 12 2016 06:37
yo! @Masd925 youre from helsinki? isnt that where Linus was from?
Markus Kiili
@Masd925
Aug 12 2016 06:37
@piq9117 Yes :)
Ken Aguilar
@piq9117
Aug 12 2016 06:37
niceeee.....
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 06:38
@silver537 Dollar sign is the back reference if i understood correctly. W3C is not listing it in their Regexp reference...
@Masd925 I thought Linus was from Espoo
h503031807
@h503031807
Aug 12 2016 06:40
?
silver537
@silver537
Aug 12 2016 06:40
@BenjamWondafrash i think that's the point of the challenge. is to get you acquainted with it. replace(([a-z])([A-Z]), "$1-$2")
SHREYA GUPTA
@shreyag020
Aug 12 2016 06:41
anyone know angularJs
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 06:41
@silver537 Why on earth is W3C missing that completely?
SHREYA GUPTA
@shreyag020
Aug 12 2016 06:41

I am taking date and time from the user input and

<input type="datetime-local" ng-model= "datetime" name="datetime" min="2016-01-01T00:00:00" max="2116-12-31T00:00:00" class="b" required/>
want to appear it in this div <div ng-bind="x.todoTime| date : 'medium'" class="bb"></div> but with the interval of 1000.How should I do it?

Js code:-

var app =angular.module('toDolist', []);
app.controller("toDoCtrl",function($scope,$interval) {
$scope.todoWork = []; $scope.todoAdd = function() {      

$scope.todoWork.push({todoText:$scope.task,todoDesc:$scope.description,todoTime:$scope.datetime,todoPriority:$scope.priority,done:false});$scope.task ='';
$scope.description ='';$scope.datetime ='';
$scope.priority =''; };$interval(function(){
$scope.datetime;; },1000); Markus Kiili @Masd925 Aug 12 2016 06:41 @BenjamWondafrash Helsinki, Espoo... Try to look at that from Texas ;) Benjam Wondafrash @BenjamWondafrash Aug 12 2016 06:41 @silver537 Also, why is there no hint for back reference in FCC? @Masd925 Oh, i think i got confused. I think he studied in Otaniemi or something. Ken Aguilar @piq9117 Aug 12 2016 06:43 @shreyag020 sorry.. but its kinda hard to read the code.. can you edit and format into code? Benjam Wondafrash @BenjamWondafrash Aug 12 2016 06:44 @silver537 So i got the solution by cheating basically. Googled and found a page by rafase282. Full solutions for every challenge... Ken Aguilar @piq9117 Aug 12 2016 06:44 all i know is Linus is from Helsinki, and now spends most of his tim in California silver537 @silver537 Aug 12 2016 06:44 @BenjamWondafrash tsk tsk tsk BAD! lol SHREYA GUPTA @shreyag020 Aug 12 2016 06:44 I am taking date and time from the user input and <input type="datetime-local" ng-model= "datetime" name="datetime" min="2016-01-01T00:00:00" max="2116-12-31T00:00:00" class="b" required/> want to appear it in this div <div ng-bind="x.todoTime| date : 'medium'" class="bb"></div> but with the interval of 1000.How should I do it? Js code:- var app =angular.module('toDolist', []); app.controller("toDoCtrl",function($scope, $interval) {$scope.todoWork = [];

$scope.todoAdd = function() { $scope.todoWork.push({todoText:$scope.task,todoDesc:$scope.description,todoTime:$scope.datetime,todoPriority:$scope.priority,done:false});
$scope.task ='';$scope.description ='';
$scope.datetime ='';$scope.priority ='';
};
$interval(function(){$scope.datetime;;
},1000);

Ken Aguilar
@piq9117
Aug 12 2016 06:45
var app =angular.module('toDolist', []);
app.controller("toDoCtrl",function($scope,$interval) {
$scope.todoWork = [];$scope.todoAdd = function() {
$scope.todoWork.push({ todoText:$scope.task,
todoDesc: $scope.description, todoTime:$scope.datetime,
todoPriority: $scope.priority, done: false });$scope.task ='';
$scope.description ='';$scope.datetime ='';
$scope.priority =''; };$interval(function(){
$scope.datetime; },1000); SHREYA GUPTA @shreyag020 Aug 12 2016 06:45 sorry its appearing in that way Benjam Wondafrash @BenjamWondafrash Aug 12 2016 06:45 @silver537 How was I supposed to find that 1$ if that was the 'meat and potatoes' of this challenge. There was no hints to this.
silver537
@silver537
Aug 12 2016 06:46
@BenjamWondafrash one thing i like about FCC is they help you out, BUT they also expect you to find more information outside the scope of the site. in order to complete some of these challenges, you litereally have to research. which is what universities teach you to do when going for a diploma.
SHREYA GUPTA
@shreyag020
Aug 12 2016 06:46
$interval(function(){$scope.datetime;;
},1000); why should it be $scope.datetime; @piq9117 Benjam Wondafrash @BenjamWondafrash Aug 12 2016 06:47 @silver537 I mean a hint like words "Regexp back reference". That is all I am asking. I googled and found a full solution. Not happy. Tried to find 'regexp add space between letters'. silver537 @silver537 Aug 12 2016 06:49 @BenjamWondafrash the backreference is part of the replace function not a RegEx. replace utilizes the regex object. SHREYA GUPTA @shreyag020 Aug 12 2016 06:49 @piq9117 do you get my mistake silver537 @silver537 Aug 12 2016 06:50 @BenjamWondafrash i use the MDN docs because mozilla basically owns javascript. Ken Aguilar @piq9117 Aug 12 2016 06:50 im still trying to remember angular 1.x James Dimitrakopoulos @JamesDimi Aug 12 2016 06:50 morning guys! :) silver537 @silver537 Aug 12 2016 06:51 @BenjamWondafrash so they are more 'in-depth' with javascript syntax. but they are harder to understand. lol. r2d2 @UsamaHameed Aug 12 2016 06:51 Woah @ahmadabdolsaheb Ken Aguilar @piq9117 Aug 12 2016 06:51 @shreyag020 you want to get time every 1ms? Benjam Wondafrash @BenjamWondafrash Aug 12 2016 06:51 @silver537 I am staring at this MDN String.prototype.replace and still cannot see back reference explained SHREYA GUPTA @shreyag020 Aug 12 2016 06:52 @piq9117 yes silver537 @silver537 Aug 12 2016 06:53 @BenjamWondafrash im not sure its called backreference look at the table "Specifying a string as a parameter" Ken Aguilar @piq9117 Aug 12 2016 06:53 @shreyag020 so youre sure that the user will input a date and time every 1ms? Benjam Wondafrash @BenjamWondafrash Aug 12 2016 06:54 @silver537 FOund one example. They give no name for that$1...
Helenbella
@Helenbella
Aug 12 2016 06:54
can someone explain smallest common multiple for me?
silver537
@silver537
Aug 12 2016 06:54
@BenjamWondafrash after reading that table. scroll down till you hit "Switching words in a string" it's the same concept.
SHREYA GUPTA
@shreyag020
Aug 12 2016 06:54
@piq9117 No user just put it one time I want that to apear in I ms
llamatarianism
@llamatarianism
Aug 12 2016 06:55
@BenjamWondafrash $n means "the nth captured group" here's an example regex: Markus Kiili @Masd925 Aug 12 2016 06:55 @Helenbella You need to find the smallest integer that is evenly dividable by all numbers between the given two numbers. llamatarianism @llamatarianism Aug 12 2016 06:55 /(\d)(\w)(\s)/ it contains 3 capturing groups: (\d)(\w)(\s) silver537 @silver537 Aug 12 2016 06:55 @BenjamWondafrash well the llama has entered the building. he can explain more lol @llamatarianism llamatarianism @llamatarianism Aug 12 2016 06:55 so if I was using String.prototype.replace I could refer to the 1st captured group (the digit) using $1
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 06:55
@silver537 Found it. But this is just a tricky thing to google. Just wish there was a HINT in FCC.
llamatarianism
@llamatarianism
Aug 12 2016 06:56
and the second (the word character) using $2, and the 3rd (the whitespace) as $3
Xiao Yang
@xiaopow
Aug 12 2016 06:56
Hey guys, we are on www.codeforx.com right now to help answer javascript questions. Remember to tag FreeCodeCamp so other campers can find your questions.
llamatarianism
@llamatarianism
Aug 12 2016 06:56
$1, $2 .. $9 also exist as global variables silver537 @silver537 Aug 12 2016 06:57 @BenjamWondafrash trust me, i wish for the same as well. but then again... that is part of the lesson. we have to figure it out for ourselves. even if it takes forever to do it. you don't learn without suffering. llamatarianism @llamatarianism Aug 12 2016 06:57 '1s\n'.match(/(\d)(\w)(\s)/); console.log("(\d) matches", RegExp.$1);
console.log("(\w) matches", RegExp.$2); console.log("(\s) matches", RegExp.$3);
Aug 12 2016 06:58
This message was deleted
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 06:58
@llamatarianism Just did not like the fact that i found full solutions. Would have liked a hint in FCC challenge, so that I could have studied it myself instead of seeing full solution.
r2d2
@UsamaHameed
Aug 12 2016 06:58
I have passed all tests but the last @ahmadabdolsaheb
Mark Todd
@Knochenmark
Aug 12 2016 06:59
@BenjamWondafrash usually, the solutions i find with google are either outdated or horrible :D
Aug 12 2016 06:59
sorry I didn't understand your comment. @ahmadabdolsaheb "You should not add parameters to the function. It is cheating ;)" . you mean I should do it recursively?
Markus Kiili
@Masd925
Aug 12 2016 06:59
@ahmadabdolsaheb You are supposed to use the arguments object.
Mark Todd
@Knochenmark
Aug 12 2016 06:59
@BenjamWondafrash what you need is a general idea how to solve the tasks and you just search for the pieces to get there
@ahmadabdolsaheb in that challenge one part is recursion yes
@ahmadabdolsaheb but be careful for that testcase when the second parameter is an array
Aug 12 2016 07:01
@UsamaHameed good job. I only passed three. typeof [3] is undefined for some reason
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 07:01
@Knochenmark I had both the regexp expressions correct. And one replace correct. The other replace was what i was looking for. Then at the finish line I became a cheater. Like running a marathon and hitchhiking the last 100 meters.
Aug 12 2016 07:02
@Masd925 appreciate it, @Knochenmark let me check it out. I will get back to you soon. :)
r2d2
@UsamaHameed
Aug 12 2016 07:02
@ahmadabdolsaheb I am gonna paste my code here don't look okay? :P
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 07:02
@Knochenmark Maybe i would have found this if I would exercise with regexr?
Aug 12 2016 07:03
that's fine we can do it privately too if you wanna @UsamaHameed
Markus Kiili
@Masd925
Aug 12 2016 07:03
This message was deleted
r2d2
@UsamaHameed
Aug 12 2016 07:04
Hi, I don't get why addTogether(2)([3]) does not pass. My code returns undefined for it
function addTogether() {
var args = Array.prototype.slice.call(arguments);
var check = args.every(function(value) {
if(typeof(value) == "number")
return true;
else
return false;
});
console.log(typeof(args[1]));

if(check) {
if(args.length == 2) {
return args[0] + args[1];
}
else if(args.length == 1) {
return function(a) {
return args[0] + a;
};
}

}
else {
return undefined;
}
}
I mean don't look so that it would not be spoiled for you @ahmadabdolsaheb
silver537
@silver537
Aug 12 2016 07:05
@BenjamWondafrash not necessarily. RegEx is an object, so you'll only have object oriented examples.
but pay attention to the string/array methods that implements RegEx so you can understand more on how to utilize the object.
Mark Todd
@Knochenmark
Aug 12 2016 07:05
@UsamaHameed i think you could change every to some and check for not a number
r2d2
@UsamaHameed
Aug 12 2016 07:06
Oh right, I get it @Knochenmark
Mark Todd
@Knochenmark
Aug 12 2016 07:06
@UsamaHameed second, i might have an idea why
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 07:06
@silver537 I am looking at @llamatarianism example. There Regexp.$1 is that object? Mark Todd @Knochenmark Aug 12 2016 07:06 ill check it r2d2 @UsamaHameed Aug 12 2016 07:07 Okay waiting @Knochenmark Markus Kiili @Masd925 Aug 12 2016 07:07 @UsamaHameed Your every callback has a logical problem. r2d2 @UsamaHameed Aug 12 2016 07:07 Yeah I need a some() ? silver537 @silver537 Aug 12 2016 07:07 @BenjamWondafrash no thats the replace function capture pattern. in RegEx we have something called capture groups these are wrapped in ( ) @BenjamWondafrash everytime you use a capture group, you can control them with the dollar sign $1, $2,$3...... $n Benjam Wondafrash @BenjamWondafrash Aug 12 2016 07:09 @silver537 I meant this example js '1s\n'.match(/(\d)(\w)(\s)/); console.log("(\d) matches", RegExp.$1); console.log("(\w) matches", RegExp.$2); console.log("(\s) matches", RegExp.$3);
'1s\n'.match(/(\d)(\w)(\s)/);
console.log("(\d) matches", RegExp.$1); console.log("(\w) matches", RegExp.$2);
console.log("(\s) matches", RegExp.$3); Mark Todd @Knochenmark Aug 12 2016 07:09 @UsamaHameed thought it was a coercion problem, but that wasnt the case Markus Kiili @Masd925 Aug 12 2016 07:09 This message was deleted @UsamaHameed Sorry, I need to get some coffee and then read your code again ;) r2d2 @UsamaHameed Aug 12 2016 07:10 typeof([3]) returns object. Then why does this not work? :P @Masd925 sure. Wish I could get some coffee too :P silver537 @silver537 Aug 12 2016 07:11 @BenjamWondafrash 1 is (\d) which is$1
s is (\w) which is $2 \n is (\s) which is$3
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 07:11
@silver537 How does the console.log know the capture pattern when there is no variable defined. How can we get that out of RegExp.$1 ? silver537 @silver537 Aug 12 2016 07:12 @BenjamWondafrash the match method. Markus Kiili @Masd925 Aug 12 2016 07:13 @UsamaHameed The ([3]) is passed to the returned function, and you have no check there. Mark Todd @Knochenmark Aug 12 2016 07:13 @UsamaHameed no typeof([3]) == "number" returns false @UsamaHameed here i did the number check like this Benjam Wondafrash @BenjamWondafrash Aug 12 2016 07:13 @silver537 I mean how can console log get it because we are not referring to the string in anyway inside console log? Mark Todd @Knochenmark Aug 12 2016 07:13 var noNumber = args.some(function(num){ return typeof num !== 'number'; }); if(noNumber){ return; } silver537 @silver537 Aug 12 2016 07:14 @BenjamWondafrash holy shit i just took a closer look and understood what he did. console.log(RegExp.$1)
$1 is the variable. or property to the RegEx object. notice the dot notation. oh wow.... RegEx is really powerful. r2d2 @UsamaHameed Aug 12 2016 07:15 If typeof([3]) returns false, should it not go straight to my else statement and return undefined? @Knochenmark @Masd925 Benjam Wondafrash @BenjamWondafrash Aug 12 2016 07:16 @silver537 So the RegExp has some previous matches stored in it? I don't understand how we can get stuff out from something that we did in the first line. Where is it stored, so that we can print it to screen in the following lines... Abis Mal @abisthecodermal Aug 12 2016 07:16 Hey @UsamaHameed. Which challenge? r2d2 @UsamaHameed Aug 12 2016 07:16 @Masd925 dunno why the check is true when the args are 2 and [3]. It should be false really Mark Todd @Knochenmark Aug 12 2016 07:16 @UsamaHameed no because its not in your first set of arguments r2d2 @UsamaHameed Aug 12 2016 07:16 @abisthecodermal quite far ahead :P Arguments optional :P silver537 @silver537 Aug 12 2016 07:16 @BenjamWondafrash dude... sometimes @llamatarianism dishes out some weird ass syntax that takes me a while to understand. Markus Kiili @Masd925 Aug 12 2016 07:16 @UsamaHameed addTogether(2)([3]) only passes one valid argument 2 to addTogether and your function returns the function correctly. You are just not checking the validity of the argument passed into the returned function. Abis Mal @abisthecodermal Aug 12 2016 07:17 just landed on "Sorted Union" llamatarianism @llamatarianism Aug 12 2016 07:17 I can get weirder this ain't even my final form Mark Todd @Knochenmark Aug 12 2016 07:17 @UsamaHameed its going into your else if llamatarianism @llamatarianism Aug 12 2016 07:17 : factorial ( n -- n! ) dup 0 = [ drop 1 ] [ dup 1 - factorial * ] if ; r2d2 @UsamaHameed Aug 12 2016 07:18 Oh so the function call is wrong? And the compiler is only calling addTogether(2)? @abisthecodermal nice. good work. I am free most of the time so I can dedicate a lot of time here I need to place a check in my else if then Benjam Wondafrash @BenjamWondafrash Aug 12 2016 07:19 @llamatarianism Could u clarify this. Does the RegExp object(or is it prototype) hold the previous matches in it? How can u log the results of the match() without referring to any variable? Markus Kiili @Masd925 Aug 12 2016 07:19 @UsamaHameed On addTogether(2)([3]), addTogether is called with argument 2 and it returns a function. That function is called with [3] there. Mark Todd @Knochenmark Aug 12 2016 07:19 return function(b) { return b instanceof Array ? undefined : a+b; }; @UsamaHameed for your return function? :P llamatarianism @llamatarianism Aug 12 2016 07:19 @BenjamWondafrash the first one Yan Kozlovskiy @YanKozlovskiy Aug 12 2016 07:19 how do you kill a process in windows? llamatarianism @llamatarianism Aug 12 2016 07:19 RegExp.$1-9 automatically get set to the previous matches
Yan Kozlovskiy
@YanKozlovskiy
Aug 12 2016 07:20
an application is causing me to not be able to use the computer normally but good thing i can use tab and this chat is running
silver537
@silver537
Aug 12 2016 07:20

@BenjamWondafrash

'1s\n'.match(/(\d)(\w)(\s)/);
console.log("(\d) matches", RegExp.$1); console.log("(\w) matches", RegExp.$2);
console.log("(\s) matches", RegExp.$3); in the first line we initially assign$1, $2,$3 with the order of the capture groups respectively. They're defined automatically as property value for the RegEx object.
we call those values by using the RegEx.$1. and since we have the match() method assigning the value into the$n properties, it will return the repective string match.

r2d2
@UsamaHameed
Aug 12 2016 07:20
So I need a check inside my returned function right? :P
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 07:20
@llamatarianism Isn't scope a huge headache then?
Markus Kiili
@Masd925
Aug 12 2016 07:20
@UsamaHameed Yes.
llamatarianism
@llamatarianism
Aug 12 2016 07:20
pretty much
r2d2
@UsamaHameed
Aug 12 2016 07:20
Ohhhhhh
Mark Todd
@Knochenmark
Aug 12 2016 07:20
@UsamaHameed yeah, feel free to use the ternary, my b is your a and a is your arg[0]
r2d2
@UsamaHameed
Aug 12 2016 07:21
@Knochenmark I don't get this notation return b instanceof Array ? undefined : a+b; :P
Aug 12 2016 07:21
just a simple question: how come the console gives an error that addTogether is not a function?
function addTogether(first, second) {
if(typeof first !== 'number')
console.log("hello");
}
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 07:21
@llamatarianism @silver537 So i would rather store the matches to variables. Those $n are a problem if i cannot keep track of the scopes... Markus Kiili @Masd925 Aug 12 2016 07:22 @UsamaHameed Don't check for arrays. You should only check if the arguments are numbers. llamatarianism @llamatarianism Aug 12 2016 07:22 String.prototype.match returns the matches r2d2 @UsamaHameed Aug 12 2016 07:22 @ahmadabdolsaheb may be you need () with the typeof? Mark Todd @Knochenmark Aug 12 2016 07:22 @UsamaHameed if you want to look it up its called ternary operator. basically its condition ? when condition true : when condition false Benjam Wondafrash @BenjamWondafrash Aug 12 2016 07:23 @llamatarianism @silver537 meant capture patterns. Store those into variables. r2d2 @UsamaHameed Aug 12 2016 07:23 SO it is a fancy if else? @Knochenmark llamatarianism @llamatarianism Aug 12 2016 07:23 same thing Mark Todd @Knochenmark Aug 12 2016 07:23 @UsamaHameed its working analog to single statement if/else r2d2 @UsamaHameed Aug 12 2016 07:23 I have a question guys silver537 @silver537 Aug 12 2016 07:23 @BenjamWondafrash$1 - $9 are already variables. Ahmad Abdolsaheb @ahmadabdolsaheb Aug 12 2016 07:24 @UsamaHameed I dont think so :) r2d2 @UsamaHameed Aug 12 2016 07:24 Why is my last console.log undefined? If it is undefined why don't I pass the last test? :P @ahmadabdolsaheb lol Mark Todd @Knochenmark Aug 12 2016 07:24 @UsamaHameed you didnt pass anything in that console.log silver537 @silver537 Aug 12 2016 07:24 or properties of the object. hmmm. i need to experiment @BenjamWondafrash im telling you dude, @llamatarianism is weird. Benjam Wondafrash @BenjamWondafrash Aug 12 2016 07:24 @llamatarianism why would I use the dollar sign notation then? How can i safely use$1 inside a function? It may hold a pattern from outside a function.
llamatarianism
@llamatarianism
Aug 12 2016 07:25
who knows.
silver537
@silver537
Aug 12 2016 07:25
don't they get overwritten everytime you define a capture group?
llamatarianism
@llamatarianism
Aug 12 2016 07:25
stuff like this is a large part of why I think JS is poorly designed.
too many features that serve essentially no purpose.
silver537
@silver537
Aug 12 2016 07:26
or maybe too many features to be more flexible for those who come from other languages, no?
r2d2
@UsamaHameed
Aug 12 2016 07:26
Oh silly me @Knochenmark
silver537
@silver537
Aug 12 2016 07:26
JS is a loose language for the lazy.
or as you say it, for the eager
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 07:27
@llamatarianism @silver537 I need to study scopes for that RegExp.$1. silver537 @silver537 Aug 12 2016 07:27 @BenjamWondafrash ill be honest, you came up with some damn good questions. llamatarianism @llamatarianism Aug 12 2016 07:27 you realise that what you're saying is "JS is perl" Chris C. @chrisamsterdam1986 Aug 12 2016 07:27 Hello, does anyone here have any experience with typed.js? :) I'm trying to bring it into my portfolio, but it isn't working really well yet ... Would be great to have some help on that topic here :) Markus Kiili @Masd925 Aug 12 2016 07:27 @BenjamWondafrash Don't ask so hard questions, because people will start blaming the language. llamatarianism @llamatarianism Aug 12 2016 07:28 I think most people would not consider that a good thing in JS's defence, that $1 stuff is kinda common for scripting languages
it's a perl thing, and it's also in ruby
it's just that scripting languages are used for a lot more than just scripting nowadays
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 07:28
There is so many quotes here that need to go to T-shirts. Need to start that business anyday now...
silver537
@silver537
Aug 12 2016 07:28
which language was the first to utilize RegEx?
llamatarianism
@llamatarianism
Aug 12 2016 07:29
shrug
I'm pretty sure perl is where modern regexes come from
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 07:29
"JS is perl" and then walk into one of those coding brunches.
Aug 12 2016 07:29
@chrisamsterdam1986 I haven't used that library before; I've used Textillate though. Are you on Codepen or local editor? Are you adding local files or a CDN?
llamatarianism
@llamatarianism
Aug 12 2016 07:29
but I think the idea existed before that
Chris C.
@chrisamsterdam1986
Aug 12 2016 07:29
@Radascript I'm working on a portfolio of my own, and I can't figure out something specific
silver537
@silver537
Aug 12 2016 07:29
@BenjamWondafrash talk about picking fights for no good reason xD
Aug 12 2016 07:30
@UsamaHameed so you got it?
Mark Todd
@Knochenmark
Aug 12 2016 07:30
@BenjamWondafrash danger seeker? :D
Chris C.
@chrisamsterdam1986
Aug 12 2016 07:30
@Radascript so this is my portfolio: http://happiness-design.com/
Markus Kiili
@Masd925
Aug 12 2016 07:30
@BenjamWondafrash A couple of months ago I was in a restaurant called "Goto". They didn't have any t-shirts to sell.
silver537
@silver537
Aug 12 2016 07:30
@llamatarianism more than scripting? how so?
llamatarianism
@llamatarianism
Aug 12 2016 07:30
stuff like $1 is really useful for writing little command line scripts Abis Mal @abisthecodermal Aug 12 2016 07:30 Hey all. A question  function uniteUnique(arr) { return arr; } uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]); returns [1, 3, 2] Why?? llamatarianism @llamatarianism Aug 12 2016 07:31 perl has a crapton of magic variables Benjam Wondafrash @BenjamWondafrash Aug 12 2016 07:31 U would get noticed and maybe get a job. There has to be some rules though. No punching with closed fist, no beard-pulling. llamatarianism @llamatarianism Aug 12 2016 07:31 like $_ and $, and <> and whatever and $1-\$9 are examples of them
but once you start writing actual big programs
Markus Kiili
@Masd925
Aug 12 2016 07:31
@abisthecodermal The function has only one parameter that catches the first passed argument.
llamatarianism
@llamatarianism
Aug 12 2016 07:31
introducing global variables turns out to be a bad idea
r2d2
@UsamaHameed
Aug 12 2016 07:31
Thanks guys passed it @Knochenmark @Masd925
CamperBot
@camperbot
Aug 12 2016 07:31
usamahameed sends brownie points to @knochenmark and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 409 | @knochenmark |http://www.freecodecamp.com/knochenmark
:star2: 2281 | @masd925 |http://www.freecodecamp.com/masd925
silver537
@silver537
Aug 12 2016 07:31
i understand how bad global variable can be.
Benjam Wondafrash
@BenjamWondafrash
Aug 12 2016 07:32
@Masd925 So, we do this. Print them in Estonia and make million €.
r2d2
@UsamaHameed
Aug 12 2016 07:32
Abis Mal
@abisthecodermal
Aug 12 2016 07:32
This is part of "Sorted Union" Challenge. On FCC. Can I modify the function/ @Masd925
Markus Kiili
@Masd925
Aug 12 2016 07:32
@abisthecodermal Use the arguments object.
Aug 12 2016 07:32
@chrisamsterdam1986 oh yeah that's most likely a question for someone with deeper knowledge of the specific library. Good luck.
llamatarianism
@llamatarianism
Aug 12 2016 07:32
Rahul Nayak
@pragyes31
Aug 12 2016 07:32
Hi Guys, I am working on "Repeat a string repeat a string" basic algo challenege. My code is working fine. I just want to know if it can be made smaller maybe by using any of the string or array methods. Here is the code :

Aug 12 2016 07:32
@UsamaHameed cool
r2d2
@UsamaHameed
Aug 12 2016 07:32
@abisthecodermal arr receives only the first argument.
llamatarianism
@llamatarianism
Aug 12 2016 07:32
thankfully very few of these exist in JS
r2d2
@UsamaHameed
Aug 12 2016 07:32
Rahul Nayak
@pragyes31
Aug 12 2016 07:32
function repeatStringNumTimes(str, num) {
// repeat after me
var newStr = str;
if (num <= 0) {
return "";
} else {
for (var i = 1; i < num; i++) {
str += newStr;
}
}
return str;
}

repeatStringNumTimes("abc", 3);
Abis Mal
@abisthecodermal
Aug 12 2016 07:33
damn! Thanks @Masd925
CamperBot
@camperbot
Aug 12 2016 07:33
abisthecodermal sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2282 | @masd925 |http://www.freecodecamp.com/masd925
silver537
@silver537
Aug 12 2016 07:33
lmao FUCK THAT
llamatarianism
@llamatarianism
Aug 12 2016 07:33
perl has a lot of stuff like that
Aug 12 2016 07:33
@chrisamsterdam1986 how did you set up your contact form btw? PHP on the hosting server?
Aug 12 2016 07:33
nah I started from the beginning trying to solve it using a recursive fuction
llamatarianism
@llamatarianism
Aug 12 2016 07:33
perl is the epitome of "do whatever you want"
c0d0er
@c0d0er
Aug 12 2016 07:33
Hi could anybody help me on this? the solution: if(myObj.hasOwnProperty(checkProp)){return myObj[checkProp];}else{return "Not Found";} what is the meaning of (myObj.hasOwnProperty(checkProp))? there is no answer on this one, so i really dont understand why should use if(myObj.hasOwnProperty(checkProp))
silver537
@silver537
Aug 12 2016 07:33
@pragyes31 str.repeat(num)` try that.
r2d2
@UsamaHameed
Aug 12 2016 07:33
You need as many number of receiving variables as the number of arguments in the call or just use the arguments object @abisthecodermal
c0d0er
@c0d0er
Aug 12 2016 07:33
Chris C.
@chrisamsterdam1986
Aug 12 2016 07:33
@Radascript something like that, yeah
c0d0er
@c0d0er
Aug 12 2016 07:33
Hi could anybody help me on this? the solution: if(myObj.hasOwnProperty(checkProp)){return myObj[checkProp];}else{return "Not Found";} what is the meaning of (myObj.hasOwnProperty(checkProp))? there is no answer on this one, so i really dont understand why should use if(myObj.hasOwnProperty(checkProp))