21st
Mar 2017
Dan Couper
@DanCouper
Mar 21 2017 00:00
that's recusive generators ill have you know
Ashraful Islam
@iashraful
Mar 21 2017 00:00
function permAlone(str) {

var perms = [],
tmp = 0;

/* Heap's Algorithm to generate permutations*/
var genPerm = function(len, arr) {

// recursion exit condition
if(len === 1) {
perms.push(arr.join(''));
return arr;
}

for(var i = 0; i < len-1; i++){

genPerm(len-1, arr);

if(len % 2 === 0) {
tmp = arr[i];
arr[i] = arr[len-1];
arr[len-1] = tmp;
} else {
tmp = arr[0];
arr[0] = arr[len-1];
arr[len-1] = tmp;
}

}

genPerm(len-1,arr);
};

genPerm(str.split('').length, str.split(''));

// test for non-repeating char perms
return perms.filter(function(e){
return !/([a-z])\1/.test(e);
}).length;

}

permAlone('aab');
dpugachev
@dpugachev
Mar 21 2017 00:00
is that even more fashionable?
Ashraful Islam
@iashraful
Mar 21 2017 00:00
^ better
where did this weirdness come from?
function permAlone(str) {
const perms = [...permutations([...str])]
return perms.filter(chars => !hasConsecutive(chars)).length
}
my clipboard is polluted may be
Dan Couper
@DanCouper
Mar 21 2017 00:01
You can use the spread function on strings, as they're implement the iterable (?) protocol, so that makes an array of the characters
You can then
Ashraful Islam
@iashraful
Mar 21 2017 00:01
@DanCouper safe till 25000 recursion reached
Dan Couper
@DanCouper
Mar 21 2017 00:01
use the spread function directly on a generator
Haha, yeah, this will blow up
for long words
Prakash Shiwakoti
@pshiwakoti1
Mar 21 2017 00:02
im not sure what you guys are talking about
Ashraful Islam
@iashraful
Mar 21 2017 00:02
@pshiwakoti1 these are hipster talks, don't listen to these
Dan Couper
@DanCouper
Mar 21 2017 00:02
but yeah, you can use spread on the generator function, and it'll give you an array of the retun values, it's nice
dpugachev
@dpugachev
Mar 21 2017 00:03
Prakash Shiwakoti
@pshiwakoti1
Mar 21 2017 00:03
so now what do I do
Ashraful Islam
@iashraful
Mar 21 2017 00:03
what is rest operator?
dpugachev
@dpugachev
Mar 21 2017 00:03
you could copy and paste?
Ashraful Islam
@iashraful
Mar 21 2017 00:03
^ like he said
dpugachev
@dpugachev
Mar 21 2017 00:03
rest, its like [...args] take as many args as you want
Ashraful Islam
@iashraful
Mar 21 2017 00:03
oh
dpugachev
@dpugachev
Mar 21 2017 00:03
I forgot how the resat goes
I'm still new
Ashraful Islam
@iashraful
Mar 21 2017 00:03
Dan Couper
@DanCouper
Mar 21 2017 00:04
ah yeah, sorry
dpugachev
@dpugachev
Mar 21 2017 00:04
they are similiar syntax but different purpose, no?
Dan Couper
@DanCouper
Mar 21 2017 00:04
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:04
Dan Couper
@DanCouper
Mar 21 2017 00:04
they do same thing underneath even though it looks like it's different
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:04
same syntax
one is used in function args
Ashraful Islam
@iashraful
Mar 21 2017 00:04
[,,a,b] = [...abcd]
^ this is rest?
eyesore-
@eyesore-
Mar 21 2017 00:04
Rest in in a function parameters.
Prakash Shiwakoti
@pshiwakoti1
Mar 21 2017 00:04
@iashraful if I remove my regex and filter, it computes permutation of aab as length 6
eyesore-
@eyesore-
Mar 21 2017 00:04
dpugachev
@dpugachev
Mar 21 2017 00:05
eyesore-
@eyesore-
Mar 21 2017 00:05
rest function (a, b, ...args)
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:05
var foo = [1,2,3,4,5];
Ashraful Islam
@iashraful
Mar 21 2017 00:05
... => spread
eyesore-
@eyesore-
Mar 21 2017 00:05
spread [...args]
Ashraful Islam
@iashraful
Mar 21 2017 00:05
what is rest?
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:05
rest is function args
eyesore-
@eyesore-
Mar 21 2017 00:05
rest: function (a, b, ...args)
Ashraful Islam
@iashraful
Mar 21 2017 00:05
ah
Dan Couper
@DanCouper
Mar 21 2017 00:05
@iashraful
> const [a, ...b] = [1,2,3,4]
> a
1
> b
[2,3,4]
dpugachev
@dpugachev
Mar 21 2017 00:05
you don't have to use arguments[n] anymore
Ashraful Islam
@iashraful
Mar 21 2017 00:05
mandatory, and then optionals, I get it now
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:05
^
Ashraful Islam
@iashraful
Mar 21 2017 00:06
must use it somewhere tomorrow and confuse rest of the devs
thanks for teaching this evil trick :D
dpugachev
@dpugachev
Mar 21 2017 00:06
I was wondering why it was called rest, then I figured it means THE rest of the arguments
Dan Couper
@DanCouper
Mar 21 2017 00:06
function* range(max) {
let v = 0;
yield v;
while (v <= max) {
v = v + 1;
yield v;
}
}
> [...range(4)]
[0,1,2,3,4]
Ashraful Islam
@iashraful
Mar 21 2017 00:07
^ generator
Dan Couper
@DanCouper
Mar 21 2017 00:07
sorry, missed critical part there, edited
Ashraful Islam
@iashraful
Mar 21 2017 00:07
why can't I do it like this?
while(v <= max) { yield ++v; } ?
looks more confusing and complex, 10/10 in smart dev book
Dan Couper
@DanCouper
Mar 21 2017 00:08
yeah, that would be shorter, was just being explicit
:)
dpugachev
@dpugachev
Mar 21 2017 00:08
there's a js subset that doesn't use ++
Ashraful Islam
@iashraful
Mar 21 2017 00:08
got it
dpugachev
@dpugachev
Mar 21 2017 00:08
is it jslint?
Brian
@BrianCodes33
Mar 21 2017 00:09
i am confused

function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
for (var i = 0; i < collection.length; i++) {
if (collection[i].hasOwnProperty(source)) {
arr.push(collection[i]);
}
}

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

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:09
lol
that generator code
Ashraful Islam
@iashraful
Mar 21 2017 00:09
what is wrong with it @BrianCodes33 ?
Dan Couper
@DanCouper
Mar 21 2017 00:09
@dpugachev you can specify strictness, js/eslint just let you set rules about what should be treated as an error/what should be a warning when you run it against your code to check
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:09
i thought yield was a sort of return
Dan Couper
@DanCouper
Mar 21 2017 00:10
yup, it is
Ashraful Islam
@iashraful
Mar 21 2017 00:10
Eslint is weird, if you let it loose on jQuery, it'll spam your terminal with == and missing { } warnings
Dan Couper
@DanCouper
Mar 21 2017 00:10
but it doesn't exit the funtion like return
eyesore-
@eyesore-
Mar 21 2017 00:10
If you were to use a more strict writing language generators are usually used.
I.E. Java or Go
Ashraful Islam
@iashraful
Mar 21 2017 00:10
^
Dan Couper
@DanCouper
Mar 21 2017 00:10
Python is the one they basically lifted JS ones from
Brian
@BrianCodes33
Mar 21 2017 00:11
@iashraful its returning an empty array
Ashraful Islam
@iashraful
Mar 21 2017 00:11
never seen generators in Java or Go (to my little knowledge of them)
Dan Couper
@DanCouper
Mar 21 2017 00:11
Go won't have them I don't think, not needed
with Goroutines etc, amazingly easy concurrency
would be unecessary cruft I think
Ashraful Islam
@iashraful
Mar 21 2017 00:11
@BrianCodes33 odd, it seems correct to me
ah, you need to also do some checking
for the given test case, it should also do this
Prakash Shiwakoti
@pshiwakoti1
Mar 21 2017 00:14
@iashraful so what is your suggestions for me?
Ashraful Islam
@iashraful
Mar 21 2017 00:14
instead of collection[I].hasOwnProperty(source) => translates to (for given case => collection[I].hasOwnProperty({lastName: 'capulate' })
which is not correct
@BrianCodes33 it is using wrong method
instead check if source's keys are present in collection
Dan Couper
@DanCouper
Mar 21 2017 00:15
@iashraful Java calls them Iterable, same as C#, Ruby has Enumerator. PHP had them for ages, same as Perl. Haskell everything is a generator. Probably a few more as well
Ashraful Islam
@iashraful
Mar 21 2017 00:15
oh
odd, the syntax difference never caught my eyes
now I see the light
path of enlightenment
Brian
@BrianCodes33
Mar 21 2017 00:15
im not seeing it
Ashraful Islam
@iashraful
Mar 21 2017 00:15
@DanCouper thanks
CamperBot
@camperbot
Mar 21 2017 00:16
iashraful sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
Aaron Fox
@aaronfox
Mar 21 2017 00:16
Hi! In my Wikipedia Viewer I'm getting the Wikipedia snippets from the JSON url like you can see in an easier to view form here: https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=dog&utf8=
However, The snippets are cutting off the beginning descriptions up to the first <span> in the Wikipedia snippet. Would someone mind helping me get the part before the span in the snippets too?
Dan Couper
@DanCouper
Mar 21 2017 00:16
yeah, it took me a while before I clicked generators were just exactly the same as Ruby's Enumerable
Ashraful Islam
@iashraful
Mar 21 2017 00:16
@BrianCodes33 instead of checking if collection hasOwnProperty(source), you need to check if collection.hasOwnProperty(someSourceProp)
I see a double loop here
Roxroy
@roxroy
Mar 21 2017 00:17
@aaronfox , send the link to your code so that I can take a look
Aaron Fox
@aaronfox
Mar 21 2017 00:18
@roxroy https://codepen.io/afox/pen/PpQRGw try to search for dog for example, it will cut off the first five words or so
only in the results who have words before a span in their snippets though
Prakash Shiwakoti
@pshiwakoti1
Mar 21 2017 00:19
anyone please give me suggestions how I can improve
Brian
@BrianCodes33
Mar 21 2017 00:19

function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
for (var i = 0; i < collection.length; i++) {
for (var j = 0; j < source; j++) {
if (collection[i].hasOwnProperty(source[j])) {
arr.push(collection[i]);
}
}
}
return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Ashraful Islam
@iashraful
Mar 21 2017 00:19
:worried:
Prakash Shiwakoti
@pshiwakoti1
Mar 21 2017 00:19
NO REPEATS PLEASE challenge. I posted my code above
Michael Grant Warshowksy
@step48765
Mar 21 2017 00:19
 

Ashraful Islam
@iashraful
Mar 21 2017 00:19
@BrianCodes33 no no
Michael Grant Warshowksy
@step48765
Mar 21 2017 00:20
// Setup
function phoneticLookup(val) {
var result = "";

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

// Change this value to test
phoneticLookup("charlie");
can some one help me
??
Ashraful Islam
@iashraful
Mar 21 2017 00:20
@step48765 holy mango! you are returning the whole lookup table!
Michael Grant Warshowksy
@step48765
Mar 21 2017 00:20
??
Ashraful Islam
@iashraful
Mar 21 2017 00:20
??
@BrianCodes33 wait, I show you the solution
Michael Grant Warshowksy
@step48765
Mar 21 2017 00:21
it needs to be a object look up but idk
Brian
@BrianCodes33
Mar 21 2017 00:21
no solution
Prakash Shiwakoti
@pshiwakoti1
Mar 21 2017 00:21
@iashraful will you please kindly suggest
Aaron Fox
@aaronfox
Mar 21 2017 00:21
@step48765 try using a switch case to find the object
Michael Grant Warshowksy
@step48765
Mar 21 2017 00:21
i cant it needs to be an object
Aaron Fox
@aaronfox
Mar 21 2017 00:21
to find the particular match*
Michael Grant Warshowksy
@step48765
Mar 21 2017 00:21
Using Objects for Lookups
@aaronfox
@iashraful
nvm
 // Setup

function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup = {
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"
};

result = lookup[val];

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

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


 // Setup

function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup = {
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"
};

result = lookup[val];

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

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


mb
Roxroy
@roxroy
Mar 21 2017 00:25
Ashraful Islam
@iashraful
Mar 21 2017 00:25
@BrianCodes33 try this
function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
var props = Object.keys(source);
for(var i = 0; i < collection.length; i++) {
for(var prop in source) {

// check if own property and similar prop in both
if (source.hasOwnProperty(prop) && collection[i].hasOwnProperty(prop)) {

// if prop value matches, store it like there is no tomorrow
if (source[prop] === collection[i][prop]) {
arr.push(collection[i]);
}

}
}
}

// Only change code above this line
return arr;
}
the first loop goes through the whole collection
Brian
@BrianCodes33
Mar 21 2017 00:26
i dont want solution
i dont learn this way
Ashraful Islam
@iashraful
Mar 21 2017 00:26
second loop goes through every keys in the collection and checks if collection has that key, once there is a match, it checks if values are same, if same, store it
Aaron Fox
@aaronfox
Mar 21 2017 00:26
@roxroy ooh okay. Is there an easy way to ignore that span part, or will I have to use something like a regex here?
Ashraful Islam
@iashraful
Mar 21 2017 00:26
^
Dan Couper
@DanCouper
Mar 21 2017 00:27
@step48765 Yup, that's it. result should equal the property with key val in lookup. Lookup is your 'dictionary', and you look for val in it
Ashraful Islam
@iashraful
Mar 21 2017 00:27
@BrianCodes33 it is hard to explain things when there are multiple loops involved
Aaron Fox
@aaronfox
Mar 21 2017 00:27
I know regex on html is a big nono :worried:
Brian
@BrianCodes33
Mar 21 2017 00:27
there is only one loop here
Ashraful Islam
@iashraful
Mar 21 2017 00:27
where?
I see two for loops
I could do a more functional magic, but that'd be more confusing
Brian
@BrianCodes33
Mar 21 2017 00:28
your code is confusing to me
Phuong Nguyen
@neunygph
Mar 21 2017 00:29
Hello
Brian
@BrianCodes33
Mar 21 2017 00:29
Roxroy
@roxroy
Mar 21 2017 00:29
@aaronfox , I think there is a better way. let me checkl
Phuong Nguyen
@neunygph
Mar 21 2017 00:29
Can someone show me how to get and set cache response with JavaScript please?
Ashraful Islam
@iashraful
Mar 21 2017 00:29
@BrianCodes33 here is the fancy version
function whatIsInAName(collection, source) {
// What's in a name?
var props = Object.keys(source);
return collection.filter(function(coll) {
return props.every(function(p) {
return (p in coll && source[p] === coll[p]);
});
});

}
Roxroy
@roxroy
Mar 21 2017 00:30
@neunygph , welcome to the chat.
Brian
@BrianCodes33
Mar 21 2017 00:30
just posting solutions isn’t helping me
Ashraful Islam
@iashraful
Mar 21 2017 00:30
you can also use reduce if you like that
Phuong Nguyen
@neunygph
Mar 21 2017 00:31
@roxroy :smile:
Ashraful Islam
@iashraful
Mar 21 2017 00:31
well, the thing is, source is an object, it has some key:value, you need to check your collection for presence of all of the key:Value in each object of collection, if they are match, you return it @BrianCodes33
{ name: 'Brian' } here key = name, value for key name is Brian
@neunygph what do you mean get and set cache response ?
Brian
@BrianCodes33
Mar 21 2017 00:33
i know that @iashraful but this is irrelevant to solving the algorithm
Ashraful Islam
@iashraful
Mar 21 2017 00:33
:\
so you are saying the instruction is irrelevant to solving the problem
very interesting
Whonoze
@Whonoze
Mar 21 2017 00:34
im so lost idek where to start on this Celsius to fahrenheit calc :(
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:34
whonoze
Whonoze
@Whonoze
Mar 21 2017 00:34
yessir
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:34
Ashraful Islam
@iashraful
Mar 21 2017 00:34
@Whonoze , to calculate Fahrenheit, you multiply the celsius value with 9/5 and add 32
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:34
lets say fereheit
Brian
@BrianCodes33
Mar 21 2017 00:34
@iashraful both of your solutions are not friendly for beginners
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:35
how do you translate it to celsius?
Ashraful Islam
@iashraful
Mar 21 2017 00:35
@BrianCodes33 first one Is very friendly
2nd one is very unfriendly
Kurtgerteisen
@Kurtgerteisen
Mar 21 2017 00:35

can someone help me with "iterate over Arrays with map"? ar oldArray = [1,2,3,4,5];

// Only change code below this line.

var newArray = oldArray;
return val + 3;
});

console.log(oldArray); // returns {1,2,3,4,5}

Brian
@BrianCodes33
Mar 21 2017 00:35
no its not your naming conventions are unfriendly
Ashraful Islam
@iashraful
Mar 21 2017 00:35
oh
yes, naming variables is a long term issue
Keon Samuel
@keonsam
Mar 21 2017 00:36

var count = 0;

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

}
if (count > 0) {
return "Bet";
}
else {
return "Hold";
}
}
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Ashraful Islam
@iashraful
Mar 21 2017 00:36
holy dang!
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:36
post code in back ticks please
Brian
@BrianCodes33
Mar 21 2017 00:36
@iashraful and your code doesn’t even work
Phuong Nguyen
@neunygph
Mar 21 2017 00:36
@iashraful I'm trying to cache a rest API response with JavaScript
Ashraful Islam
@iashraful
Mar 21 2017 00:37
@BrianCodes33 hehe, it shouldn't directly work, otherwise you'd just put it there and say "yeah, just done"
var count = 0;

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

}
if (count > 0) {
return "Bet";
}
else {
return "Hold";
}
}
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Brian
@BrianCodes33
Mar 21 2017 00:37
you are iterating over prop and then have a variable named props. its bad naming convention
Ashraful Islam
@iashraful
Mar 21 2017 00:37
@BrianCodes33 you are welcome to correct the bugs and provide better names
I am open to learning
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:37
his convention is fine lol
Keon Samuel
@keonsam
Mar 21 2017 00:38
@iashraful are we on the same page lol?
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:38
props foreach p
Ashraful Islam
@iashraful
Mar 21 2017 00:38
@neunygph you can store the response in an object
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:38
id do props foreach prop tbh
Keon Samuel
@keonsam
Mar 21 2017 00:38

\var count = 0;

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

}
if (count > 0) {
return "Bet";
}
else {
return "Hold";
}
}
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Ashraful Islam
@iashraful
Mar 21 2017 00:38
@keonsam I just pasted your code in more pleasing format
uff
you beat me
Keon Samuel
@keonsam
Mar 21 2017 00:38
how to do that?
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:38
iashra
Brian
@BrianCodes33
Mar 21 2017 00:38
he is iterating over a temporary variable named prop and has a variable in local scope named props which he never uses
Keon Samuel
@keonsam
Mar 21 2017 00:38
how you do that?
Matthew Pengelly
@mcpengelly
Mar 21 2017 00:38
i think ppl are posting for you to solve their issues
haha
Ashraful Islam
@iashraful
Mar 21 2017 00:39
:worried: eh
I am newbie, don't know js
Roxroy
@roxroy
Mar 21 2017 00:39
@step48765 , i think i got it , give me a few minutes
Keon Samuel
@keonsam
Mar 21 2017 00:39
how did you do that
Ashraful Islam
@iashraful
Mar 21 2017 00:39
teach me
Keon Samuel
@keonsam
Mar 21 2017 00:39
the black thing
Ashraful Islam
@iashraful
Mar 21 2017 00:39
use 3 backticks
Keon Samuel
@keonsam
Mar 21 2017 00:39

\\ var count = 0;

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

}
if (count > 0) {
return "Bet";
}
else {
return "Hold";
}
}
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Ashraful Islam
@iashraful
Mar 21 2017 00:39
if its English keyboard layout, the backpack is on the left side of the key 1 under escape
^
steve
@steveo1975
Mar 21 2017 00:39
hey guys I'm having trouble with the being of javascript :storing values with the assignment operator ; i got this so far var a =7; var b=7; now i need to assign content of a to variable b any help would awesome
Brian
@BrianCodes33
Mar 21 2017 00:40
i appreciate what people do on here but there is a fine line between good programmers and good programming teachers
Ashraful Islam
@iashraful
Mar 21 2017 00:40
@steveo1975 think of vars as boxes, so how would you move content of one box to another
assuming if I do BoxA = BoxB, then all contents of BoxB will move to BoxA
Kurtgerteisen
@Kurtgerteisen
Mar 21 2017 00:40

~~~ar oldArray = [1,2,3,4,5];

// Only change code below this line.

var newArray = oldArray;
return val + 3;
});

console.log(oldArray); // returns {1,2,3,4,5}

Ashraful Islam
@iashraful
Mar 21 2017 00:41
move => copy, not remove from one box and move to another
@BrianCodes33 teach me master, the good programming skills :sparkles:
Brian
@BrianCodes33
Mar 21 2017 00:42
i am a noob.
Ashraful Islam
@iashraful
Mar 21 2017 00:42
I am also n00b, my cup is empty
teach me noob master
:sparkles:
Brian
@BrianCodes33
Mar 21 2017 00:43
i am a bigger noob. i just get irritated when people post solutions. its ok thank you sorry for my frustration
Charles Williams
@cfunkles
Mar 21 2017 00:43
Working on falsy bouncer, I know my problem, NaN !== NaN evaluates false. I don't know how to fix this to get it to be true using my existing way?

function bouncer(arr) {
// Don't show a false ID to this bouncer.
var newBouncerArr = arr.filter(function(val) {

return val !== false && val !== "" && val !== 0 && val !== undefined && val !== null && val !== NaN;
});
return newBouncerArr;

}

bouncer([7, "ate", "", false, 9, 0, undefined, null, NaN]);
Keon Samuel
@keonsam
Mar 21 2017 00:43
I am super bad at this
lol
Kurtgerteisen
@Kurtgerteisen
Mar 21 2017 00:44
^same
Ashraful Islam
@iashraful
Mar 21 2017 00:44
@BrianCodes33 I did most of the learning seeing other people's solution, in long term you need to actually read other people's code(not to mention frequent copy paste from stack overflow posts), so better get used to it
@BrianCodes33 your job is to see why someone posted something like it is and why it works
that's how you learn(or so I did) :D
@keonsam try to use if/else, don't jump to switch if you can
Roxroy
@roxroy
Mar 21 2017 00:45
@aaronfox , you were missing a closing bracket. try this
$(".search-results").append("<br><a href=\"https://en.wikipedia.org/wiki/" + searchObjects[i].title + "\" target=\"_blank\"><div class=\"result\"><div class=\"result-title\">" + entryTitle + "</div><div class=\"result-snippet\">" + resultSnippet + "</div></div></a>"); Keon Samuel @keonsam Mar 21 2017 00:46 if I use if else my code will be so long lol how far are you? Ashraful Islam @iashraful Mar 21 2017 00:46 @aaronfox why do you use escaping? use ' ' for basic strings and use " " inside strings @keonsam use if else wisely Aaron Fox @aaronfox Mar 21 2017 00:46 @iashraful thanks. I'll keep that in mind CamperBot @camperbot Mar 21 2017 00:46 aaronfox sends brownie points to @iashraful :sparkles: :thumbsup: :sparkles: :cookie: 570 | @iashraful |http://www.freecodecamp.com/iashraful Ashraful Islam @iashraful Mar 21 2017 00:47 @aaronfox it is also easier to concatenate a string in multiple lines, keeps sanity Aaron Fox @aaronfox Mar 21 2017 00:47 @SkyCoder01 Yeah my urls were returning the wrong snippets; thanks for pointing me towards generators! CamperBot @camperbot Mar 21 2017 00:47 aaronfox sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles: :cookie: 609 | @skycoder01 |http://www.freecodecamp.com/skycoder01 Richard Kim @richardk88 Mar 21 2017 00:47 function caseInSwitch(val) { var answer = ""; // Only change code below this line switch (val){ case 1: return "alpha"; break; case 2: return "beta"; break; case 3: return "gamma"; break; case 4: return "delta"; break; } // Only change code above this line return answer; } // Change this value to test caseInSwitch(1);  i passed the challenge but i got 4 error marks in the editor and was wondering why. any advice? Roxroy @roxroy Mar 21 2017 00:48 @aaronfox , did it work Ashraful Islam @iashraful Mar 21 2017 00:48 @keonsam what is the problem with your solution? Kurtgerteisen @Kurtgerteisen Mar 21 2017 00:48 @iashraful could you help me with iterate over arrays with map? var oldArray = [1,2,3,4,5]; // Only change code below this line. var newArray = oldArray; var addThree = newArray.map(function(val) { return val + 3; }); console.log(addThree); // returns {4,5,6,7,8} console.log(oldArray); // returns {1,2,3,4,5} Ashraful Islam @iashraful Mar 21 2017 00:48 ^ looks nice very clean and tidy Aaron Fox @aaronfox Mar 21 2017 00:49 @roxroy It helped me me for the future, yes. Thank you! But my main problem right now is that my urls are returning the wrong snippets, so I'm fixing that now CamperBot @camperbot Mar 21 2017 00:49 aaronfox sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles: :cookie: 420 | @roxroy |http://www.freecodecamp.com/roxroy Greg Laux @GRLaux Mar 21 2017 00:49 ' // Setup function phoneticLookup(val) { var result = ""; // Only change code below this line var lookup = { "alpha": "Adams", "bravo": "Boston", "charlie":"Chicago", "delta":"Denver", "echo":"Easy", "foxtrot":"Frank" }; } var result = lookup; // Only change code above this line return result; } // Change this value to test phoneticLookup("charlie");' whoops, sorry Ashraful Islam @iashraful Mar 21 2017 00:50 @GRLaux to access the value from a lookup table, you need to do this lookupTable[termToLookFor] result = lookup => makes your result a lookup table Kurtgerteisen @Kurtgerteisen Mar 21 2017 00:51 @iashraful it says you should add three to each value in the array... did i do this incorrectly? Greg Laux @GRLaux Mar 21 2017 00:51 ah, gotcha, thank you @iashraful CamperBot @camperbot Mar 21 2017 00:51 grlaux sends brownie points to @iashraful :sparkles: :thumbsup: :sparkles: :cookie: 571 | @iashraful |http://www.freecodecamp.com/iashraful Ashraful Islam @iashraful Mar 21 2017 00:51 it seems to be correct @Kurtgerteisen Kurtgerteisen @Kurtgerteisen Mar 21 2017 00:52 @iashraful thats what i thought, but its not accepting it... not really sure what the issue is Ashraful Islam @iashraful Mar 21 2017 00:52 which challenge? link please Kurtgerteisen @Kurtgerteisen Mar 21 2017 00:52 Johnny @JohnnyBizzel Mar 21 2017 00:53 @Kurtgerteisen val += 3 ? Ashraful Islam @iashraful Mar 21 2017 00:54 @JohnnyBizzel no val + 3 is fine @Kurtgerteisen I see your problem you should not make a addThree Kurtgerteisen @Kurtgerteisen Mar 21 2017 00:54 yeah +=3 didnt work Ashraful Islam @iashraful Mar 21 2017 00:54 just make the new array have values with 3 added Johnny @JohnnyBizzel Mar 21 2017 00:54 @iashraful yes? Charles Williams @cfunkles Mar 21 2017 00:55 @Kurtgerteisen I don't think you need to use console.log Ashraful Islam @iashraful Mar 21 2017 00:55 var oldArray = [1,2,3,4,5]; // Only change code below this line. var newArray = oldArray; newArray = newArray.map(function(val) { return val + 3; }); ^ Stephen James @sjames1958gm Mar 21 2017 00:55 @Kurtgerteisen you should set newArray to the result of the map over oldArray - not introduce another variable addThree Ashraful Islam @iashraful Mar 21 2017 00:55 don't make any new arrays and remove console logs Johnny @JohnnyBizzel Mar 21 2017 00:56 @iashraful where is teh function defined? Ashraful Islam @iashraful Mar 21 2017 00:56 @Kurtgerteisen what @sjames1958gm said @JohnnyBizzel no function in that challenge just basic map @Kurtgerteisen you should not make new variables, just use old ones, like newArray and oldArray don't make new ones like addThree Keon Samuel @keonsam Mar 21 2017 00:58 @iashraful what challenge you on? Kurtgerteisen @Kurtgerteisen Mar 21 2017 00:58 @iashraful okay got it thank you very much! CamperBot @camperbot Mar 21 2017 00:58 kurtgerteisen sends brownie points to @iashraful :sparkles: :thumbsup: :sparkles: :cookie: 572 | @iashraful |http://www.freecodecamp.com/iashraful Ashraful Islam @iashraful Mar 21 2017 00:58 @keonsam am on challenge "Confuse all newbies and scare them away from JS" :D Keon Samuel @keonsam Mar 21 2017 00:59 lol that looks like a newbie challenge but the code is too complicated Ashraful Islam @iashraful Mar 21 2017 01:00 :D complicated is fun Keon Samuel @keonsam Mar 21 2017 01:00 don't show off your skills just yet Ashraful Islam @iashraful Mar 21 2017 01:00 if it was easy, no one would pay you to do this stuff, right? Keon Samuel @keonsam Mar 21 2017 01:00 pay me great D Kurtgerteisen @Kurtgerteisen Mar 21 2017 01:01 i dont even know where to start with this one Ashraful Islam @iashraful Mar 21 2017 01:04 @Kurtgerteisen to make something private, declare them inside a function Keon Samuel @keonsam Mar 21 2017 01:05 the person that remembers all these things are super gifted Ashraful Islam @iashraful Mar 21 2017 01:05 var veryPublic = 'Am all open'; function privacy( ) { // anything declared inside a function is private and only available to that function var amPrivate = 'govt. secrets'; }; @keonsam I can access veryPublic from anywhere ^ but amPrivate is only available inside the privacy function Conrad Kay @conradkay Mar 21 2017 01:06 @keonsam troof Keon Samuel @keonsam Mar 21 2017 01:08 all I know is that one is local and is global Saboor Malik @MathematicsCoding Mar 21 2017 01:08 about @iashraful CamperBot @camperbot Mar 21 2017 01:08 :cookie: 572 | @iashraful |http://www.freecodecamp.com/iashraful Charles Williams @cfunkles Mar 21 2017 01:08 should I be concerned the freeCodeCamp challenge I am on is playing something in the background? the page tab shows a audio icon and I am listening to some guy talk about coding? I don't want to exit and loose the problem? Roxroy @roxroy Mar 21 2017 01:09 @iashraful , locally declared variable can only be seen from within the local scope. This help to hide data from other functions Ashraful Islam @iashraful Mar 21 2017 01:10 @keonsam what @roxroy told me ^ about @MathematicsCoding CamperBot @camperbot Mar 21 2017 01:10 :cookie: 220 | @mathematicscoding |http://www.freecodecamp.com/mathematicscoding Cristian @Ccastillo06 Mar 21 2017 01:10 hi! anyone knows why codepen blocks my API calls from openweathermaps? I can't do the project if I can't get the data D: and tried using http, JSON or ajax calling but nothing Kurtgerteisen @Kurtgerteisen Mar 21 2017 01:12 @iashraful im sorry but i still am very unsure what im suppose to do Avinash @avinashreddy24 Mar 21 2017 01:13 // Setup function abTest(a, b) { // Only change code below this line if(a <= 0 && b <= 0 ){ return undefined; } // Only change code above this line else return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2)); } // Change values below to test your code abTest(2,2); Ashraful Islam @iashraful Mar 21 2017 01:13 @Kurtgerteisen I am also not sure how to explain scope to you at this time Avinash @avinashreddy24 Mar 21 2017 01:13 I am trying to solve Return Early Pattern for Functions Saboor Malik @MathematicsCoding Mar 21 2017 01:13 I dont understand with this challenge.... Avinash @avinashreddy24 Mar 21 2017 01:14 I am trying to solve Return Early Pattern for Functions// Setup function abTest(a, b) { // Only change code below this line if(a <= 0 && b <= 0 ){ return undefined; } // Only change code above this line else return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2)); } // Change values below to test your code abTest(2,2); it is showing error Charles Williams @cfunkles Mar 21 2017 01:14 Does anybody think I should report what just happened on the page I was just working on? it randomly started to play an audio lecture in the background!!! Was I hacked? the lecture was mentioning free code camp Avinash @avinashreddy24 Mar 21 2017 01:14 can any one help Stephen Ott @otter37 Mar 21 2017 01:14 @cfunkles try Numbers.isNaN(val) Charles Williams @cfunkles Mar 21 2017 01:15 @otter37 that didn't work I am wonder if I need to make a global function to compare NaN? Ashraful Islam @iashraful Mar 21 2017 01:17 @Ccastillo06 you need to use some kind of tunnel to bypass the cors issue Johnny @JohnnyBizzel Mar 21 2017 01:18 @cfunkles IS that a preview video? Saboor Malik @MathematicsCoding Mar 21 2017 01:18  // Setup var testObj = { 12: "Namath", 16: "Montana", 19: "Unitas" }; // Only change code below this line; var playerNumber = testObj[16]; // Change this Line var player = testObj; // Change this Line @JohnnyBizzel :wave: Johnny @JohnnyBizzel Mar 21 2017 01:18 @MathematicsCoding :wave: ;) Cristian @Ccastillo06 Mar 21 2017 01:19 @iashraful I tried setting the http to crossdomain but didn't work neither D: And if i run the code on my pc it works perfectly @iashraful could you give me some insight please? Keon Samuel @keonsam Mar 21 2017 01:19 tell a subject that is harder than this? lol Saboor Malik @MathematicsCoding Mar 21 2017 01:20  // Setup var testObj = { 12: "Namath", 16: "Montana", 19: "Unitas" }; // Only change code below this line; var playerNumber = 1; // Change this Line var player = testObj[16]; // Change this Line You should be using the variable playerNumber in your bracket notation How? Charles Williams @cfunkles Mar 21 2017 01:20 @JohnnyBizzel I didn't listen to closely, I tried looking for a video playing on the page but couldn't find one Ashraful Islam @iashraful Mar 21 2017 01:21 var playerNumber = 16; var player = testObj[playerNumber]; @MathematicsCoding Johnny @JohnnyBizzel Mar 21 2017 01:21 @cfunkles Strange! Saboor Malik @MathematicsCoding Mar 21 2017 01:21 Oh... Johnny @JohnnyBizzel Mar 21 2017 01:21 @cfunkles Try a different browser! Conrad Kay @conradkay Mar 21 2017 01:21 @conradkay var userOnline = 0; function countOnline(obj) { for (let user in obj) { if (user[online]) { userOnline += 1; } } return userOnline; } console.log(countOnline(users));  ^ i am trying to find the number of people online each user is in a dictionary inside of a larger dictionary which contains the online attribute which is either true or false. Ashraful Islam @iashraful Mar 21 2017 01:21 @cfunkles may be it was some sort of video thingy? Saboor Malik @MathematicsCoding Mar 21 2017 01:21 @iashraful Thanks CamperBot @camperbot Mar 21 2017 01:21 mathematicscoding sends brownie points to @iashraful :sparkles: :thumbsup: :sparkles: :cookie: 573 | @iashraful |http://www.freecodecamp.com/iashraful Charles Williams @cfunkles Mar 21 2017 01:21 @JohnnyBizzel Once I clicked a link and came back the audio was gone Saboor Malik @MathematicsCoding Mar 21 2017 01:21 Helped me understand very clearly Ashraful Islam @iashraful Mar 21 2017 01:22 :\ JDW @jd-wheaton Mar 21 2017 01:22 @cfunkles Did you get Falsy Bouncer working? Ashraful Islam @iashraful Mar 21 2017 01:22 @MathematicsCoding experiment with it, seeing a solution and feeling you understood is bad for learning Charles Williams @cfunkles Mar 21 2017 01:22 the code not yet, the weird audio is gone JDW @jd-wheaton Mar 21 2017 01:23 @cfunkles Your not far off. Make note they included the Boolean Objects as a helpful link. That's what your missing. Charles Williams @cfunkles Mar 21 2017 01:24 @iashraful it's weird that I couldn't find a video, it did kind of sounds like a youTube video blog about web development Ashraful Islam @iashraful Mar 21 2017 01:24 :D may be you caught a glimpse of FCC new beta or something, sounds very interesting Riadh @KWFE Mar 21 2017 01:25 hello, who want to help me in this challenge function nextInLine(arr, item) { // Your code here arr.push(); return nextInLine(); // Change this line } // Test Setup var testArr = [1,2,3,4,5]; // Display Code console.log("Before: " + JSON.stringify(testArr)); console.log(nextInLine(testArr, 6)); // Modify this line to test console.log("After: " + JSON.stringify(testArr)); Charles Williams @cfunkles Mar 21 2017 01:25 @jd-wheaton I'm reading through those, I am trying the isNaN() functions can't figure out the syntax I think JDW @jd-wheaton Mar 21 2017 01:26 You don't need to do the test cases, let the Boolean method do the work. Ashraful Islam @iashraful Mar 21 2017 01:26 @cfunkles use filter with Boolean if you pass any false values to Boolean it'll be falsified for example Boolean(NaN); // => false so if you do it in a loop, it'll pick out all false values best is filter Saboor Malik @MathematicsCoding Mar 21 2017 01:29  // Setup function phoneticLookup(val) { var result = ""; // Only change code below this line switch(val) { case "alpha": result = "Adams"; break; case "bravo": result = "Boston"; break; case "charlie": result = "Chicago"; break; case "delta": result = "Denver"; break; case "echo": result = "Easy"; break; case "foxtrot": result = "Frank"; break; case "": result = undefined; } // Only change code above this line return result; } // Change this value to test phoneticLookup("charlie"); Charles Williams @cfunkles Mar 21 2017 01:29 I'm getting closer Justin Arenas @Samuraitenor Mar 21 2017 01:29 Have some issues with the JS escape sequence... can someone take a look at what I may be doing ? Saboor Malik @MathematicsCoding Mar 21 2017 01:29 It says this challenge doesnt want me to use case, switch, or if statements but lookup statements? Ashraful Islam @iashraful Mar 21 2017 01:29 var x = [0,100,'hello',false,NaN,null, 20.1,undefined].filter(Boolean); console.log(x); // => [100,'hello, 20.1] @cfunkles Charles Williams @cfunkles Mar 21 2017 01:31 @iashraful I did this, and now I'm filtering out my strings isNaN(val) === false that did filter out NaN at least JDW @jd-wheaton Mar 21 2017 01:31 @cfunkles check your private message from me Ashraful Islam @iashraful Mar 21 2017 01:31 why do you need to filter out strings? Charles Williams @cfunkles Mar 21 2017 01:31 I don't want to Ashraful Islam @iashraful Mar 21 2017 01:32 Boolean will return false only, if it is a falsy value Justin Arenas @Samuraitenor Mar 21 2017 01:32 @MathematicsCoding how did you place your code in the thread like that? Saboor Malik @MathematicsCoding Mar 21 2017 01:32 ''' CamperBot @camperbot Mar 21 2017 01:32 :bulb: to format code use backticks!  more info Saboor Malik @MathematicsCoding Mar 21 2017 01:32 Click more info ^^^ ''' code ''' CamperBot @camperbot Mar 21 2017 01:33 :bulb: to format code use backticks!  more info Saboor Malik @MathematicsCoding Mar 21 2017 01:33 Use  instead of ''' Pagnito @Pagnito Mar 21 2017 01:33 why is this na infinite loop? isnt it supposed to loop as long as is less than str string or(var i = 0; i < str.length; i++) { d+=str[i].charCodeAt(); CamperBot @camperbot Mar 21 2017 01:33 :bulb: to format code use backticks!  more info Pagnito @Pagnito Mar 21 2017 01:33 or(var i = 0; i < str.length; i++) { d+=str[i].charCodeAt(); Ashraful Islam @iashraful Mar 21 2017 01:33 @cfunkles can I see what you are trying?(code) ? Charles Williams @cfunkles Mar 21 2017 01:33  function bouncer(arr) { // Don't show a false ID to this bouncer. var newBouncerArr = arr.filter(function(val) { return val !== false && val !== "" && val !== 0 && val !== undefined && val !== null && val !== NaN; }); return newBouncerArr; } bouncer([7, "ate", "", false, 9, 0, undefined, null, NaN]); Ashraful Islam @iashraful Mar 21 2017 01:33 @cfunkles no, that is too extended just use boolean JDW @jd-wheaton Mar 21 2017 01:34 @iashraful I tried to tell him repeatedly. @stephenhuh to let the Boolean method do the work. Ashraful Islam @iashraful Mar 21 2017 01:34 function bouncer(arr) { // Don't show a false ID to this bouncer. var newBouncerArr = arr.filter(function(val) { return Boolean(val); }); return newBouncerArr; } @cfunkles what you are doing in that long line of !== and ===, boolean does it for you JDW @jd-wheaton Mar 21 2017 01:34 function bouncer(arr) { return arr.filter(Boolean); } Ashraful Islam @iashraful Mar 21 2017 01:35 ^ yes shortest Saboor Malik @MathematicsCoding Mar 21 2017 01:35 @iashraful can you help me with this code? Pagnito @Pagnito Mar 21 2017 01:35 why is my loop infinite isnt it supposed end when i reaches length of str for(var i = 0; i < str.length; i++) { d+=str[i].charCodeAt(); Ashraful Islam @iashraful Mar 21 2017 01:35 @Pagnito can I see your whole code? Saboor Malik @MathematicsCoding Mar 21 2017 01:36  // Setup function phoneticLookup(val) { var result = ""; // Only change code below this line switch(val) { case "alpha": result = "Adams"; break; case "bravo": result = "Boston"; break; case "charlie": result = "Chicago"; break; case "delta": result = "Denver"; break; case "echo": result = "Easy"; break; case "foxtrot": result = "Frank"; break; case "": result = undefined; } // Only change code above this line return result; } // Change this value to test phoneticLookup("charlie"); You should not use case, switch, or if statements How do I use lookup statements? Ashraful Islam @iashraful Mar 21 2017 01:36 :worried: Pagnito @Pagnito Mar 21 2017 01:36 @iashraful function rot13(str) { var d = []; var g = []; for(var i = 0; i < str.length; i++) { d+=str[i].charCodeAt(); for(var c = 0; c < d.length; c++) { g.push(Number(d[c]));  }  } } rot13("SERR PBQR PNZC"); Ashraful Islam @iashraful Mar 21 2017 01:36 :worried: Saboor Malik @MathematicsCoding Mar 21 2017 01:37 @iashraful Please? Justin Arenas @Samuraitenor Mar 21 2017 01:37 js var myStr = "FirstLIne\n\SecondLine\\rThirdLine."; // Change this line Saboor Malik @MathematicsCoding Mar 21 2017 01:37 @Samuraitenor ''' code ''' CamperBot @camperbot Mar 21 2017 01:37 :bulb: to format code use backticks!  more info Ashraful Islam @iashraful Mar 21 2017 01:37 function rot13(str) { var d = []; var g = []; for(var i = 0; i < str.length; i++) { d+=str[i].charCodeAt(); for(var c = 0; c < d.length; c++) { g.push(Number(d[c])); } } } rot13("SERR PBQR PNZC"); Saboor Malik @MathematicsCoding Mar 21 2017 01:37 Use  Ashraful Islam @iashraful Mar 21 2017 01:38 @Pagnito it doesn't seem to be an infinite loop it just doesn't return anything may be return g; at the end ? Pagnito @Pagnito Mar 21 2017 01:38 @iashraful why is when i give it alert(g) to see whats in my g array thats hwne it says it Ashraful Islam @iashraful Mar 21 2017 01:38 also, if you declare d as Array, I am not sure why you use It as String @Pagnito try adding this at the end return g; Pagnito @Pagnito Mar 21 2017 01:39 yea but then it stops the loop Ashraful Islam @iashraful Mar 21 2017 01:39 also you need to revert from char code back to string Pagnito @Pagnito Mar 21 2017 01:40 yea im not done with the code but i cant understand why i cant get an array of numbers correctly Ashraful Islam @iashraful Mar 21 2017 01:40 function rot13(str) { var d = []; var g = []; for(var i = 0; i < str.length; i++) { d+=str[i].charCodeAt(); for(var c = 0; c < d.length; c++) { g.push(Number(d[c])); } } return g.map(function(n) { return String.fromCharCode(n); }).join(''); } rot13("SERR PBQR PNZC"); Saboor Malik @MathematicsCoding Mar 21 2017 01:40 God damn it Why isn't someone helping me?! Ashraful Islam @iashraful Mar 21 2017 01:40 @Pagnito see if it works Saboor Malik @MathematicsCoding Mar 21 2017 01:40 Im going to other chat.. More helpful.. Justin Arenas @Samuraitenor Mar 21 2017 01:41  var myStr =" FirstLine \n \\SecondLine\\ \r ThirdLine." Pagnito @Pagnito Mar 21 2017 01:41 @iashraful nah it game some picture of a bunch of red dots Justin Arenas @Samuraitenor Mar 21 2017 01:41 woo finally figured out how to put that damn code in there.... so I'm on that early challenge and for the life of me can't figure out what it isn't correct? Ashraful Islam @iashraful Mar 21 2017 01:41 @Pagnito but still it will not work, because you are regenerating the whole sequence everytime you need to do 1 loop only then map them back to string Pagnito @Pagnito Mar 21 2017 01:42 @iashraful how am i regenerating the whole sequence what do u mean by that Ashraful Islam @iashraful Mar 21 2017 01:42 but if I recall correctly rot13 used different algorithm, may be forward/reverse 13 characters or something d+=str[i].charCodeAt(); Pagnito @Pagnito Mar 21 2017 01:43 so what does that do wrong Ashraful Islam @iashraful Mar 21 2017 01:43 it just keeps on concatenating everything to d but when the 2nd loop is entered, it will generate from beginning everytime something like [1,1,2,1,2,3,1,2,3,4] <== just example, not exactly what is happening in your loop, but similar see how they are repeating Pagnito @Pagnito Mar 21 2017 01:45 oooh Ashraful Islam @iashraful Mar 21 2017 01:45 try to separate the loops Pagnito @Pagnito Mar 21 2017 01:45 i see hold on Ashraful Islam @iashraful Mar 21 2017 01:45 in one loop collect all charCode in d then once that loop is complete use another loop to do other things also, you need to do some mathematics in 2nd loop to move your character by 13 letters on each side Pagnito @Pagnito Mar 21 2017 01:47 @iashraful yea it seems to work that way, im not sure. i try to use alert to let me know if my loop worked and stuff of that sort but when i use alert on my loops it seems to always make them infinite Ashraful Islam @iashraful Mar 21 2017 01:47 yes Pagnito @Pagnito Mar 21 2017 01:47 yea i know i was planning to do that after i turned them into numbers Ashraful Islam @iashraful Mar 21 2017 01:47 there are so many steps don't use alert, use console.log Pagnito @Pagnito Mar 21 2017 01:47 @iashraful do u know why alert does that tho Ashraful Islam @iashraful Mar 21 2017 01:48 there are just too many alerts so it seems they are infinite it grows exponentially, like I said the repeating 1 => 1 alert [1,1,2] = 2 more alerts [1,1,2,1,2,3,] = 3 more alerts and so on Pagnito @Pagnito Mar 21 2017 01:49 hmm i see Ashraful Islam @iashraful Mar 21 2017 01:49 don't use alert, always console.log Charles Williams @cfunkles Mar 21 2017 01:49 I got it to pass with @jd-wheaton code, but I couldn't with @iashraful code. after dinner I'll look more at understanding that method. Anybody think I should report the audio I had in the background or be concerned about security. If it was freeCodeCamp doing something with their beta and I just happened to here I don't care as much. Ashraful Islam @iashraful Mar 21 2017 01:50  function rot13(str) { var d = []; var g = []; for(var i = 0; i < str.length; i++) { d+=str[i].charCodeAt(); for(var c = 0; c < d.length; c++) { g.push(Number(d[c])); } console.log(g); } return g; } rot13("SERR PBQR PNZC"); @cfunkles what method? Pagnito @Pagnito Mar 21 2017 01:51 @iashraful ok will do, thanks for the help. CamperBot @camperbot Mar 21 2017 01:51 pagnito sends brownie points to @iashraful :sparkles: :thumbsup: :sparkles: :cookie: 574 | @iashraful |http://www.freecodecamp.com/iashraful JDW @jd-wheaton Mar 21 2017 01:51 @cfunkles running up to date browser code, patched system, etc.? Ashraful Islam @iashraful Mar 21 2017 01:51 :+1: @jd-wheaton :smile: that was funny JDW @jd-wheaton Mar 21 2017 01:52 @iashraful heh - I think he was referring to the Boolean method, that he nearly recreated himself. Ashraful Islam @iashraful Mar 21 2017 01:53 :\ could be magic JDW @jd-wheaton Mar 21 2017 01:53 @magicsauceFTW # ghostInMachine Saboor Malik @MathematicsCoding Mar 21 2017 01:54 UGH UGH JDW @jd-wheaton Mar 21 2017 01:54 ### ERR Saboor Malik @MathematicsCoding Mar 21 2017 01:54 # ghost!RUN JDW @jd-wheaton Mar 21 2017 01:55 Destroyer function is destroying me I think I need to stop for the night Ashraful Islam @iashraful Mar 21 2017 01:55 browsers often act up, once in early 2015 or 2016, there was someone looking for help, he was confused why this was not working function something(val){ var String = val.toString(); for(var i = 0; I < String.length; i++) { console.log(String.fromCharCode( String[I].charCodeAt(i))); } } ^ dang auto correct, I capitalised :worried: JDW @jd-wheaton Mar 21 2017 01:56 lmao Ashraful Islam @iashraful Mar 21 2017 01:56 I was very confused as to why he decided to overwrite String JDW @jd-wheaton Mar 21 2017 01:56 it must all be a string! <hashtag> Austin Tan @AustinTan Mar 21 2017 01:57 // Setup var a; var b = 2; // Only change code below this line var a = 7, b = 7; var b = 7, b = 7; a should be assigned to b with = what this mean guys? Ashraful Islam @iashraful Mar 21 2017 01:57 ^ literally what it says David Amanze @GodKingShogun Mar 21 2017 01:57 anyone know how i can push an array of numbers into a fromCharCode :smile: JDW @jd-wheaton Mar 21 2017 01:57 @AustinTan means that b = a Ashraful Islam @iashraful Mar 21 2017 01:57 it means a should be equal to b Austin Tan @AustinTan Mar 21 2017 01:57 @jd-wheaton ohhh thanks CamperBot @camperbot Mar 21 2017 01:57 austintan sends brownie points to @jd-wheaton :sparkles: :thumbsup: :sparkles: :cookie: 253 | @jd-wheaton |http://www.freecodecamp.com/jd-wheaton Ashraful Islam @iashraful Mar 21 2017 01:58 @GodKingShogun I think this may work var myStr = arrOfNums.map(String.fromCharCode); but not sure if the 2nd and 3rd argument will mess it up David Amanze @GodKingShogun Mar 21 2017 01:59 @iashraful what do you mean by second and third argument. i only have one array Charles Williams @cfunkles Mar 21 2017 02:00 @iashraful I think I get it now. not method but using Booleon Ashraful Islam @iashraful Mar 21 2017 02:00 Array.map => returns 3 arguments,one element, index of that element, the whole array instance seems to work try it David Amanze @GodKingShogun Mar 21 2017 02:00 @iashraful i feel like i just asked a very sill question but still answer :cry: silly* Avinash @avinashreddy24 Mar 21 2017 02:01 Any clues to solve counting cards any one please Ashraful Islam @iashraful Mar 21 2017 02:02 @GodKingShogun it is like this, when you call map, the function inside map receives one element, the index of that element and also the array David Amanze @GodKingShogun Mar 21 2017 02:02 @avinashreddy24 what do you have so far Charles Williams @cfunkles Mar 21 2017 02:02 @jd-wheaton new Mac, using safari. I think it's up to date? Avinash @avinashreddy24 Mar 21 2017 02:02 @GodKingShogun Ashraful Islam @iashraful Mar 21 2017 02:02 sometimes certain function accept a 2nd argument, like parseInt(num, base), which can cause issues Avinash @avinashreddy24 Mar 21 2017 02:02 var count = 0; function cc(card) { // Only change code below this line if(card>6){ return"Bet"; } else if(card){ return "Hold"; } return "Bet"; // Only change code above this line } @GodKingShogun JDW @jd-wheaton Mar 21 2017 02:02 @cfunkles Ditch Safari, use Chrome or Firefox. Joseph @revisualize Mar 21 2017 02:03 @avinashreddy24 You're trying to return based on the value of the card. You should be returning based on the value of count. @avinashreddy24 Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count. If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count. Then the function will 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. Avinash @avinashreddy24 Mar 21 2017 02:03 ok but how to change the count value Ashraful Islam @iashraful Mar 21 2017 02:03 parseInt(11,8); // base 8 maps to => 9 parseInt(11,16); // base 16 maps to => 17 Joseph @revisualize Mar 21 2017 02:03 @avinashreddy24 How do you change a variable count's value? Avinash @avinashreddy24 Mar 21 2017 02:05 ok @revisualize thanks i got it now CamperBot @camperbot Mar 21 2017 02:05 avinashreddy24 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles: :star2: 3558 | @revisualize |http://www.freecodecamp.com/revisualize Charles Williams @cfunkles Mar 21 2017 02:05 @jd-wheaton whats wrong with Safari? David Amanze @GodKingShogun Mar 21 2017 02:06 @iashraful i looked up what parseInt does earlier and i thought it returned the first string number into a number JDW @jd-wheaton Mar 21 2017 02:06 @cfunkles The dev tools in Chrome and Firefox are much better. The JS engine in Chrome and Firefox are much better. The plugins are better for Chrome and Firefox. These are just my opinions. David Amanze @GodKingShogun Mar 21 2017 02:10 @iashraful i also used what you suggested but what was returned was a weird array of letters followed by a slash followed by numbers :cry: result= number.map(String.fromCharCode); return result; result= number.map(String.fromCharCode); return result; Charles Williams @cfunkles Mar 21 2017 02:12 @jd-wheaton That sounds like a good reason to use those. Is security an issue? @jd-wheaton When I typed that question in I almost thought I would get a camperbot message to tell me why to use chrome. Ashraful Islam @iashraful Mar 21 2017 02:15 @GodKingShogun parseInt takes 2 arguments, 1st is the actual number, 2nd is the base JDW @jd-wheaton Mar 21 2017 02:15 @cfunkles Security is always the issue, but it's also the most difficult to remedy because a lot of it depends on your activity and behavior. Personally, I use Chrome Canary which is the Bleading edge release of Chrome, usually updated daily. And I install a simple Ad-block addon/plugin. I abstain from porn, torrent searching, etc, because there are many exploits in the wild that can compromise even the most hardened of systems. Ashraful Islam @iashraful Mar 21 2017 02:16 @GodKingShogun let me try, can you give me some example number array? David Amanze @GodKingShogun Mar 21 2017 02:16 @iashraful okay give me one sec @iashraful this should return aren't bonfires fun [65,114,101,46,119,36,96,110,102,105,114,117,35,100,116,110,33] Ashraful Islam @iashraful Mar 21 2017 02:20 @GodKingShogun you don't need map you can use String.fromCharCode.apply(numArr) David Amanze @GodKingShogun Mar 21 2017 02:20 @iashraful so what did you end up doing micah4232 @micah4232 Mar 21 2017 02:21 hello peps can i get some help on this convert to celsius? please and thank you Ashraful Islam @iashraful Mar 21 2017 02:21 here,  String.fromCharCode.apply(null, [65,114,101,46,119,36,96,110,102,105,114,117,35,100,116,110,33]); this gives me 'Are.w$'nfiru#dtn!'
seems like your unicode values are not correct
which challenge is this?
Charles Williams
@cfunkles
Mar 21 2017 02:22
@jd-wheaton those are all good practices, I use as well to stay protected. I am just weirded out by that audio playing, but not too worried since the audio was about coding and mentioned FCC in it. That makes me think I heard something FCC was doing and was just a glich and not to worry that I have been compromise?
David Amanze
@GodKingShogun
Mar 21 2017 02:23
@iashraful its the binary agent challenge
Jacoby Clarke
@Jacobycodes18
Mar 21 2017 02:23
hello people, i'm having a little bit of trouble with the palindrome challenge.
David Amanze
@GodKingShogun
Mar 21 2017 02:25
@iashraful let me double check my code for getting the numbers
JDW
@jd-wheaton
Mar 21 2017 02:25
@cfunkles Unless your a target for some personal reason, I doubt you were compromised. It may have just been a glitch on the backend or in your browser. You can always report what you saw to be safe, but I doubt it was anything serious. Of course Guucifer 2.0 may have just installed a botnet on our machine and your going to attack the Pentagon tonight.
Ashraful Islam
@iashraful
Mar 21 2017 02:26
@GodKingShogun works fine for me
are you sure your conversion was correct ?
David Amanze
@GodKingShogun
Mar 21 2017 02:26
@iashraful but thanks for the help with transferring the array of numbers to a string... i should be able to take it from here :smile:
CamperBot
@camperbot
Mar 21 2017 02:26
godkingshogun sends brownie points to @iashraful :sparkles: :thumbsup: :sparkles:
Ashraful Islam
@iashraful
Mar 21 2017 02:27
here

function binaryAgent(str) {
var nums = str.split(" ").map(function(e) { return parseInt(e,2); });
return String.fromCharCode.apply(null, nums);
}

binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");
check
David Amanze
@GodKingShogun
Mar 21 2017 02:27
@iashraful im going to check my conversion and let you know when i pass it
Ashraful Islam
@iashraful
Mar 21 2017 02:27
^ this one passes all tests
David Amanze
@GodKingShogun
Mar 21 2017 02:27
@iashraful must be a tiny detail i forgot
JDW
@jd-wheaton
Mar 21 2017 02:27
@iashraful my machine just Seg Faulted
Ashraful Islam
@iashraful
Mar 21 2017 02:27
@jd-wheaton :worried: is that good or bad news?
if you have monies, then good news, but new machine
JDW
@jd-wheaton
Mar 21 2017 02:28
@iashraful was j/k, in ref: binaryAgent code :P
Ashraful Islam
@iashraful
Mar 21 2017 02:28
oh
JDW
@jd-wheaton
Mar 21 2017 02:29
this is JS, what you doing with Binary
David Amanze
@GodKingShogun
Mar 21 2017 02:29
@iashraful lol i wrote all of this just to get the numbers

function binaryAgent(str) {
var baseTen=[128,64,32,16,8,4,2,1];
var binaryNumbers= str.split(" ");
var ascii=[];
var number=[];
var counter=0;
var counter1=0;
var result;
for (var i=0; i<binaryNumbers.length; i++){
for (var j=0; j<binaryNumbers[i].length; j++){
if (binaryNumbers[i][j]==="0") {
ascii.push(0);
} else{
ascii.push(baseTen[j]);
}

}
}
for (var k=0; k<ascii.length; k++){
if (counter<=7) {
counter1 += ascii[k];
counter++;
} else {
number.push(counter1);
counter=0;
counter1=0;
}
}
Ashraful Islam
@iashraful
Mar 21 2017 02:29
^ this is natural
I also did this stuff back in days
let me find my solution
Charles Williams
@cfunkles
Mar 21 2017 02:29
@jd-wheaton okay, then for the record it wasn't me. I just a noob
Jacoby Clarke
@Jacobycodes18
Mar 21 2017 02:30
function palindrome(str) {
var sym = /\W|_g/;
str = str.replace(sym, "").toLowerCase();
var palindromic = str.replace(sym,"").toLowerCase();
palindromic = palindromic.split("").reverse("").join("");
return Boolean(str === palindromic);
}
any help here?
Ashraful Islam
@iashraful
Mar 21 2017 02:30
@GodKingShogun I did this weird stuff In binary agent, back in 2015
function binaryAgent(str) {
return str.replace(/[10]+ ?/g, function(bin){
return String.fromCharCode(parseInt(bin,2));
});
}

binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111');
^ does in place replacement using regexp
Chu Nam Anh
@kuzco77
Mar 21 2017 02:30

'''
function myLocalScope() {
'use strict';

var myVar = "hello";
console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
var myVar ="hello"; //

// Now remove the console log line to pass the test
'''

i have already declare my global variable but it still said "No global '''myVar''' variable

CamperBot
@camperbot
Mar 21 2017 02:30
:bulb: to format code use backticks!  more info
Chu Nam Anh
@kuzco77
Mar 21 2017 02:31
function myLocalScope() {
'use strict';

var myVar = "hello";
console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
var myVar ="hello"; //

// Now remove the console log line to pass the test
i have already declare my global variable but it still said "No global myVar variable
David Amanze
@GodKingShogun
Mar 21 2017 02:32
@iashraful even that looks much simplistic
Ashraful Islam
@iashraful
Mar 21 2017 02:32
^ remove console.log to pass the test
@GodKingShogun when I did, there was something called pair programming, I had some other expert guy helping me out
when I did this, regexp sounded like quantum physics
that guy explained what each term in regexp meant and he was technically my hero then
:D
but now I try to avoid regexp, too confusing for my little brain
David Amanze
@GodKingShogun
Mar 21 2017 02:34
@iashraful i need me a hero too lol
Ashraful Islam
@iashraful
Mar 21 2017 02:34
pair programming is gone, no more hero :D
David Amanze
@GodKingShogun
Mar 21 2017 02:35
@iashraful then i will just have to become the hero :smile: lol
Chaz
@Chrljnsn
Mar 21 2017 02:35
Hey guys, im doing the increment numbers and its saying that myVar = 87++; is wrong. How can i fix it?
Ashraful Islam
@iashraful
Mar 21 2017 02:35
JSMan :smile:
@Chrljnsn very good question, now show us your code so we can copy paste it and pass the tests :D
Chaz
@Chrljnsn
Mar 21 2017 02:36

var myVar = 87;

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

David Amanze
@GodKingShogun
Mar 21 2017 02:36
@iashraful i keep seeing the ? pop up every now and then in javascript. what does it do
Ashraful Islam
@iashraful
Mar 21 2017 02:36
?
David Amanze
@GodKingShogun
Mar 21 2017 02:36
@Chrljnsn what do you need help with
@iashraful and yes
Chaz
@Chrljnsn
Mar 21 2017 02:36
its saying that it is wrong and i dont understand why
Ashraful Islam
@iashraful
Mar 21 2017 02:36
like this var something = (someTest) ? thisIfTrue : thisIfFalse; ?
David Amanze
@GodKingShogun
Mar 21 2017 02:37
@iashraful yes i encountered it in the previous challenge and again i see you wrote it in your code
Ashraful Islam
@iashraful
Mar 21 2017 02:37
it is called ternary operator
it returns a value depending on test pass or fail
Chaz
@Chrljnsn
Mar 21 2017 02:39
its saying im not using the ++ operator, how am i not?
David Amanze
@GodKingShogun
Mar 21 2017 02:39
@Chrljnsn try myVar++
Ashraful Islam
@iashraful
Mar 21 2017 02:39
var x = 100;
var a = (x > 50) ? 10 : 20; // => a = 10 as x is > 50
var b = (x < 50) ? 10 : 20; // => b = 20 as x is not less than 50
^
JDW
@jd-wheaton
Mar 21 2017 02:40
@iashraful Can you take a look at my Seek and Destroy for me?
Ashraful Islam
@iashraful
Mar 21 2017 02:40
what exactly to look at @jd-wheaton
Chaz
@Chrljnsn
Mar 21 2017 02:40
@GodKingShogun yeah that worked, bit confused but ok, thanks
CamperBot
@camperbot
Mar 21 2017 02:40
chrljnsn sends brownie points to @godkingshogun :sparkles: :thumbsup: :sparkles:
JDW
@jd-wheaton
Mar 21 2017 02:40
function destroyer(arr) {

var seek = [];
var outcome = [];
for (var i = 1; i < arguments.length; i++) {
seek.push(arguments[i]);
console.log("seek: " + seek);
}

function destroy(value) {
return !seek.includes(value);
}
outcome = seek.filter(destroy);
console.log("outcome: " + outcome);
}
Ashraful Islam
@iashraful
Mar 21 2017 02:41
:worried: very complex code
what is it doing?
JDW
@jd-wheaton
Mar 21 2017 02:42
removing elements from an array that are provided as arguments in the intial array like offering
Ashraful Islam
@iashraful
Mar 21 2017 02:42
you need to separate the input and the elements to remove
here what I see is, it'll remove technically everything excluding the initial array
JDW
@jd-wheaton
Mar 21 2017 02:42
yeah, my for loop does that, and it works
David Amanze
@GodKingShogun
Mar 21 2017 02:42
@iashraful makes sense so if the code on the left of ? evaluates to true then it takes the value left of the colon and if it is false it will take the value to the right of the colon
Ashraful Islam
@iashraful
Mar 21 2017 02:43
yes
@GodKingShogun you got it
it is very handy to quickly write some if/else without making it 6 lines
@jd-wheaton your loop is not separating anything
it is just taking all arguments into seek, and then looking for its presence
if I did destroyer([1,2,3], 2,3), your seek will become [ [1,2,3], 2, 3]
JDW
@jd-wheaton
Mar 21 2017 02:45
it becomes [2,3]
Ashraful Islam
@iashraful
Mar 21 2017 02:46
after seek.filter(destroy), it'll become []
are you sure it becomes 2,3 ? doesn't seem like that
joopt
@joopt
Mar 21 2017 02:46
How do i check if a function has two arguments?ie testFunction(2) or testFunction(2)(3)
Alex G
@glazey132
Mar 21 2017 02:47
can someone tell me whats wrong with my first for loop? Why cant you push an element into the array?
Ashraful Islam
@iashraful
Mar 21 2017 02:47
@joopt what do you mean 2 arguments?
Alex G
@glazey132
Mar 21 2017 02:47

function rot13(str) {
var output = [];
for (var j = 0; j < str.length; j++){
output.push.str(j).charCodeAt();
}

for (var i = 0; i < output.length; i++) {
if (output[i] >= 65 && output[i] <=90) {
if (output[i] >= 78) {
output[i] = (output[i] + 13) - 26;
}

 else if (output[i] < 78) {
output[i] = output[i] +13;
}

}

ouput[i] = String.fromCharCode(ouput[i]);

output = output.join("");

return output;

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

JDW
@jd-wheaton
Mar 21 2017 02:47
it should be [2,3] , do arguments start at 0 or 1?
Ashraful Islam
@iashraful
Mar 21 2017 02:47
arguments start at 0
joopt
@joopt
Mar 21 2017 02:48
@iashraful for example testFunction(2)(3) takes two arguments 2 and 3
Ashraful Islam
@iashraful
Mar 21 2017 02:48
but when you filter it, !seek.includes(value); will return false, if an element exists in array, when filter receives a false, it doesn't keep that element
so your outcome becomes=>[] empty array
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 02:49
Is nesting for loops insanely hard or am i just dumb? Or both.
Ashraful Islam
@iashraful
Mar 21 2017 02:49
@joopt testFunction(2)(3) => this one is possible if testFunction is returning a function that'll take 3 as argument
@Tiff32 don't try to nest loops, they are kind of confusing always
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 02:50
@iashraful I'm on the lesson for it :\
my brain is basically about to explode i can't comprehend lol
Ashraful Islam
@iashraful
Mar 21 2017 02:50
also which challenge is it?
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 02:50
i haven't even started I can't literally comprehend it lmfao. It's "Nesting For Loops"
joopt
@joopt
Mar 21 2017 02:50
@iashraful its the arguments optional challenge
function addTogether(x) {
if (arguments[1]){
return arguments[0]+arguments[1];}
if (!parseInt(arguments[0],10)|| !parseInt(arguments[1],10)) {
return undefined;
} else {
return function (y){
return x + y;
};
}
}

addTogether(2)(3);
Ashraful Islam
@iashraful
Mar 21 2017 02:50
nesting means loop inside loop
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 02:51
oh that makes sense actually l
Ashraful Islam
@iashraful
Mar 21 2017 02:51
Saboor Malik
@MathematicsCoding
Mar 21 2017 02:52
@Tiff32
Ashraful Islam
@iashraful
Mar 21 2017 02:52
you are using closures now
Saboor Malik
@MathematicsCoding
Mar 21 2017 02:52
Ashraful Islam
@iashraful
Mar 21 2017 02:52
@joopt the arguments optional doesn't use closures
you are using unnecessary complexity
Saboor Malik
@MathematicsCoding
Mar 21 2017 02:52
@Tiff32 Can you help me with this challenge? :p
"Using Objects for Lookups"
Im swear I have been working on it for an hour...
joopt
@joopt
Mar 21 2017 02:53

Closures
Arguments object

akhilreddy2623
@akhilreddy2623
Mar 21 2017 02:54
can any one help me with "Word Blanks" java Script"
Ashraful Islam
@iashraful
Mar 21 2017 02:55
@joopt ops! I spoke too soon, sorry :worried:
Johnny
@JohnnyBizzel
Mar 21 2017 02:56
@akhilreddy2623 Just use the parameters and spaces. Don't add any extra words
akhilreddy2623
@akhilreddy2623
Mar 21 2017 02:56

var result = "";
// Your code below this line
result="cat "+"little "+"hit "+"slowly.";
result="big "+"dog "+"ran "+"quickly.";
//wordBlanks("cat", "little", "hit", "slowly");

// Your code above this line
return result;
}

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

it has only one return ;
Phillip Troutman
@troutman21
Mar 21 2017 02:57
Man this Profile Look Up challenge is still killing me @JohnnyBizzel
Saboor Malik
@MathematicsCoding
Mar 21 2017 02:57

# SCREAMING

Johnny
@JohnnyBizzel
Mar 21 2017 02:57
@akhilreddy2623 these are parameters: myNoun, myAdjective, myVerb, myAdverb)
@troutman21 Everyone's favourite! I told you :D
Saboor Malik
@MathematicsCoding
Mar 21 2017 02:58
@JohnnyBizzel I hate this freaking challenge
I have been working on it more than an hour!
Johnny
@JohnnyBizzel
Mar 21 2017 02:58
Need to see code...
Saboor Malik
@MathematicsCoding
Mar 21 2017 02:58

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

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

};
lookup.alpha;
// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup("charlie");
akhilreddy2623
@akhilreddy2623
Mar 21 2017 02:58
@JohnnyBizzel Thank You
CamperBot
@camperbot
Mar 21 2017 02:58
akhilreddy2623 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1528 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Mar 21 2017 02:58
@MathematicsCoding I've been on challenges longer than an hour my friend!
Saboor Malik
@MathematicsCoding
Mar 21 2017 02:59
One challenge?
Johnny
@JohnnyBizzel
Mar 21 2017 02:59
@MathematicsCoding you need bracket notation instead of dot notation because you are using a variable
Saboor Malik
@MathematicsCoding
Mar 21 2017 02:59
I completed 20+ challenges today but this..
Johnny
@JohnnyBizzel
Mar 21 2017 02:59
@MathematicsCoding wait until you get to advanced challenges.
Saboor Malik
@MathematicsCoding
Mar 21 2017 02:59
Okay

// Setup
function phoneticLookup(val) {

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

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

// Change this value to test
phoneticLookup("charlie");
Johnny
@JohnnyBizzel
Mar 21 2017 03:00
@MathematicsCoding and you need to assign it to result
@troutman21 What did you code?
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:00
There
Johnny
@JohnnyBizzel
Mar 21 2017 03:00
@MathematicsCoding you stopped using val?
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:00
Huh...
Johnny
@JohnnyBizzel
Mar 21 2017 03:00
Parameter is val
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:01
Š
Johnny
@JohnnyBizzel
Mar 21 2017 03:01
@MathematicsCoding the object seems to have shrunk - and now the code looks invalid.
:astonished:
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:02
  lookup["alpha"];
Why is it wrong?
Johnny
@JohnnyBizzel
Mar 21 2017 03:02
:x:
Brandon Zamorano
@BrandonZamorano
Mar 21 2017 03:02
@MathematicsCoding You're trying to look up val. Well, supposed to atleast.
Johnny
@JohnnyBizzel
Mar 21 2017 03:02
@MathematicsCoding phoneticLookup("alpha");
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:03
// Setup
function phoneticLookup(val) {
var result = "";

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

};
lookup[alpha];
// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup("alpha");
Johnny
@JohnnyBizzel
Mar 21 2017 03:04
@MathematicsCoding should be result = lookup[val] but I don't know what happened to your object.
Phillip Troutman
@troutman21
Mar 21 2017 03:04
So far this is where i am. I know that im still not there.... @JohnnyBizzel
function lookUpProfile(firstName, prop){
// Only change code below this line
for(i=0;i<contacts.length;i++){
if(contacts[i].hasOwnProperty("firstName") && contacts[i].hasOwnProperty("prop")){//I think this is correct.
return prop;
}
else if(contacts[i].hasOwnProperty("firstName")===true&& contacts[i]!==true){// this isnt.
if(contacts[i].firstName!==firstName){
return "No such contact";
}
}
else{
return "No such property";
}
}
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:05
UGH I hate it I give up
Johnny
@JohnnyBizzel
Mar 21 2017 03:05
formatted code?
Phillip Troutman
@troutman21
Mar 21 2017 03:05
how do i do that ?
I was just going to ask
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:05
Im quitting...
Johnny
@JohnnyBizzel
Mar 21 2017 03:05
@MathematicsCoding reset the challenge and put what I told you
'''
CamperBot
@camperbot
Mar 21 2017 03:05
:bulb: to format code use backticks!  more info
Johnny
@JohnnyBizzel
Mar 21 2017 03:05
Camperbot knows
akhilreddy2623
@akhilreddy2623
Mar 21 2017 03:05
@JohnnyBizzel hey johnny i have seen your profile ,can you help me best place to learn .net courses like c#,asp.net asp.net MVC that really hepls my career and in what order do i need to learn them.
Johnny
@JohnnyBizzel
Mar 21 2017 03:05
@MathematicsCoding a winner never quits and a quitter never wins
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:06
Well I didnt want to quit
But my hands does
They just typed itself!
Johnny
@JohnnyBizzel
Mar 21 2017 03:06
@troutman21
Phillip Troutman
@troutman21
Mar 21 2017 03:07
'''
function lookUpProfile(firstName, prop){
// Only change code below this line
for(i=0;i<contacts.length;i++){
if(contacts[i].hasOwnProperty("firstName") && contacts[i].hasOwnProperty("prop")){//I think this is correct.
return prop;
}
else if(contacts[i].hasOwnProperty("firstName")===true&& contacts[i]!==true){// this isnt.
if(contacts[i].firstName!==firstName){
return "No such contact";
}
}
else{
return "No such property";
}
}
'''
CamperBot
@camperbot
Mar 21 2017 03:07
:bulb: to format code use backticks!  more info
Johnny
@JohnnyBizzel
Mar 21 2017 03:07
back ticks

#  not '

function lookUpProfile(firstName, prop){
// Only change code below this line
for(i=0;i<contacts.length;i++){
if(contacts[i].hasOwnProperty("firstName") && contacts[i].hasOwnProperty("prop")){//I think this is correct.
return prop;
}
else if(contacts[i].hasOwnProperty("firstName")===true&& contacts[i]!==true){// this isnt.
if(contacts[i].firstName!==firstName){
return "No such contact";
}
}
else{
return "No such property";
}
}
@troutman21 you can't do this: contacts[i].hasOwnProperty("prop")
This is testing for the literal string "prop" not the variable.

So remove the quotes

Here contacts[i].hasOwnProperty("firstName") :x:

contacts[i].firstName (we can use dot notation)

Phillip Troutman
@troutman21
Mar 21 2017 03:08
function lookUpProfile(firstName, prop){ // Only change code below this line for(i=0;i<contacts.length;i++){ if(contacts[i].hasOwnProperty("firstName") && contacts[i].hasOwnProperty("prop")){//I think this is correct. return prop; } else if(contacts[i].hasOwnProperty("firstName")===true&& contacts[i]!==true){// this isnt. if(contacts[i].firstName!==firstName){ return "No such contact"; } } else{ return "No such property"; } }
ugh this is pissing me off lol
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:09
lol
'''
code
'''
CamperBot
@camperbot
Mar 21 2017 03:09
:bulb: to format code use backticks!  more info
Johnny
@JohnnyBizzel
Mar 21 2017 03:09
3 back ticks , shift enter, code, shift enter, 3 back ticks
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:09
Use 
Yeah
'''
code
'''
CamperBot
@camperbot
Mar 21 2017 03:09
:bulb: to format code use backticks!  more info
Phillip Troutman
@troutman21
Mar 21 2017 03:10
lol thanks Camper BOT ! haha (he said with heavy sarcasm)
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:10
lol
@troutman21 try it..
'''
code
'''
WITH BACKTICKS
CamperBot
@camperbot
Mar 21 2017 03:10
:bulb: to format code use backticks!  more info
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:10
@camperbot shut up!
Ashraful Islam
@iashraful
Mar 21 2017 03:11
@joopt here is a solution

var args = arguments;

// single args but not number
if (args.length === 1 && typeof args[0] !== 'number') {
return;
}

// double args
if (args.length === 2) {

// nums so return sum
if (typeof args[0] === 'number' && typeof args[1] === 'number' ) {
return args[0] + args[1];
} else { // one is invalid arg, return undef
return;
}

}

return function (y) {
// invalid arg type
if (typeof y !== 'number') {
return;
}

return args[0] + y;
};
}

addTogether(2,3);
Mar 21 2017 03:11

## Markdown code formatting article

Phillip Troutman
@troutman21
Mar 21 2017 03:11
@JohnnyBizzel so it should look like ...
'''
contacts[i].hasOwnProperty(prop)

CamperBot
@camperbot
Mar 21 2017 03:11
:bulb: to format code use backticks!  more info
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:11
@troutman21 YES
 only
JDW
@jd-wheaton
Mar 21 2017 03:12
@iashraful I was really close... I wasn't applying the filter to the correct array.... /facepalm
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:12
Both 
Ashraful Islam
@iashraful
Mar 21 2017 03:12
Johnny
@JohnnyBizzel
Mar 21 2017 03:12
@troutman21 correct
Phillip Troutman
@troutman21
Mar 21 2017 03:12
hahahah wth
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:12
@troutman21  only.... no ''
Mar 21 2017 03:12
Phillip Troutman
@troutman21
Mar 21 2017 03:12
thanks guys. Im calling it a day. Obviously i have been at this for too long.
JDW
@jd-wheaton
Mar 21 2017 03:12
function destroyer(arr) {

var seeking = [];
for (var i = 1; i < arguments.length; i++) {
seeking.push(arguments[i]);
}

function destruction(value) {
return !seeking.includes(value);
}

var outcome = arr.filter(destruction);
console.log("seeking: " + seeking + "\n" + "outcome: " + outcome);
return outcome;
}
Ashraful Islam
@iashraful
Mar 21 2017 03:12
@jd-wheaton you can directly return arr.filter
akhilreddy2623
@akhilreddy2623
Mar 21 2017 03:12
@JohnnyBizzel hey johnny i have seen your profile ,can you help me best place to learn .net courses like c#,asp.net asp.net MVC that really hepls my career and in what order do i need to learn them.
Johnny
@JohnnyBizzel
Mar 21 2017 03:12
@iashraful No problem, just helping out.
JDW
@jd-wheaton
Mar 21 2017 03:13
I know I want to catch in in log
Ashraful Islam
@iashraful
Mar 21 2017 03:13
@JohnnyBizzel good work! Respect :clap:
Johnny
@JohnnyBizzel
Mar 21 2017 03:13
@akhilreddy2623 I recommend Pluralsight
@iashraful ;)
Simmo
@simmosim
Mar 21 2017 03:13
Ashraful Islam
@iashraful
Mar 21 2017 03:13
@jd-wheaton good work! I see your trick with var i = 1
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:13

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

// Only change code below this line
switch(val) {
case "alpha":
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
break;
case "":
result = undefined;
}

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

// Change this value to test
phoneticLookup("charlie");
akhilreddy2623
@akhilreddy2623
Mar 21 2017 03:13
@JohnnyBizzel thank you
CamperBot
@camperbot
Mar 21 2017 03:13
akhilreddy2623 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:warning: akhilreddy2623 already gave johnnybizzel points
Simmo
@simmosim
Mar 21 2017 03:14

Hi. can anyone help me understand why my Switch statements are not working please? function caseInSwitch(val) {
// Only change code below this line
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;

default:

// Only change code above this line
}
}

Johnny
@JohnnyBizzel
Mar 21 2017 03:14
@simmosim I guess you should be using val somewhere
JDW
@jd-wheaton
Mar 21 2017 03:14
yeah, skip over first "argument" haha hackish
Mar 21 2017 03:14
@simmosim val is the function argument - you should use that in your switch( ) statement
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:14
** this challenge
Johnny
@JohnnyBizzel
Mar 21 2017 03:15
This message was deleted
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:15
What am I supposed to do with val?
Ashraful Islam
@iashraful
Mar 21 2017 03:15
@MathematicsCoding you can also do this
// Setup
function phoneticLookup(val) {
var result;

// Only change code below this line
switch(val) {
case "alpha":
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
break;
}

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

// Change this value to test
phoneticLookup("charlie");
Simmo
@simmosim
Mar 21 2017 03:15
Thanks @khaduch and @JohnnyBizzel I tried switch (val) {
case 1: ...but still not working
CamperBot
@camperbot
Mar 21 2017 03:15
simmosim sends brownie points to @khaduch and @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1529 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Ashraful Islam
@iashraful
Mar 21 2017 03:15
when a var is declared but not assigned anything, it is by default undefined
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:15
@iashraful hm that the same?
Ashraful Islam
@iashraful
Mar 21 2017 03:15
I just removed some extra things from your code
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:15
oh
Ashraful Islam
@iashraful
Mar 21 2017 03:16
if you need to keep something undefined, don't assign anything to it
var x,y,z; // all are now undefined
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:16
That it im throwing my laptop
Johnny
@JohnnyBizzel
Mar 21 2017 03:17
@simmosim switch (answer) { when answer has been set to "" ???
David Amanze
@GodKingShogun
Mar 21 2017 03:17
@JohnnyBizzel :wave:
Johnny
@JohnnyBizzel
Mar 21 2017 03:17
@GodKingShogun Hiya King
Ashraful Islam
@iashraful
Mar 21 2017 03:17
I think ^ this phonetic lookup is better done with a lookup table
David Amanze
@GodKingShogun
Mar 21 2017 03:18
@iashraful so i fixed my code and it is returning everthing properly until it gets to the last character. both problems i have to pass end in ? and ! respectively
Simmo
@simmosim
Mar 21 2017 03:18
@JohnnyBizzel Yeah, not sure how I ended up with that haha ... but I still can't figure it out. I have switch (val) but still not working... Any idea what I need to change?
David Amanze
@GodKingShogun
Mar 21 2017 03:18
@iashraful is that an effect of using String.fromCharCode() the way you told me to use
it
Ashraful Islam
@iashraful
Mar 21 2017 03:19
// Setup
function phoneticLookup(val) {
var result;

// Only change code below this line
var myLookup = {
bravo: 'Boston',
charlie: 'Chicago',
delta: 'Denver',
echo: 'Easy',
foxtrot: 'Frank'
};

result = myLookup[val];

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

// Change this value to test
phoneticLookup("charlie");
Johnny
@JohnnyBizzel
Mar 21 2017 03:19
@simmosim can you show what you have now?
@iashraful Looks correct
Ashraful Islam
@iashraful
Mar 21 2017 03:20
lookup tables are slightly faster than actual switch
^
Simmo
@simmosim
Mar 21 2017 03:20
Ashraful Islam
@iashraful
Mar 21 2017 03:20
num operations are smaller
Johnny
@JohnnyBizzel
Mar 21 2017 03:20
@simmosim not sure what += does
Ashraful Islam
@iashraful
Mar 21 2017 03:21
@simmosim you are not doing it right, in comment it says //Only change below this line but you seem to have changed above that too
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:21

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

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

// Change this value to test
phoneticLookup("charlie");
I forgot to do result =
Ashraful Islam
@iashraful
Mar 21 2017 03:21
or @MathematicsCoding has changed the var answer to result
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:21
Simmo
@simmosim
Mar 21 2017 03:22
@iashraful I haven't altered anything above or below the line
Ashraful Islam
@iashraful
Mar 21 2017 03:22
oh, so @MathematicsCoding has changed it
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:22
@iashraful I was actually so close but these code are from youtube...
I was so close and didnt add result =
Simmo
@simmosim
Mar 21 2017 03:22
i mean, I've only changed things in the area it specifies.
Ray Martinez
@rayjrm
Mar 21 2017 03:23
Hello, all
Johnny
@JohnnyBizzel
Mar 21 2017 03:23
@simmosim I think you just need to say = for all cases , not +=
Ashraful Islam
@iashraful
Mar 21 2017 03:23
@simmosim you forgot to close your switch }
Simmo
@simmosim
Mar 21 2017 03:23
@JohnnyBizzel Changed all my += to = but not working :(
Ashraful Islam
@iashraful
Mar 21 2017 03:23
the missing } after default:
check
Johnny
@JohnnyBizzel
Mar 21 2017 03:23
@simmosim why does it fail?
Ashraful Islam
@iashraful
Mar 21 2017 03:25
whelp
time to sleep
night all! :+1:
Simmo
@simmosim
Mar 21 2017 03:25
@JohnnyBizzel These are the error messages. @iashraful It looks to me like the { is closed
Johnny
@JohnnyBizzel
Mar 21 2017 03:25
@iashraful :zzz:
Simmo
@simmosim
Mar 21 2017 03:25
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:25
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++);{
product = arr[i][j];}
}

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
I am so dumb. I don't fully grasp this question or why I'm getting it off. It's Nesting FOr Looops.
Ashraful Islam
@iashraful
Mar 21 2017 03:26
@simmosim your screenshot shows that the } is in the wrong place
remove one } from the end and then add it after the line default:
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:26
@Tiff32 Did you code all day?
Johnny
@JohnnyBizzel
Mar 21 2017 03:26
@simmosim default needs something
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:26
Ashraful Islam
@iashraful
Mar 21 2017 03:26
@JohnnyBizzel default can be empty
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:26
@MathematicsCoding not too much, had a little extra work to do. Yesterday I did quite a bit haha.
Ashraful Islam
@iashraful
Mar 21 2017 03:27
@simmosim is returning inside the default, instead of at the end of function
Simmo
@simmosim
Mar 21 2017 03:27
@iashraful Thank you!!! That was it!!!!
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:27
@MathematicsCoding where are you at?
CamperBot
@camperbot
Mar 21 2017 03:27
simmosim sends brownie points to @iashraful :sparkles: :thumbsup: :sparkles:
Johnny
@JohnnyBizzel
Mar 21 2017 03:27
@simmosim return is in the wrong place
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:27
Testing Objects for Properties
Ashraful Islam
@iashraful
Mar 21 2017 03:27
ok, night night
Simmo
@simmosim
Mar 21 2017 03:27
thanks @JohnnyBizzel
CamperBot
@camperbot
Mar 21 2017 03:27
:warning: simmosim already gave johnnybizzel points
simmosim sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:27
@MathematicsCoding how's it going? need any help?
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:27
Eh not really
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:28
ok good luck :D
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:28
I just started this challenge
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:28
oh :P
Johnny
@JohnnyBizzel
Mar 21 2017 03:28
@Tiff32 multiply using *
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:29
@JohnnyBizzel it shows up as "null" then when i put the *
Johnny
@JohnnyBizzel
Mar 21 2017 03:29
@simmosim ;) any time
@Tiff32 What happens when you multiply by zero?
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:29
@JohnnyBizzel lol fml
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:29
CamperBot
@camperbot
Mar 21 2017 03:29
Simmo
@simmosim
Mar 21 2017 03:29
You from Leeds @JohnnyBizzel ?!
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:29
Wtf 103?
What did you skip?
Johnny
@JohnnyBizzel
Mar 21 2017 03:29
@simmosim Sure am
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:30
I started with Java
Simmo
@simmosim
Mar 21 2017 03:30
I'm from York, but living in Taiwan these days
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:30
Oh
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:30
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:30
I see...
Nah
Im on 225
Simmo
@simmosim
Mar 21 2017 03:30
You're a poker player too?!
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:30
oh dang. did you do html
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:30
Yeah
since the beginning
Very beginning..
Johnny
@JohnnyBizzel
Mar 21 2017 03:30
@simmosim Excellent. It's 3:30 am here!
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:30
I'm gonna go back at some point. I just did it on code academy for awhile and needed something different here
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:30
I see
Johnny
@JohnnyBizzel
Mar 21 2017 03:30
@simmosim not high stakes! :P
Simmo
@simmosim
Mar 21 2017 03:31
haha Coming up to midday in Taipei :D @JohnnyBizzel
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:31
yeah this is much better imo.
more intuitive.
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:31
Yeah lol
Rob Tieffenbacher III
@Tiff32
Mar 21 2017 03:31
my buddy just reccomended it to me and i loved it since i started
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:31
Same here
Johnny
@JohnnyBizzel
Mar 21 2017 03:31
@simmosim How is life in Taiwan?
Simmo
@simmosim
Mar 21 2017 03:32
@JohnnyBizzel haha Me either. Been to the Grovesner in Leeds a couple of times but usually play when I pass through London. Life here is great. Cheap, safe, lovely people, beautiful nature, good times :D
Johnny
@JohnnyBizzel
Mar 21 2017 03:32
@simmosim I've been to Hong Kong many times. I really like it but it gets hot!!
I think I prefer Seoul.
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:33
I think I will be drinking coffee soon..
Coding/Coffee
Johnny
@JohnnyBizzel
Mar 21 2017 03:33
:coffee:
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:33
Since I have been coding I always get tired...
Simmo
@simmosim
Mar 21 2017 03:33
Yeah, Taipei's like a waaaay more chill Hong Kong. Gets hot here May - Sept but loads of mountains, rivers and beaches to cool down at
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:34
SOmeone i felt like I could do some challenge but instead I went to sleep...
Johnny
@JohnnyBizzel
Mar 21 2017 03:34
@simmosim Ha ha. I can imagine some people saying "Not as nice as Yorkshire though" :joy:
@simmosim Where did you see the poker? GitHub?
Simmo
@simmosim
Mar 21 2017 03:35
haha @JohnnyBizzel Well, Yorkshire definitely has some great nature and cities. Just veeeeery different from here. It's way cheaper here and the weather is better and you could leave your iphone on a bench all day and no one would think about taking it
Yeah, github. Get much use from the pokerassistant you built?
Johnny
@JohnnyBizzel
Mar 21 2017 03:36
@simmosim Yes, I like the Chinese people. You get respect from most of them.
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:37
I cant wait to finish basic javascript so I can finally move on from this hell...
Simmo
@simmosim
Mar 21 2017 03:37
Only 2% of Taiwanese see themselves as Chinese. Kinda like calling the Irish "British"
Johnny
@JohnnyBizzel
Mar 21 2017 03:37
@simmosim No, hardly play anymore. It's good for a house game. If you have a windows PC the EXE should just run (that's in the Debug folder)
Saboor Malik
@MathematicsCoding
Mar 21 2017 03:37
Well night :p
Simmo
@simmosim
Mar 21 2017 03:38
Nice one. Haven't been playing lately but will give it a try if we game a game going
Johnny
@JohnnyBizzel
Mar 21 2017 03:38
@simmosim oh, I know about that. They all speak Cantonese in HK.
@simmosim I did a better version in C# but that's not on GitHub yet.
Simmo
@simmosim
Mar 21 2017 03:39
Nice one! ...OK, back to the study @JohnnyBizzel Good chatting! Say hello to Yorkshire for me! :D
Johnny
@JohnnyBizzel
Mar 21 2017 03:39
Haha, ok! I'm following you now ;)
PM me if you need any more help.
@MathematicsCoding sleep well :zzz:
Simmo
@simmosim
Mar 21 2017 03:40
:+1:
Cheers @JohnnyBizzel
Johnny
@JohnnyBizzel
Mar 21 2017 03:41
@simmosim TTFN ;)
kylefujisawa
@kylefujisawa
Mar 21 2017 03:57

Hi all, I'm learning JS for the first time and am having trouble with the syntax for Switch Statements for a challenge.

Here is my attempt:

function caseInSwitch(val) {
case 1:
break;
...
}

caseInSwitch(1);

tech-tron
@tech-tron
Mar 21 2017 04:02
whats object references??
kylefujisawa
@kylefujisawa
Mar 21 2017 04:03
i figured it out!
thanks @tech-tron , but i looked further up the chat and someone had the same question.
CamperBot
@camperbot
Mar 21 2017 04:03
kylefujisawa sends brownie points to @tech-tron :sparkles: :thumbsup: :sparkles:
AKS
@amitkumarsarangi
Mar 21 2017 04:12
Hi guys... I have created a pomodoro clock... show some love on codepen if you liked my effort...
http://codepen.io/amitkumarsarangi/full/qrxBNL/
Daniel Bucket
@danielbucket
Mar 21 2017 04:22

Anyone look at #167 for me? All except a single test will pass. I can't see why. Here's what I'm passing in...
switch(card) {

case 2,3,4,5,6:
count = 5;
return (count + " Bet");

case 7,8,9:
count = 0;
return (count + " Hold");

case 10,'J','Q','K','A':
count = -5;
return (count + " Hold");

//this case does not pass
case 3,7,'Q',8,'A':
count = -1;
return (count + " Hold");

case 2,'J',9,2,7:
count = 1;
return (count + " Bet");

case 2,2,10:
count = 1;
return (count + " Bet");

case 3,2,'A',10,'K':
count = -1;
return (count + " Hold");

}
}

Manish Giri
@Manish-Giri
Mar 21 2017 04:25
@danielbucket
1. the syntax for your case statements are wrong
2. you should "return" outside the switch block
Mathew Santiago
@Matazn123
Mar 21 2017 04:25
How would one go about excluding everything but characters and numbers from a string?
Manish Giri
@Manish-Giri
Mar 21 2017 04:25
@Matazn123 use a regular expression...
Mathew Santiago
@Matazn123
Mar 21 2017 04:25
I meant without a regular expression XD Would a regex work on this freecodecamp palindromes ?
My bad for not being clear
Manish Giri
@Manish-Giri
Mar 21 2017 04:26
yep
most people do use regex
for palindromes
Mathew Santiago
@Matazn123
Mar 21 2017 04:26
Alright then, I shall research some stuff on it.
I appreciate that, thank you
Rohan Sharma
@RhnSharma
Mar 21 2017 04:27
Can someone help on this "factorize a number"
here is my code

function factorialize(num) {
num=1;
for (var i=0;i<=num;i--)
return num*i;
}

factorialize(5);
Daniel Bucket
@danielbucket
Mar 21 2017 04:27
@Manish-Giri
Why would all the others run except that one?
Rohan Sharma
@RhnSharma
Mar 21 2017 04:31
???
Roxroy
@roxroy
Mar 21 2017 04:31
@RhnSharma , 1, You need to add a new variable to hold the results.
1. Remove num=1, so that you do not loose what was sent into the function. You need to keep that # and pass it to the for loop.
Manish Giri
@Manish-Giri
Mar 21 2017 04:32
@RhnSharma
1. you're starting the loop at i = 0, and yet instead of incrementing to num, you're decrementing
2. inside the for, return will terminate the loop at the first iteration.
Avery Biskup
@fraknard
Mar 21 2017 04:33
Anyone need help?
Rohan Sharma
@RhnSharma
Mar 21 2017 04:34
@Manish-Giri i didnt understand
??
Rohan Sharma
@RhnSharma
Mar 21 2017 04:42
@fraknard yup
Stanley Davis
@de-facto
Mar 21 2017 04:44
@RhnSharma I think what you need to do is set your counter to the argument provided in the parameter (num), and as you are already supplying the starting count with num, you will need to subtract 1 from the count; your iterator (final condition) should be set to decrement; your condition should be the case that num is greater than one; if it is not, you risk entering an infinite loop. You must then explicitly state what you want to do with the variable num, that is, num gets ( = ) what? You are almost there.
Richard Belotte
@belotte
Mar 21 2017 04:48

can some one tell me why I am getting unexpected token error in the following:

function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr !== false && !=== null && arr !=== 0 && !== "" && !== undefined && typeof(arr) === 'number' && !isNaN(arr);
console.log(arr);
}

?

Stanley Davis
@de-facto
Mar 21 2017 04:49
@RhnSharma One thing: you must set a condition in the first instance to check IF num is zero or less.
Rohan Sharma
@RhnSharma
Mar 21 2017 04:49
@de-facto ok i will try thanks
CamperBot
@camperbot
Mar 21 2017 04:49
rhnsharma sends brownie points to @de-facto :sparkles: :thumbsup: :sparkles:
Stanley Davis
@de-facto
Mar 21 2017 04:52
@belotte You might want to check your comparison of null and zero.
@persie09
Mar 21 2017 04:53
can someone help me with counting card program in Javascript please
Stanley Davis
@de-facto
Mar 21 2017 04:54
@persie09 What is the problem?
@persie09
Mar 21 2017 04:54
I am having trouble solving it
I will share the code
sec

var count = 0;

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

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

this returns -1 Hold and not other values
Sandip Shrestha
@saninmersion
Mar 21 2017 04:56
@persie09 you are wrong here else if ( 10 > card > 7)
Stanley Davis
@de-facto
Mar 21 2017 04:56
Yo
@persie09
Mar 21 2017 04:56
how do i write it?
Stanley Davis
@de-facto
Mar 21 2017 04:57
@persie09 you can't say count += 0
@persie09
Mar 21 2017 04:57
okay
thats right
Sandip Shrestha
@saninmersion
Mar 21 2017 04:58
@persie09 you gotta use something like else if(card>sth && card<sth)
@persie09
Mar 21 2017 04:58
so should I remove the code block completely or what?
Stanley Davis
@de-facto
Mar 21 2017 04:59
Please, read the rules of the game again, but think about using the switch() method; it could improve your understanding of the requirement.
@persie09
Mar 21 2017 04:59
the problem is everytime it returns -1 Hold
yeah okay
switch might be better
Thanks I will try
Sandip Shrestha
@saninmersion
Mar 21 2017 04:59
@persie09 what I am saying is when there are two or more conditions, you gotta use operators like && or ||
Kevin Collins
@kev0587
Mar 21 2017 05:00
I worked on the Record Collection and Profile Lookup challenges for hours before I finally gave up and seeked help. unfortunately, I ended up running past a reply that included the solution, but my confusion comes from the solution. For both challenges, you needed to use a nested if statement. when did we learn about nested if statements at anytime before those 2 challenges? are nested if statements the same thing as else if? im confused as to why 2 challenge solutions would require the use of nested if statements were never brought up or shown to us to begin with
@persie09
Mar 21 2017 05:00
okay sandip
thanks for that
Ogundele Olumide
@Lumexralph
Mar 21 2017 05:02
@kev0587 just need to know what to do... you have to study resources beyond FCC...
Sandip Shrestha
@saninmersion
Mar 21 2017 05:02
@kev0587 you have learned nested elements if not 'nested if' and if statements so it should not be that much a bother
Stanley Davis
@de-facto
Mar 21 2017 05:02
@kev0587 Nested if statements are almost like else-if statements, but in order for the script to run, all conditions must be
@kev0587 Met. Sorry, big thumbs.
Richard Belotte
@belotte
Mar 21 2017 05:05
@de-facto thank you
CamperBot
@camperbot
Mar 21 2017 05:05
belotte sends brownie points to @de-facto :sparkles: :thumbsup: :sparkles:
Manish Giri
@Manish-Giri
Mar 21 2017 05:05
@Lumexralph :wave:
Ogundele Olumide
@Lumexralph
Mar 21 2017 05:06
@Manish-Giri good morning buddy :smile:
Kevin Collins
@kev0587
Mar 21 2017 05:06
@Lumexralph I wouldn't be using this site if i already knew what to do. I had no idea you were even able to do nested if statements, how would I have known to study resources about nested if statements outside of FCC if I didn't even know they were a thing to begin with? @saninmersion when you reach the Record Collection challenge, the only nested element you've learned is Arrays.
Brian
@BrianCodes33
Mar 21 2017 05:07
@kev0587 i agree there is a big jump in logic it starts out easy then gets tremendously hard without any proper explanations
Ogundele Olumide
@Lumexralph
Mar 21 2017 05:08
@kev0587 i understand... just see FCC as a a guide, they can't teach you everything, that's why they gave so many options to be helped if you run into trouble, you code with me, read other people's code, read more...
Hector
Mar 21 2017 05:08
Hello all -- working on 'mutations' and passing all test save for one, which is really stumping me... any suggestions or hints as to where I'm going wrong??
function mutation(arr) {
var first = arr[0].toLowerCase();
var second = arr[1].toLowerCase();
console.log(first, second);

for (var i = 0; i < second.length; i++) {
console.log(second[i]);
if (first.indexOf(second[i]) !== -1) {
return true;
} else {
return false;
}
}
}

mutation(["hello", "hey"]);
Sandip Shrestha
@saninmersion
Mar 21 2017 05:09
@kev0587 it does get complex really fast. but that's what forums and chatrooms are for. Also fcc is not perfect. They are working continuousl on it to make it better
Manish Giri
@Manish-Giri
Mar 21 2017 05:09
@Lumexralph good morning :sunny: :sun_with_face:
Sandip Shrestha
@saninmersion
Mar 21 2017 05:10
@hectorcoronado what test case does it not pass?
Manish Giri
@Manish-Giri
Mar 21 2017 05:10
if (first.indexOf(second[i]) !== -1) {
return true;
} else {
return false;
}
if second[0] is a match, it will return true
Ogundele Olumide
@Lumexralph
Mar 21 2017 05:11
@Manish-Giri slept good now :smirk: ? quasi-Insomaniac
Manish Giri
@Manish-Giri
Mar 21 2017 05:11
that will halt your code and will return a value of true, without checking for the remaining letters @hectorcoronado
@Lumexralph haha, nope, clocked 6 am last night!
Hector
Mar 21 2017 05:11
@saninmersion when I invoke the function with "hello" and "hey" as arguments (as elements of the 'arr' argument) -- it should return false...
Ok, thanks @Manish-Giri ... I suspected it was something like that, but found it oddly coincidental that so many test cases would pass
CamperBot
@camperbot
Mar 21 2017 05:12
hectorcoronado sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4863 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Mar 21 2017 05:12
@hectorcoronado take hello and hey for instance, h being the first letter in hey is a match in hello, so it returns true..
doesn't check for ey anymore.
Jor
@joreyesl
Mar 21 2017 05:12
@hectorcoronado true would mean that all the letters in hey are in hello, so how soon can we say its true? after checking 1 letter, 2 letters, or 3 letters? In your code when would we want to return true?
Daniel Jobe
@slingshotdancu
Mar 21 2017 05:13
hey room, I'm having problems with the hasOwnProperty method, anyone fancy helping? At this point I'm just trying to get the firstName returned if it exists:
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if(contacts.hasOwnProperty("firstName") === true) {
return contacts.firstName;
} else {
return "No such contact";
}
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Hector
Mar 21 2017 05:14
hmmm... Ok, thought it'd automagically continue checking so long as it'd not reached the end of the string, so I'll go back and think of how to make it so that it does... thanks @joreyesl @Manish-Giri @saninmersion
CamperBot
@camperbot
Mar 21 2017 05:14
hectorcoronado sends brownie points to @joreyesl and @manish-giri and @saninmersion :sparkles: :thumbsup: :sparkles:
Ogundele Olumide
@Lumexralph
Mar 21 2017 05:15
@slingshotdancu (contacts.hasOwnProperty("firstName") you're not picking the object contacts[i]
Chris Cullen
@123xylem
Mar 21 2017 05:16

My Put Request is being handled as a POST request even though im using method-override... ANy idea why?

<form action="/camps/<%=camp._id%>?_method=PUT" method="POST">

My form^^^^^^
Method overried below:

 methodOverride      =require("method-override"),

app.use(methodOverride("_method"));

Are they not linked or somethign?

Daniel Jobe
@slingshotdancu
Mar 21 2017 05:18
@Lumexralph ah, right. thanks!
CamperBot
@camperbot
Mar 21 2017 05:18
:star2: 1346 | @lumexralph |http://www.freecodecamp.com/lumexralph
slingshotdancu sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
Arezohayeman
@Arezohayeman
Mar 21 2017 05:19
Http:
Chris Cullen
@123xylem
Mar 21 2017 05:20
https://webdevlearning-clayton901.c9users.io/camps/58d0b6e20229220ab4452a2a/?_method=put
Cannot POST /camps/58d0b6e20229220ab4452a2a/
Getting this error from above query
RakeshNerkar
@Rakesh18754
Mar 21 2017 05:24
how to debug the data prameter in ajax call.....I want toi check whether the correct value is getting passed or its a null any idea?
jquery normal ajax
in chrome dev tools
Kevin Peña
@kebien6020
Mar 21 2017 05:25
@Rakesh18754 just use console.log with the variable holding the parameter or the full url
@Rakesh18754 If you provide the relevant code I can give you more detailed instructions
RakeshNerkar
@Rakesh18754
Mar 21 2017 05:27
@kebien6020 where should i write the console .log
var xhr = $.ajax({ url: contextPath + '/getADMoreInfoData', type: 'POST', data: { "url" : url, "dateTime": dateTime, "assetIp" : assetIp, "user_name" : userNameADmodels }, traditional: true, beforeSend: function(xhr) { xhr.setRequestHeader("X-CSRF-Token",$("input[name='_csrf']").val());
},
success: function(jsonResponse) {
$('#malware-menu').empty(); beforeSend , succes wehre? I want to check whether the correct values are passed or not for all data attr Kevin Peña @kebien6020 Mar 21 2017 05:29 @Rakesh18754 You can do console.log before this line of code with url, dateTime, assetIp and userNameADmodels or you can look at the network tab in the dev tools RakeshNerkar @Rakesh18754 Mar 21 2017 05:30 @kebien6020 this line of code ???? Kevin Peña @kebien6020 Mar 21 2017 05:31 console.log(url, dateTime, assetIp, userNameADmodels) var xhr =$.ajax({
type: 'POST',
data: {
"url" : url,
"dateTime": dateTime,
"assetIp" : assetIp,
},
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRF-Token", $("input[name='_csrf']").val()); }, success: function(jsonResponse) {$('#malware-menu').empty();
RakeshNerkar
@Rakesh18754
Mar 21 2017 05:32
ok..i am getting the values outside ajax...any method in which i can check during the ajax call
@kebien6020
Kevin Peña
@kebien6020
Mar 21 2017 05:33
@Rakesh18754 Well then you would have to use the Network tab in the chrome dev tools
RakeshNerkar
@Rakesh18754
Mar 21 2017 05:33
ok
Ayush Bahuguna
@relentless-coder
Mar 21 2017 05:33
hey, I am sorry, but yesterday I asked a question, but then I had to leave urgently, so I couldn't be a part of the discussion so I am asking it again
Kevin Peña
@kebien6020
Mar 21 2017 05:43
@Rakesh18754 You can check how jQuery serializes parameters by using $.param(obj, true). The true as second parameter tells it to use traditional serialization (the one you are using in your provided code) Ayush Bahuguna @relentless-coder Mar 21 2017 05:43  var bookStartDate = '2017-03-21'; var bookEndDate = '2017-04-24'; var setStartDate = new Date(bookStartDate); var setEndDate = new Date(bookEndDate); console.log(setEndDate) var noOfDays = (setEndDate.getTime() - setStartDate.getTime())/86400000; console.log(noOfDays); var startDate = setStartDate.getDate(); var todayDate = new Date() var dateCollection = []; for(var k = 0; k <= noOfDays; k++){ todayDate.setDate(startDate + k); (function(value){ var date = new Date(value); console.log(value, date); dateCollection.push(date); })(todayDate); } so I am trying to set a series of dates between a start date and end data, but the problem is that when numbers exceeds the range of a particular month, my date object gives out weird dates, how do I tackle it? don't want the solution, but a starting point would be great Kevin Peña @kebien6020 Mar 21 2017 05:45 @Rakesh18754 var encoded =$.param(data, true)
var decoded = decodeURIComponent(encoded)
console.log(encoded)
console.log(decoded)
var xhr = $.ajax({ //... Aaron Bell @awb715 Mar 21 2017 05:48 anyone up to steamroller? Deep Verma @deepverma3003 Mar 21 2017 05:48 Not yet Kevin Peña @kebien6020 Mar 21 2017 05:54 @relentless-coder Maybe it has to do with the format of the string dates? In my machine this happens Kevin Peña @kebien6020 Mar 21 2017 06:02 @relentless-coder You could also look into using momentjs. I've only worked a little bit with it but it is pretty nice. Maybe try something like moment("20170321", "YYYYMMDD").add(1, 'days') RakeshNerkar @Rakesh18754 Mar 21 2017 06:04 @kebien6020 var encoded =$.param(data, true)
var decoded = decodeURIComponent(encoded)
console.log(encoded)
console.log(decoded)
VM1905:3 name=10.0.6.57(Amelia+Pullman)&_children=%5Bobject+Object%5D&_children=%5Bobject+Object%5D&_children=%5Bobject+Object%5D&_children=%5Bobject+Object%5D&_children=%5Bobject+Object%5D&parent=%5Bobject+Object%5D&depth=2&x=76.92307692307692&y=360&id=8&x0=76.92307692307692&y0=360
VM1905:4 name=10.0.6.57(Amelia+Pullman)&_children=[object+Object]&_children=[object+Object]&_children=[object+Object]&_children=[object+Object]&_children=[object+Object]&parent=[object+Object]&depth=2&x=76.92307692307692&y=360&id=8&x0=76.92307692307692&y0=360
first one is encoded
second one is decoded
but did not understood wats the difference
only instead of " [ " it uses " %5 "
i mean in debugging how it helps us ?
Kevin Peña
@kebien6020
Mar 21 2017 06:05
@Rakesh18754 encoded is literally what is sent to the server, decoded is a more human-readable representation
RakeshNerkar
@Rakesh18754
Mar 21 2017 06:05
ok @kebien6020
Kevin Peña
@kebien6020
Mar 21 2017 06:06
@Rakesh18754 The important think to notice are the [object Object] things, these are not probably what you meant to send to the server
Ayush Bahuguna
@relentless-coder
Mar 21 2017 06:06
@kebien6020 It's okay, I solved it. I used a different approach. I use a while loop which compares the milliseconds of startDate and endDate, while the startDate <= endDate, I keep adding 86400000 to the startDate and create a new date with that and push it to my collection
Kevin Peña
@kebien6020
Mar 21 2017 06:08
@relentless-coder I first thought of that but didn't suggest it because it may have problems with daylight savings or things like that which cause some days to not have 86400000 ms in them
Ayush Bahuguna
@relentless-coder
Mar 21 2017 06:12
well, my app is limited to indian users, and we don't have any concept of daylight savings, I don't even know what that is other than that it is a thing in west and some countries in east
Manish Giri
@Manish-Giri
Mar 21 2017 06:13
daylight savings is very annoying
Kevin Peña
@kebien6020
Mar 21 2017 06:13
@Rakesh18754 try not using the traditional serialization mode (so $.param(data, false)). If that produces the string you want to send to the server, in the $.ajax configuration object set traditional to false. If not, then maybe look into serializing yourself the data you want to send to the server into a string.
Richard Belotte
@belotte