26th
Jun 2017
koder3
@koder3
Jun 26 2017 00:00 UTC

function binaryAgent(str) {
var e = []
var r = str.split(" ")
for (var i = 0; i < r.length; i++){
e.push(String.fromCharCode(parseInt(r[i], 2)))
}
return e.join("")
}

binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111")
any way i can optimize this @sjames1958gm
Michael
@HAWKKER
Jun 26 2017 00:00 UTC
The wording here is confusing me. "MYVAR is not the same as MyVar nor myvar. It is possible to have multiple distinct variables with the same name but different casing. It is strongly recommended that for the sake of clarity, you do not use this language feature." What does it mean by language feature, is it telling me not to use capatilization, or myvar, or javascript as a whole? I don't know if I'm just being silly..
Sparkin
@seanparkin
Jun 26 2017 00:00 UTC
'''
'''
CamperBot
@camperbot
Jun 26 2017 00:00 UTC
:bulb: to format code use backticks!  more info
Stephen James
@sjames1958gm
Jun 26 2017 00:01 UTC
@koder3 Not really - you can use map instead of for loop
  return str.split(' ').map(function(e) {
return String.fromCharCode(parseInt(e, 2));
}).join('');
Sparkin
@seanparkin
Jun 26 2017 00:02 UTC
@dyon3334
function orbitalPeriod(arr) {
var GM = 398600.4418;

var newArr = [];
for (i =0;i<arr.length;i++) {
newArr.push({name: arr[i].name, orbialPeriod: result});
}
return newArr;

}
onejo578
@onejo578
Jun 26 2017 00:03 UTC
@HAWKKER it just means that, even though you can use two variables with the same spelling (ie, myVar and myVAR), you should avoid it as it's confusing.
CamperBot
@camperbot
Jun 26 2017 00:04 UTC
koder3 sends brownie points to @seanparkin :sparkles: :thumbsup: :sparkles:
koder3
@koder3
Jun 26 2017 00:04 UTC
@sjames1958gm thats beautiful. thanks
CallMeOrange
@EgnaroDev
Jun 26 2017 00:04 UTC
@HAWKKER and JavaScript are case sensitive, for that challenge I believe you just have to fix these variables to match both
Joseph
@revisualize
Jun 26 2017 00:05 UTC
:|
kumquatfelafel
@kumquatfelafel
Jun 26 2017 00:06 UTC
@HAWKKER By language feature, they mean the fact that javascript is case sensitive. (which is why you could have myvar, myVar, etc.)
Michael
@HAWKKER
Jun 26 2017 00:06 UTC
@onejo578
CallMeOrange
@EgnaroDev
Jun 26 2017 00:06 UTC
yeah what @kumquatfelafel said
Joseph
@revisualize
Jun 26 2017 00:06 UTC
@HAWKKER JavaScript is case sensitive. You should have learned that in one of the lessons.
CallMeOrange
@EgnaroDev
Jun 26 2017 00:06 UTC
lol now 3 guys have said it
Michael
@HAWKKER
Jun 26 2017 00:07 UTC
@onejo578 Thank you, I just shouldn't use the two at the same time. Makes sense.
CamperBot
@camperbot
Jun 26 2017 00:07 UTC
hawkker sends brownie points to @onejo578 :sparkles: :thumbsup: :sparkles:
kumquatfelafel
@kumquatfelafel
Jun 26 2017 00:07 UTC
It's not over until everybody says it!
Joseph
@revisualize
Jun 26 2017 00:07 UTC
Look.
Repeating the same thing from multiple isn't always a bad thing.
kumquatfelafel
@kumquatfelafel
Jun 26 2017 00:07 UTC
^true. Differing perspective and some such. ;)
Michael
@HAWKKER
Jun 26 2017 00:07 UTC
@revisualize I Understood they were case sensitive but the wording was confusing, this is the first tutorial to explain it..
Joseph
@revisualize
Jun 26 2017 00:08 UTC
If I ask a question and 4 people say the same thing differently. That re-affirms the response as factual.
Thomas
@thojaco
Jun 26 2017 00:09 UTC
@revisualize thanks!
CamperBot
@camperbot
Jun 26 2017 00:09 UTC
thojaco sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4256 | @revisualize |http://www.freecodecamp.com/revisualize
CallMeOrange
@EgnaroDev
Jun 26 2017 00:09 UTC
@HAWKKER well now you have understood that JS is case-sensitive, do you need any help with that challenge?
kumquatfelafel
@kumquatfelafel
Jun 26 2017 00:10 UTC
@HAWKKER yeah, I getcha. You have to look at the context a bit to figure out that by "language feature" they mean that.
CallMeOrange
@EgnaroDev
Jun 26 2017 00:11 UTC
Alright I managed to figure this out, so is this good way to do it?

function multiplyAll(arr) {
var product = 1;

for (var i = 0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
product = product*arr[i][j];
}
}
return product;
}

multiplyAll([[1],

[2],

[3]]);
I tried var array = arr[i][j] then return product*array; that didn't work why?
Is it because they are in different scopes?
Michael
@HAWKKER
Jun 26 2017 00:12 UTC
@MCTwoDigitZero No thank you, I have struggled with some of these basic initial javascript tutorials but I'm getting there
CamperBot
@camperbot
Jun 26 2017 00:12 UTC
hawkker sends brownie points to @mctwodigitzero :sparkles: :thumbsup: :sparkles:
CallMeOrange
@EgnaroDev
Jun 26 2017 00:12 UTC
@HAWKKER Alright, Good Luck with JavaScript
Take notes if needed :/
Michael
@HAWKKER
Jun 26 2017 00:12 UTC
:)
Moisés Man
@moigithub
Jun 26 2017 00:13 UTC
i and j are only defined inside the loop
soo probably was scopes as u said @MCTwoDigitZero
CallMeOrange
@EgnaroDev
Jun 26 2017 00:13 UTC
I see
So that was only reason
thanks @moigithub
CamperBot
@camperbot
Jun 26 2017 00:14 UTC
mctwodigitzero sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3421 | @moigithub |http://www.freecodecamp.com/moigithub
Sunny Wong
@swong194
Jun 26 2017 00:16 UTC
hi
every1 does javascript allow for negative index arrays
Sparkin
@seanparkin
Jun 26 2017 00:17 UTC
@swong194 I am pretty sure that you can't have a negative array index
Can anyone help me with my issue with the Map the Debris challenge?
Moisés Man
@moigithub
Jun 26 2017 00:20 UTC
@swong194 some methods allows negative index like mdn.io/slice
Sunny Wong
@swong194
Jun 26 2017 00:22 UTC
@moigithub @seanparkin thanks, that sucks i thought i saw a FCC where i used negative index
CamperBot
@camperbot
Jun 26 2017 00:22 UTC
swong194 sends brownie points to @moigithub and @seanparkin :sparkles: :thumbsup: :sparkles:
:star2: 3422 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jun 26 2017 00:29 UTC
$T = 2 \times PI \times \sqrt{\frac{a^3}{GM}}$
@seanparkin
CallMeOrange
@EgnaroDev
Jun 26 2017 00:33 UTC
@moigithub What kind of formula is that?
Moisés Man
@moigithub
Jun 26 2017 00:34 UTC
debris map, from the wiki if i recall
Sparkin
@seanparkin
Jun 26 2017 00:35 UTC
@moigithub yeah that was the code that I was using. Realized that I misspelled one of the variables. Thank you for the help
CamperBot
@camperbot
Jun 26 2017 00:35 UTC
seanparkin sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3423 | @moigithub |http://www.freecodecamp.com/moigithub
J-Mag Guthrie
@baseballpoetess
Jun 26 2017 00:41 UTC
@revisualize gracias
CamperBot
@camperbot
Jun 26 2017 00:41 UTC
baseballpoetess sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4257 | @revisualize |http://www.freecodecamp.com/revisualize
Yang Lu
@Luyang2016
Jun 26 2017 00:46 UTC

var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUp(firstName, prop){
// 请把你的代码写在这条注释以下
for(var i=0;i<4;i++){
if (contacts[i].firstName==firstName){
if (contacts[i].hasOwnProperty(prop)){return contacts[i][prop];
}
else{return "No such property";}
}
else{return "No such contact";}

}
}

lookUp("Sherlock", "likes");
Why can't I pass this?
It's profile lookup in basic Javascript.
luccifer00
@luccifer00
Jun 26 2017 00:48 UTC
@Luyang2016 you should use .length property
Yang Lu
@Luyang2016
Jun 26 2017 00:49 UTC
Where? @luccifer00
luccifer00
@luccifer00
Jun 26 2017 00:49 UTC
i < contacts.length; i++
@Luyang2016 why do u use 4?
Yang Lu
@Luyang2016
Jun 26 2017 00:50 UTC
I still can't pass
Is it the for loop?
luccifer00
@luccifer00
Jun 26 2017 00:51 UTC
let me see
else{return "No such contact"; try to put outside the loop @Luyang2016
Yang Lu
@Luyang2016
Jun 26 2017 00:54 UTC
I think something is wrong with the for loop. Because when i =0, only the name akira satisfies.
And only this condition is right .
luccifer00
@luccifer00
Jun 26 2017 00:55 UTC
the loop is ok, if u add what i said before contacts.length
also you shold use strict equal in firstName === firstName
Yang Lu
@Luyang2016
Jun 26 2017 00:57 UTC

var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUp(firstName, prop){

for(var i=0;i < contacts.length; i++){
if (contacts[i].firstName===firstName){
if (contacts[i].hasOwnProperty(prop)){return contacts[i][prop];
}
else{return "No such property";}
}

}
else{return "No such contact";}
}

lookUp("Sherlock", "likes");
You mean like this.？Now it says the grammar is wrong
luccifer00
@luccifer00
Jun 26 2017 01:01 UTC
you no need the last else
just return without {}
that should work
crimsonangel665
@crimsonangel665
Jun 26 2017 01:03 UTC
hey, having trouble with
Returning Boolean Values from Functions: cant get it to equal true
function isLess(a, b) {
// Fix this code
return a === b;
}
// Change these values to test
isLess(10, 15);
Yang Lu
@Luyang2016
Jun 26 2017 01:04 UTC
@luccifer00 It passed. Thank you.
CamperBot
@camperbot
Jun 26 2017 01:04 UTC
luyang2016 sends brownie points to @luccifer00 :sparkles: :thumbsup: :sparkles:
Grigor Minasyan
@gogminsam
Jun 26 2017 01:05 UTC
Can someone help me with Caesars Cipher?

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

}
newarr.join("");
return newarr;

}

// Change the inputs below to test
rot13("SERR PBQR PNZABCAM");
luccifer00
@luccifer00
Jun 26 2017 01:05 UTC
@crimsonangel665 use the logic
Grigor Minasyan
@gogminsam
Jun 26 2017 01:05 UTC
What's wrong with my code?
Moisés Man
@moigithub
Jun 26 2017 01:05 UTC
and check what ur IF condition doing
@gogminsam space is charcode 32
and 32 is <= 77
luccifer00
@luccifer00
Jun 26 2017 01:07 UTC
@crimsonangel665 if the name of the function isLess (a, b) why u want to make strict equal??
crimsonangel665
@crimsonangel665
Jun 26 2017 01:07 UTC
isLess(10,15) should return true
is what its asking me to di
do*
luccifer00
@luccifer00
Jun 26 2017 01:08 UTC
@crimsonangel665 yes, that is true.... but you have to write your code
crimsonangel665
@crimsonangel665
Jun 26 2017 01:09 UTC
mine is exactly the same as the example and that is what is confusing me
luccifer00
@luccifer00
Jun 26 2017 01:09 UTC
no no @crimsonangel665 isLess (a,b) to test your function you can change that values isLess(1,100)
Grigor Minasyan
@gogminsam
Jun 26 2017 01:09 UTC
@moigithub I have changed || to && and it still doesnt work, return something like this
["", "\u000e","",........
luccifer00
@luccifer00
Jun 26 2017 01:09 UTC
so @crimsonangel665 10 is a, and 15 is b!!! rewrite your code
@crimsonangel665 in your code you write a===b the function reads, 10===15.... thats is becouse the result is false! becouse 10, isn't equal to 15.... so what sign could be insted === ??? ... think about it..
Jose R Perez
@perezvenegas
Jun 26 2017 01:12 UTC
help!
"Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed."
crimsonangel665
@crimsonangel665
Jun 26 2017 01:13 UTC
@luccifer00 im still confused but ill have a play
luccifer00
@luccifer00
Jun 26 2017 01:15 UTC
its simple @crimsonangel665
function isLess(a, b) {
// Fix this code
return a === b; //you should change === to <, becouse a is minos to b, (a,b) is (10,15)
}
// Change these values to test
isLess(10, 15);
crimsonangel665
@crimsonangel665
Jun 26 2017 01:17 UTC
then why would the example show something different?
@luccifer00 thankyou btw
CamperBot
@camperbot
Jun 26 2017 01:18 UTC
crimsonangel665 sends brownie points to @luccifer00 :sparkles: :thumbsup: :sparkles:
luccifer00
@luccifer00
Jun 26 2017 01:18 UTC
if you read the example the functios is called function isEqual(a,b)
crimsonangel665
@crimsonangel665
Jun 26 2017 01:20 UTC
i didnt think the function name mattered it could of been apple
Joseph
@revisualize
Jun 26 2017 01:21 UTC
@luccifer00 minos?
What is minos?
luccifer00
@luccifer00
Jun 26 2017 01:22 UTC
sorry minor!
Joseph
@revisualize
Jun 26 2017 01:22 UTC
@luccifer00 Less than.
luccifer00
@luccifer00
Jun 26 2017 01:22 UTC
haha i have english problems!!
Joseph
@revisualize
Jun 26 2017 01:22 UTC
Daniel Narilton
@spaganger
Jun 26 2017 01:23 UTC
I'm struggling to get the index of the smallest element in my array: https://codepen.io/anon/pen/LLzyvg?editors=0010 Anyone?
Moisés Man
@moigithub
Jun 26 2017 01:23 UTC
@gogminsam soo whats ur current code ?
Tricia
@patricia07
Jun 26 2017 01:24 UTC
hey guys can u help me please
is this right?
var thirdLetterOfLastName = lastName[3];
Moisés Man
@moigithub
Jun 26 2017 01:25 UTC
JS uses 0 based index @patricia07
Ravi Kishore Thella
@ravikishorethella
Jun 26 2017 01:25 UTC
@patricia07 count starts from zero
@patricia07 if you want the third character then it should be lastName[2]
Tricia
@patricia07
Jun 26 2017 01:29 UTC
oh i see thanks!!!
JuanDavid31
@JuanDavid31
Jun 26 2017 01:35 UTC
Hello everybody
Have someone done the Smallest Common Multipli challenge? i think it is badly written
Joel Korcsmaros
@lossness
Jun 26 2017 01:37 UTC
Can someone check out this gist? It's passing the test but it's not actually printing anything to console. glitch maybe? (prob not) https://gist.github.com/lossness/f64d78cb4589de7478dcd3994d48c0b9
JuanDavid31
@JuanDavid31
Jun 26 2017 01:39 UTC
These are the outputs
Hi, I work as a programmer
Hi, I work as a super programmer
seems ok to me
Joel Korcsmaros
@lossness
Jun 26 2017 01:39 UTC
thx @JuanDavid31
CamperBot
@camperbot
Jun 26 2017 01:40 UTC
lossness sends brownie points to @juandavid31 :sparkles: :thumbsup: :sparkles:
JuanDavid31
@JuanDavid31
Jun 26 2017 01:40 UTC
you are welcome
Karen
@karengeerts
Jun 26 2017 01:43 UTC

Hi all - I'm stuck with Mutations challenge. The code does what the challenge prescribes - but it is not accepted as a correct solution.
What am I doing wrong?

function mutation(arr) {
var sourceString = arr[0];
var checkString = arr[1];
var iterations = checkString.length;
var value = "true";
sourceString = sourceString.toLowerCase();
checkString = checkString.toLowerCase();
for (var i=0; i<=iterations; i++){
var letter = checkString.charAt(i);
var check = sourceString.indexOf(letter);
if (check == -1){
value ="false";
}
}
return value;
}
mutation(["voodoo", "no"])

Moisés Man
@moigithub
Jun 26 2017 01:44 UTC
@karengeerts u need to return a boolean value.. true or false
without quotes.. quotes.. make it a string
Karen
@karengeerts
Jun 26 2017 01:49 UTC
I understand the boolean value but not your comment re quotes and strings?
Karen
@karengeerts
Jun 26 2017 01:55 UTC
thx @moigithub - the boolean comment pointed me in the right direction!
CamperBot
@camperbot
Jun 26 2017 01:55 UTC
karengeerts sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3424 | @moigithub |http://www.freecodecamp.com/moigithub
Aizaz Shahid
@aizazshahid
Jun 26 2017 01:56 UTC

@karengeerts please paste your code as formatted, next time when you will try to paste:

put your code between those backticks, but remember to put  them in new lines.



Karen
@karengeerts
Jun 26 2017 02:01 UTC
thx @forwebtech - I saw the little markdown help button too late! will remember for next time
CamperBot
@camperbot
Jun 26 2017 02:01 UTC
karengeerts sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
Jun 26 2017 02:06 UTC
hey hey
CallMeOrange
@EgnaroDev
Jun 26 2017 02:10 UTC
?
kumquatfelafel
@kumquatfelafel
Jun 26 2017 02:15 UTC

Say I wanted to take a numeric string and add 1 to each digit such that, e.g. "9309" becomes "104110". If I were to do something like this (I'm sure there are better ways, but bear with me)

function addOneToDigits1(number) {
return number.split('').reduce((a,b) => a + (+b +1)).join(''); //This doesn't modify first digit
}
return number.split('').reduce((a,b) => (+a + 1) + b).join(''); //This doesn't modify last digit
}
return number.split('').reduce((a,b) => (+a + 1) + '' + (+b + 1)).join(''); //this doubly modifies sandwiched digits
}

So I know that for the first and second one, you could always shift/unshift or pop/push a " ", e.g., to trick it into modifying the untouched digit, but... this just feels a bit disappointing somehow. Is there a way to handle the ends using reduce alone, or would you want to call some other method to do that?

kumquatfelafel
@kumquatfelafel
Jun 26 2017 02:21 UTC
^ when I say using reduce alone, I mean without using shift or the like
(low priority question) :p
fdemaa
@fdemaa
Jun 26 2017 02:26 UTC
@kumquatfelafel Can you help me with my algorithm ? I m trying to slice an array a X number of times in subarrays, i m trying to use a loop, but i dont know how to slice it properly in subarrays;
kumquatfelafel
@kumquatfelafel
Jun 26 2017 02:26 UTC
(I notice there is an "initialValue" in documentation, but can you still include this using =>?)
@fdemaa possibly? Getting a bit tired, and may misadvise. Do you have any code to look at?
Claudio Restifo
@Marmiz
Jun 26 2017 02:29 UTC

@kumquatfelafel the way I'd approach it:

1- convert the string into an array with split
2- map into the array, convert the string into a number and add 1
3- take those numbers, convert back to string values and join them together.

You should be able to use reduce, but I don't see the need of it when all you want is to just add 1 to each element of the array. Map seems more intuitive.

fdemaa
@fdemaa
Jun 26 2017 02:29 UTC
@kumquatfelafel yes but its just all wrong lol okey i will show you

function chunkArrayInGroups(arr, size) {
/*
Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.

*/

var emptyArray=[];
var iterations= Math.ceil(arr.length/size);
console.log(iterations);

for ( i=0; i<=iterations; i++ ){
var temporary = arr.slice(size);
emptyArray.push(temporary);
}
console.log(emptyArray);
}

chunkArrayInGroups(["a", "b", "c", "d","e"], 2);
kumquatfelafel
@kumquatfelafel
Jun 26 2017 02:30 UTC
@Marmiz thanks
CamperBot
@camperbot
Jun 26 2017 02:30 UTC
kumquatfelafel sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
Claudio Restifo
@Marmiz
Jun 26 2017 02:31 UTC
@kumquatfelafel remember to work with the correct type of variable, in JS
('10') +1 returns 101 [String 10 + number 1 returns '101']
Grigor Minasyan
@gogminsam
Jun 26 2017 02:32 UTC
@moigithub this is my code
Ryan Malm
@Rybar
Jun 26 2017 02:32 UTC
How are people with free codepen accounts solving the CORS problem when doing AJAX requests, like for the random quote generator?
kumquatfelafel
@kumquatfelafel
Jun 26 2017 02:32 UTC
@Marmiz aye :). I've come to get a lot more careful about that than I was at first.
Grigor Minasyan
@gogminsam
Jun 26 2017 02:32 UTC

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

}
newarr.join("");
return newarr;

}

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

Moisés Man
@moigithub
Jun 26 2017 02:33 UTC
@Rybar using JSONP
@gogminsam backticks on its OWN line
and u still using OR (which is wrong)
true OR false --- > result true
if at least 1 side is true.. the whole thing becomes true
Ryan Malm
@Rybar
Jun 26 2017 02:35 UTC
@moigithub Thanks.
CamperBot
@camperbot
Jun 26 2017 02:35 UTC
rybar sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3425 | @moigithub |http://www.freecodecamp.com/moigithub
Grigor Minasyan
@gogminsam
Jun 26 2017 02:35 UTC
@moigithub the backticks were for code, im on phone they didn't work. There's no backticks on my code
kumquatfelafel
@kumquatfelafel
Jun 26 2017 02:35 UTC
@fdemaa arr.slice(size) will take from the arr[size] until (inclusive) arr[arr.length - 1] (end of array).
Grigor Minasyan
@gogminsam
Jun 26 2017 02:36 UTC
@moigithub sorry I sent you the wrong code, my current code is with && but it still doesn't work
Moisés Man
@moigithub
Jun 26 2017 02:37 UTC
u doing -13 on the index.. and should be -13 on the char code @gogminsam
fdemaa
@fdemaa
Jun 26 2017 02:37 UTC
@kumquatfelafel thanks, i will check that then
CamperBot
@camperbot
Jun 26 2017 02:37 UTC
fdemaa sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
Claudio Restifo
@Marmiz
Jun 26 2017 02:37 UTC

@fdemaa remember that the first parameter in slice is where you wnat to start "slicing" so

var temporary = arr.slice(size);

you are start slicing your array from arr[2] in this case

Moisés Man
@moigithub
Jun 26 2017 02:39 UTC
@fdemaa slice can take a second parameter/index
if u dont specify it will slice from first param to last element
fdemaa
@fdemaa
Jun 26 2017 02:39 UTC
@Marmiz @moigithub thanks!
Yes i forget about the (begin, end) LOL
CamperBot
@camperbot
Jun 26 2017 02:39 UTC
fdemaa sends brownie points to @marmiz and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3426 | @moigithub |http://www.freecodecamp.com/moigithub
CallMeOrange
@EgnaroDev
Jun 26 2017 02:45 UTC
Hey this is my Profile Lookup code..

var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
var result = contacts;

for (var i = 0; i < result; i++) {
}
var value = result;

if (firstName!==result[i].firstName) {
return "No such contact";
} else {
return "No such property";
}
return value;
}

lookUpProfile("Akira", "likes");
My question is ... I want to know if these if statements are correct
:zzz:
Forget it.. they are working but I think they may be wrong somehow..
kumquatfelafel
@kumquatfelafel
Jun 26 2017 02:55 UTC

if(firstName!==result[i].firstName)
return "No such contact"; //But we've only checked one contact.
else if(firstName === result[i].firstName)
return "No such property"; //Why? We haven't checked for any properties.

You're also not utilizing your for loop.

As for

var result = contacts;
var value = result;

There's not much point in creating these variables.

Eric Hasegawa
@EricHasegawa
Jun 26 2017 02:56 UTC
I'm on the "Return Largest Number in Arrays" challenge, can anyone help me out?
kumquatfelafel
@kumquatfelafel
Jun 26 2017 02:57 UTC
@EricHasegawa sure.
Eric Hasegawa
@EricHasegawa
Jun 26 2017 02:57 UTC
function largestOfFour(arr) {

var standard = 0;

for (var i=0; i < arr; i++) {

for (var j=0; i< arr[i]; i++) {
if (arr[j] > standard ) {
standard = arr[i];
}
}

}

return standard;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
@kumquatfelafel
I'm not sure how to progress from here, is this looking okay so far?
sethsdo
@sethsdo
Jun 26 2017 02:59 UTC

'''function lookUpProfile(firstName, prop){
// Only change code below this line
var i = 0;

while (i < contacts.length) {
if (contacts[i].hasOwnProperty(firstName) === true) {
return contacts[i][firstName];
} else {
return "No such contact";
}

if (contacts[i].hasOwnProperty(prop)  === true) {
return contacts[i][prop];
} else {
return "No such property";
} 

}

i++;
// Only change code above this line
}

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

Hey, I pretty new and have been working on this problem for awhile, could someone point me to what I'm missing in this code?
fdemaa
@fdemaa
Jun 26 2017 03:01 UTC
@sethsdo you have to use a for loop and inside put the conditions
well you are using it
lol
i didnt saw it
sethsdo
@sethsdo
Jun 26 2017 03:02 UTC
sorry, i formatted it wrong when I submitted it.
fdemaa
@fdemaa
Jun 26 2017 03:03 UTC
You have to return contacts[i]prop, when the 2 conditions are true:
when firstname is an actual firstname and the property exist
Eric Hasegawa
@EricHasegawa
Jun 26 2017 03:03 UTC
@sethsdo I think you can edit it even after sending it to the chat, try clicking the three dots to the right of the message
kumquatfelafel
@kumquatfelafel
Jun 26 2017 03:03 UTC
@EricHasegawa Right. So, first things first, we want this function to return an array. Also, you're referencing the elements of your 2d array incorrectly. Also, your conditions (checks) for the for loop are incorrect. You want i < arr.length, for example. Putting .length after an array's variable name will give you the number of elements in said array.
@EricHasegawa Indeed, comments can be edited for a period of time after they're posted
Eric Hasegawa
@EricHasegawa
Jun 26 2017 03:05 UTC

function largestOfFour(arr) {

var standard = 0;

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

for (var j=0; i< arr[j]; i++) {
if (arr[j] > standard ) {
standard = arr[j];
}
}

}

return standard;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
@kumquatfelafel Is that looking better?
Sorry that second for loop should say j++, I corrected it in my code
aewalefo
@aewalefo
Jun 26 2017 03:09 UTC

Hello friends! I am working through "Stand in Line" in Basic Java Script.

These are the instructions:
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
This is what I've done so far:
function nextInLine(arr, item) {
arr = [1, 2, 3];
item = 4;
arr = arr.push(item);
arr = arr.shift(0);
return nextInLine;

I'm getting an error that says "arr.shift is not a function"

Can someone help me understand what I'm missing please?

Claudio Restifo
@Marmiz
Jun 26 2017 03:16 UTC
@aewalefo can you please post your code? with all the braces and functions call? It's hard to understand what you did with the info provided
aewalefo
@aewalefo
Jun 26 2017 03:18 UTC

@Marmiz sure, let me try to copy/paste again. I've been messing with it, so it's different now. This is my entire screen:

function nextInLine(arr, item) {
arr = [1, 2, 3];
item = 4;
arr.push(item);
removed = arr.shift();

return removed; // 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));

fdemaa
@fdemaa
Jun 26 2017 03:20 UTC
@EricHasegawa yes you should fix some things in the if also
Claudio Restifo
@Marmiz
Jun 26 2017 03:20 UTC
@aewalefo
You are passing two arguments to the functions, meaning that inside it arr and item are already declared and populated with values.
So for instance if I am calling my functions with some values they will be passed to my functions.
function nextInLine(arr, item) {
// inside here arr is [1,2,3]
//and item is 6
}

nextInLine([1,2,3], 6)

while in your code you are:

var testArr = [1,2,3,4,5] //this is an array called testArray
nextInLine(testArr, 6)) // I am passing into my function testArray and 6

function nextInLine(arr, item) {
//i receive testArray and here it's called arr
// 6 is now called item

arr = [1, 2, 3]; // but wait now arr is this thig, it's no more testArray
item = 4; // same for item. now it's 4 and not 6
arr.push(item);
removed = arr.shift();
return removed; // Change this line
}

Make sense?

aewalefo
@aewalefo
Jun 26 2017 03:26 UTC
@Marmiz ok, so are you saying that I did not need to declare values for arr and item? I only need to "add the number to the end of the array, then remove the first element of array"?
Claudio Restifo
@Marmiz
Jun 26 2017 03:27 UTC

@aewalefo for the rest your function idea is correct:

arr.push(item);
removed = arr.shift();
return removed; // Change this line

but by declaring values inside the function with this:

arr = [1, 2, 3];
item = 4;

does not matter which value I decide to pass they will aways be [1,2,3] and 4. Which is not what you want, you want your function to works with the values it receive

aewalefo
@aewalefo
Jun 26 2017 03:27 UTC
@Marmiz GOT IT!!! :D
@Marmiz I deleted my assignments and it worked :) thank you!!
CamperBot
@camperbot
Jun 26 2017 03:28 UTC
aewalefo sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
Claudio Restifo
@Marmiz
Jun 26 2017 03:30 UTC
@aewalefo to give you a simpler example: I create a function that takes a number and give me back the number +1.
But if inside i declare number to be a specific value it will always be that, no matter what I pass to it
function add1(num){
num = 6
return num +1
}

add1(3) // expect to be 4 but it return 7
add1(1) // expect to be 2 but return 7
CallMeOrange
@EgnaroDev
Jun 26 2017 03:31 UTC
Can someone help me with Profile Lookup :/
I think Im close but statements are probably wrong..
kumquatfelafel
@kumquatfelafel
Jun 26 2017 03:32 UTC

@EricHasegawa I would review nested for loops challenge.
You can think of a 2d array as being a bit like a grid.
arr[0][0] arr[0][1] arr[0][2] arr[0][3]
arr[1][0] arr[1][1] arr[1][2] arr[1][3]
arr[2][0] arr[2][1] arr[2][2] arr[2][3]

If you say arr, it will reference the entire array. If you say arr[0], it will reference the array containing elements arr[0][0] arr[0][1] arr[0][2] arr[0][3]. (note, each row is essentially it's own array).
If you want to reference a single value in the array, you have to include both coordinates, or "indices". For example, arr[1,1] would give me whatever value is stored in arr[1][1].

If I say arr.length, it will tell me how many elements (arr[0], arr[1], arr[2]) there are. You can also think of it like "how many rows".

If I say arr[0].length, it will tell me how many elements there are in arr[0] (arr[0][0], arr[0][1], arr[0][2], arr[0][3]).

When you say "i < arr[j]", this is wrong. When you say "arr[j] > standard", this is wrong. When you say "standard = arr[j]", this is also wrong.

You have the right idea, but you are not applying it properly for 2d-arrays, nested for loops, and you still need to take care of the return. The return itself will require not a single value, but an array of the highest value for each sub-array in the original array. Is there a function we can use to add elements to an array?

(technically, you don't have to do it this way, but understanding how to do it with nested for loop still important, and a good starting point)

grhiong
@grhiong
Jun 26 2017 03:34 UTC

function mutation(arr) {
// 请把你的代码写在这里
var first = arr.slice(0,1).join();
var str = arr.slice(1,2).join();
var sep = str.split("");
for(var i in sep)
{
if(first.toLowerCase().indexOf(sep[i].toLowerCase()) != -1)
{
return true;
}
else
{
return false;
}
}

}

mutation(["hello", "hey"]);
the result should be false,however it returns true,who can tell me the reason?

@Marmiz
CallMeOrange
@EgnaroDev
Jun 26 2017 03:35 UTC
Let me restart Profile Lookup then follow instructions by order this time :/
Alma Niu
@Justdoit2
Jun 26 2017 03:40 UTC
replacing if else chains with switch
CallMeOrange
@EgnaroDev
Jun 26 2017 03:41 UTC
@Justdoit2 Me?
Claudio Restifo
@Marmiz
Jun 26 2017 03:41 UTC
@grhiong I think you confused the -1 of indexOf.
indexOf return -1 if the element is not there... so why would you want to return true if the element is not there?
sethsdo
@sethsdo
Jun 26 2017 03:41 UTC
@fdemaa thanks for your tips, I got it worked out. Although it's not as elegant as I was wanting, the good thing is it works! :smile:
CamperBot
@camperbot
Jun 26 2017 03:41 UTC
sethsdo sends brownie points to @fdemaa :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
Jun 26 2017 03:43 UTC
I don't feel like I've done enough in here today.
kumquatfelafel
@kumquatfelafel
Jun 26 2017 03:43 UTC
@revisualize If it makes you feel any better, I don't feel like I've done enough anywhere today. :p
Joseph
@revisualize
Jun 26 2017 03:44 UTC
@kumquatfelafel I went on a couple of bike rides.
That was fun.
Of course, I have an electric bike.
kumquatfelafel
@kumquatfelafel
Jun 26 2017 03:45 UTC
Matthew
@muzcmancoder91
Jun 26 2017 03:46 UTC
How do I Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

function abTest(a, b) {
// Only change code below this line

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

Joseph
@revisualize
Jun 26 2017 03:46 UTC
@muzcmancoder91 Write an if statement for me.
kumquatfelafel
@kumquatfelafel
Jun 26 2017 03:47 UTC
Pretty much just took dogs for a few walks, got lunch, took shower. Not very eventful day.
Matthew
@muzcmancoder91
Jun 26 2017 03:48 UTC
an if statement for a and b together?
Joseph
@revisualize
Jun 26 2017 03:48 UTC
@muzcmancoder91 I didn't mention anything about a or b. I just asked you to write an if statement for me.
Matthew
@muzcmancoder91
Jun 26 2017 03:49 UTC
if (){
}
Joseph
@revisualize
Jun 26 2017 03:49 UTC
@muzcmancoder91 Great. Can you add a condition to that if statement ... for a variable a being less than 0?
Matthew
@muzcmancoder91
Jun 26 2017 03:50 UTC
if (a < 0) {
}
Joseph
@revisualize
Jun 26 2017 03:50 UTC
Great.
Matthew
@muzcmancoder91
Jun 26 2017 03:51 UTC
Thanks
Joseph
@revisualize
Jun 26 2017 03:51 UTC
@muzcmancoder91 Can you add an additional condition to that if condition for having another variable ... or b less than 0
Matthew
@muzcmancoder91
Jun 26 2017 03:52 UTC
} else if (b < 0) {
}
Joseph
@revisualize
Jun 26 2017 03:52 UTC
@muzcmancoder91 No.
Matthew
@muzcmancoder91
Jun 26 2017 03:52 UTC
?
Joseph
@revisualize
Jun 26 2017 03:52 UTC
@muzcmancoder91 I didn't mention anything about an else
kumquatfelafel
@kumquatfelafel
Jun 26 2017 03:53 UTC
Matthew
@muzcmancoder91
Jun 26 2017 03:54 UTC
Do I use a ||?
Joseph
@revisualize
Jun 26 2017 03:54 UTC
@muzcmancoder91 That's an or in JavaScript.
Matthew
@muzcmancoder91
Jun 26 2017 03:55 UTC
Ok could you give me a clue?
Joseph
@revisualize
Jun 26 2017 03:55 UTC
@muzcmancoder91 How about you show me what you've come up with and we'll work from there.
Matthew
@muzcmancoder91
Jun 26 2017 03:56 UTC
if (a < 0 || b < 0) {
return undefined;
}
Joseph
@revisualize
Jun 26 2017 03:56 UTC
@muzcmancoder91 GREAT!
@muzcmancoder91 So, what's your question again?
@muzcmancoder91 Did you see what I did there by the way that I asked you questions? And how I had you break the problem down. Then how you solved it on your own.
kumquatfelafel
@kumquatfelafel
Jun 26 2017 03:59 UTC
@muzcmancoder91 If you feel like answering an additional conceptual question to test your understanding, why would you use || as opposed to && here?
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:04 UTC
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:04 UTC
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:05 UTC
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:05 UTC
ah
tiger500
@tiger500
Jun 26 2017 04:05 UTC
guys can u help me Create a // style comment that contains at least five letters.
Create a / / style comment that contains at least five letters.
Make sure that you close the comment with a */.
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:07 UTC

my codes are...................................function nextInLine(arr, item) {
var removedNum= arr.shift();
arr.unshift(6);

return removedNum; // 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));

langtson
@langtson
Jun 26 2017 04:08 UTC
I think it means @tiger500
/* 12345 */
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:08 UTC

@DevinderThakur So your removal will *mostly* work properly, but mostly isn't quite always enough.

You're supposed to add to the end, and then afterwards remove from beginning of array.

tiger500
@tiger500
Jun 26 2017 04:09 UTC
@langtson thanks
CamperBot
@camperbot
Jun 26 2017 04:09 UTC
tiger500 sends brownie points to @langtson :sparkles: :thumbsup: :sparkles:
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:10 UTC
@kumquatfelafel
Joseph
@revisualize
Jun 26 2017 04:10 UTC
@DevinderThakur You're doing things out of order.
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:10 UTC
@kumquatfelafel checking it
Joseph
@revisualize
Jun 26 2017 04:10 UTC
@DevinderThakur Also, where does .. .unshift() put the element?
@DevinderThakur Why are you using the arr parameter and not the item parameter?
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:11 UTC
@revisualize checking it
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:17 UTC
Yeah. You shouldn't be adding the literal value 6 to the array. You don't know what value the person using your function will want to add. They might add 6, sure, but they also might add 23, or "kumquatfelafel is spelled wrong".
victortran2015
@victortran2015
Jun 26 2017 04:22 UTC

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

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

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

Example Output
"-3 Hold"
"5 Bet"

Hint
Do NOT reset count to 0 when value is 7, 8, or 9.

can anyone help me with this one please ?
This is what I have done so far

var count = 0;

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

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

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

}

if (count<=0){

return "\""+count+" "+"Hold"+"\"" ;

}
else {return "\""+count+" "+"Bet"+"\"";

  }

}

// Only change code above this line
}

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

kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:24 UTC

@victortran2015 They don't actually want the quotes on the outside.

Just 0 Hold, 3 Bet, etc is fine.

severusKen
@severusKen
Jun 26 2017 04:24 UTC
Hi everyone, just a small question for the FrontEnd challenge number 145. I don't understand the first requirement which is: "myStr should have encoded text with the proper escape sequences and no spacing."
M-C-Haker
@M-C-Haker
Jun 26 2017 04:25 UTC
Looking for some assistance on the mymusic array. Task: Add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings. To add a new ablum would you use some sort of .shift to add the album? how do you poing additional strings to specific properties?
severusKen
@severusKen
Jun 26 2017 04:25 UTC
My code has met all the requirement but this.
var myStr="\FirstLine\\nSecondLine\rThirdLine";
fdemaa
@fdemaa
Jun 26 2017 04:26 UTC
@M-C-Haker shift is for arrays, not for objects
you have an array?
M-C-Haker
@M-C-Haker
Jun 26 2017 04:26 UTC
it says its an array @fdemaa
fdemaa
@fdemaa
Jun 26 2017 04:27 UTC
do you have the code?
M-C-Haker
@M-C-Haker
Jun 26 2017 04:27 UTC
In fact it's an array which contains an object
I listed the task above here is code
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
];
fdemaa
@fdemaa
Jun 26 2017 04:31 UTC

you need to add another object,and inside that put the properties and the array that the exercise told you

To add the album wich is the object you have to do it like:

{

new album

}

Csaba Balogh
@JasonCorp84
Jun 26 2017 04:31 UTC
Hello everyone!
var obj2 = Object.keys(source).toString();// source keys
var valami = source.obj2;
Joseph
@revisualize
Jun 26 2017 04:31 UTC
@severusKen Because you're not escaping things in the correct order ... your code isn't meeting all of the requirements.
Csaba Balogh
@JasonCorp84
Jun 26 2017 04:31 UTC
what is wrong with this ?
Joseph
@revisualize
Jun 26 2017 04:33 UTC
@JasonCorp84 Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
Csaba Balogh
@JasonCorp84
Jun 26 2017 04:33 UTC
@revisualize awesome! Thank you!
CamperBot
@camperbot
Jun 26 2017 04:33 UTC
jasoncorp84 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4258 | @revisualize |http://www.freecodecamp.com/revisualize
Csaba Balogh
@JasonCorp84
Jun 26 2017 04:34 UTC
That was exactly what i was looking for
severusKen
@severusKen
Jun 26 2017 04:34 UTC
@revisualize Oh i forgot the order ... Thks alot :)
tiger500
@tiger500
Jun 26 2017 04:35 UTC
how u make a should be assigned to b with =
dascreator
@dascreator
Jun 26 2017 04:35 UTC
Hello all, I am having a hard time figuring out what I am missing with a switch statement. Can anyone help?
Joseph
@revisualize
Jun 26 2017 04:35 UTC
@tiger500 How do you assign the value of 7 to a variable num?
tiger500
@tiger500
Jun 26 2017 04:36 UTC
var a=7;
var b = 7;
Joseph
@revisualize
Jun 26 2017 04:36 UTC
@tiger500 Nope.
tiger500
@tiger500
Jun 26 2017 04:36 UTC
then how
Joseph
@revisualize
Jun 26 2017 04:36 UTC
@tiger500 Can you answer my question?
Csaba Balogh
@JasonCorp84
Jun 26 2017 04:36 UTC
var num = 7;
var num = 7;
Joseph
@revisualize
Jun 26 2017 04:37 UTC
@JasonCorp84 I'm asking them NOT you.
But, thanks though?
Csaba Balogh
@JasonCorp84
Jun 26 2017 04:37 UTC
sorry
M-C-Haker
@M-C-Haker
Jun 26 2017 04:37 UTC
@fdemaa oh i see now, i guess i was reading it wrong we're adding additional information to my music now necessiarily modifying what's in the current variable, if that makes any sense
@fdemaa thanks
CamperBot
@camperbot
Jun 26 2017 04:37 UTC
m-c-haker sends brownie points to @fdemaa :sparkles: :thumbsup: :sparkles:
fdemaa
@fdemaa
Jun 26 2017 04:37 UTC
@M-C-Haker np man!
Joseph
@revisualize
Jun 26 2017 04:38 UTC
@tiger500 How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:38 UTC
= is known as an assignment operator. You can ... I'm too tired. I leave this in your capable hands @revisualize :p
Matthew
@muzcmancoder91
Jun 26 2017 04:38 UTC
What's wrong with my code?

var total = 0;

for (var i = 0; i < myArray.length; i++){
total += myArray[i];
}

Use a for loop to work to push the values 1 through 5 onto myArray.
dascreator
@dascreator
Jun 26 2017 04:38 UTC
any help getting this one going would be greatly appreciated.
Joseph
@revisualize
Jun 26 2017 04:38 UTC
@dascreator You're console.log'ing when you should be changing the value of the variable answer
@dascreator Can you delete the spam?
dascreator
@dascreator
Jun 26 2017 04:39 UTC
sorry for the repetitive sends, my computer froze then released my several attempts at once. lol
Joseph
@revisualize
Jun 26 2017 04:39 UTC
@dascreator You can delete posts.
CallMeOrange
@EgnaroDev
Jun 26 2017 04:40 UTC
@revisualize Hey
Do you have any notes for Profile Lookup :/
Joseph
@revisualize
Jun 26 2017 04:40 UTC
@MCTwoDigitZero I do.
I've solved that challenge 5 different ways.
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:40 UTC
(To delete, click ... that shows up when you drag mouse over your comment)
dascreator
@dascreator
Jun 26 2017 04:41 UTC
done thanks.
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:41 UTC
CallMeOrange
@EgnaroDev
Jun 26 2017 04:41 UTC
@revisualize Can you take a look at mine?
Joseph
@revisualize
Jun 26 2017 04:41 UTC
@MCTwoDigitZero Sure.
CallMeOrange
@EgnaroDev
Jun 26 2017 04:41 UTC


function lookUpProfile(firstName, prop) {

for (var i = 0; i < contacts.length; i++) {
console.log(contacts[i]);

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

}

lookUpProfile("Kristian", "lastName");
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:41 UTC
@kumquatfelafel thanks
CamperBot
@camperbot
Jun 26 2017 04:41 UTC
devinderthakur sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
Jun 26 2017 04:42 UTC
@MCTwoDigitZero WHY!? WHY!? Did you post the huge array?
CallMeOrange
@EgnaroDev
Jun 26 2017 04:42 UTC
Relax..
Joseph
@revisualize
Jun 26 2017 04:42 UTC
@MCTwoDigitZero Okay. Let me ask you a question.
CallMeOrange
@EgnaroDev
Jun 26 2017 04:42 UTC
Yes?
dascreator
@dascreator
Jun 26 2017 04:42 UTC
@revisualize thanks for the help, got it!
CamperBot
@camperbot
Jun 26 2017 04:42 UTC
dascreator sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4259 | @revisualize |http://www.freecodecamp.com/revisualize
Matthew
@muzcmancoder91
Jun 26 2017 04:42 UTC

// Setup
var myArray = [];

// Only change code below this line.

for (var i = 0; i < 5; i++){
myArray.push(i);
}

Csaba Balogh
@JasonCorp84
Jun 26 2017 04:42 UTC

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

if (collection[i].hasOwnProperty(valami)){

arr.push(collection[i]);
}
}
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:42 UTC
@camperbot how to send brownie points
Csaba Balogh
@JasonCorp84
Jun 26 2017 04:43 UTC
I got some weird error here
CallMeOrange
@EgnaroDev
Jun 26 2017 04:43 UTC
@DevinderThakur type thanks @person
You did it but no space
Matthew
@muzcmancoder91
Jun 26 2017 04:43 UTC
It says myArray should equal [1, 2, 3, 4, 5]
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:44 UTC
thanks@ @MCTwoDigitZero
CamperBot
@camperbot
Jun 26 2017 04:44 UTC
devinderthakur sends brownie points to @mctwodigitzero :sparkles: :thumbsup: :sparkles:
CallMeOrange
@EgnaroDev
Jun 26 2017 04:44 UTC
@muzcmancoder91 So what is i < 5
Joseph
@revisualize
Jun 26 2017 04:44 UTC
@MCTwoDigitZero Let's first evaluate this:
(firstName !== contacts[i].firstName)
So, with the function call of .... lookUpProfile("Kristian", "lastName");
you're basically doing...
("Kristian" !== contacts[i].firstName)
Then you need to look at the fact that...
i = 0; on the first iteration.
So... ("Kristian" !== contacts[0].firstName)
Then.. ("Kristian" !== "Akira")
is ("Kristian" !== "Akira") true or false?
Matthew
@muzcmancoder91
Jun 26 2017 04:44 UTC
@MCTwoDigitZero I'm not sure :D
CallMeOrange
@EgnaroDev
Jun 26 2017 04:44 UTC
false?
Joseph
@revisualize
Jun 26 2017 04:45 UTC
@MCTwoDigitZero Look at it again.
CallMeOrange
@EgnaroDev
Jun 26 2017 04:45 UTC
@muzcmancoder91 i < 5 var i is less than 5
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:45 UTC
thanks @MCTwoDigitZero
CamperBot
@camperbot
Jun 26 2017 04:45 UTC
devinderthakur sends brownie points to @mctwodigitzero :sparkles: :thumbsup: :sparkles:
:warning: devinderthakur already gave mctwodigitzero points
CallMeOrange
@EgnaroDev
Jun 26 2017 04:45 UTC
@revisualize alright
Matthew
@muzcmancoder91
Jun 26 2017 04:45 UTC
I guess
Joseph
@revisualize
Jun 26 2017 04:45 UTC
@MCTwoDigitZero Is 1 !== 5 true or false?
CallMeOrange
@EgnaroDev
Jun 26 2017 04:45 UTC
@revisualize false
Joseph
@revisualize
Jun 26 2017 04:46 UTC
@MCTwoDigitZero 1 not equal to 5 ... is false?
Csaba Balogh
@JasonCorp84
Jun 26 2017 04:46 UTC
1 is not equal to 5
CallMeOrange
@EgnaroDev
Jun 26 2017 04:46 UTC
oh..
Joseph
@revisualize
Jun 26 2017 04:46 UTC
In what world is 1 not equal to 5 ... false?
Is this the twilight zone?
CallMeOrange
@EgnaroDev
Jun 26 2017 04:46 UTC
1 is not equal to 5..
Matthew
@muzcmancoder91
Jun 26 2017 04:46 UTC
yes it's not equal
CallMeOrange
@EgnaroDev
Jun 26 2017 04:46 UTC
I dont understand how it is true
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:46 UTC
@DevinderThakur I... don't remember what I did, but np :laughing:
CallMeOrange
@EgnaroDev
Jun 26 2017 04:46 UTC
Ok this is confusing
Joseph
@revisualize
Jun 26 2017 04:47 UTC
@MCTwoDigitZero Because 1 is NOT equal to 5.
Matthew
@muzcmancoder91
Jun 26 2017 04:47 UTC
Correct it's not
Joseph
@revisualize
Jun 26 2017 04:47 UTC
1 is 1 ... 5 is 5
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:47 UTC
thanks@ @kumquatfelafel
CamperBot
@camperbot
Jun 26 2017 04:47 UTC
devinderthakur sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:warning: devinderthakur already gave kumquatfelafel points
CallMeOrange
@EgnaroDev
Jun 26 2017 04:47 UTC
Yes I understand... I thought it meant false
Ok its true
Joseph
@revisualize
Jun 26 2017 04:47 UTC
@MCTwoDigitZero Let's first evaluate this:
(firstName !== contacts[i].firstName)
So, with the function call of .... lookUpProfile("Kristian", "lastName");
you're basically doing...
("Kristian" !== contacts[i].firstName)
Then you need to look at the fact that...
i = 0; on the first iteration.
So... ("Kristian" !== contacts[0].firstName)
Then.. ("Kristian" !== "Akira")
is ("Kristian" !== "Akira") true or false?
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:47 UTC
Matthew
@muzcmancoder91
Jun 26 2017 04:47 UTC
I'm not just trying to figure out what I'm doing wrong
CallMeOrange
@EgnaroDev
Jun 26 2017 04:48 UTC
true
But doesn't it check all objects first?
Joseph
@revisualize
Jun 26 2017 04:48 UTC
@MCTwoDigitZero So because "Kristian" is not equal to "Akira" ... with it being true... The true statement is invoked.
@MCTwoDigitZero Where in my explanation do you see me looking at any other object?
Dave Reichert
@davidreichert
Jun 26 2017 04:49 UTC
I need help on Using Objects for Lookups
CallMeOrange
@EgnaroDev
Jun 26 2017 04:49 UTC
@revisualize None..
Dave Reichert
@davidreichert
Jun 26 2017 04:49 UTC


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

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

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

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

Joseph
@revisualize
Jun 26 2017 04:49 UTC
@MCTwoDigitZero Okay.
Dave Reichert
@davidreichert
Jun 26 2017 04:49 UTC
// Setup
function phoneticLookup(val) {
var result = "";

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

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

// Change this value to test
phoneticLookup("charlie");
M-C-Haker
@M-C-Haker
Jun 26 2017 04:49 UTC
@fdemaa ok i guess i'm still not doing something right
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:49 UTC
today i will only learn how to send brownie points @camperbot
Joseph
@revisualize
Jun 26 2017 04:49 UTC
@davidreichert You're overwriting the val parameter with an object.
CallMeOrange
@EgnaroDev
Jun 26 2017 04:49 UTC
So how do I make it to test all objects first?
M-C-Haker
@M-C-Haker
Jun 26 2017 04:49 UTC
var myMusic = [
[
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
]
[
{
"artist": "Rage Against the Machine",
"title": "Killing in the name of",
"release_year": 2010,
"formats": [
"CD",
"MP3",
"Apple Music"],
}
]
];
Joseph
@revisualize
Jun 26 2017 04:49 UTC
@MCTwoDigitZero You need to change your code.
CallMeOrange
@EgnaroDev
Jun 26 2017 04:49 UTC
Right..
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:49 UTC
Joseph
@revisualize
Jun 26 2017 04:50 UTC
@DevinderThakur You're not including a space.
CallMeOrange
@EgnaroDev
Jun 26 2017 04:50 UTC
@DevinderThakur You need space between them.. are you trolling?
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:50 UTC
@muzcmancoder91 in your code, for the first iteration what is the value of i?
for(var i = 0; i < 5; i++) {
arr.push(i); //the first time this line of your code is executed, what is added to array?
}
Dave Reichert
@davidreichert
Jun 26 2017 04:50 UTC
@revisualize What does var result = ""; do?
Devinder Thakur
@DevinderThakur
Jun 26 2017 04:50 UTC
no
Joseph
@revisualize
Jun 26 2017 04:50 UTC
@davidreichert It declares a variable called result and assigns it the value of an empty string.
@davidreichert What does var num = 7; do?
Dave Reichert
@davidreichert
Jun 26 2017 04:51 UTC
It creates a variable called num and assigns a value of 7 to it
Joseph
@revisualize
Jun 26 2017 04:51 UTC
@davidreichert Great.
jasonrest
@jasonrest
Jun 26 2017 04:51 UTC
Solved! quick question about Ceaser's Cipher. Why is it necessary to join after the decoded array has been arranged? I don't understand why that's necessary.
function rot13(str) { // LBH QVQ VG!
var abc = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',     'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M'];

var decoded = [];

for (i = 0;i < str.length; i++){
var newArr = abc.indexOf(str[i]) + 13;
if (abc.indexOf(str[i]) == -1){
decoded.push(str[i]);
}
else{
decoded.push(abc[newArr]);
}
}
return decoded.join("");
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Matthew
@muzcmancoder91
Jun 26 2017 04:51 UTC
@kumquatfelafel Is it 0?
Coy Sanders
@coymeetsworld
Jun 26 2017 04:52 UTC
because you need to return a string @jasonrest. decoded is an array
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:52 UTC
@muzcmancoder91 why is that your guess?
Joseph
@revisualize
Jun 26 2017 04:52 UTC
@jasonrest Because you're returning an array if you don't .join() ... The instructions state to return a string.
@coymeetsworld :wave:
Matthew
@muzcmancoder91
Jun 26 2017 04:53 UTC
Thanks @kumquatfelafel
CamperBot
@camperbot
Jun 26 2017 04:53 UTC
muzcmancoder91 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
Jun 26 2017 04:53 UTC
@revisualize hey
Matthew
@muzcmancoder91
Jun 26 2017 04:53 UTC
I had to change the 0 to a 1
jasonrest
@jasonrest
Jun 26 2017 04:53 UTC
@coymeetsworld @revisualize got it. Thanks. attention to detail.
CamperBot
@camperbot
Jun 26 2017 04:53 UTC
jasonrest sends brownie points to @coymeetsworld and @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4260 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 2880 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:53 UTC
@muzcmancoder91 :+1:
Matthew
@muzcmancoder91
Jun 26 2017 04:53 UTC
Thanks! It's been a long evening haha
Coy Sanders
@coymeetsworld
Jun 26 2017 04:53 UTC
yep thats important @jasonrest :+1:
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:54 UTC
@muzcmancoder91 get it. Quite frankly, I'm surprised I'm still able to speak.
:p
Matthew
@muzcmancoder91
Jun 26 2017 04:54 UTC
Yes agreed :D
Dave Reichert
@davidreichert
Jun 26 2017 04:55 UTC
@revisualize Why doesn't this work?
// Setup
function phoneticLookup(val) {
var result = "";

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

// Change this value to test
phoneticLookup("charlie");
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:55 UTC
@davidreichert Dave.val searches for "val" as opposed to "alpha" or "bravo" or etc.
Joseph
@revisualize
Jun 26 2017 04:56 UTC
@davidreichert Because you're doing it backwards.
M-C-Haker
@M-C-Haker
Jun 26 2017 04:56 UTC
trying to create a mymusic[1] object but it's saying that's not valid anyone have any advice on this challenge?
Joseph
@revisualize
Jun 26 2017 04:56 UTC
@davidreichert Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:56 UTC
^this :laughing:
Joseph
@revisualize
Jun 26 2017 04:57 UTC
@M-C-Haker How do you create an array with two elements... Each of them is an object: [ { ... } , { ... } ] The ...s are supposed to be your object properties.
tiger500
@tiger500
Jun 26 2017 04:58 UTC

// Setup
var a;
var b = 2;
var b=7;
var a=7;

// Only change code below this line

what did i do wrong

Joseph
@revisualize
Jun 26 2017 04:59 UTC
@tiger500 Did you read what I wrote?
@tiger500
How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
kumquatfelafel
@kumquatfelafel
Jun 26 2017 04:59 UTC
@tiger500 Hint: You can also have variables to the right of the assignment operator, =.
Joseph
@revisualize
Jun 26 2017 04:59 UTC
@tiger500 You're also doing things out of order.
@tiger500 You're also changing code above the line.
Variables hold values.
tiger500
@tiger500
Jun 26 2017 05:03 UTC
@revisualize @kumquatfelafel thanks
CamperBot
@camperbot
Jun 26 2017 05:03 UTC
tiger500 sends brownie points to @revisualize and @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:star2: 4261 | @revisualize |http://www.freecodecamp.com/revisualize
Csaba Balogh
@JasonCorp84
Jun 26 2017 05:04 UTC
  var obj2 = Object.keys(source).toString();// source keys
var valami = source[obj2];

for (var i = 0; i < collection.length){
if(valami === collection[i][obj2]){
arr.push(collection[i][obj2]);
}
}
what am I missing here ?
Jason Spence
@sfrjrs
Jun 26 2017 05:04 UTC
I'm stuck.
for (var i = 0; i < contacts.length; i++) {
if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
return contacts[i].prop;
} else if(contacts[i].firstName != firstName) {
return 'No such contact';
} else if(!contacts[i].hasOwnProperty(prop)) {
return 'No such property';
}
}
Joseph
@revisualize
Jun 26 2017 05:04 UTC
@sfrjrs You have a few issues.
@sfrjrs First...
@sfrjrs Re: contacts[i].prop; ... Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
Ruben Dario
@rubendmatos1985
Jun 26 2017 05:05 UTC
Hello friends. I need some help
M-C-Haker
@M-C-Haker
Jun 26 2017 05:05 UTC
@revisualize that's pretty much what i have, but it is not correct
var myMusic =
[
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
];
[
{
"artist": "Rage Against the Machine",
"title": "Killing in the name of",
"release_year": 2010,
"formats": [
"CD",
"MP3",
"Apple Music"],
}
];
Joseph
@revisualize
Jun 26 2017 05:05 UTC
@M-C-Haker It isn't correct.
Ruben Dario
@rubendmatos1985
Jun 26 2017 05:06 UTC
I am making the diferent challenges
in Jascript
Manish Giri
@Manish-Giri
Jun 26 2017 05:06 UTC
@M-C-Haker looks like you have 2 sets of [ ]?
Zack
@CrowsVeldt
Jun 26 2017 05:06 UTC
@JasonCorp84 You're missing the iterator in your 'if' statement. add: i++ to the end
Ruben Dario
@rubendmatos1985
Jun 26 2017 05:06 UTC
but i made the code correctly
and the web site dont let me go forward
Zack
@CrowsVeldt
Jun 26 2017 05:06 UTC
@JasonCorp84 That's what I noticed anyway
Manish Giri
@Manish-Giri
Jun 26 2017 05:06 UTC
@M-C-Haker to add elements to an array, you only separate them with ,
like numbers = [1, 2, 3]
Csaba Balogh
@JasonCorp84
Jun 26 2017 05:06 UTC
@CrowsVeldt thank you!
CamperBot
@camperbot
Jun 26 2017 05:06 UTC
jasoncorp84 sends brownie points to @crowsveldt :sparkles: :thumbsup: :sparkles:
Zack
@CrowsVeldt
Jun 26 2017 05:06 UTC
:)
M-C-Haker
@M-C-Haker
Jun 26 2017 05:07 UTC
@revisualize correct dirctions state "Add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings." so basically create another array first on billy joel already given,..
Joseph
@revisualize
Jun 26 2017 05:07 UTC
@M-C-Haker You have this...
var myMusic =
[
{
....
}
];  // the ; is a statement terminator
[
{
...
}
];
Manish Giri
@Manish-Giri
Jun 26 2017 05:07 UTC
if your array elements are objects, same rule applies
things = [{ object1}, {object2}]
@M-C-Haker
Joseph
@revisualize
Jun 26 2017 05:07 UTC
@M-C-Haker You're making [ { ... } ] ; [ { ... } ]
Manish Giri
@Manish-Giri
Jun 26 2017 05:07 UTC
Ryan Nelson
@iamryandnelson
Jun 26 2017 05:08 UTC
I'm getting a horrible audio lag on mobile :worried: . Can someone tell me how to fix this, please?
https://codepen.io/iamryandnelson/pen/BZWrmq
Jon
@jonandrepedersen
Jun 26 2017 05:08 UTC
function truncateString(str, num) {
var reLength = str.slice(0,num);

if (str.length > num && num > 3) {
return reLength.slice(0, -3) + "...";
} else if (str.length > num && num <= 3) {
return reLength + "...";
}
return reLength;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Can't believe I actually made this all by myself. Very proud. However, I would like to ask if there are any bad habits or otherwise better ways of coding this. Help much appreciated.
https://www.freecodecamp.com/challenges/truncate-a-string
M-C-Haker
@M-C-Haker
Jun 26 2017 05:08 UTC
@Manish-Giri it's asking me to add another album, if i just separate with commons it is telling me i have duplicate properties
Manish Giri
@Manish-Giri
Jun 26 2017 05:09 UTC
@M-C-Haker fix the problem of the double [ ] I pointed out, then post your code again
M-C-Haker
@M-C-Haker
Jun 26 2017 05:10 UTC
@Manish-Giri you're the man, thanks i should have been using the comma, instead of the ';'
CamperBot
@camperbot
Jun 26 2017 05:10 UTC
m-c-haker sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6116 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 26 2017 05:10 UTC
@M-C-Haker :+1:
Joseph
@revisualize
Jun 26 2017 05:10 UTC
@sfrjrs Second...
When you make the function call of lookUpProfile("Kristian", "lastName");
You have a problem with...
else if(contacts[i].firstName != firstName)
Because if we break it down when i = 0;
(contacts[i].firstName != firstName)
(contacts[0].firstName != firstName)
(contacts[0].firstName != "Kristian")
("Akira" != "Kristian")
... You're then doing a return "No such contact";
M-C-Haker
@M-C-Haker
Jun 26 2017 05:10 UTC
@Manish-Giri how long have you been coding?
Manish Giri
@Manish-Giri
Jun 26 2017 05:11 UTC
@M-C-Haker been a while, about 4 years seriously, 6-7 in total..
David Bercovici
@davidberco
Jun 26 2017 05:11 UTC
Hello everyone, the task of word blanks in javascript, which operators do I have to use?
Manish Giri
@Manish-Giri
Jun 26 2017 05:12 UTC
@davidberco + for string concatenation..
kumquatfelafel
@kumquatfelafel
Jun 26 2017 05:12 UTC
@jonandrepedersen If num is 2, for example, and str is 10 characters long, your return should be the first 2 characters of str, followed by "..."
Joseph
@revisualize
Jun 26 2017 05:12 UTC
@davidberco = and +
Jon
@jonandrepedersen
Jun 26 2017 05:12 UTC
@kumquatfelafel I will test that now, thanks
CamperBot
@camperbot
Jun 26 2017 05:13 UTC
jonandrepedersen sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
M-C-Haker
@M-C-Haker
Jun 26 2017 05:13 UTC
@Manish-Giri ok i'm happy to here that, i think this is the 2nd or 3rd time you've helped me out and i was starting to get a little frustated and wondering how come this guy has all the answers lol. Not everyone is counting in the weeks like me i guess. Appreciate the help again.
Manish Giri
@Manish-Giri
Jun 26 2017 05:14 UTC
lol
welcome, and good luck!
@M-C-Haker
Jon
@jonandrepedersen
Jun 26 2017 05:14 UTC
@kumquatfelafel it does do that. And as mentioned, I succeeded in the challenge. However, I am sure the code could have been written better
David Bercovici
@davidberco
Jun 26 2017 05:14 UTC
@revisualize there is something I missing because I cannot get the result, thanks I will try it harder
CamperBot
@camperbot
Jun 26 2017 05:14 UTC
davidberco sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4262 | @revisualize |http://www.freecodecamp.com/revisualize
Manish Giri
@Manish-Giri
Jun 26 2017 05:15 UTC
@davidberco remember to add spaces, you won't pass without those.
kumquatfelafel
@kumquatfelafel
Jun 26 2017 05:15 UTC
@jonandrepedersen oh. Misread that as asking for help. I should be going to sleep haha
Jon
@jonandrepedersen
Jun 26 2017 05:16 UTC
@kumquatfelafel Hehe no worries, but maybe you also meant that I shouldn't rely on my new variable but rather keep the code consistent with str? That there is no need for the var basically? :)
I got a feeling of that, just not sure how I would go about it
kumquatfelafel
@kumquatfelafel
Jun 26 2017 05:17 UTC
@jonandrepedersen Maybe. Whatever is right. That's obviously what I meant. :p
Joseph
@revisualize
Jun 26 2017 05:17 UTC
Okay.
David Bercovici
@davidberco
Jun 26 2017 05:17 UTC
@Manish-Giri hum, spaces into the strings? I'm quite lost
Jon
@jonandrepedersen
Jun 26 2017 05:18 UTC
@kumquatfelafel :p
Joseph
@revisualize
Jun 26 2017 05:18 UTC
@davidberco " " <-- a space
"These words have spaces between them."
Manish Giri
@Manish-Giri
Jun 26 2017 05:19 UTC
@davidberco when you use the function parameters, you need to add spaces between them, like
myNoun + " " + ... + " " + ...
CallMeOrange
@EgnaroDev
Jun 26 2017 05:20 UTC
@revisualize You said you had 5 ways to solve Profile Lookup, can you use switch statements?
David Bercovici
@davidberco
Jun 26 2017 05:20 UTC
@revisualize oh got it
@Manish-Giri oh now I know what you mean
Joseph
@revisualize
Jun 26 2017 05:20 UTC
@MCTwoDigitZero Yes, but, that's just silly.
CallMeOrange
@EgnaroDev
Jun 26 2017 05:20 UTC
True
I was curiously :/ , not planning to use it
Ryan Nelson
@iamryandnelson
Jun 26 2017 05:21 UTC
Why do I get a horrible audio lag on mobile? :worried: . Anyone had this problem?
https://codepen.io/iamryandnelson/pen/BZWrmq
CallMeOrange
@EgnaroDev
Jun 26 2017 05:22 UTC
Looks like I wont be able to solve Profile Lookup today
Night...
Joseph
@revisualize
Jun 26 2017 05:23 UTC
CallMeOrange
@EgnaroDev
Jun 26 2017 05:23 UTC
@revisualize No sorry.. I deleted the tab
can you link me to it again?
Too many tabs annoyed me, sorry
Joseph
@revisualize
Jun 26 2017 05:23 UTC
CallMeOrange
@EgnaroDev
Jun 26 2017 05:23 UTC
@revisualize thanks
CamperBot
@camperbot
Jun 26 2017 05:23 UTC
mctwodigitzero sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4263 | @revisualize |http://www.freecodecamp.com/revisualize
CallMeOrange
@EgnaroDev
Jun 26 2017 05:24 UTC
I will read it when I come back
Night guys
Mohamed Osman
@trc5019
Jun 26 2017 05:24 UTC
Hey guys I'm creating a factory function and needed some help . I wanted to know why introduce is not a function here when i call it on the person object
function person(firstName, lastName, age, gender, employed, occupation, married) {
return {
sayName() {
return firstName + " " + lastName;
}

}

return {
introduce() {
return "Hello, my name is " + firstName + " " + lastName + "." + "I am " + age + " years old. I am a " + gender + ".";
}

}
}

var john = person("John", "Doe", 18, "male", false, null, true);

console.log(john.introduce());
Joseph
@revisualize
Jun 26 2017 05:24 UTC
@trc5019 Ummm...
@trc5019 introduce() will never get accessed.
Manish Giri
@Manish-Giri
Jun 26 2017 05:25 UTC
@trc5019 the return after the first point terminates the function.
Joseph
@revisualize
Jun 26 2017 05:26 UTC
The return statement ends function execution and specifies a value to be returned to the function caller.
Syntax
return [[expression]];
expression
The expression to return. If omitted, undefined is returned instead.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
kumquatfelafel
@kumquatfelafel
Jun 26 2017 05:26 UTC

@MCTwoDigitZero For example.

if (x < a)
doSomething();
else if(x < b)
doSomethingElse();
else
dance();

is logically equivalent to

switch(true){
case x<a:
doSomething();
break;
case x<b:
doSomethingElse();
break;
default:
dance();
break;
}

But you'd never really go through the trouble of doing something like that with a switch statement.

Mohamed Osman
@trc5019
Jun 26 2017 05:26 UTC
@Manish-Giri i understand so what can i do to make it work?
Manish Giri
@Manish-Giri
Jun 26 2017 05:27 UTC
@trc5019 maybe create an object with the 2 functions as properties, and return that object?
CallMeOrange
@EgnaroDev
Jun 26 2017 05:27 UTC
@kumquatfelafel I dont like switch statements, I can use it but I want to use if statements for this challenge
I was charging my laptop, so Im leaving...
Bye
Mohamed Osman
@trc5019
Jun 26 2017 05:28 UTC
@Manish-Giri thanks
CamperBot
@camperbot
Jun 26 2017 05:28 UTC
trc5019 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6117 | @manish-giri |http://www.freecodecamp.com/manish-giri
David Bercovici
@davidberco
Jun 26 2017 05:28 UTC
I'm still in the problem of madlibs. I cannot figure out what is the meaning of:
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
Ian Nicholson
@ipnicholson
Jun 26 2017 05:29 UTC

What am I doing wrong?

Type Error: arr.shift is not a function.

function nextInLine(arr, item) {
arr = arr.push(item);
removed = arr.shift();
return removed;
}
kumquatfelafel
@kumquatfelafel
Jun 26 2017 05:29 UTC
@ipnicholson arr.push() returns length of array iirc
Krittiya Clark
@krittiyaclark
Jun 26 2017 05:29 UTC
Hi everyone - I am struck with the weather app project. What is a better way to show weather icons? I use http://erikflowers.github.io/weather-icons/
Manish Giri
@Manish-Giri
Jun 26 2017 05:30 UTC
@ipnicholson arr.push() returns the length of the new array, so arr is now a number.
and .shift() won't work on number.
@davidberco code?
kumquatfelafel
@kumquatfelafel
Jun 26 2017 05:30 UTC
@ipnicholson ^^^ It does both. Many functions perform an operation along with returning a value of some kind. Well... other than undefined. But either way, you wouldn't want arr = arr. push(item) unless you were sure that push returned the new array. Which, as stated, it doesn't so this gets you into trouble.
Ian Nicholson
@ipnicholson
Jun 26 2017 05:34 UTC
@Manish-Giri I'm calling this on an array:
// 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));
Joseph
@revisualize
Jun 26 2017 05:34 UTC
Manish Giri
@Manish-Giri
Jun 26 2017 05:35 UTC
@ipnicholson if you're stuck - post your code, not the setup
Veronica Eulenberg
@HappyViki
Jun 26 2017 05:36 UTC
Why doesn’t it return the length?
function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line

arr = collection.filter(function(value){
var sNum = 0;
for (var i in source) {
if (value[i] == source[i]) {
return source.length;
}
}

});

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

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "c": 2 });
Ian Nicholson
@ipnicholson
Jun 26 2017 05:36 UTC
@Manish-Giri Here's everything:
function nextInLine(arr, item) {
arr = arr.push(item);
removed = arr.shift([0]);
return removed;
}

// 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));
Manish Giri
@Manish-Giri
Jun 26 2017 05:37 UTC
@ipnicholson
1. as I said earlier, .push() returns a length
2. .shift() doesn't take any arguments, just .shift()
Joseph
@revisualize
Jun 26 2017 05:37 UTC

@ipnicholson Because of how you've written your code. You're making arr a number.
Look:
The push() method adds one or more elements to the end of an array and returns the new length of the array.
So, when you do:

var myArr = [ 2 , 4 , 6 , 8 ];
var len = myArr.push(10);

the value of myArr becomes [ 2 , 4 , 6 , 8 , 10 ]
And the value of len is a number 5

var myArr = [ 2 , 4 , 6 , 8 ];
var myArr = myArr.push(10);

myArr is now just 5

Manish Giri
@Manish-Giri
Jun 26 2017 05:37 UTC
@ipnicholson unless you need the length of the new array, you should just do arr.push(item)
hello can someone tell me why
arr[i].toLowerCase()
doesnt work on arr=["hello","Hello"]?
kumquatfelafel
@kumquatfelafel
Jun 26 2017 05:37 UTC
Joseph
@revisualize
Jun 26 2017 05:37 UTC
@Urio Strings are immutable.
Manish Giri
@Manish-Giri
Jun 26 2017 05:38 UTC
@Urio you need to save the value from .toLowerCase()
it won't change in place.
Joseph
@revisualize
Jun 26 2017 05:38 UTC
@Urio
var myArr = [ "Word" ];
myArr[0].toLowerCase(); // This doesn't mutate the Array element.
@revisualize that's what I have
Joseph
@revisualize
Jun 26 2017 05:39 UTC
@Urio But, that doesn't work.
David Bercovici
@davidberco
Jun 26 2017 05:39 UTC

@Manish-Giri
var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

Joseph
@revisualize
Jun 26 2017 05:39 UTC
@Urio myArr[0] is a string and strings are immutable.
Manish Giri
@Manish-Giri
Jun 26 2017 05:39 UTC
@davidberco where's the code you wrote?
Aizaz Shahid
@aizazshahid
Jun 26 2017 05:40 UTC
@Urio .toLowerCase() returns the new string, so you also need to assign it.
kumquatfelafel
@kumquatfelafel
Jun 26 2017 05:40 UTC
And the way toLowerCase gets around strings being immutable is by returning a new string, and thus you need to... ^^^
Ian Nicholson
@ipnicholson
Jun 26 2017 05:40 UTC
@Manish-Giri @revisualize Thanks, I will have another go at it. That .push() returns the length of the new array was not made clear to me in the lesson on it.
CamperBot
@camperbot
Jun 26 2017 05:40 UTC
ipnicholson sends brownie points to @manish-giri and @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4264 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 6118 | @manish-giri |http://www.freecodecamp.com/manish-giri
@revisualize Thanks I fixed it
CamperBot
@camperbot
Jun 26 2017 05:41 UTC
urio sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4265 | @revisualize |http://www.freecodecamp.com/revisualize
Veronica Eulenberg
@HappyViki
Jun 26 2017 05:41 UTC
How do I get source’s length?
function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line

return source.length;

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

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "c": 2 });
Joseph
@revisualize
Jun 26 2017 05:41 UTC
@HappyViki source is an object.
David Bercovici
@davidberco
Jun 26 2017 05:41 UTC
Joseph
@revisualize
Jun 26 2017 05:42 UTC
@HappyViki Do Objects have .lengths?
Manish Giri
@Manish-Giri
Jun 26 2017 05:42 UTC
what's the += for?
@davidberco
Joseph
@revisualize
Jun 26 2017 05:42 UTC
I need to go to bed.
Veronica Eulenberg
@HappyViki
Jun 26 2017 05:42 UTC
@revisualize it doesn’t look like it. that’s why I’m asking.
Joseph
@revisualize
Jun 26 2017 05:43 UTC
@HappyViki You can't get the length of an object.
Veronica Eulenberg
@HappyViki
Jun 26 2017 05:43 UTC
@revisualize I guess I’ll go a different route then :(
Joseph
@revisualize
Jun 26 2017 05:44 UTC
@HappyViki You can get all of the Object Keys and have them put into an array.. then you can get the .length of the new array.
Manish Giri
@Manish-Giri
Jun 26 2017 05:44 UTC
Joseph
@revisualize
Jun 26 2017 05:45 UTC
Global Object
Object.prototype.hasOwnProperty()
Object.keys()
Veronica Eulenberg
@HappyViki
Jun 26 2017 05:45 UTC
lol
me = lazy
me = should stop being lazy
Joseph
@revisualize
Jun 26 2017 05:46 UTC
Okay. I'm out.
Baibhav Gautam
@baibhavx
Jun 26 2017 05:52 UTC
Guys I am doing the pomodoro clock project. In order to tick the clock down I am trying to use setTimeout inside a while loop but its not working and the browser freezes. Anyone know whats going on?
kumquatfelafel
@kumquatfelafel
Jun 26 2017 05:53 UTC
@davidberco Not only do you need the words, you also need to include spaces between the words.
rajeshvarisharma
@rajeshvarisharma
Jun 26 2017 05:59 UTC
Stand in Line 169
function nextInLine(arr, item) {
arr.push(item);
arr.shift();
return item; // Change this line
}
error?
Coy Sanders
@coymeetsworld
Jun 26 2017 06:00 UTC
what is your function returning @rajeshvarisharma ?
kumquatfelafel
@kumquatfelafel
Jun 26 2017 06:00 UTC
@rajeshvarisharma You want to return the item you've removed.
Coy Sanders
@coymeetsworld
Jun 26 2017 06:00 UTC
and what do they ask you to return?
rajeshvarisharma
@rajeshvarisharma
Jun 26 2017 06:00 UTC
function should return the lement that was removed
kumquatfelafel
@kumquatfelafel
Jun 26 2017 06:01 UTC
@rajeshvarisharma how do we do that?
Coy Sanders
@coymeetsworld
Jun 26 2017 06:04 UTC
@rajeshvarisharma but your code isn't doing that, its returning item
the parameter you're passing in
Gary Fitzwater
@garyfalkland
Jun 26 2017 06:04 UTC
function caseInSwitch(val) {
// Only change code below this line
switch(val);
case 1:
break;

case 2:
break;

case 3:
break;

case 4:
break;

default:
break;

// Only change code above this line
}

// Change this value to test
caseInSwitch(1);
Cant figure this out
kumquatfelafel
@kumquatfelafel
Jun 26 2017 06:06 UTC
@garyfalkland
switch (val){
blah blah blah
}
Gary Fitzwater
@garyfalkland
Jun 26 2017 06:07 UTC
Yeah got thanks
@kumquatfelafel thanks
CamperBot
@camperbot
Jun 26 2017 06:07 UTC
garyfalkland sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
Nitin Sahu
@globefire
Jun 26 2017 06:07 UTC
var myStr = '<a href= http://www.example.com';

Remove all the backslashes ()
You should have two single quotes ' and four double quotes "
Only remove the backslashes \ used to escape quotes.

var myStr = '<a href= http://www.example.com';

kumquatfelafel
@kumquatfelafel
Jun 26 2017 06:07 UTC
@garyfalkland np. Apologies for somewhat lackluster attempt there, but been a long day :p
Nitin Sahu
@globefire
Jun 26 2017 06:07 UTC
this is the requirement can't figure out
somebody help
lol anyone there?
kumquatfelafel
@kumquatfelafel
Jun 26 2017 06:10 UTC
@globefire target is not a variable here. That bit was a part of the original string.

Add this ^^^ back into your string myStr, where it was originally.

Nitin Sahu
@globefire
Jun 26 2017 06:12 UTC
ok but according to requirement they want me to remove all bacslashes also they need me to remove backslashes \ to used escape quotes i can't understand what to do
ok fine i'll try
Joshua Frias
@Juke-Magic
Jun 26 2017 06:16 UTC
guys how to extract "hey" in ["hello", "hey"] using slice
kumquatfelafel
@kumquatfelafel
Jun 26 2017 06:16 UTC
\ = backslash. Have you deleted all the backslashes in that string, or are there still backslashes present?
Nitin Sahu
@globefire
Jun 26 2017 06:16 UTC
no there are backslashes
Stanford Lin
@StanfordLin
Jun 26 2017 06:17 UTC
Hi, I need some help with Using Objects for Lookups
Nitin Sahu
@globefire
Jun 26 2017 06:17 UTC
there is a condition which says remove all backslashes and there's another condition which says "Only remove the backslashes \ used to escape quotes"
Joshua Frias
@Juke-Magic
Jun 26 2017 06:17 UTC
nvm
kumquatfelafel
@kumquatfelafel
Jun 26 2017 06:18 UTC
@globefire whenever a \ comes immediately before a ", it is being used to escape quotes.
Nitin Sahu
@globefire
Jun 26 2017 06:19 UTC
yup I got it

You should have two single quotes ' and four double quotes "

then what does this condition means?

kumquatfelafel
@kumquatfelafel
Jun 26 2017 06:20 UTC
The other aspect of this is that you might notice, things have gone a bit off now that you've removed the backslashes. The reason for this is that when the " characters are not escaped, they're treated as the beginning/end of a string.
Nitin Sahu
@globefire
Jun 26 2017 06:21 UTC
yes correct
kumquatfelafel
@kumquatfelafel
Jun 26 2017 06:22 UTC
However, if you replace the outermost " on both sides with ', it will treat " as ", much like it did when you had the \
Nitin Sahu
@globefire
Jun 26 2017 06:23 UTC
ohhhh i got it
thanks man
Stanford Lin
@StanfordLin
Jun 26 2017 06:23 UTC
nvm I got it
kumquatfelafel
@kumquatfelafel
Jun 26 2017 06:24 UTC
@globefire so "a\"\"\"a" and 'a"""a' will give you same string, but the second one a lot easier to type right? ;)
Nitin Sahu
@globefire
Jun 26 2017 06:24 UTC
thanks @kumquatfelafel
CamperBot
@camperbot
Jun 26 2017 06:24 UTC
globefire sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
kumquatfelafel
@kumquatfelafel
Jun 26 2017 06:24 UTC
np
Nitin Sahu
@globefire
Jun 26 2017 06:25 UTC
yes @kumquatfelafel perfect
kumquatfelafel
@kumquatfelafel
Jun 26 2017 06:26 UTC
@globefire One thing worth noting though is that when you have single quotes ' on the outside, suddenly you have to use \ to escape single quotes on the inside :laughing:
So it's kind of a trade-off... one poison for another. :p
David Bercovici
@davidberco
Jun 26 2017 06:28 UTC
@Manish-Giri adding the word to string :|
Kelechi Chinaka
@ke1echi
Jun 26 2017 06:33 UTC
@Manish-Giri so much ambiguities i cant place ma hands on..still have not fixed that code
Menlam Choden
@menlam
Jun 26 2017 06:44 UTC

function bouncer(arr) {
// Don't show a false ID to this bouncer.

var right=arr.filter(function(arr){return arr;});
return right;
}

bouncer([7, "ate", "", false, 9]);
*this is my code and it works,,, i wasjust testing ,,but instead it worked for all testcases,, how,,, should't it return all array

Joshua Frias
@Juke-Magic
Jun 26 2017 06:45 UTC
guys will a==A be true??
tiger500
@tiger500
Jun 26 2017 06:49 UTC
guys how do u studlyCapVar is defined and has a value of 10
Dan Couper
@DanCouper
Jun 26 2017 06:50 UTC
@21-Orange case sensitive, so no.
tiger500
@tiger500
Jun 26 2017 06:52 UTC
how do u define studlyCapvar as a value of 10
anyone
kumquatfelafel
@kumquatfelafel
Jun 26 2017 06:58 UTC

@menlam filter keeps values in array that meet a given condition and doesn't keep those that don't. In this case, when you say return arr (which is not the same as the arr you're filtering btw), this is actually coerced into a value that is either true or false (behind the scenes). In javascript, there are "falsy" and "truthy" values. Falsy values are values other than and including false that, when cast to a boolean, become false. Truthy values become true.

Dan Couper
@DanCouper
Jun 26 2017 06:58 UTC
@menlam You have stumbled across the easiest way to solve this, but you've named your parameter confusingly. filter goes through your array one by one, and the function runs once for every value. The argument you give to that function just represents one value. You've called it arr, but inside that function it isn't the array, it's just a value in the array, you have just given it the same name. arr.filter(function(arrValue) { return arrValue; }). Does that make sense? I'll explain why it works if it does
Menlam Choden
@menlam
Jun 26 2017 07:00 UTC
@DanCouper yeah can you explain me why it works hehe,,, very confusing whatever you said,, new to programming
kumquatfelafel
@kumquatfelafel
Jun 26 2017 07:01 UTC
@DanCouper I'll leave it in your capable hands (*evil laugh*)
G'night :p
Menlam Choden
@menlam
Jun 26 2017 07:02 UTC
@kumquatfelafel sorry did not see your comment..hehe.. thanks though :)
CamperBot
@camperbot
Jun 26 2017 07:02 UTC
menlam sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
Dan Couper
@DanCouper
Jun 26 2017 07:03 UTC
@menlam So it's what @kumquatfelafel said as well, filter takes a function that has to return true of false for a single value. You give that function to filter, and filter runs it for every element in your array. 2 secs, I'll just get to my computer, it's easier if I show an example
Hard to type on a phone
kumquatfelafel
@kumquatfelafel
Jun 26 2017 07:03 UTC
@menlam Honestly, I'm so tired I have no clue how much of that is true. It just seemed like I was only one on at moment haha
though yeah. night
Dan Couper
@DanCouper
Jun 26 2017 07:04 UTC
:) :sleeping:
Menlam Choden
@menlam
Jun 26 2017 07:04 UTC
@DanCouper Yeah that I understood, but I have not given any conditions, so on what basis is it getting filtered
@kumquatfelafel night , thanks anyway
CamperBot
@camperbot
Jun 26 2017 07:05 UTC
menlam sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
:warning: menlam already gave kumquatfelafel points
Dan Couper
@DanCouper
Jun 26 2017 07:05 UTC
:thumbsup: sooooo, the function has to return true or false, and if it doesn't, filter will convert truthy values to true, and falsey values to false
Menlam Choden
@menlam
Jun 26 2017 07:06 UTC
Oh @DanCouper now I got it,, thanks :)
CamperBot
@camperbot
Jun 26 2017 07:06 UTC
menlam sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
Dan Couper
@DanCouper
Jun 26 2017 07:06 UTC
so if you just return the value, it will read bouncer([7, "ate", "", false, 9]); as bouncer([true, true, false, true, true])
Note this is exactly what if statements do as well - if(0) will be false, if(1) will be true
:thumbsup: is a bit magical, JS rules for coercing things to true or false are something you have to be careful with (you'll find it's one of the major problems in the language, because wierd things sometimes get treated as true/false)
Menlam Choden
@menlam
Jun 26 2017 07:10 UTC
okay @DanCouper thanks a lot
CamperBot
@camperbot
Jun 26 2017 07:10 UTC
menlam sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:warning: menlam already gave dancouper points
Dan Couper
@DanCouper
Jun 26 2017 07:12 UTC
:) Oh, and this is the same as using the filter, just for completeness:
result = [];
for (let i = 0; i < arr.length; i++) {
if (arr[i]) result.push(arr[i])
}
return result;
Menlam Choden
@menlam
Jun 26 2017 07:14 UTC
@DanCouper :+1:
Blauelf
@Blauelf
Jun 26 2017 07:18 UTC
I think JavaScript's coercion rules to boolean are not that weird (six falsy values, anything else is truthy). Coercion rules for example for == or + are a lot weirder.
Ghost
@ghost~593024a8d73408ce4f63eac0
Jun 26 2017 07:24 UTC
Dan Couper
@DanCouper
Jun 26 2017 07:25 UTC
@Blauelf it's more when you're checking things like existence of stuff in the DOM it gets painful; it's not that they're hard, it's that you just need to be careful & that there are a few footguns
if can force a very defensive coding style, which means more boilerplate
Blauelf
@Blauelf
Jun 26 2017 07:27 UTC
@DanCouper Like a property in one browser being a string (which could be empty and therefore falsy) and a function in another browser (which is always truthy)? I think I've seen such thing, but usually wrote code like if (typeof something === "function").
Stanford Lin
@StanfordLin
Jun 26 2017 07:28 UTC
Hey, can anyone give me a hand on nesting for loops?
Dan Couper
@DanCouper
Jun 26 2017 07:30 UTC
Was thnking more like
const foo = document.querySelector('.foo');
const bars = document.querySelectorAll('.bars');

// ..........later
if (foo) /* do something */;
if (bars) /* do something else, but this is always true */;
Very easy to fix, but very easy to make the mistake in the first place
& gets painful on large apps
Stanford Lin
@StanfordLin
Jun 26 2017 07:34 UTC
nvm, got it to work
Kelechi Chinaka
@ke1echi
Jun 26 2017 07:34 UTC
hi guys
Write function parseFloat (for Javascript parseF) which takes a string and returns a number or Nothing (for Python None, for Javascript null) if conversion is not possible.
function parseF(s) {
return (isNaN(Number(s)) == true) ? null : parseFloat(Number(s));
}
what am i doing wrong
@Blauelf
Blauelf
@Blauelf
Jun 26 2017 07:38 UTC
Looks like a codewars kata :D
Kelechi Chinaka
@ke1echi
Jun 26 2017 07:38 UTC
yea :smile: @Blauelf
Blauelf
@Blauelf
Jun 26 2017 07:39 UTC
@kelechichinaka I think that one should at least return null for empty string. Do you have specific test cases where it fails?
Or did they somehow keep you from using parseFloat? (BTW, Number(s) already creates a float)
Kelechi Chinaka
@ke1echi
Jun 26 2017 07:42 UTC
should return null where its NaN
Claudio Restifo
@Marmiz
Jun 26 2017 07:43 UTC
@kelechichinaka I suggest you to use Number.isNaN instead of the plain isNaN method.
Kelechi Chinaka
@ke1echi
Jun 26 2017 07:43 UTC
am having a hard time with the isNaN
Blauelf
@Blauelf
Jun 26 2017 07:44 UTC
Are ".5" or "5." valid numbers in this definition?
Kelechi Chinaka
@ke1echi
Jun 26 2017 07:45 UTC
yes
Claudio Restifo
@Marmiz
Jun 26 2017 07:46 UTC
@kelechichinaka is a string like two suppose to be returned?
Kelechi Chinaka
@ke1echi
Jun 26 2017 07:47 UTC
no 2.0
Claudio Restifo
@Marmiz
Jun 26 2017 07:47 UTC
Because if not you can simply switch to:
  return (Number.isNaN(s) === true) ? null : parseFloat(Number(s));
Kelechi Chinaka
@ke1echi
Jun 26 2017 07:47 UTC
tried that already , fails 2 tests @Marmiz
Claudio Restifo
@Marmiz
Jun 26 2017 07:48 UTC
even better : Number(s) since as @Blauelf suggested you don't need to parse it in this case
Blauelf
@Blauelf
Jun 26 2017 07:48 UTC
I just tried a regular expression, and it worked well.
Kelechi Chinaka
@ke1echi
Jun 26 2017 07:49 UTC
:clap: never imagined that
Blauelf
@Blauelf
Jun 26 2017 07:50 UTC
Probably overkill. Most of the solutions tested on isNaN(parseFloat(s)).
Oh, test cases are not complete. The test case "47,11" would return 47 for many of the solutions, as parseFloat would end parsing at ,.
Kelechi Chinaka
@ke1echi
Jun 26 2017 07:53 UTC
am lost :worried: @Blauelf
mrjerem
@mrjerem
Jun 26 2017 07:53 UTC

help I have no idea where to start "The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

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

Blauelf
@Blauelf
Jun 26 2017 07:55 UTC
@kelechichinaka The test cases allow about any solution, complete or not.
Tiago Malheiro
@Azzrah
Jun 26 2017 07:55 UTC
is this a bug? why this works in this challenge https://www.freecodecamp.com/challenges/falsy-bouncer
function bouncer(arr) {
var correct = arr.filter(function correction(value){
return value;
});
return correct;
}

bouncer([1, null, NaN, 2, undefined]);
Claudio Restifo
@Marmiz
Jun 26 2017 07:55 UTC
@mrjerem it's like math, but instead of x and y 's you name them Celsius and Farenheit
Blauelf
@Blauelf
Jun 26 2017 07:56 UTC
@Azzrah filter treats all truthy values like true and all falsy values like false
Tiago Malheiro
@Azzrah
Jun 26 2017 07:57 UTC
@Blauelf So filter does all the work by itself? Well that was lucky of me, I reached this code by mistake
mrjerem
@mrjerem
Jun 26 2017 07:57 UTC
ah got it! I wasn't sure if I needed to put var on front of them
Blauelf
@Blauelf
Jun 26 2017 07:59 UTC
@Azzrah Usually, you want to return true or false in a filter callback, mostly for better readability. filter won't care, it tests for truthy/falsy only (like if and many others do)
Claudio Restifo
@Marmiz
Jun 26 2017 07:59 UTC
@mrjerem you put var when you want to instruct the computer that 'the following is a varaible with this name, keep it save somewhere cos I may need it later'
mrjerem
@mrjerem
Jun 26 2017 08:00 UTC
so you put var in front of a word and you can use it later with just the word yes?
Thomas Faller
@thomasfaller
Jun 26 2017 08:00 UTC
Hey guys!
I just finished my Integer to Romannumber challenge and I came up with that:
https://codepen.io/thomasfaller/pen/VWMxLj?editors=0012
I started with a complicated set of looping that was hard to troubleshoot. But in the end the object/table does the trick. Is that good or can it be improved?
Claudio Restifo
@Marmiz
Jun 26 2017 08:03 UTC

@mrjerem yes:

var x = 1

then you can reuse the values somewhere:

y = x * 2

// y = 2
mrjerem
@mrjerem
Jun 26 2017 08:03 UTC
@Marmiz okay clear enough for now thanks :smile:
CamperBot
@camperbot
Jun 26 2017 08:03 UTC
mrjerem sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
Claudio Restifo
@Marmiz
Jun 26 2017 08:10 UTC

@thomasfaller It's good for sure ^^, but as everything can be improved.
For starter you could have a table that have only the 'breaking point' of roman numerals:

eg: you don't need to know that 1 - 2 - 3 - 4 are I - II - III - IV
but you only need to know that from 1 to 3 you can add as many I as needed, until you reach the next breaking point of four that is a IV.

Then use this concept of looping to construct the string.

Mai Thinh
@mthinh
Jun 26 2017 08:15 UTC
Do I need a loop for "Title Case a Sentence" challenge ? pls?
schizo99
@shashank1999coder
Jun 26 2017 08:16 UTC

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

}
else if (strokes <=par-2){
return "Eagle";

}
else if (strokes = par-1 ) {
return "Birdie";
}
else if (strokes = par) {
return "Par";
}
else if (strokes = par + 1) {
return "Bogey";
}
else if (strokes = par+2 ) {
return "Double Bogey";
}
else if ( strokes >=par+3){
return "Go Home!"
}
else {
return "Change Me";
}
// Only change code above this line
}

// Change these values to test
golfScore(5, 4);
what's wrong plz help

Alan Alickovic
@alan2207
Jun 26 2017 08:17 UTC
@shashank1999coder if strokes = 1
needs to be === instead of =
= is assigment operator
you have that in several conditions
schizo99
@shashank1999coder
Jun 26 2017 08:18 UTC
@alan2207 thanks
CamperBot
@camperbot
Jun 26 2017 08:18 UTC
shashank1999coder sends brownie points to @alan2207 :sparkles: :thumbsup: :sparkles:
Blauelf
@Blauelf
Jun 26 2017 08:18 UTC
@shashank1999coder Also, check spelling, I think it's "Hole-in-one!"
schizo99
@shashank1999coder
Jun 26 2017 08:18 UTC
that was very silly mistake by me
Alan Alickovic
@alan2207
Jun 26 2017 08:19 UTC
@shashank1999coder you will get used to it
Mai Thinh
@mthinh
Jun 26 2017 08:19 UTC
Do I need a loop for "Title Case a Sentence" challenge ? pls?
Alan Alickovic
@alan2207
Jun 26 2017 08:20 UTC
@mthinh you could also use regular expression
lazzlo
@lazzlo
Jun 26 2017 08:26 UTC
@thomasfaller You are aware that your code breaks when you enter a number above 9999, right?
mrjerem
@mrjerem
Jun 26 2017 08:29 UTC
I can't get thios writen out as I want "FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine"
it comes out as "var myStr ="FirstLine\n\SecondLine\\rThirdLine\""
Claudio Restifo
@Marmiz
Jun 26 2017 08:31 UTC
@mrjerem the extra " at the end is a typo or in your code?
mrjerem
@mrjerem
Jun 26 2017 08:32 UTC
@Marmiz Its not type its reffering to the whole "var.... text
Thomas Faller
@thomasfaller
Jun 26 2017 08:33 UTC
@Lazzlo Of course it does but the FreeCodeCamp challenge doesn’t test number over that limit. I could just add the missing ones in the table though.
:innocent:
Zack
@CrowsVeldt
Jun 26 2017 08:34 UTC
@mrjerem if you put backticks ()around your code it will be formatted automatically and easier to read
mrjerem
@mrjerem
Jun 26 2017 08:34 UTC
No I added it here on chat to refer to my code :D
@CrowsVeldt okay thanks :)
CamperBot
@camperbot
Jun 26 2017 08:34 UTC
mrjerem sends brownie points to @crowsveldt :sparkles: :thumbsup: :sparkles:
Claudio Restifo
@Marmiz
Jun 26 2017 08:34 UTC
@mrjerem read this to learn to format text in chat
lazzlo
@lazzlo
Jun 26 2017 08:34 UTC
@thomasfaller Yeah, I know it doesn't test them. I just mentioned it because the way your code is structured makes it hard for it to scale upwards in case you would ever want that in the future.
Nitin Sahu
@globefire
Jun 26 2017 08:36 UTC
hi
Blauelf
@Blauelf
Jun 26 2017 08:37 UTC
lo
Thomas Faller
@thomasfaller
Jun 26 2017 08:37 UTC
@Lazzlo You’re right, it’s not the best possible converter, I’ll work on one that scales up. Thanks ;)
CamperBot
@camperbot
Jun 26 2017 08:37 UTC
thomasfaller sends brownie points to @lazzlo :sparkles: :thumbsup: :sparkles:
Menlam Choden
@menlam
Jun 26 2017 08:38 UTC

function mutation(arr) {
var y=arr[0].indexOf(arr[1]);
if(y==-1)
{
return false;
}
else
{
return true;
}
}

mutation(["Mary", "Army"]); This is true for only some case,,, whats wrong

lazzlo
@lazzlo
Jun 26 2017 08:38 UTC
@thomasfaller :)
@Lazzlo Let me know if you need help
@thomasfaller Oops wrong tag
Alan Alickovic
@alan2207
Jun 26 2017 08:40 UTC
@menlam are you handling uppercase and lowercase?
because you should
Menlam Choden
@menlam
Jun 26 2017 08:48 UTC
@alan2207 yeah, but first why is it not working for all cases

@alan2207 function mutation(arr) {
arr[0].toLowerCase();
arr[1].toLowerCase();
var arr1=arr[0].split('');
var arr2=arr[1].split('');
var y=arr[0].indexOf(arr[1]);
if(y==-1)
{
return false;
}
else
{
return true;
}

}

mutation(["Mary", "Army"]);

it works for mutation(["hello", "hey"])
Alan Alickovic
@alan2207
Jun 26 2017 08:50 UTC
@menlam but letters in second item doesn't have to be in order, the task is just to check if the first item contains all the letters of the second item
Menlam Choden
@menlam
Jun 26 2017 08:50 UTC
yeah @alan2207 how to do that
Alan Alickovic
@alan2207
Jun 26 2017 08:51 UTC
you need to loop through all letters in second item, and if any of letters are not also in first item, you need to return false
otherwise it is true
Menlam Choden
@menlam
Jun 26 2017 08:52 UTC
@alan2207 okay, let me check and get back to you
@alan2207 thanks
CamperBot
@camperbot
Jun 26 2017 08:52 UTC
menlam sends brownie points to @alan2207 :sparkles: :thumbsup: :sparkles:
Menlam Choden
@menlam
Jun 26 2017 08:55 UTC

@alan2207 function mutation(arr) {
arr[0].toLowerCase();
arr[1].toLowerCase();
var arr1=arr[0].split('');
var arr2=arr[1].split('');
for(var i=0;i<=arr2.length;i++)
{
if(arr2[i]==arr1)
{
return true;
}
else
{
return false;
}
}

}

mutation(["Mary", "Army"]);

@alan2207 did not work, maybe I am doing something wrong,
Alan Alickovic
@alan2207
Jun 26 2017 08:56 UTC
@menlam inside for loop you need to check if the letter is not included in the first item
if so, just return false
otherwise after the loop . you can return true, since all letters are contained within first item
Menlam Choden
@menlam
Jun 26 2017 08:58 UTC
@alan2207 Sorry I did not get you
Alan Alickovic
@alan2207
Jun 26 2017 08:58 UTC
@menlam ok, let's go slowly
Menlam Choden
@menlam
Jun 26 2017 08:59 UTC
@alan2207 thanks :)
CamperBot
@camperbot
Jun 26 2017 08:59 UTC
menlam sends brownie points to @alan2207 :sparkles: :thumbsup: :sparkles:
:warning: menlam already gave alan2207 points
Blauelf
@Blauelf
Jun 26 2017 08:59 UTC
@menlam toLowerCase returns a new string (cannot change the one it's working on as strings are immutable), you could for example use it like var arr1 = arr[0].toLowerCase().split('');
Alan Alickovic
@alan2207
Jun 26 2017 09:00 UTC
tou do not have to split items, since we can loop through strings as well
Blauelf
@Blauelf
Jun 26 2017 09:00 UTC
@menlam Also, i < arr2.length instead of <=, and what @alan2207 said, strings are array-like (have length and numeric properties).
Menlam Choden
@menlam
Jun 26 2017 09:01 UTC
@Blauelf okay, so what am I doing wrong
Alan Alickovic
@alan2207
Jun 26 2017 09:02 UTC
@menlam loop through the second item, and check if any of its letters are contained within the first item, you can use indexOf method
Kamal
@kpbro
Jun 26 2017 09:02 UTC
hey. can someone help me a little in frontend? i am stuck on random quote machine
i have used api for random quotes but, it is showing same quote everytime and not random
Long Nguyen
@longnt80
Jun 26 2017 09:04 UTC
please try to beat my AI:
https://codepen.io/longnt80/full/BZWBxm/
jasonrest
@jasonrest
Jun 26 2017 09:05 UTC
just a quick question. In order to generate a random quote, this should be working right?
var quote = ["test quote 1", "test quote 2", "test quote 3", "test quote 4"];
function randomquote(){
var randomNumber = Random.Range(0,4);
var newQuote = quote[randomNumber];
return newQuote;
}
randomquote();
Kamal
@kpbro
Jun 26 2017 09:06 UTC
@jasonrest it will work fine. but u should have much more quotes than 4. And if you use api it is better
jasonrest
@jasonrest
Jun 26 2017 09:07 UTC
@kpbro this is just a test to make sure I understand the logic of my solution. and I am new to Api's. do you mean use Json to connect to another quote source.
Markus Kiili
@Masd925
Jun 26 2017 09:08 UTC
@jasonrest You have this Random.Range defined somewhere?
Long Nguyen
@longnt80
Jun 26 2017 09:08 UTC
@jasonrest Random.Range is this javascript?
Kamal
@kpbro
Jun 26 2017 09:08 UTC
@jasonrest i am trying the same challenge. i succeed in taking quote from api, but it is not ranom everytime
jasonrest
@jasonrest
Jun 26 2017 09:09 UTC
@longnt80 I apologize is that not a built in function
@kpbro seems you're ahead of me. just starting on it.
schizo99
@shashank1999coder
Jun 26 2017 09:10 UTC

function caseInSwitch(val) {
// Only change code below this line
switch (val) {
case 1:
console.log("alpha");
break;

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

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

case 4:
console.log("delta");
break;

}

// Only change code above this line
}

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

pz help
Kamal
@kpbro
Jun 26 2017 09:10 UTC
@jasonrest u have to create function for random number using math.rand
Alan Alickovic
@alan2207
Jun 26 2017 09:10 UTC
@shashank1999coder you need also default value, i think
jasonrest
@jasonrest
Jun 26 2017 09:11 UTC
@kpbro oh math.rand is the built in function.
Markus Kiili
@Masd925
Jun 26 2017 09:11 UTC
@jasonrest Math.random() will give a random float between 0(inclusive) and 1(exclusive). There was a challenge earlier about generating random integers.
Kamal
@kpbro
Jun 26 2017 09:11 UTC
@jasonrest yep.. using math.rand use some logic to get in your range of 0 to 4
@Masd925 hey can you help me with api?
jasonrest
@jasonrest
Jun 26 2017 09:13 UTC
@Masd925 right. has to be
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
schizo99
@shashank1999coder
Jun 26 2017 09:13 UTC
@alan2207 still not working
Alan Alickovic
@alan2207
Jun 26 2017 09:13 UTC
@shashank1999coder what challenge is it?
@Masd925 you need to round it to lower whole number
Markus Kiili
@Masd925
Jun 26 2017 09:14 UTC
@alan2207 Yes.
schizo99
@shashank1999coder
Jun 26 2017 09:14 UTC
jasonrest
@jasonrest
Jun 26 2017 09:15 UTC
@kpbro can you elaborate on taking quote from api. I was just going to create an array with about 20 strings in it and randomize from it. I assume json
Alan Alickovic
@alan2207
Jun 26 2017 09:15 UTC
@shashank1999coder you need to store something to result variable, not console.log it
instead, whatever you were logging to the console, you should store to the result variable
so that it can be returned after the switch statement
Kamal
@kpbro
Jun 26 2017 09:16 UTC
 $('#getMessage').on("click",function(){$.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&callback=", function(a) {
var html="";
a.forEach(function(val){
html+='<div class="quote">';
html+="<b>"+val.content+"</b>"+"<br>"+"<em>-"+val.title+"</em>";
html+="</div>";
});
@jasonrest
here http:// is api that i am using+
Daniel Romero
@Ranacode
Jun 26 2017 09:17 UTC
let categorieLinks = document.querySelectorAll('a.link-category');

this.firstChild.style.color = "white";
});
this.firstChild.style.color = "black";
});
}
I have a question, if i swap function() to => arrow function, the 'this' word doesn't work like before, why?
Alan Alickovic
@alan2207
Jun 26 2017 09:17 UTC
@Masd925 you should use Math.floor method to wrap this expression you already used
Markus Kiili
@Masd925
Jun 26 2017 09:18 UTC
@alan2207 I was just telling @jasonrest the correct method to use.
Alan Alickovic
@alan2207
Jun 26 2017 09:19 UTC
@Ranacode the context of this is from its enclosing scope when using arrow functions
@Masd925 oh sorry, didn't read it well then
Daniel Romero
@Ranacode
Jun 26 2017 09:20 UTC
I don't understand, then, how can i access to the invoke object?
jasonrest
@jasonrest
Jun 26 2017 09:22 UTC
@kpbro @Masd925 @longnt80 Thanks
CamperBot
@camperbot
Jun 26 2017 09:22 UTC
jasonrest sends brownie points to @kpbro and @masd925 and @longnt80 :sparkles: :thumbsup: :sparkles:
:star2: 4279 | @masd925 |http://www.freecodecamp.com/masd925
Alan Alickovic
@alan2207
Jun 26 2017 09:23 UTC
@Ranacode how did you create object?
schizo99
@shashank1999coder
Jun 26 2017 09:26 UTC
@alan2207 not working
Daniel Romero
@Ranacode
Jun 26 2017 09:28 UTC
Thanks @alan2207
CamperBot
@camperbot
Jun 26 2017 09:28 UTC
ranacode sends brownie points to @alan2207 :sparkles: :thumbsup: :sparkles:
Alan Alickovic
@alan2207
Jun 26 2017 09:29 UTC
schizo99
@shashank1999coder
Jun 26 2017 09:32 UTC

function caseInSwitch(val) {
// Only change code below this line
case 1:
console.log("alpha");
break;

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

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

case 4:
console.log("delta");
break;
default:
console.log();

}

// Only change code above this line
}

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

Jon
@jonandrepedersen
Jun 26 2017 09:33 UTC
Anyone else working on the Seek and Destroy challenge?
Alan Alickovic
@alan2207
Jun 26 2017 09:33 UTC
@shashank1999coder you should not call console.log, but store what that value to answer variable
Gary Fitzwater
@garyfalkland
Jun 26 2017 09:33 UTC
case 2:
break;
Alan Alickovic
@alan2207
Jun 26 2017 09:35 UTC
@garyfalkland simpler when you post the code :smile:
Baibhav Gautam
@baibhavx
Jun 26 2017 09:35 UTC
Almost done with my Pomodoro Clock project. Can I please get some feedback/suggestions? I want to do a similar animation like the given example where the circle slowly fills up with another color as time ticks by. I have no idea how to do that. Can someone point me to the right direction?
https://codepen.io/baibhavx/pen/KqXBwW
schizo99
@shashank1999coder
Jun 26 2017 09:35 UTC

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

case 2:
break;

case 3:
break;

case 4:
break;

}

// Only change code above this line
}

// Change this value to test
caseInSwitch(2);
still not working

Blauelf
@Blauelf
Jun 26 2017 09:36 UTC
@shashank1999coder Switch on val, not answer
Gary Fitzwater
@garyfalkland
Jun 26 2017 09:36 UTC
you have wrong value in switch()
Sweet Coding :)
@SweetCodingInc
Jun 26 2017 09:37 UTC
@Ranacode : That's because you're likely to have textNode as first child of your a.link-category. And text nodes do not have .style. That is why it is breaking. It is not a problem with this
Blauelf
@Blauelf
Jun 26 2017 09:37 UTC
@shashank1999coder Switch will evaluate the expression it's meant to switch on, and compare it to the values of the expressions in the case statements, and execute code after the first case statement the values are equal.
Michiel
@MichielHuijse
Jun 26 2017 09:39 UTC
For some reason this json request is giving a 404: $.getJSON("https://api.darksky.net/forecast/" + api_Key + "/" + loc0 + "," + loc1 , function(data){ console.log(data); // for testing purposes. }); AnkitKamdar @AnkitKamdar Jun 26 2017 09:41 UTC Use backslashes to assign a string to the myStr variable so that if you were to print it to the console, you would see: I am a "double quoted" string inside "double quotes". Run tests (ctrl + enter) Michiel @MichielHuijse Jun 26 2017 09:44 UTC @AnkitKamdar are you answering me? Blauelf @Blauelf Jun 26 2017 09:46 UTC @AnkitKamdar Inside a string literal marked with double quotes, double quotes which are meant to be part of the string need to be escaped as \" satyendra kr pandit @satyendra2013 Jun 26 2017 09:46 UTC Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed. function nextInLine(arr, item) { // Your code here arr.push(10); var itm=arr.shift(item); return itm; // Change this line } // Test Setup var testArr = [5,6,7,8,9]; // Display Code console.log("Before: " + JSON.stringify(testArr)); console.log(nextInLine(testArr, 1)); // Modify this line to test console.log("After: " + JSON.stringify(testArr)); Blauelf @Blauelf Jun 26 2017 09:46 UTC @satyendra2013 Why do you push 10? And shift ignores arguments. satyendra kr pandit @satyendra2013 Jun 26 2017 09:46 UTC help me to verify-nextInLine([], 1) should return 1 @Blauelf it is said in the problem Blauelf @Blauelf Jun 26 2017 09:47 UTC Why do you push 10? satyendra kr pandit @satyendra2013 Jun 26 2017 09:48 UTC @Blauelf Hey we have to verify these four-nextInLine([], 1) should return 1 nextInLine([2], 1) should return 2 nextInLine([5,6,7,8,9], 1) should return 5 After nextInLine(testArr, 10), testArr[4] should be 10 Blauelf @Blauelf Jun 26 2017 09:48 UTC I don't think the problem states you should push 10, you should push the number passed to the function! satyendra kr pandit @satyendra2013 Jun 26 2017 09:49 UTC @Blauelf oo...how can we perform that Blauelf @Blauelf Jun 26 2017 09:49 UTC arr.push(item) heroiczero @heroiczero Jun 26 2017 09:49 UTC @satyendra2013 you need to push the parameter of the item in the function nextInLine(arr, item) and shift and return the first element of the arr satyendra kr pandit @satyendra2013 Jun 26 2017 09:50 UTC yeah it works thanks @Blauelf and @heroiczero CamperBot @camperbot Jun 26 2017 09:50 UTC satyendra2013 sends brownie points to @blauelf and @heroiczero :sparkles: :thumbsup: :sparkles: :star2: 1424 | @heroiczero |http://www.freecodecamp.com/heroiczero :star2: 4458 | @blauelf |http://www.freecodecamp.com/blauelf nitessaini @nitessaini Jun 26 2017 09:51 UTC can somebody help me on the counting cards challenge Blauelf @Blauelf Jun 26 2017 09:52 UTC @nitessaini Two parts 1. For certain values of card, increment or decrement global variable count 2. Return a string built from count and either Bet or Hold (depending only on count), with a space between number and word Don't mix the two. Bet/Hold does not at all depend on card. nitessaini @nitessaini Jun 26 2017 09:54 UTC this is code i have written til now var count = 0; function cc(card) { // Only change code below this line if (card>=2 && card<=6){ count=count+5; return '"'+count + ' Bet"'; } else if (card>=7 && card<=9){ count=count+0; return '"'+count + ' Hold"'; } return "Change Me"; // Only change code above this line } // Add/remove calls to test your function. // Note: Only the last will display cc(7); cc(8); cc(9); am i going in right direction? Blauelf @Blauelf Jun 26 2017 09:55 UTC You mixed the two. Don't. Also, increment in steps of 1, not 5. And there should be no " within the string returned. Ankita @ankitayadav1441995 Jun 26 2017 10:01 UTC plz help me with this code.. its the one with the challenge - using objects for lookups Stephen James @sjames1958gm Jun 26 2017 10:02 UTC @ankitayadav1441995 The object shouild not be assigned to val -the instructions suggest lookup Michiel @MichielHuijse Jun 26 2017 10:02 UTC Hi my second https json request is not working in the following code. Whats wrong? // Global variables underneath var api_Key = "e4ee4e08479f304c27ed35b06b56f873"; var loc0, loc1;$(document).ready(function(){
$.getJSON("http://ipinfo.io", function(data){ console.log(data); // for testing purposes. var city = data.city; var region = data.region;$("#location").html(city + ", " + region); // @Todo do not replace location but instead make the text "your current location is:"

  var loc = data.loc;
var locArray = loc.split(",");
loc0 = locArray[0];
loc1 = locArray[1];      

});

$.getJSON("https://api.darksky.net/forecast/" + api_Key + "/" + loc0 + "," + loc1 , function(data){ console.log(data); // for testing purposes. }); }); Stephen James @sjames1958gm Jun 26 2017 10:02 UTC @ankitayadav1441995 Those red circles are telling you there should be a comma not a semicolon between object properties Ankita @ankitayadav1441995 Jun 26 2017 10:03 UTC @sjames1958gm i m not geeting how to do. @sjames1958gm ohh..ya ..thanks.. CamperBot @camperbot Jun 26 2017 10:03 UTC ankitayadav1441995 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 7897 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Stephen James @sjames1958gm Jun 26 2017 10:03 UTC @ankitayadav1441995 var lookup = { "alpha": "Adams", } then use lookup and the property in val to set result @MichielHuijse Your second getJSON needs to run within the context of the callback from the first or the values loc0 and loc1 will not be set Michiel @MichielHuijse Jun 26 2017 10:07 UTC @sjames1958gm but I defined loc0 and loc1 both globally, so they should be available in the second json request right? Ankita @ankitayadav1441995 Jun 26 2017 10:07 UTC @sjames1958gm thanks ..i did it.. CamperBot @camperbot Jun 26 2017 10:07 UTC ankitayadav1441995 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :warning: ankitayadav1441995 already gave sjames1958gm points Stephen James @sjames1958gm Jun 26 2017 10:07 UTC @ankitayadav1441995 :+1: Rinor Bivolaku @RinorNotorious Jun 26 2017 10:09 UTC Hello guys, can someone tell me why isn't this working? - function rot13(str) { // LBH QVQ VG! return str.split('').map(function(val){ x = val.charCodeAt(0); if(x < 65 || x > 90){ return String.fromCharCode(); } else if(x < 78){ return String.fromCharCode(x + 13); } return String.fromCharCode(x-13); }).join(""); } // Change the inputs below to test rot13("SERR PBQR PNZC"); - Stephen James @sjames1958gm Jun 26 2017 10:09 UTC @RinorNotorious Your first return doesn't have a value passed to fromCharCode @RinorNotorious Suggestion, when you say not working provide samples of input / output aren't working Rinor Bivolaku @RinorNotorious Jun 26 2017 10:11 UTC I got the FreeCodeCamp but the spaces were missing I just passed the first fromCharCode the argument needed (x) and now it's done thank you for your help Stephen James @sjames1958gm Jun 26 2017 10:11 UTC @RinorNotorious :+1: Michiel @MichielHuijse Jun 26 2017 10:12 UTC @sjames1958gm I am getting this error: XMLHttpRequest cannot load https://api.darksky.net/forecast/e4ee4e08479f304c27ed35b06b56f873/52.3819,4.8716. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. Stephen James @sjames1958gm Jun 26 2017 10:14 UTC @MichielHuijse That is because basic XHR requests cannot be made from different domains. jquery supports jsonp which is a mechanism to get around this error. add &callback=? to the end of your URL and that will tell jquery to use jsonp CamperBot @camperbot Jun 26 2017 10:22 UTC michielhuijse sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 7898 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Stephen James @sjames1958gm Jun 26 2017 10:23 UTC @MichielHuijse Do you have this in code pen? Michiel @MichielHuijse Jun 26 2017 10:24 UTC I am working locally, once deleted all my code by mistake But I can put it in codepen one in a sec @sjames1958gm The javascript still does not work in codepen but here is a link: https://codepen.io/michiel-huijse/pen/eBWBVz Thomas @sjurs1 Jun 26 2017 10:30 UTC Hi guys. I completed the "Map the Debris" challenge by using a for loop, but could anyone display how I would have done this using .reduce()?  function orbitalPeriod(arr) { var GM = 398600.4418; var earthRadius = 6367.4447; var result = []; for (var i = 0; i < arguments[0].length; i++) { var orbRad = earthRadius + arguments[0][i].avgAlt; var orbPer = Math.round(Math.PI*2*(Math.sqrt(Math.pow(orbRad,3)/GM))); result.push({"name": arguments[0][i].name, "orbitalPeriod": orbPer}); } return result; } orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}]); Stephen James @sjames1958gm Jun 26 2017 10:31 UTC @MichielHuijse I had to change the http for the first URL to https, but still getting an error Michiel @MichielHuijse Jun 26 2017 10:32 UTC @sjames1958gm ok, thanks that makes it work indeed Stephen James @sjames1958gm Jun 26 2017 10:32 UTC @MichielHuijse My bad since callback is the first query parameter it needs ? not & ?callback=? @sjurs1 You could use reduce, although map seems more appropriate as you have an array mapped to another Michiel @MichielHuijse Jun 26 2017 10:34 UTC @sjames1958gm so this: "&callback=?" should be changed to what? Stephen James @sjames1958gm Jun 26 2017 10:34 UTC @sjurs1  return arr.reduce(function(acc, ent) { var axis = ent.avgAlt + earthRadius; acc.push({ name: ent.name, orbitalPeriod: Math.floor(2 * Math.PI * Math.sqrt(axis * axis * axis / GM) + 0.5) }); return acc; }, []); @MichielHuijse change the & to ? Michiel @MichielHuijse Jun 26 2017 10:36 UTC @sjames1958gm hee thanks! CamperBot @camperbot Jun 26 2017 10:36 UTC michielhuijse sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :warning: michielhuijse already gave sjames1958gm points Thomas @sjurs1 Jun 26 2017 10:38 UTC @sjames1958gm Thanks man! That's interesting. I feel like I should make an effort to really get comfortable with higher-order functions CamperBot @camperbot Jun 26 2017 10:38 UTC sjurs1 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 7899 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm ChoiYoungdo @ChoiYoungdo Jun 26 2017 10:40 UTC Can someone help me with this? It's an item counter for a cart and I need to change item count of each without depending on a variable and I can't seem to do that. Here's a pen: https://codepen.io/Choi-YoungDo/pen/GEMWwd?editors=0010 Nitin Sahu @globefire Jun 26 2017 10:41 UTC wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib what does this mean ? Jayne @jayne88 Jun 26 2017 10:44 UTC Hi guys, having trouble with a challenge, the card counting one. Googled it as I couldn't remember the order of the syntax but I am still doing something wrong and I'm not sure what, any suggestions? var count = 0; function cc(card) { // Only change code below this line if (card <= 6){ count++; } else if (card >=9){ count += 0; } else {count--; } if (count <= 0) { return count + "Hold"; }else { return count +"Bet"; } // Only change code above this line } // Add/remove calls to test your function. // Note: Only the last will display cc(3); cc(7); cc('K'); cc('A'); KinderPreet Singh @kindercappy Jun 26 2017 10:48 UTC return count + " Hold"; ? @jayne88 Rahul Khopade @khopaderahul01 Jun 26 2017 10:48 UTC FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine ?? myStr should have encoded text with the proper escape sequences and no spacing. myStr should have one newline character \n myStr should have one carriage return character \r myStr should have two correctly escaped backslash characters \ ?? KinderPreet Singh @kindercappy Jun 26 2017 10:49 UTC @khopaderahul01 you are not supposed to write them in english. read the table carefeully. Jayne @jayne88 Jun 26 2017 10:49 UTC @kindercappy yeah it was that and I used the wrong comparison operator, > instead of <. thanks! Is googling for help okay or considered cheating do you think? CamperBot @camperbot Jun 26 2017 10:49 UTC jayne88 sends brownie points to @kindercappy :sparkles: :thumbsup: :sparkles: :cookie: 289 | @kindercappy |http://www.freecodecamp.com/kindercappy KinderPreet Singh @kindercappy Jun 26 2017 10:50 UTC @jayne88 google is your best friend Rahul Khopade @khopaderahul01 Jun 26 2017 10:50 UTC didnt get tghe quen KinderPreet Singh @kindercappy Jun 26 2017 10:51 UTC you put a new line with \n. @khopaderahul01 nitessaini @nitessaini Jun 26 2017 10:51 UTC @Blauelf i followed your points and some part of code is working now, but still there is some issue with code. can you check what wrong i am doing here. KinderPreet Singh @kindercappy Jun 26 2017 10:52 UTC you put a backslash in a string with this \ @khopaderahul01 nitessaini @nitessaini Jun 26 2017 10:52 UTC KinderPreet Singh @kindercappy Jun 26 2017 10:52 UTC \\ @khopaderahul01 Rahul Khopade @khopaderahul01 Jun 26 2017 10:52 UTC Donee ! Thanks @kindercappy CamperBot @camperbot Jun 26 2017 10:52 UTC khopaderahul01 sends brownie points to @kindercappy :sparkles: :thumbsup: :sparkles: :cookie: 290 | @kindercappy |http://www.freecodecamp.com/kindercappy Jon @jonandrepedersen Jun 26 2017 10:54 UTC json.forEach(function(val) { var keys = Object.keys(val); html += "<div class = 'cat'>"; keys.forEach(function(key) { html += "<strong>" + key + "</strong>: " + val[key] + "<br>"; }); html += "</div><br>"; }); I copied in the correct code, and I do get a "Pass" on the challenge. But nothing of value occurs on the visual phone app (which it says it is supposed to). Is something wrong? https://www.freecodecamp.com/challenges/convert-json-data-to-html Stephen James @sjames1958gm Jun 26 2017 10:54 UTC @nitessaini Don't return inside the switch - After the switch you need to compare count to zero and then return Bet vs hold Jon @jonandrepedersen Jun 26 2017 10:55 UTC Hmm judging on the next challenge, it seems to be intended this way ChoiYoungdo @ChoiYoungdo Jun 26 2017 10:59 UTC What's wrong with this? Say I have multiple items, when click an item the value would increase/decrease but it seems that the other items are dependent on each other as I get the same value for the rest of the items. Help? var itemCount = 1; // item --$('.item-counter .item-minus').click(function(){
if(itemCount <= 1) {
itemCount = 1;
}
else{
itemCount -=1;
}
$(this).siblings('h3').html(itemCount); }); // item ++$('.item-counter .item-plus').click(function(){
itemCount += 1;
$(this).siblings('h3').html(itemCount); }); Stephen James @sjames1958gm Jun 26 2017 10:59 UTC @jonandrepedersen Looks like the getJSON is not retrieving any data Jon @jonandrepedersen Jun 26 2017 10:59 UTC @sjames1958gm seemed to be the way the example was made. On the next challenge all the text is converted to images etc. Stephen James @sjames1958gm Jun 26 2017 11:00 UTC @ChoiYoungdo You are setting them all from the same variable. Whey you get the click, get the current value from the HTML and inc/dec that value Jon @jonandrepedersen Jun 26 2017 11:00 UTC As in: I thought images etc. would show through the API by default ChoiYoungdo @ChoiYoungdo Jun 26 2017 11:01 UTC @sjames1958gm How does one do that? I can't seem to get it using .innerHTML or .html / .innerText.text? Stephen James @sjames1958gm Jun 26 2017 11:02 UTC @ChoiYoungdo $(this).siblings('h3').text()` this doesn't work?