30th
Jun 2017
kumquatfelafel
@kumquatfelafel
Jun 30 2017 00:00
@saifsmailbox98 I believe that will get rid of complaints, yes.
Mirza Arslan
@arslan555
Jun 30 2017 00:00

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.

code

var count = 0;

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

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

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

trying to solve it but couldn't get better results anyone here to help me please /

Stephen James
@sjames1958gm
Jun 30 2017 00:00
@saifsmailbox98 I think so, the support for it is in you browser, just fixing the linter
Manish Giri
@Manish-Giri
Jun 30 2017 00:00
@arslan555 why don't you post just your code, instead of all the instructions
Stephen James
@sjames1958gm
Jun 30 2017 00:01
@arslan555 The solution is two parts. compare card per the table and modify count
Then compare count to zero to determine Bet vs Hold
Saif Ur Rahman
@saifsmailbox98
Jun 30 2017 00:01
@sjames1958gm @kumquatfelafel , yes that works, the little warning sign says use 'esversion:6' but that was not working.
Tyler Johnson
@tylerjj17
Jun 30 2017 00:02
does anyone know the twitch api mine isnt working https://codepen.io/tylerjj17/pen/rwJzMv?editors=1010
Mirza Arslan
@arslan555
Jun 30 2017 00:02
@sjames1958gm i just tired to solve it in that way...but could'nt get better reults , can you please share me code.
Manish Giri
@Manish-Giri
Jun 30 2017 00:02
@tylerjj17 look at the browser console..
Mirza Arslan
@arslan555
Jun 30 2017 00:02
@Manish-Giri here are instructions
Stephen James
@sjames1958gm
Jun 30 2017 00:02
Mirza Arslan
@arslan555
Jun 30 2017 00:04
@sjames1958gm aahh...yead i tried it yesterday...but have some little confusion ..whome i did'nt resolve..so i decided to post this question could you help me please in th !!
Saif Ur Rahman
@saifsmailbox98
Jun 30 2017 00:05
Mirza Arslan
@arslan555
Jun 30 2017 00:05
@saifsmailbox98 tried it many times
Stephen James
@sjames1958gm
Jun 30 2017 00:05
@arslan555 https://github.com/sjames1958gm/freecodecamp/blob/master/counting-cards.js
Here is a link to my solution, I would suggest you persevere.
Saif Ur Rahman
@saifsmailbox98
Jun 30 2017 00:06
@arslan555 I can only give you the solution.
Mirza Arslan
@arslan555
Jun 30 2017 00:06
@saifsmailbox98 thank you :)
CamperBot
@camperbot
Jun 30 2017 00:06
arslan555 sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
kumquatfelafel
@kumquatfelafel
Jun 30 2017 00:06
@arslan555 do you want any help understanding @sjames1958gm solution?
Saif Ur Rahman
@saifsmailbox98
Jun 30 2017 00:06
@arslan555 its better that you code it all again and post your code here.
Mirza Arslan
@arslan555
Jun 30 2017 00:07
@sjames1958gm oo thanks buddy...i just triyd to do it with if/if else it seems to be a better approach .
CamperBot
@camperbot
Jun 30 2017 00:07
arslan555 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7956 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Saif Ur Rahman
@saifsmailbox98
Jun 30 2017 00:07
Can this be shortened more?
``````/*jshint esversion: 6 */
function rot13(str) { // LBH QVQ VG!
return str.replace(/[A-Z]/g,a=>String.fromCharCode(65+a.charCodeAt()%26));
}``````
Mirza Arslan
@arslan555
Jun 30 2017 00:08
@saifsmailbox98 this isn't my solution
kumquatfelafel
@kumquatfelafel
Jun 30 2017 00:08
@saifsmailbox98 can change to const, e.g.
Saif Ur Rahman
@saifsmailbox98
Jun 30 2017 00:08
@arslan555 its not for you.
kumquatfelafel
@kumquatfelafel
Jun 30 2017 00:09
so
`const rot13 = str => str.replace(/[A-Z]/g,a=>String.fromCharCode(65+a.charCodeAt()%26));`
Saif Ur Rahman
@saifsmailbox98
Jun 30 2017 00:10
@kumquatfelafel i wasn't too sure about changing the predefined fucntion.
thanks @kumquatfelafel
CamperBot
@camperbot
Jun 30 2017 00:10
saifsmailbox98 sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
Saif Ur Rahman
@saifsmailbox98
Jun 30 2017 00:14
@kumquatfelafel even `rot13 = str => str.replace(/[A-Z]/g,a=>String.fromCharCode(65+a.charCodeAt()%26));` works
kumquatfelafel
@kumquatfelafel
Jun 30 2017 00:14

@kumquatfelafel i wasn't too sure about changing the predefined function.

Yeah, they allow it. From what I've seen so far anyway... can't say I've tried doing everything in es6. :p

Saif Ur Rahman
@saifsmailbox98
Jun 30 2017 00:18
I think I need to sleep now :scream:
kumquatfelafel
@kumquatfelafel
Jun 30 2017 00:18
@saifsmailbox98 yeah. Knows either way.
https://repl.it/JILJ/1
Saif Ur Rahman
@saifsmailbox98
Jun 30 2017 00:18
@kumquatfelafel yeah.
:wave: goodbye
kumquatfelafel
@kumquatfelafel
Jun 30 2017 00:19
seeya
onejo578
@onejo578
Jun 30 2017 00:20
So I've got the answer just by following their examples but could someone please talk me through this?:
``````function multiplyAll(arr) {
var product = 1;
// Only change code below this line

for (var i=0; i < arr.length; i++) {
for (var a=0; a < arr[i].length; a++) {
product *= arr[i][a];
}
}
// Only change code above this line
return product;
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);``````
I don't understand the `arr[i] bit`. What array is that referring to? and where was it established?
kumquatfelafel
@kumquatfelafel
Jun 30 2017 00:21
@onejo578 if you add js after first set of ` like so
```js
it looks nicer. :p
onejo578
@onejo578
Jun 30 2017 00:22
@kumquatfelafel so like
``//code here etc``
hmm
Kervtuza
@Kervtuza
Jun 30 2017 00:24
Hey guys, I am working on the Show Local Weather challenge and things are going well. I am running into a problem trying to run a forEach loop to iterate through a json object. Can someone give me a hand? https://codepen.io/Kervtuza/pen/RgLzyP?editors=1011
Manish Giri
@Manish-Giri
Jun 30 2017 00:24
@Kervtuza what's the problem?
Diego Mayer
@Chrono79
Jun 30 2017 00:24
@Kervtuza isn't forEach for arrays?
Kervtuza
@Kervtuza
Jun 30 2017 00:25
@Chrono79 I don't know? is it? is that why it doesn't work?
@Manish-Giri the problem is I am trying to use a forEach loop to print out the json file to the page, i feel like my code is right but nothing appears when i press the button
Diego Mayer
@Chrono79
Jun 30 2017 00:26
Manish Giri
@Manish-Giri
Jun 30 2017 00:26
@Kervtuza you can use `for..in` to iterate through the `json` object.
kumquatfelafel
@kumquatfelafel
Jun 30 2017 00:26

example:
Suppose I have
`arr[0][0] arr[0][1] arr[0][2] arr[0][3]`
So arr[0] here is not a single value, but actually an array itself.

A 2d array is essentially when inside your array, you have subarrays.
@onejo578

Manish Giri
@Manish-Giri
Jun 30 2017 00:27
``````for(var prop in json) {
// do something here
}``````
@Kervtuza
Kervtuza
@Kervtuza
Jun 30 2017 00:28
@Manish-Giri oh okay, I will give that a shot and let you know how that goes
Diego Mayer
@Chrono79
Jun 30 2017 00:28
@Kervtuza look at the developer tools console:
`Uncaught TypeError: json.forEach is not a function`
And why are you doing this?
``````    var rawJson = JSON.stringify(data);
json = JSON.parse(rawJson);``````
Manish Giri
@Manish-Giri
Jun 30 2017 00:29
@Kervtuza also, use the browser console. Codepen console doesn't display errors correctly.
Kervtuza
@Kervtuza
Jun 30 2017 00:30
@Chrono79 I though I had to stringify and then parse the data to display it right? no?
Manish Giri
@Manish-Giri
Jun 30 2017 00:31
`json = JSON.parse(rawJson);` is the same as `data`
Diego Mayer
@Chrono79
Jun 30 2017 00:31
No, you're doing the same as array.join(" ").split(" ") (well, not exactly, but close :P)
Kervtuza
@Kervtuza
Jun 30 2017 00:31
I am new to APIs and json, so jsut a bit confused
ohhhh
Manish Giri
@Manish-Giri
Jun 30 2017 00:33
@Kervtuza if you're unsure of what type is the data you're getting back, always use `console.log()` statements to verify it in the console..
Kervtuza
@Kervtuza
Jun 30 2017 00:33
well for some reason, if I were to do console.log(data.length) it returns every individual char in the object....if i do console.log(json.length) it returns the number of properties in the object?
Diego Mayer
@Chrono79
Jun 30 2017 00:34
@Kervtuza and as @Manish-Giri suggested, use the browser console, codepen console won't show the object content if it's too long
Kervtuza
@Kervtuza
Jun 30 2017 00:34
ohhhhh
okay
ill try using the browser console
Harry Fahringer III
@harryrf
Jun 30 2017 00:37
This API gathers your location based on your IP, does it work for everyone? https://geoip-db.com/jsonp/ It's spot on for me and I live in a small unknown town.
I would like that change over from geolocation.getCurrentLocation() to avoid the errors.
Steven Nyeo
@limpingstone
Jun 30 2017 00:42
How can `addTogether(2)(3)`
Be identified as two arguments?
(On challenge: Arguments Optional)
Stephen James
@sjames1958gm
Jun 30 2017 00:43
@limpingstone It is only one argument to addTogether the (3) is passed to the function that addTogether returns when only one argument
Steven Nyeo
@limpingstone
Jun 30 2017 00:46
@sjames1958gm Does that mean the second (3) is just recalling the function again? Do we have to create a new function then?
``TypeError: addTogether(...) is not a function``
Stephen James
@sjames1958gm
Jun 30 2017 00:48
@limpingstone No, addTogether returns a function reference when there is only one parameter and that function is called.
function test() {
return function() { console.log("test"); }
}
test()()
would output test to console
luccifer00
@luccifer00
Jun 30 2017 00:52
Hi again! I just finished the basic algoritms challenges, and finished the api ajax and json starting levels. Now i have to start to build a quote machine, but as far as i see, us a huge jump, on coding, using html bootstramp (easy) using jquery ( the basic codes than the teach us) and use json..... i have to ask, there is any other places to help me to do this challenges by my own???
Or i can use this chat for each question that i will have??
Steven Nyeo
@limpingstone
Jun 30 2017 00:53

@sjames1958gm

``````if (arguments.length == 1) {
return function(val){
return val + arguments[0];
};
}``````

Is this how the second layer of function is listed?

@luccifer00 Youtube is a good place to find resource ;)
Stephen James
@sjames1958gm
Jun 30 2017 00:55
@limpingstone no You will need to assign arguments[0] to another variable (so it is accessible to the function returned)
Then return just the fucntion definition
luccifer00
@luccifer00
Jun 30 2017 00:55
lol @sjames1958gm
Steven Nyeo
@limpingstone
Jun 30 2017 00:57

@sjames1958gm

``````if (arguments.length == 1) {
var arg0 = arguments[0];
return function(val){
return val + arg0;
};
}``````

Got it. What do you mean by the function definition?

Stephen James
@sjames1958gm
Jun 30 2017 00:57
``````function(val){
return val + arg0;
};``````
This is the function definition
Avery Biskup
@fraknard
Jun 30 2017 00:57
Steven Nyeo
@limpingstone
Jun 30 2017 01:00
@sjames1958gm
Eric Hasegawa
@EricHasegawa
Jun 30 2017 01:01
Can anyone tell me why instead of the "Get Help" option on my projects, it now says "Get Hint" instead? And why I have to search up gitter and find the room to access this now?
Steven Nyeo
@limpingstone
Jun 30 2017 01:02

@sjames1958gm

``````function addTogether() {
if (typeof arguments[0] === 'number' && typeof arguments[1] == 'number') {

if (arguments.length == 1) {
var arg0 = arguments[0];

return function(val) {
return val + arg0;
};
}

else if (arguments.length >= 2) {
return arguments[0] + arguments[1];
}
else {
return undefined;
}
}

}

Not sure where it went wrong

luccifer00
@luccifer00
Jun 30 2017 01:03
@EricHasegawa i am asking the same, it happens yesterday evening
Stephen James
@sjames1958gm
Jun 30 2017 01:03
@limpingstone one thing is you are checking arguments[1] before you check if there is an arguments[1]
Avery Biskup
@fraknard
Jun 30 2017 01:08
Kyle Holm
@thekholm80
Jun 30 2017 01:10
@fraknard i win after 3?
Ednor
@ednor
Jun 30 2017 01:11
Hello guys, how is everything ?
Steven Nyeo
@limpingstone
Jun 30 2017 01:11
@ednor Good! Thanks for asking :)
CamperBot
@camperbot
Jun 30 2017 01:11
limpingstone sends brownie points to @ednor :sparkles: :thumbsup: :sparkles:
Ednor
@ednor
Jun 30 2017 01:11
I am in trouble since yesterday with a challenge
today I want to solve it
Steven Nyeo
@limpingstone
Jun 30 2017 01:11
@ednor :joy: just sent out a brownie point
which one
Ednor
@ednor
Jun 30 2017 01:12
Challenge 197: **Return Early Pattern for Functions
Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
here is my code:
``````
// Setup
function abTest(a, b) {
// Only change code below this line
console.log(a < 0 || b < 0);

// Only change code above this line

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

// Change values below to test your code
abTest(2,2);``````
Steven Nyeo
@limpingstone
Jun 30 2017 01:14
@ednor Don't log the stuff into the console
Just use if statement cuz `a < 0 || b < 0` is a condition statement
Stephen James
@sjames1958gm
Jun 30 2017 01:14
@ednor Look at the instructions `if a or b are less than 0` this tells me that you should have an if statement
luccifer00
@luccifer00
Jun 30 2017 01:14
@fraknard , i don t reach that level, but, try to get harder (10 levels min) and are the buttons on off set correctly??
Steven Nyeo
@limpingstone
Jun 30 2017 01:15
@ednor ```if (a<0 || b<0) return undefined;```
Ednor
@ednor
Jun 30 2017 01:15
@sjames1958gm , we have left if a while, now we are in switch
@ednor ```if (a<0 || b<0) return undefined;```
Doesn't work !
Eric Hasegawa
@EricHasegawa
Jun 30 2017 01:17
``````
function bouncer(arr) {

var toDump = [false, null, 0, "", undefined, NaN];

for (var i=0; i < arr.length; i++) {
if (arr.indexOf(toDump) === -1) {
return arr;
} else {
return arr.splice(i, 1);

}

}

}

bouncer([7, "ate", "", false, 9]);``````
Could someone tell me why this code isn't working?
Steven Nyeo
@limpingstone
Jun 30 2017 01:17
@sjames1958gm Thanks for the help. It's solved
CamperBot
@camperbot
Jun 30 2017 01:17
limpingstone sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7957 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 30 2017 01:17
@limpingstone :+1:
Ednor
@ednor
Jun 30 2017 01:18
@limpingstone , does not work
Stephen James
@sjames1958gm
Jun 30 2017 01:18
@EricHasegawa one thing you are shrinking the array while looping over it
Also, NaN will not work that way
Steven Nyeo
@limpingstone
Jun 30 2017 01:18
@ednor !! That was what I typed down tho
Diego Mayer
@Chrono79
Jun 30 2017 01:19
You are going to use if for the rest of your (programmer) life, it's not something you passed and won't ever use again
Eric Hasegawa
@EricHasegawa
Jun 30 2017 01:19
@sjames1958gm What am I doing to shrink the array? and why won't NaN work that way?
Avery Biskup
@fraknard
Jun 30 2017 01:19
@luccifer00 @thekholm80 I was just testing, the winning level is now 20.
Ednor
@ednor
Jun 30 2017 01:20
@Chrono79
``````
// Setup
function abTest(a, b) {
// Only change code below this line
console.log(a < 0 || b < 0);

// Only change code above this line

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

// Change values below to test your code
abTest(2,2);``````
Kyle Holm
@thekholm80
Jun 30 2017 01:20
@fraknard i like the design
Diego Mayer
@Chrono79
Jun 30 2017 01:20
@ednor see what @limpingstone told you to use
@sjames1958gm also told you to not use console.log
Avery Biskup
@fraknard
Jun 30 2017 01:20
@luccifer00 haha, about the buttons, I was a little confused about that, but my friend thought this looked better.
@thekholm80 Thanks!
CamperBot
@camperbot
Jun 30 2017 01:21
fraknard sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1219 | @thekholm80 |http://www.freecodecamp.com/thekholm80
Ednor
@ednor
Jun 30 2017 01:22
@Chrono79 , I have replaced console.log with if, nada !
Steven Nyeo
@limpingstone
Jun 30 2017 01:22
@Chrono79 Use what? lol I'm confused
Diego Mayer
@Chrono79
Jun 30 2017 01:22
@ednor ```if (a<0 || b<0) return undefined;```
Ednor
@ednor
Jun 30 2017 01:22
I have used console.log because it is in the Example
``````function myFun() {
console.log("Hello");
return "World";
console.log("byebye")
}
myFun();``````
Steven Nyeo
@limpingstone
Jun 30 2017 01:22
@ednor @Chrono79
``````if (a<0 || b<0)
return undefined;``````
Diego Mayer
@Chrono79
Jun 30 2017 01:23
@limpingstone yes, that's what you suggested him to use, doesn't it?
Steven Nyeo
@limpingstone
Jun 30 2017 01:23
@Chrono79 Exactly :thumbsup:
Ednor
@ednor
Jun 30 2017 01:23
damn !
Steven Nyeo
@limpingstone
Jun 30 2017 01:23
Good luck bro
Ednor
@ednor
Jun 30 2017 01:23
IT WORKS !
Steven Nyeo
@limpingstone
Jun 30 2017 01:23
;)
Ednor
@ednor
Jun 30 2017 01:24
``````// Setup
function abTest(a, b) {
// Only change code below this line
if (a < 0 || b < 0) return undefined;

// Only change code above this line

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

// Change values below to test your code
abTest(2,2);``````
Steven Nyeo
@limpingstone
Jun 30 2017 01:24
@ednor :thumbsup:
Diego Mayer
@Chrono79
Jun 30 2017 01:25
@ednor it's not copy/paste what you have to use in every challenge, some require you apply things you used before maybe in a different way
Ednor
@ednor
Jun 30 2017 01:25
I have complicated my code for no reason
Diego Mayer
@Chrono79
Jun 30 2017 01:25
:+1:
Ednor
@ednor
Jun 30 2017 01:26
@Chrono79 , you are right
Thanks @Chrono79 , @limpingstone and @sjames1958gm
CamperBot
@camperbot
Jun 30 2017 01:26
ednor sends brownie points to @chrono79 and @limpingstone and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7958 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 4444 | @chrono79 |http://www.freecodecamp.com/chrono79
Ednor
@ednor
Jun 30 2017 01:26
let me continue with the next challenge
I will get back to you if I have need any help
Steven Nyeo
@limpingstone
Jun 30 2017 01:27
@ednor Have fun bro
Joseph
@revisualize
Jun 30 2017 01:30
hi.
Salman Shahid
@salman-shahid
Jun 30 2017 01:31
Hi, when a function is called like this: `addTogether(2)(3)` what happens to `(3)`
Joseph
@revisualize
Jun 30 2017 01:31
@salman-shahid currying
@salman-shahid funfunfunction youtube has a good video.
Salman Shahid
@salman-shahid
Jun 30 2017 01:32
CHeers mate.
Keon Samuel
@keonsam
Jun 30 2017 01:32
@salman-shahid maybe it calls for function twice.
Salman Shahid
@salman-shahid
Jun 30 2017 01:33
Joseph
@revisualize
Jun 30 2017 01:34
@salman-shahid it is a tough concept.
Salman Shahid
@salman-shahid
Jun 30 2017 01:34
I have a test in an exercise where I have addTogether(2,3) and I also have addTogether(2)(3)
Joseph
@revisualize
Jun 30 2017 01:35
@salman-shahid watch that video and google: JavaScript currying
Salman Shahid
@salman-shahid
Jun 30 2017 01:35
ahh, I undestand how it works now.
but how would I handle the case when both arguments are given at once and not seperately?
..just check if both given - I feel like there is a better way
Joseph
@revisualize
Jun 30 2017 01:36
`arguments`
is `arguments[1]` undefined?
Salman Shahid
@salman-shahid
Jun 30 2017 01:37
Understood, thanks.
Keon Samuel
@keonsam
Jun 30 2017 01:37
@revisualize function()() is different from function(()()).
Salman Shahid
@salman-shahid
Jun 30 2017 01:37
Also, how would this concept be helpful in a real world scenario?
Keon Samuel
@keonsam
Jun 30 2017 01:37
I think lol.
Joseph
@revisualize
Jun 30 2017 01:37
i need the brownie point.
@salman-shahid i cant explain that right now.
Keon Samuel
@keonsam
Jun 30 2017 01:37
or sammich?
Salman Shahid
@salman-shahid
Jun 30 2017 01:37
Ok, thanks anyway @revisualize I will try google it
CamperBot
@camperbot
Jun 30 2017 01:37
salman-shahid sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4285 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 30 2017 01:38
@salman-shahid i broke my left wrist today.
Keon Samuel
@keonsam
Jun 30 2017 01:38
you need to hold off of the mas.
jk
Joseph
@revisualize
Jun 30 2017 01:40
Ming Zhu
@chocobrownie
Jun 30 2017 01:40

Hi guys, I'm doing the sort US phone number challenge and I have questions about RegExp: I see the ppl in the forum built it like this

``````var regex = /^(1\s?)?(\(\d{3}\)|\d{3})[\s\-]?\d{3}[\s\-]?\d{4}\$/;
return regex.test(str);

//or
var re = /^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})\$/;
return re.test(str);``````

First of all, I have no idea how this works and there's not a tutorial I can finish in 15 min that tells me what to do.
Secondly, I find it useful to simply do var re=/[(]+[0-9]+[0-9]....../i Is this a valid way as well? What are the differences?

Joseph
@revisualize
Jun 30 2017 01:40
my wrist. both ulna and radius.
Keon Samuel
@keonsam
Jun 30 2017 01:40
that is hand not wrist.
kumquatfelafel
@kumquatfelafel
Jun 30 2017 01:41
ack
Keon Samuel
@keonsam
Jun 30 2017 01:42
breaking a bone must hurt as hell.
CallMeOrange
@EgnaroDev
Jun 30 2017 01:42
@revisualize What happened to your wrist?
Joseph
@revisualize
Jun 30 2017 01:42
i broke 2. same time.
CallMeOrange
@EgnaroDev
Jun 30 2017 01:43
Like closing car trunk itself by accident?
Joseph
@revisualize
Jun 30 2017 01:43
CallMeOrange
@EgnaroDev
Jun 30 2017 01:43
Wow
Typing might hurt..
Joseph
@revisualize
Jun 30 2017 01:43
slid on wet pavement
CallMeOrange
@EgnaroDev
Jun 30 2017 01:43
I see
Damn like @keonsam said
breaking a bone must hurt as hell.
Ming Zhu
@chocobrownie
Jun 30 2017 01:46

Repost: Hi guys, I'm doing the sort US phone number challenge and I have questions about RegExp: I see the ppl in the forum built it like this

``````var regex = /^(1\s?)?(\(\d{3}\)|\d{3})[\s\-]?\d{3}[\s\-]?\d{4}\$/;
return regex.test(str);

//or
var re = /^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})\$/;
return re.test(str);``````

First of all, I have no idea how this works and there's not a tutorial I can finish in 15 min that tells me what to do.
Secondly, I find it useful to simply do var re=/[(]+[0-9]+[0-9]....../i Is this a valid way as well? What are the differences?

Keon Samuel
@keonsam
Jun 30 2017 01:48
@chocobrownie do you know how regex works?
Ming Zhu
@chocobrownie
Jun 30 2017 01:48
@keonsam I know how to use a finished Regex, I know they are between / / and within it has [ ], and ^ means non? this is all I know rn
g is global and i is first case
CallMeOrange
@EgnaroDev
Jun 30 2017 01:49
@chocobrownie you are correct about g, i and ^
well `i` means to ignore all lowercase or uppercase
Ming Zhu
@chocobrownie
Jun 30 2017 01:50
ic
Keon Samuel
@keonsam
Jun 30 2017 01:50
good, I just google most of my regex.
Ming Zhu
@chocobrownie
Jun 30 2017 01:50
But Who am I supposed to understand this "/^(1\s?)?((\d{3})|\d{3})[\s-]?\d{3}[\s-]?\d{4}\$/;"
how*
Stephen James
@sjames1958gm
Jun 30 2017 01:50
@chocobrownie The ^ at the beginning means pin this to the start of the string and \$ at the end means pin to the end
which means the whole string has to match
Ming Zhu
@chocobrownie
Jun 30 2017 01:51
In this case I'm testing phone numbers @keonsam https://www.freecodecamp.com/challenges/validate-us-telephone-numbers
Then you can understand what these means, `d`, `g` etc..
Ming Zhu
@chocobrownie
Jun 30 2017 01:51
@sjames1958gm Ic, thanks for the input
CamperBot
@camperbot
Jun 30 2017 01:51
chocobrownie sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7959 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
@moigithub
Jun 30 2017 01:53
Stephen James
@sjames1958gm
Jun 30 2017 01:53
@chocobrownie This is a pretty complex one to try and evaluate without more experience
Ming Zhu
@chocobrownie
Jun 30 2017 01:54
@sjames1958gm It's in the challenges, I will need to take care of this
Stephen James
@sjames1958gm
Jun 30 2017 01:55
@revisualize Ouch. I pulled my hamstring at work on Monday. It was raining so I tried to jump over the flower beds in front
of our building and my right foot stuck and my left didn't
CallMeOrange
@EgnaroDev
Jun 30 2017 01:55
I hate cramp..
Ming Zhu
@chocobrownie
Jun 30 2017 01:55
@moigithub I think regexone.com is really gonna help once in for all.... Apreciate it
Long Nguyen
@longnt80
Jun 30 2017 01:56
what is `Symbol()` in javascript?
Ednor
@ednor
Jun 30 2017 01:58
Back to you guys with Counting Cards (Blackjack)
this is the challenge:
and this is my code:
CallMeOrange
@EgnaroDev
Jun 30 2017 01:59
@ednor You did nothing :/
Ednor
@ednor
Jun 30 2017 01:59
``````
var count = 0;

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

return "1 Bet";
// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');``````
CallMeOrange
@EgnaroDev
Jun 30 2017 01:59
ah
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:01
When count is 0 or negative, you return your current count and hold... otherwise, you return your current count and bet. Don't try to hardcode the count.
Ednor
@ednor
Jun 30 2017 02:02
hello @kumquatfelafel , nice to see you there tonight
Stephen James
@sjames1958gm
Jun 30 2017 02:02
@ednor re-read the instructions - you are adding the function name to count??
@moigithub
Jun 30 2017 02:02
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:02
@sjames1958gm also this^
CallMeOrange
@EgnaroDev
Jun 30 2017 02:02
@kumquatfelafel :clap:
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:02
hiya
CallMeOrange
@EgnaroDev
Jun 30 2017 02:03
@kumquatfelafel He already know how to do that lol
Ednor
@ednor
Jun 30 2017 02:03
QUESTION: am I in the right way ?
CallMeOrange
@EgnaroDev
Jun 30 2017 02:03
Well not really
@ednor Close
Ming Zhu
@chocobrownie
Jun 30 2017 02:03
@moigithub
Jun 30 2017 02:03
what that mean? @chocobrownie
CallMeOrange
@EgnaroDev
Jun 30 2017 02:03
@ednor learn increment and decrement
Ming Zhu
@chocobrownie
Jun 30 2017 02:04
@moigithub Just literally, u r not talking too much but gives out helpful resources. I like that style lol
@moigithub
Jun 30 2017 02:04
cuz lazyness @chocobrownie
CallMeOrange
@EgnaroDev
Jun 30 2017 02:05
@moigithub are only capable to help
:)
Ming Zhu
@chocobrownie
Jun 30 2017 02:06
@moigithub Laziness is the best teacher
CallMeOrange
@EgnaroDev
Jun 30 2017 02:06
``````var sum=0;
for(i=4; i<8; i++) {
if (i == 6) {
continue;
}
sum += i;
}
document.write(sum);``````
Why did it return 1?
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:06
@ednor The way you've listed your cases? Top notch! What your cases are actually doing isn't correct though. What you're currently telling it to do is increase the value of cc by one. cc is a function. You are also passing cc through switch which is wrong
Ednor
@ednor
Jun 30 2017 02:07
Guys, as I am approaching the last challenges of basic JS, as it's much more difficult ;(
CallMeOrange
@EgnaroDev
Jun 30 2017 02:07
@ednor Dont worry, after Counting Cards there is one more hard challenge then you are ready
That is Profile Lookup :/
@moigithub
Jun 30 2017 02:08
4,5,6,7 .. but skiped 6
soo did 3 iterations
shouldnt be 4+5+7 = 16 ? @MCTwoDigitZero
yep..t ested give 16
CallMeOrange
@EgnaroDev
Jun 30 2017 02:08
@moigithub what you said is correct, but only one digit and sololearn said the answer is 1
I dont know why..
Ednor
@ednor
Jun 30 2017 02:08
@ednor Dont worry, after Counting Cards there is one more hard challenge then you are ready
Oky Doky
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:08
@MCTwoDigitZero that just seems... wrong.... (1 I mean)
CallMeOrange
@EgnaroDev
Jun 30 2017 02:09
@kumquatfelafel Exactly
@moigithub Oh you are actually right, and you explained more clearly now I understand
I just picked a hint then `1` just show up but there was actually a room to add..
@moigithub
Jun 30 2017 02:10
:D
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:10
0 plus any i value between 4 and 7 can't give 1.
CallMeOrange
@EgnaroDev
Jun 30 2017 02:10
Yeah
``````var x = 0;
while(x<6) {
x++;
}
document.write(x);``````
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:11
@MCTwoDigitZero Maybe they just left out the 6? :p
CallMeOrange
@EgnaroDev
Jun 30 2017 02:11
Sololearn return 6 but I thought its supposed to return 5? since `x<6`

@kumquatfelafel

I just picked a hint then `1` just show up but there was actually a room to add..

kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:12
@kumquatfelafel Will stop when x is 6.
CallMeOrange
@EgnaroDev
Jun 30 2017 02:12
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:12
when x is 5, keeps looping
CallMeOrange
@EgnaroDev
Jun 30 2017 02:12
isn't that 5?
@moigithub
Jun 30 2017 02:12
when x is 5 it do x++
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:12
^
CallMeOrange
@EgnaroDev
Jun 30 2017 02:12
I see
Dang I forgot 3 types of loop
that is, for, while and...
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:13
while loop: while condition true, loop until not true. Or until crash... or until earth engulfed by sun. Whichever comes first. :p
@moigithub
Jun 30 2017 02:13
do while ?
CallMeOrange
@EgnaroDev
Jun 30 2017 02:13
oh yes do
do is just like while right?
Whats the difference between them?
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:15
do while : do executes the code at least once, then is treated like while.
CallMeOrange
@EgnaroDev
Jun 30 2017 02:15
I see
No cycle? just once?
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:15
@MCTwoDigitZero once, then it acts like a while loop
CallMeOrange
@EgnaroDev
Jun 30 2017 02:16
Do I need to know do loop?
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:16
While loop will not execute code at all if condition false in beginning.
CallMeOrange
@EgnaroDev
Jun 30 2017 02:16
Yeah
Was wondering what do does
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:17
@MCTwoDigitZero modified responses a bit so a little more clear. Sorry, long night :p
CallMeOrange
@EgnaroDev
Jun 30 2017 02:17
Yeah, but it will keeps loop until condition is false right?
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:17
Both will keep looping until condition is false, yes.
CallMeOrange
@EgnaroDev
Jun 30 2017 02:17
Then return it after it is false?
well kinda before false?
@moigithub
Jun 30 2017 02:18
the thing inside () are the condition, and it only execute the code block
IF condition is true/truthy
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:18
Basically, do while checks the condition afterwards. While checks the condition before.
CallMeOrange
@EgnaroDev
Jun 30 2017 02:18
I see `do while` loop once then do `while`
@moigithub
Jun 30 2017 02:20
soo first code wont show anything
but second will
CallMeOrange
@EgnaroDev
Jun 30 2017 02:20
right while will return only if it is true?
Joe Franco
@BoostedB14
Jun 30 2017 02:20
Does anyone have a minute to help explain stand in line solution from the basic jacascript section?
CallMeOrange
@EgnaroDev
Jun 30 2017 02:21
@BoostedB14 There is only two methods you need, and that is `push` and `shift`, You push something at end of an array then return something that is removed
Manish Giri
@Manish-Giri
Jun 30 2017 02:21
@BoostedB14 there are two steps in that challenge -
1. add the number item to the end of the array arr
2. remove the first element from the array arr and return it.
The two functions - `.push()` and `.shift()` would be helfpul.
CallMeOrange
@EgnaroDev
Jun 30 2017 02:21
well well..
I was in rush so my message can be mistaken
@moigithub
Jun 30 2017 02:25
`while( true === false ){ alert("boo"); }` // condition will be false.. so alert wont be executed
`do { alert("boo"); } while( true === false )` // since the condition is at the end.. alert gets executed once
CallMeOrange
@EgnaroDev
Jun 30 2017 02:25
I understand how while loop works but not a lot about do while
Ednor
@ednor
Jun 30 2017 02:26
``````
var count = 0;

function cc(card) {
// Only change code below this line
card(2, 3, 4, 5, 6);
return cc++;
card (7, 8, 9);
return 0;
card(10, 'J', 'Q', 'K', 'A');
return cc--;
}

return "1 Bet";
// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');``````
CallMeOrange
@EgnaroDev
Jun 30 2017 02:26
Oh its like when condtion is met then it `do` that alert..
Ednor
@ednor
Jun 30 2017 02:26
still not works
@moigithub
Jun 30 2017 02:26
same thing.. its just the conditional evaluation position
CallMeOrange
@EgnaroDev
Jun 30 2017 02:27
@ednor why did you change it?
@moigithub
Jun 30 2017 02:27
no.. it first DO.. then evaluate if should continue doing...
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:27
@ednor Hate to say it, but you got rid of the parts that were good and kept the parts that were bad.
CallMeOrange
@EgnaroDev
Jun 30 2017 02:28
All of your switch methods was correct but not return like `count = cc--`
Ednor
@ednor
Jun 30 2017 02:29
@ednor why did you change it?
BECAUSE..., you made believe I was wrong in my approach
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:30
@MCTwoDigitZero do while would be like if you said "Would you like to play again" at the end of game. Game is going to play at least once, and depending on their response, it may play again.
CallMeOrange
@EgnaroDev
Jun 30 2017 02:30
@ednor ..., you can change it back and fix `count = cc--` and others like that
@moigithub
Jun 30 2017 02:30
`while () {}` // should i hit u ? (it ask for permission first )
`do.. while()` // hit/enjoy the moment and apologize later .. Oh sry.. wrong person :P
CallMeOrange
@EgnaroDev
Jun 30 2017 02:30
@moigithub lol
Ednor
@ednor
Jun 30 2017 02:32
@ednor ..., you can change it back and fix `count = cc--` and others like that
Done !
``````
var count = 0;

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

return "1 Bet";
// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');``````
CallMeOrange
@EgnaroDev
Jun 30 2017 02:32
Ok so now works on `count = cc--;`
and others
That is all I can do for you :p
@kumquatfelafel hey I saw your profile and I think you are really good with algorithms.
Ednor
@ednor
Jun 30 2017 02:35
@MCTwoDigitZero , I will try my best to fix it.
CallMeOrange
@EgnaroDev
Jun 30 2017 02:35
Say.. Im not good at solving algorithms but do you know any site where I can practice? maybe relearning things?
Eric Hasegawa
@EricHasegawa
Jun 30 2017 02:35
``````
function destroyer(arr) {

var args = Array.prototype.slice.call(arguments);

for (var i=0; i < arr.length; i++) {
for (var j=0; j < args.length; i++) {
if (arr[i] === args[j]) {
delete arr[i];
}

}}
return arr.filter(Boolean);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);``````
Can anyone tell me why this isn't working? it crashes my browser
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:36
@EricHasegawa (var j=0; j < args.length; i++) {
Check increment.
Eric Hasegawa
@EricHasegawa
Jun 30 2017 02:37
@kumquatfelafel Right thanks man, also is there any chance you could explain what's going on twith the args variable
CamperBot
@camperbot
Jun 30 2017 02:37
erichasegawa sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:37
@MCTwoDigitZero thanks.
CamperBot
@camperbot
Jun 30 2017 02:37
kumquatfelafel sends brownie points to @mctwodigitzero :sparkles: :thumbsup: :sparkles:
Eric Hasegawa
@EricHasegawa
Jun 30 2017 02:37
I had to copy most of the code and don't understand it very well
@MCTwoDigitZero I'd recommend Codewars, it's a site where you create little programs and gain points for it, level up etc.
CallMeOrange
@EgnaroDev
Jun 30 2017 02:38
Yeah, they dont really works for me
Im not good with basic algorithms yet
I just want to improve my solving skills for algorithms and write it better
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:38
@EricHasegawa too tired. :p
Eric Hasegawa
@EricHasegawa
Jun 30 2017 02:39
@kumquatfelafel Fair enough
Ednor
@ednor
Jun 30 2017 02:39
That's all for today. I will continue tomorrow
CallMeOrange
@EgnaroDev
Jun 30 2017 02:39
@kumquatfelafel such an excuse...
Ednor
@ednor
Jun 30 2017 02:39
Have a good night all
CallMeOrange
@EgnaroDev
Jun 30 2017 02:39
@ednor Night
Eric Hasegawa
@EricHasegawa
Jun 30 2017 02:39
@MCTwoDigitZero There's some fairly simple ones on there to start with, but also you could review free code camp lessons or try something like Codecademy
CallMeOrange
@EgnaroDev
Jun 30 2017 02:40
@EricHasegawa Right now, Im on sololearn and codeschool
They seems good
I already tried codefights and codewars but you could say its a bit advanced for me, rather its too hard for me, I dont know..
Eric Hasegawa
@EricHasegawa
Jun 30 2017 02:42
@MCTwoDigitZero I know what you mean, I'm having tons of trouble going through basic algorithms as well
CallMeOrange
@EgnaroDev
Jun 30 2017 02:42
Yeah
I am able to solve just few of them by myself
bitcoinabdi
@bitcoinabdi
Jun 30 2017 02:44
``````function filteredArray(arr, elem) {
let newArr = [];
// change code below this line
for (let i = 0; i < arr.length; i++) {
let b = arr[i];
var size = b.length;

for (let j = 0; j < b.length; j++) {

if (b[j] === elem) {
size--;}

}
if(size==b.length){
newArr=arr.splice(i,1);

}
}

// change code above this line
return newArr;

} // function

// change code here to test different cases:
console.log(filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18));``````
someone help with this
CallMeOrange
@EgnaroDev
Jun 30 2017 02:47
Perhaps I should try JS courses on beta fCC for a while
Claudio Restifo
@Marmiz
Jun 30 2017 02:47
@bitcoinabdi `splice` changes the array in place, meaning that the looping over that array has no guarantee to be consistent.
Use another method (like `slice`) that does not modify the array
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:48

@MCTwoDigitZero First thing I would do is what you're doing now. Get really comfortable with basics... really familiarize yourself with different loops, the different types of increments, yada yada yada. I would also try to write functions that do... more or less... what some of the functions you use on a regular basis do (though some may be a bit too ugly) :p. This can give deeper understanding of what's happening, and help you make the connection of "well I could do this here". A couple of the simpler ones you could try are indexOf and includes (they can be done in a very similar fashion). Even if what you do is not quite what they do behind the scenes, it is still good practice and can help to get a feel.

I would also get comfortable with the object lookups.

CallMeOrange
@EgnaroDev
Jun 30 2017 02:49
How do you know if I am not comfortable with object lookups?
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:50
These are just generalizations. :p
CallMeOrange
@EgnaroDev
Jun 30 2017 02:50
@kumquatfelafel Well lol, thanks very much for your big message
CamperBot
@camperbot
Jun 30 2017 02:50
mctwodigitzero sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
Claudio Restifo
@Marmiz
Jun 30 2017 02:50
@bitcoinabdi plus you want to remove the entire sub-array that contains that number. You can use `indexOf` to find if `eleme` is inside the sub-array. If so remove it
CallMeOrange
@EgnaroDev
Jun 30 2017 02:51
I guess I should stop overthinking over what I should do
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:51
as long as you keep coding, you're probably gonna be learning something :p
CallMeOrange
@EgnaroDev
Jun 30 2017 02:51
True
Well thats out of question
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:54
Supposedly this is pretty good, but I haven't had a chance to read. https://github.com/getify/You-Dont-Know-JS
CallMeOrange
@EgnaroDev
Jun 30 2017 02:54
Yeah I have one book of YDKJS
That and Eloquent JS but this one I haven't read
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:55
trying to help other people solve their problems... is definitely helpful... since it can force you to think about how to explain something in lots of different ways
pjalexander
@pjalexander
Jun 30 2017 02:55
I think it depends. If your having problems remembering syntax and which methods do what, etc... then a book like beginning javascript can definitely help. If your having problems with logic and how to incorporate it into your coding, then only more coding(practice practice practice) can help imo.
CallMeOrange
@EgnaroDev
Jun 30 2017 02:56
I think my problem is just logic..
@kumquatfelafel @pjalexander thanks and @kumquatfelafel I will try one of these book (already have one) so going to read it
CamperBot
@camperbot
Jun 30 2017 02:57
mctwodigitzero sends brownie points to @kumquatfelafel and @pjalexander :sparkles: :thumbsup: :sparkles:
:warning: mctwodigitzero already gave kumquatfelafel points
CallMeOrange
@EgnaroDev
Jun 30 2017 02:57
I must stop overthinking over things and read YDKJS..
Bye
kumquatfelafel
@kumquatfelafel
Jun 30 2017 02:58
see ya

then only more coding(practice practice practice) can help imo.

Coding and age. It's a well known and widely accepted fact that older people are always more logical. :o

Now... where did I put my hat?
kumquatfelafel @kumquatfelafel is off to find their hat, and bids all adieu...
Eric Hasegawa
@EricHasegawa
Jun 30 2017 03:21
Can anyone help me with an algorithm problem that's not in the FCC curriculum?
Ogundele Olumide
@Lumexralph
Jun 30 2017 03:21
@EricHasegawa ask if we can we'll
Eric Hasegawa
@EricHasegawa
Jun 30 2017 03:22
``````function getCount(str) {
var vowelsCount = 0;
var splitUp = str.split("");

for (var i = 0; i <splitUp.length; i++) {
if (splitUp[i] === "a" || "e" || "i" || "o" || "u") {
vowelsCount = vowelsCount + 1;
}}

return vowelsCount;

}``````
So this code is supposed to count all of the vowels in a string, but when "should be defined" is tested it returns 11, not 5
Anyone know why?
Ogundele Olumide
@Lumexralph
Jun 30 2017 03:25
@EricHasegawa you have to expand the comparison in js when you do something like this `word == "a || b"` what happens is if what's on left is `true`, that is returned but if what's on left is `false` what's on right is returned without even checking the value of what's on the right
@EricHasegawa what you should do is to expand your comparison..... `splitUp[i] === "a" || splitUp[i] === "e"........`
Eric Hasegawa
@EricHasegawa
Jun 30 2017 03:29
``````function getCount(str) {
var vowelsCount = 0;
var splitUp = str.split("");

for (var i = 0; i <splitUp.length - 1; i++) {
if (splitUp.charAt[i] === "a" || splitUp.charAt[i] === "e"
|| splitUp.charAt[i] === "i" || splitUp.charAt[i] === "o"
|| splitUp.charAt[i] === "u") {
vowelsCount = vowelsCount + 1;
}}

return vowelsCount;

}``````
I changed it to this, but it still won't work
@Lumexralph
Joseph
@revisualize
Jun 30 2017 03:31
@EricHasegawa a switch would be better
Ogundele Olumide
@Lumexralph
Jun 30 2017 03:32

@EricHasegawa

`````` if (splitUp[i] === "a" || splitUp[i] === "e" || splitUp[i] === "i" || splitUp[i] === "o" ||splitUp[i] ===  "u") {
vowelsCount = vowelsCount + 1;
}``````

this is all you need to do with the initial code

Joseph
@revisualize
Jun 30 2017 03:33
maybe `.toLowerCase()` as well?
Markus Kiili
@Masd925
Jun 30 2017 03:33
@EricHasegawa You could use `["a","e","i", "o", "u"]` or `"aeiou"` and `indexOf` instead too.
Joseph
@revisualize
Jun 30 2017 03:34
@Masd925 :wave:
Markus Kiili
@Masd925
Jun 30 2017 03:34
Morning.
Eric Hasegawa
@EricHasegawa
Jun 30 2017 03:34
@revisualize @Masd925 Yeah haha I'm realizing I did this poorly now, but still I'd rather fix my own code then restart
Just because I want to learn what's wrong with it
Joseph
@revisualize
Jun 30 2017 03:35
@EricHasegawa you dont need .split
Ogundele Olumide
@Lumexralph
Jun 30 2017 03:35
@EricHasegawa :point_up: June 30, 2017 4:32 AM you're to expand the comparison in the first code you posted
@Masd925 Good Morning
Eric Hasegawa
@EricHasegawa
Jun 30 2017 03:36
``````function getCount(str) {
var vowelsCount = 0;
var splitUp = str.toLowerCase();

for (var i = 0; i <splitUp.length - 1; i++) {
if (splitUp.charAt[i] === "a" || splitUp.charAt[i] === "e"
|| splitUp.charAt[i] === "i" || splitUp.charAt[i] === "o"
|| splitUp.charAt[i] === "u") {
vowelsCount = vowelsCount + 1;
}}

return vowelsCount;

}``````
This is my code now, it returns 0
Ogundele Olumide
@Lumexralph
Jun 30 2017 03:37
@EricHasegawa why doing this in your loop condition `i <splitUp.length - 1` ?
@EricHasegawa why don't you go back to the first code you posted?
Eric Hasegawa
@EricHasegawa
Jun 30 2017 03:39
@Lumexralph What's wrong with my current code that's correct in my old code?
Ogundele Olumide
@Lumexralph
Jun 30 2017 03:40
@EricHasegawa using `charAt`
Eric Hasegawa
@EricHasegawa
Jun 30 2017 03:41

function getCount(str) {
var vowelsCount = 0;
var splitUp = str.toLowerCase();

for (var i = 0; i <splitUp.length; i++) {
if (splitUp.charAt[i] === "a" || splitUp.charAt[i] === "e"
|| splitUp.charAt[i] === "i" || splitUp.charAt[i] === "o"
|| splitUp.charAt[i] === "u") {
vowelsCount = vowelsCount + 1;
}}

return vowelsCount;

}

How am I using charAt wrong?
@Lumexralph Oh I figured it out! So I don't need any more help, but could you explain why I had to take charAt out?
Ogundele Olumide
@Lumexralph
Jun 30 2017 03:45
@EricHasegawa not to take it out you are to use parenthesis `( i )` not `[ i ]` with `charAt`
Joseph
@revisualize
Jun 30 2017 03:48
@EricHasegawa `.charAt()` is a method
Eric Hasegawa
@EricHasegawa
Jun 30 2017 03:48
@Lumexralph Got it, but why doesn't the function work when charAt is in it?
Joseph
@revisualize
Jun 30 2017 03:49
you need () with methods
Ogundele Olumide
@Lumexralph
Jun 30 2017 03:49
@EricHasegawa it'll work still you got the syntax wrong it should be `charAt(i)` not `charAt[i]`
Joseph
@revisualize
Jun 30 2017 03:49
Eric Hasegawa
@EricHasegawa
Jun 30 2017 03:50
@Lumexralph Ah right. Well thank you! and thanks @revisualize as well
CamperBot
@camperbot
Jun 30 2017 03:50
erichasegawa sends brownie points to @lumexralph and @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2006 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 4286 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 30 2017 03:50
@Lumexralph gratz on 2000.
Ogundele Olumide
@Lumexralph
Jun 30 2017 03:50
@EricHasegawa :+1:
@revisualize :smile: :bow:
Joseph
@revisualize
Jun 30 2017 03:51
Im here trying to help ... i should go back to bed.
heh
Menlam Choden
@menlam
Jun 30 2017 03:55

function titleCase(str) {
var str1=str.toLowerCase();
var str2=str1.split(" ");
var j=[""];
var k;
for(var i=0;i<=str2.length;i++){

``  j[i]=str2[i].charAt(0).toUpperCase().join(" ");``

}
return j;
}

titleCase("I'm a little tea pot");
what is wrong here

Bomee
@Bomulacious
Jun 30 2017 03:57
Hi, I'm having difficulty understanding this challenge. https://www.freecodecamp.com/challenges/check-for-palindromes It says remove all space, symbols etc but then those things count when checking for palindroms...? Could anyone clarify this for me?
Ogundele Olumide
@Lumexralph
Jun 30 2017 03:58
@menlam 1. you need to check your loop condition `;i<=str2.length` at last iteration `str2[i]` will be `undefined`
Menlam Choden
@menlam
Jun 30 2017 03:59
@Lumexralph how to solve it
Eric Hasegawa
@EricHasegawa
Jun 30 2017 03:59
@Bomulacious If you look at the tests and the expected results, you'll see that they ignore all punctuation spaces etc.
Long Nguyen
@longnt80
Jun 30 2017 03:59
hey guys, do you know why getElementsByClassName doesn't work with forEach in this case:
https://codepen.io/longnt80/pen/jwajew?editors=1011
Ogundele Olumide
@Lumexralph
Jun 30 2017 03:59
@menlam 2.. you need to concatenate with the substring of the string in `str[i]`, you can't mutate a string
Bomee
@Bomulacious
Jun 30 2017 04:00
@EricHasegawa i think i just confused myself, i solved it, thanks!
CamperBot
@camperbot
Jun 30 2017 04:00
bomulacious sends brownie points to @erichasegawa :sparkles: :thumbsup: :sparkles:
Eric Hasegawa
@EricHasegawa
Jun 30 2017 04:01
@Bomulacious No worries!
Ogundele Olumide
@Lumexralph
Jun 30 2017 04:02
@longnt80 it Returns an array-like object
@longnt80 to be able to use the methods of an array, you need to make `squares` a true array by converting it to one to be be able to use the `forEach method`
Long Nguyen
@longnt80
Jun 30 2017 04:04
@Lumexralph why does it work with querySelectorAll? querySelectorAll also didn't return a true array
@Lumexralph
here's the pen again, I put in some console.log:
https://codepen.io/longnt80/pen/jwajew?editors=1011
Ogundele Olumide
@Lumexralph
Jun 30 2017 04:07
@longnt80 it should work then, let me take a closer look
Long Nguyen
@longnt80
Jun 30 2017 04:07
@Lumexralph the for loop works with both
Manish Giri
@Manish-Giri
Jun 30 2017 04:12

@longnt80

Returns an array-like object of all child elements which have all of the given class names.

I guess that's probably why
@Lumexralph good morning ggm :smiling_imp:
Markus Kiili
@Masd925
Jun 30 2017 04:14
@longnt80 Nodelists have a forEach method https://developer.mozilla.org/en-US/docs/Web/API/NodeList
Long Nguyen
@longnt80
Jun 30 2017 04:14
@Manish-Giri ok, so getEle.. return an array-like
and querySe.. return an NodeList
@Masd925 @Manish-Giri @Lumexralph thanks
CamperBot
@camperbot
Jun 30 2017 04:15
longnt80 sends brownie points to @masd925 and @manish-giri and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 6151 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 2007 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 4281 | @masd925 |http://www.freecodecamp.com/masd925
Ogundele Olumide
@Lumexralph
Jun 30 2017 04:16
@Masd925 yes it does
Manish Giri
@Manish-Giri
Jun 30 2017 04:16
@Lumexralph congrats on 2000!!
Ogundele Olumide
@Lumexralph
Jun 30 2017 04:16
@Manish-Giri good morning :smiling_imp:
@Manish-Giri thanks :bow:
CamperBot
@camperbot
Jun 30 2017 04:16
lumexralph sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6152 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ogundele Olumide
@Lumexralph
Jun 30 2017 04:17
@Manish-Giri so it is fetch + merge for me too now
Manish Giri
@Manish-Giri
Jun 30 2017 04:17
@Lumexralph niice
Ogundele Olumide
@Lumexralph
Jun 30 2017 04:20
@longnt80 it is working with `forEach` method
Long Nguyen
@longnt80
Jun 30 2017 04:21

@Lumexralph

@longnt80 it is working with `forEach` method

getElementsByClassName?

Ogundele Olumide
@Lumexralph
Jun 30 2017 04:21
@longnt80 yes
Long Nguyen
@longnt80
Jun 30 2017 04:22
@Lumexralph no
maybe I commented the lines while you were checking the code
Manish Giri
@Manish-Giri
Jun 30 2017 04:22
@Lumexralph going well, firing in some queries right now
Long Nguyen
@longnt80
Jun 30 2017 04:23
Ogundele Olumide
@Lumexralph
Jun 30 2017 04:23
@longnt80 actually it returns a `NodeList` which has its own method similar to the `forEach` of an array
Long Nguyen
@longnt80
Jun 30 2017 04:24
@Lumexralph that's the querySelectorAll
getElementsByClassName return a HTMLCollection
and it doesn't work with forEach
Ogundele Olumide
@Lumexralph
Jun 30 2017 04:26
@longnt80 yeah that's true, it doesn't return a NodeList
Manish Giri
@Manish-Giri
Jun 30 2017 04:27
this should work
``````  var squares = document.getElementsByClassName('square'); // It doesn't work for button forEach
[...squares].forEach(square => console.log(square));``````
Ogundele Olumide
@Lumexralph
Jun 30 2017 04:27
@longnt80 but there's a workaround
Long Nguyen
@longnt80
Jun 30 2017 04:28
yes only way is to turn it to array
Ogundele Olumide
@Lumexralph
Jun 30 2017 04:29
@longnt80 just as we said earlier make it an array-like object, seems we have to convert to an array
Pete Givens
@petegivens
Jun 30 2017 04:30
can anyone tell me what's wrong with this code? It's supposed to accept an array as an argument and return an object with the first element of the array as the key and the last element of the array as it's value
``````function transformFirstAndLast(array) {
var obj = {
array[0]: array[array.length - 1]
};
return obj;
}``````
Ogundele Olumide
@Lumexralph
Jun 30 2017 04:30
@longnt80 querySelectorAll returns a `NodeList` which has its own `forEach` method, i wonder why they made the getElementsByClassName different
Pete Givens
@petegivens
Jun 30 2017 04:31

E.g. it should handle input like:
`['Kevin', 'Bacon', 'Love', 'Hart', 'Costner', 'Spacey']`

Function's return value (output):

``````{
Kevin : 'Spacey'
}``````
Markus Kiili
@Masd925
Jun 30 2017 04:31
@longnt80 You can also use `call` method to make any array method work on any array-like object.
Long Nguyen
@longnt80
Jun 30 2017 04:31
@Lumexralph good question, I want to know myself
I read about the difference between the two but cannot understand it yet
@Masd925 ok, let me check
@moigithub
Jun 30 2017 04:33

@petegivens
this es5 syntax

``````var obj={};
obj[array[0]] = array.pop(); // same as length thing``````

or using es6 "computed properties"

``````var obj = {
[array[0]]: array.pop();  // notice the extra brackets
}``````
Long Nguyen
@longnt80
Jun 30 2017 04:33

@Manish-Giri
[...squares].forEach(square => console.log(square));

is this something I can use anywhere now instead of the current syntax that FCC teach?

Pete Givens
@petegivens
Jun 30 2017 04:34
es6 is what I was using or what you're using?
Manish Giri
@Manish-Giri
Jun 30 2017 04:34
@longnt80 some old browsers might not have support for ES6 yet
but yeah you should be good generally
Pete Givens
@petegivens
Jun 30 2017 04:34
i've heard of ecmascript a million times but i still don't understand the difference between that and javascript :(
Long Nguyen
@longnt80
Jun 30 2017 04:34
@Manish-Giri ok, I think I'll try it more, thanks
CamperBot
@camperbot
Jun 30 2017 04:34
longnt80 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: longnt80 already gave manish-giri points
Markus Kiili
@Masd925
Jun 30 2017 04:35
@petegivens ECMAScript is a language standard. Javascript is an implementation of that standard.
Pete Givens
@petegivens
Jun 30 2017 04:36
what other implementations are there?
Markus Kiili
@Masd925
Jun 30 2017 04:37
JScript, ActionScript.
Pete Givens
@petegivens
Jun 30 2017 04:38
@moigithub i see the extra brackets but i don't understand why they're there lol
@moigithub
Jun 30 2017 04:38
u can google for "computed properties"
or es6 javascript
but to do what u want.. check above code :P
Pete Givens
@petegivens
Jun 30 2017 04:40
@moigithub thanks. top result on that search is Object Initializer...?
CamperBot
@camperbot
Jun 30 2017 04:40
petegivens sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3452 | @moigithub |http://www.freecodecamp.com/moigithub
Pete Givens
@petegivens
Jun 30 2017 04:42
so basically when initializing an object, anytime i'm not using the literal property name i have to surround it with brackets?
``````var x = "name";
var obj = {
[x] : "Pete"
}``````
should create an object with a key of "name" and a value of Pete?
@moigithub
Jun 30 2017 04:43
ye
Pete Givens
@petegivens
Jun 30 2017 04:43
whereas
```
var x = "name";
var obj = {
oops
``````var x = "name";
var obj = {
x : "Peter"
}``````
would create an object with a key of "x" and a value of "peter"
@moigithub
Jun 30 2017 04:44
yep
Ogundele Olumide
@Lumexralph
Jun 30 2017 04:45
@longnt80 this way, using the `HTML Live collection` array-like object like `arguments` in function as the `this` reference
``````var squares = document.getElementsByClassName('square'); // It doesn't work for button forEach

Array.prototype.forEach.call(squares, function(square){
console.log(square);
});``````
Pete Givens
@petegivens
Jun 30 2017 04:45
cool man thanks again @moigithub
CamperBot
@camperbot
Jun 30 2017 04:45
:warning: petegivens already gave moigithub points
petegivens sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
Pete Givens
@petegivens
Jun 30 2017 04:56
@moigithub that code isn't working ;\
var obj = {
[array[0]]: array.pop(); // notice the extra brackets
}
``````var obj = {
[array[0]]: array.pop();  // notice the extra brackets
}``````
if I leave your semicolon after pop() it gives me a syntax error. If i remove the semicolon it returns undefined
Manish Giri
@Manish-Giri
Jun 30 2017 04:58
@petegivens is that the Hackreactor Module 0 challenge?
Pete Givens
@petegivens
Jun 30 2017 04:58
err nevermind, i'm dumb
the semicolon is wrong but the undefined was happening becuase i forgot to call the method :)
@Manish-Giri yep
Ogundele Olumide
@Lumexralph
Jun 30 2017 04:58
@petegivens it's an object literal
@Manish-Giri what good image hosting site do you know?
Manish Giri
@Manish-Giri
Jun 30 2017 05:00
@Lumexralph I use dropbox
very reliable
Ogundele Olumide
@Lumexralph
Jun 30 2017 05:00
@Manish-Giri ha... forgot :smile:
Avery Biskup
@fraknard
Jun 30 2017 05:00
Ogundele Olumide
@Lumexralph
Jun 30 2017 05:01
@Manish-Giri trying to take my portfolio page to my github pages
@Manish-Giri can't believe I did some very nasty stuffs
Manish Giri
@Manish-Giri
Jun 30 2017 05:02
lol
Ogundele Olumide
@Lumexralph
Jun 30 2017 05:02
seriously, I was just asking myself, what was I thinking doing this that
Pete Givens
@petegivens
Jun 30 2017 05:07
can you guys look at this please? https://repl.it/JIY8/1
I have 3 separate versions of the function and I don't understand why the second commented out one is showing bad syntax
``````var inputArray = ['Queen', 'Elizabeth', 'Of Hearts', 'Beyonce'];

function transformFirstAndLast(array) {
var obj = {
[array[0]]: array.pop()
}
return obj;
}
transformFirstAndLast(inputArray);

// This one is bad syntax because I use the var declaration...why here and not in the first function?
function transformFirstAndLast2(array) {
var obj = {
[array[0]] : array[1];
}
return obj;
}
transformFirstAndLast2(inputArray);

function transformFirstAndLast3(array) {
obj = {
[array[0]] : array[1]
}
return obj;
}
transformFirstAndLast3(inputArray);``````
Long Nguyen
@longnt80
Jun 30 2017 05:08
@Lumexralph thanks man :point_up: June 30, 2017 11:45 AM
CamperBot
@camperbot
Jun 30 2017 05:08
longnt80 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: longnt80 already gave lumexralph points
Pete Givens
@petegivens
Jun 30 2017 05:09
oh oops it's just a semicolon again
TIME FOR BED
Manish Giri
@Manish-Giri
Jun 30 2017 05:09
@petegivens `[array[0]] : array[1];`
no `;`
Pete Givens
@petegivens
Jun 30 2017 05:10
yeah lol thanks
i'm surprised # 3 works without the var declaration
the things you learn when you're sleep deprived and make typos and omissions D:
Ogundele Olumide
@Lumexralph
Jun 30 2017 05:11
@petegivens if you use a variable name without the keyword JS makes it a global variable so it would work
Pete Givens
@petegivens
Jun 30 2017 05:11
i see
@Manish-Giri @Lumexralph ty both
CamperBot
@camperbot
Jun 30 2017 05:11
petegivens sends brownie points to @manish-giri and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 2008 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 6153 | @manish-giri |http://www.freecodecamp.com/manish-giri
Baibhav Gautam
@baibhavx
Jun 30 2017 05:14
what do you recommend using for Simon game user interface. I was thinking canvas but I don't have any experience with it
Level32
@BENticLabs
Jun 30 2017 05:15
``````Object {
channel: "https://api.twitch.tv/kraken/channels/ELS_CSGO",
self: "https://api.twitch.tv/kraken/streams/ELS_CSGO"
},
stream: Object {
_id: 25614668720,
average_fps: 50,
game: "Counter-Strike: Global Offensive",
viewers: 617
}
}``````
console.log(data); //spits out the above JSON
console.log(data.viewers); //undefined
Does anyone know why data.viewers is undefined?
Manish Giri
@Manish-Giri
Jun 30 2017 05:18
@BENticLabs `data.stream.viewers`
try that
Level32
@BENticLabs
Jun 30 2017 05:19
@Manish-Giri Ah, thank you
CamperBot
@camperbot
Jun 30 2017 05:19
benticlabs sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6154 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 30 2017 05:28
@BENticLabs :+1:
Maks Ushakov
@maks-ushakov
Jun 30 2017 05:29
hello, i get stuck on "No repeats please" challenge and no idea how to solve this.
First idea was get all mutation, but it looks complicated. Another idea was get formula but my formula did not work.
Any suggest?
Long Nguyen
@longnt80
Jun 30 2017 05:31
@maks-ushakov I used heap's algorithm for that challenge
Maks Ushakov
@maks-ushakov
Jun 30 2017 05:32
CamperBot
@camperbot
Jun 30 2017 05:32
maks-ushakov sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
Long Nguyen
@longnt80
Jun 30 2017 05:33
@baibhavx I haven't started on simon game but I'd probably use css only
Baibhav Gautam
@baibhavx
Jun 30 2017 05:33
@longnt80 yeah someone just told me that it can be done with css in the other chat room. :)
Gonna start today
Long Nguyen
@longnt80
Jun 30 2017 05:34
@maks-ushakov here's the resource that I used to convert to javascript: https://en.wikipedia.org/wiki/Heap%27s_algorithm
@baibhavx here's something I did a few weeks ago https://codepen.io/longnt80/pen/xrRjGa
Baibhav Gautam
@baibhavx
Jun 30 2017 05:36
That looks like a good start
surferpilgrim
@surferpilgrim
Jun 30 2017 05:38
when you reverse an array are the indicies reversed as well?
Long Nguyen
@longnt80
Jun 30 2017 05:38
@surferpilgrim no
Baibhav Gautam
@baibhavx
Jun 30 2017 05:39
@longnt80 wow I like your tictactoe
awesome job!
Long Nguyen
@longnt80
Jun 30 2017 05:41
@baibhavx thanks!
it took me a week, I redid the whole thing one time though
CamperBot
@camperbot
Jun 30 2017 05:41
longnt80 sends brownie points to @baibhavx :sparkles: :thumbsup: :sparkles:
surferpilgrim
@surferpilgrim
Jun 30 2017 06:01
I'm writing a function that returns a range array between two values [a,b],if b>a then I use the reverse method so i can get the same array I'd get if b<a, the problem with my code I think is the if else statement.I tried to write it where if b>a, reverse the array,return a range array then sum the values in the range array and return a single value.if b<a then it'd do the same thing without reversing
``````
function sumAll(arr) {
j=arr[0];
k=arr[1];
var targetLength = (k-j)+1;
var a = Array(targetLength);
var b = Array.apply(null,a);
var d = c.reverse();
if(j>k){
return d.reduce(function(x,y){
return x+y;});
}
else if(j<k){
return c.reduce(function(x,y){
return x+y;
});
}

}
sumAll([5, 10]);``````
Ayush Mahajan
@ay2306
Jun 30 2017 06:10
Can someone tell me if code is legal or not
`if(min==sec==hr==0){//some code}`
Ogundele Olumide
@Lumexralph
Jun 30 2017 06:10
@surferpilgrim what should your function do exactly?
@ay2306 it legal, just know the association
@ay2306 it's left -to-right
Ayush Mahajan
@ay2306
Jun 30 2017 06:13
@Lumexralph left-to-right mean?
Ogundele Olumide
@Lumexralph
Jun 30 2017 06:14
@ay2306 `min` will be compared to `sec`, the result of both will be compared to `hr` then finally compared to `0`, you would end up comparing `true/false` to `0`
Ayush Mahajan
@ay2306
Jun 30 2017 06:15
@Lumexralph Ohhh... thanks... so I should not use it... lol
CamperBot
@camperbot
Jun 30 2017 06:15
ay2306 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 2009 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 30 2017 06:15
@ay2306 if you know what you want to do, you can but if you don't, then don't sweat it
surferpilgrim
@surferpilgrim
Jun 30 2017 06:16
@Lumexralph create a range array, then sum that range array
Bennett Elder
@bennett-elder
Jun 30 2017 06:16
That much together would make it more difficult to read than necessary
Ayush Mahajan
@ay2306
Jun 30 2017 06:17
@Lumexralph No worries bro, I found an alternative to what I wanted to do
`if((min == hr)&&(sec==0)&&(min==0))`
Ogundele Olumide
@Lumexralph
Jun 30 2017 06:17
@surferpilgrim is it saying you create the array or just some the values in the range inclusive or exclusive?
@bennett-elder I agree
@ay2306 cool
surferpilgrim
@surferpilgrim
Jun 30 2017 06:18
@Lumexralph I'm working on the 1st intermediate algorithim challenge
@Lumexralph I don't understand what you mean by inclusive and exclusive
Ogundele Olumide
@Lumexralph
Jun 30 2017 06:19
@surferpilgrim should it include 5 and 10 ? or not
Long Nguyen
@longnt80
Jun 30 2017 06:20
hey guys, in this website car comparison feature, the data is loaded from a json file. Is there any way to get that json file?
https://www.mazda3.ca/en/sedan/honda
surferpilgrim
@surferpilgrim
Jun 30 2017 06:21
@Lumexralph it should
Ogundele Olumide
@Lumexralph
Jun 30 2017 06:21
@longnt80 sure, if you can get the URL the data is loaded from
@surferpilgrim you can use a loop and a variable to accumulate the result of adding the values
Long Nguyen
@longnt80
Jun 30 2017 06:22
@Lumexralph I viewed the source, it only has `\$.get('json/data.json', function (jsonData)`
try pasting `https://www.mazda3.ca/json/data.json` but nothing
surferpilgrim
@surferpilgrim
Jun 30 2017 06:23
@Lumexralph that part works, the problem is when you have an array like [10,5]
Ogundele Olumide
@Lumexralph
Jun 30 2017 06:24
@surferpilgrim then it's safe to always sort the array in ascending order
Maks Ushakov
@maks-ushakov
Jun 30 2017 06:24
@longnt80
https://www.mazda3.ca/en/sedan/json/data.json
try this. And maybe some anty CORS
Long Nguyen
@longnt80
Jun 30 2017 06:25
@maks-ushakov thanks
CamperBot
@camperbot
Jun 30 2017 06:25
longnt80 sends brownie points to @maks-ushakov :sparkles: :thumbsup: :sparkles:
surferpilgrim
@surferpilgrim
Jun 30 2017 06:25
@Lumexralph that's what my if statement was suppose to do, so when there is an array like [10,5] the if statement would take the reverse of that statement then collect its sum
Ogundele Olumide
@Lumexralph
Jun 30 2017 06:26
@longnt80 then I don't know how that will happen, it's on the server and the author of the site created the data I think
Maks Ushakov
@maks-ushakov
Jun 30 2017 06:26
i use dev tools network tab and XHR filter to find the link
ddr901
@ddr901
Jun 30 2017 06:29
hi guys
Ogundele Olumide
@Lumexralph
Jun 30 2017 06:30
@surferpilgrim you got so many verbose stuffs there, i'm sorry I have to go, running late for work but if you can first sort the array in ascending order, get a variable initialized to 0, use a for loop with starting index at the first element in the array, condition will be the`index <= second element in the array` to include the last element, then `i++` then you simply do `variable += index;` then return the variable outside the loop, that should give you the sum in the range if I don't miss anything out
later guys :wave:
ddr901
@ddr901
Jun 30 2017 06:31
anyone knows how to finished <Word Blanks>
J-Mag Guthrie
@baseballpoetess
Jun 30 2017 06:33
Yes
I have a tougher question. is there some way to test for vowelness or do I have to come up with one?
kumquatfelafel
@kumquatfelafel
Jun 30 2017 06:36
@baseballpoetess there isn't a "vowel" special character in regex if that's what you mean??
J-Mag Guthrie
@baseballpoetess
Jun 30 2017 06:37
I don't know if regex would help me even.
poromore
@poromore
Jun 30 2017 06:38
hello, I'm having trouble learning what the "this" keyword exactly does in constructor functions. can someone explain to me what it does and what it means in the simplest way possible?? im a 15 year old with a vocabulary that is not as advanced as it should be.
J-Mag Guthrie
@baseballpoetess
Jun 30 2017 06:38
i didn't know js had constructors.
that seems more a java thing.
Gulsvi
@gulsvi
Jun 30 2017 06:39
Yes, but maybe defined differently than in Java: https://www.freecodecamp.com/challenges/make-a-person
Glen Westbrook
@glynnw
Jun 30 2017 06:39
Yes it has constructors with the new class syntax
poromore
@poromore
Jun 30 2017 06:40
im on the object oriented and functional programming section of freecodecamp
J-Mag Guthrie
@baseballpoetess
Jun 30 2017 06:40
ooo that's scary.
Glen Westbrook
@glynnw
Jun 30 2017 06:40
It is basically a bolt on over the prototypal inheritance
poromore
@poromore
Jun 30 2017 06:41
ive searched and watched many videos explaining the "this" keyword in constructor functions and none of them have striked my brain with any sort of helpful information.
Gulsvi
@gulsvi
Jun 30 2017 06:42
I always think of `this` as referring to the current context of what you are using
but I barely use constructors and with ES6 arrow functions, don't use `this` anymore at all
poromore
@poromore
Jun 30 2017 06:43
damn
KinderPreet Singh
@kindercappy
Jun 30 2017 06:49
Wikipedia Viewer challenge. Please check it out. Feedback appreciated.
https://codepen.io/kindercappy/full/weymvN/
Pieter Stokkink
@forkerino
Jun 30 2017 06:50
@poromore inside the constructor function, `this` refers to the object created when the constructor is called with `new`
poromore
@poromore
Jun 30 2017 06:53
thanks! @forkerino
CamperBot
@camperbot
Jun 30 2017 06:53
poromore sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2793 | @forkerino |http://www.freecodecamp.com/forkerino
Nitin
@thenm
Jun 30 2017 06:54
``````var message = '';
var students = [
{
name: 'Nitin',
track: ['Js', 'HTML', 'CSS'],
points: 9,
achievement: 3
},
{
name: 'Vaibhav',
track: ['Vue', 'HTML', 'CSS'],
points: 8,
achievement: 4
},
{
name: 'Kishore',
track: ['Vue', 'Angular', 'CSS'],
points: 10,
achievement: 5
},
{
name: 'Abhishek',
track: ['Node', 'Vue', 'Angular'],
points: 10,
achievement: 5
},
{
name: 'Ranjit',
track: ['Node', 'Riot', 'CSS'],
points: 9,
achievement: 4
}
];

function print(message){
document.getElementById('page').innerHTML = message;
}

for(var i = 0; i < students.length; i++){
message = "<p>"+ students[i].name + "</p>";
message += message
print(message);
}``````
I want to print the students name to document. I simply get Ranjit printed twice. What I am doing wrong?
Glen Westbrook
@glynnw
Jun 30 2017 06:55
You can edit your message. Also the ``` has to be on a new line. @thenm
Nitin
@thenm
Jun 30 2017 06:56
@glynnw ok
Vivek Ranjan
@vivekranjan92
Jun 30 2017 06:57

Hi, I am making a progressive web app and for that i have visited the link below:-

https://engineering.musefind.com/build-your-first-progressive-web-app-with-react-8e1449c575cd

But while doing "getting set up" when i run this command in terminal it says "npm ERR! not ok code 0" can some body please help me. How do I correct it to make my first PWA.

Glen Westbrook
@glynnw
Jun 30 2017 07:00
@vivekranjan92 Are you use homebrew to install node and npm?
Pieter Stokkink
@forkerino
Jun 30 2017 07:00
@vivekranjan92 which command? npm install ... ?
Ronald T. Casili
@nvlled
Jun 30 2017 07:00
@thenm remove `message += message`
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:00
@forkerino npm install -g create-react-app
create-react-app pwa-experiment
Pieter Stokkink
@forkerino
Jun 30 2017 07:00
@vivekranjan92 those are two commands
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:00
this is the command i am running @forkerino
Glen Westbrook
@glynnw
Jun 30 2017 07:01
@vivekranjan92 Sounds like the issue is trying to install globally
Pieter Stokkink
@forkerino
Jun 30 2017 07:01
@vivekranjan92 which one gives the error? You should run them one by one
Sweet Coding :)
@SweetCodingInc
Jun 30 2017 07:01

@thenm You're overwriting the innerHTML of #page. It is writing the things to your page but it happens so fast that you only see the last one.

``````function print(message){
document.getElementById('page').innerHTML += message;
}``````

Notice it's `+= message`

And the reason it is shown twice is becuase you have `message += message`. Remove that you will see the name once

Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:01
@forkerino yeah but i am running first command first and it is saying npm ERR! not ok code 0
@forkerino
Pieter Stokkink
@forkerino
Jun 30 2017 07:01
ok
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:02
I have tried to run them onw by one but after running the first command I am getting the above mentioned error
Glen Westbrook
@glynnw
Jun 30 2017 07:02
@vivekranjan92 Can you tell me your OS?
Nitin
@thenm
Jun 30 2017 07:02
@SweetCodingInc let me give a try :smile:
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:02
@glynnw so how should i solve this?
Pieter Stokkink
@forkerino
Jun 30 2017 07:03
@vivekranjan92 what version of npm do you have installed? Which Operating System?
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:03
@glynnw its ubuntu 14.04
Sweet Coding :)
@SweetCodingInc
Jun 30 2017 07:03
@thenm
``````function print(message) {
document.getElementById("page").innerHTML += message;
}

function begin() {
for (var i = 0; i < students.length; i++) {
message = "<p>" + students[i].name + "</p>";
print(message);
}
}``````
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:03
@forkerino
14.04
Glen Westbrook
@glynnw
Jun 30 2017 07:03
@vivekranjan92 you can use sudo infront of it but I feel like that isn't a full solution
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:04
hmnn
Glen Westbrook
@glynnw
Jun 30 2017 07:05
IDK honestly with Ubuntu. I'm not on that particular distro.
Nitin
@thenm
Jun 30 2017 07:05
@SweetCodingInc get only the last student name printed
http://jsbin.com/jiguvobusu/edit?html,js,output
Pieter Stokkink
@forkerino
Jun 30 2017 07:06
@vivekranjan92 can you type `npm -v`?
Glen Westbrook
@glynnw
Jun 30 2017 07:06
I have my own npm setup to use a different directory than default for global installs so that I don't have to use sudo @vivekranjan92
Sweet Coding :)
@SweetCodingInc
Jun 30 2017 07:06

@thenm This line

``document.getElementById('page').innerHTML = message;``

should be

``document.getElementById('page').innerHTML += message;``
@vivekranjan92 : Are you behind proxy?
Pieter Stokkink
@forkerino
Jun 30 2017 07:07
@glynnw ah, that might be it. I'm on windows and it never complained about -g...
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:07
@SweetCodingInc no
Sweet Coding :)
@SweetCodingInc
Jun 30 2017 07:07
`node ok code 0` error comes up when the npm registry is unreachable
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:07
@forkerino wait a sec i am running the 1st command with SUDO
Pieter Stokkink
@forkerino
Jun 30 2017 07:07
:+1:
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:07
@glynnw trying with sudo
Sweet Coding :)
@SweetCodingInc
Jun 30 2017 07:08
@vivekranjan92 : If sudo doesn't work, can you run this command `npm ping` ?
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:08
when i run the command with sudo i get this
Glen Westbrook
@glynnw
Jun 30 2017 07:09
Looks like it worked to me
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:09
@SweetCodingInc yes i will
Bennett Elder
@bennett-elder
Jun 30 2017 07:09
@poromore I'd try going through the ydkjs books from the beginning, over and over until it clicks
Sweet Coding :)
@SweetCodingInc
Jun 30 2017 07:09
@vivekranjan92 : You got it done correctly this time
Nitin
@thenm
Jun 30 2017 07:09
@SweetCodingInc Thanks...Yeah it worked thank for helping but is there a way to keep print function as it is and pass the whole html as message parameter which is to be printed?
CamperBot
@camperbot
Jun 30 2017 07:09
thenm sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:10
really?? is it working now?? so can i run further command now?? @SweetCodingInc
Pieter Stokkink
@forkerino
Jun 30 2017 07:10
@vivekranjan92 looking good!
Sweet Coding :)
@SweetCodingInc
Jun 30 2017 07:11
@thenm Yes... There is... Just append your message with new content and call print function outside of for loop, like this
``````function print(message){
document.getElementById('page').innerHTML = message;
}

for(var i = 0; i < students.length; i++){
message += "<p>"+ students[i].name + "</p>";
}

print(message);``````
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:11
thanks a lot for your support :) :clap: @forkerino @SweetCodingInc @glynnw
CamperBot
@camperbot
Jun 30 2017 07:11
vivekranjan92 sends brownie points to @forkerino and @sweetcodinginc and @glynnw :sparkles: :thumbsup: :sparkles:
:star2: 2794 | @forkerino |http://www.freecodecamp.com/forkerino
Sweet Coding :)
@SweetCodingInc
Jun 30 2017 07:11
@vivekranjan92 Yes. You are all set :+1:
Vivek Ranjan
@vivekranjan92
Jun 30 2017 07:11
@SweetCodingInc ok thanks a ton
CamperBot
@camperbot
Jun 30 2017 07:11
vivekranjan92 sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:warning: vivekranjan92 already gave sweetcodinginc points
@csikos3d
Jun 30 2017 07:12
hi, I am at the Confirm the Ending challenge end I use prety simple code to solve and its work properly(returning with the right values in any given cases) but pretty sure there is some misunderstanding on my side cuz fcc not let me pass:

Â´Â´Â´
function confirmEnding(str, target) {

var strEnd = str.substr(-1,1);

``````if(strEnd == target){
return "True";

}``````

return "False";
}

confirmEnding("Bastian", "n");
Â´Â´Â´

Sweet Coding :)
@SweetCodingInc
Jun 30 2017 07:13
@csikos3d You're almost there... But you need to take as many characters from the end of the string as target.length

so your

``var strEnd = str.substr(-1,1);``

should really be

``var strEnd = str.substr(-target.length);``
@csikos3d
Jun 30 2017 07:14
@SweetCodingInc thank You I was not sure if it s important but maybe I missunderstud the instruction, thanks :-)
CamperBot
@camperbot
Jun 30 2017 07:14
csikos3d sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
Nitin
@thenm
Jun 30 2017 07:14
@SweetCodingInc Thanks a lot Have great day :+1:
Sweet Coding :)
@SweetCodingInc
Jun 30 2017 07:16
@csikos3d @thenm :+1:
@csikos3d Here is a simpler alternative to your code
``````function confirmEnding(str, target) {
return target === str.substr(-target.length);
}

confirmEnding("Bastian", "astian");``````
You don't need to store everything in a variable. In the beginning, sure. For understanding. But you will have to move to making code more concise sooner or later.
@csikos3d
Jun 30 2017 07:21
@SweetCodingInc thanks it s looks great :-) but I am not sure about Â´Â´Â´(-target.lenght)Â´Â´Â´, what that eventually does? I never saw this before :-(
CamperBot
@camperbot
Jun 30 2017 07:21
csikos3d sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:warning: csikos3d already gave sweetcodinginc points
Sweet Coding :)
@SweetCodingInc
Jun 30 2017 07:22
@csikos3d : It will take `target.length` which is a number. And you pass that number with - sign as a parameter to `.substr`
Dan Couper
@DanCouper
Jun 30 2017 07:23
If you give a single negative number to slice, it starts the slice from that number backwards from the end to the end. `"Hello".slice(-2)` is `lo`
Sweet Coding :)
@SweetCodingInc
Jun 30 2017 07:23
so `.substr` will take that many number of characters from the end of the string.
such that
``````"AdamCS".substr(-1) // S
@csikos3d
Jun 30 2017 07:24
oh, I am pretty sure in fcc i did not meat with slice till now but thanks I will check that out @DanCouper @SweetCodingInc
CamperBot
@camperbot
Jun 30 2017 07:24
csikos3d sends brownie points to @dancouper and @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:warning: csikos3d already gave sweetcodinginc points
Kamal
@kpbro
Jun 30 2017 07:58
Thomas
@sjurs1
Jun 30 2017 08:04
@kpbro For starters val isn't defined in your tweet.click-function, it's out of scope from your json call
Kamal
@kpbro
Jun 30 2017 08:05
@sjurs1 so i have to change location of val.content
inside function
Ccs99817
@ccs99817
Jun 30 2017 08:08
https://codepen.io/ccs99817/pen/MoQrVG?editors=0010
The two variables which are geoLatitude and geoLogitude does not change. They remains as default value. WHY??!! =^=;
J-Mag Guthrie
@baseballpoetess
Jun 30 2017 08:12
probably because you don' t mov e
Sweet Coding :)
@SweetCodingInc
Jun 30 2017 08:13
@ccs99817 I forked and modified your pen and made some changes.. take a look at line #19 and #72
You need to understand async nature of js :)
alpox
@alpox
Jun 30 2017 08:14
@ccs99817 that happens when you try to use the variables synchronously but the request for the geolocation responses asynchronous - this means you run the code which uses the variables BEFORE the new values even arrived
Ccs99817
@ccs99817
Jun 30 2017 08:16
@alpox How can I get it fixed? I have tried many methods
I used the callback, but it doesn't work. Possibly, I used it wrongly.
alpox
@alpox
Jun 30 2017 08:19
You will have to call your other methods which make use of the values inside of the callback
Ccs99817
@ccs99817
Jun 30 2017 08:25

@alpox

``````function getLocationAndCurrentTime(callback, callback) {
...
callback();
callback();
}``````

I thought I need to do this == haha
THX

CamperBot
@camperbot
Jun 30 2017 08:25
ccs99817 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:warning: ccs99817 already gave alpox points
Ccs99817
@ccs99817
Jun 30 2017 08:26
CamperBot
@camperbot
Jun 30 2017 08:26
ccs99817 sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
Thomas
@sjurs1
Jun 30 2017 08:36
Which JS editor should I use? Atom?
Pieter Stokkink
@forkerino
Jun 30 2017 08:37
@sjurs1 whichever one you enjoy using.
Dan Couper
@DanCouper
Jun 30 2017 08:37
Any one you want will do, Atom and VSCode have the most traction at the minute
Thomas
@sjurs1
Jun 30 2017 08:38
Guess I'll just go with atom then
J-Mag Guthrie
@baseballpoetess
Jun 30 2017 08:52
hi
Where do you set the variable for the minutes, I would look at that.
(I'm still back on "fear no letter" so i may not be much help)
Kshitijaa Jaglan
@KshitijaaJaglan
Jun 30 2017 09:02
Can someone tell me whats wrong with this code in the challenge
``````// Setup
var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
if(myObj.hasOwnProperty(checkObj)){
return myObj.checkObj;
}
else{

return "Change Me!";
}

// Test your code by modifying these values
alpox
@alpox
Jun 30 2017 09:05
@KshitijaaJaglan You use the variable `checkObj` as propertyname - but that is the name of your function
Kshitijaa Jaglan
@KshitijaaJaglan
Jun 30 2017 09:07
@alpox so what should I write as the propertyname?
alpox
@alpox
Jun 30 2017 09:07
@KshitijaaJaglan Also, if you have a variable with which you want to access a key of an object, you need bracket syntax - dot syntax only works for exact matches.
``````var obj = {
property: "foo",
};

console.log(myObj.property); // Logs "foo"
console.log(myObj[property]); // Logs "bar"``````
@KshitijaaJaglan The propertyname is given to you as the first parameter to your function. The name is quite descriptive
Kshitijaa Jaglan
@KshitijaaJaglan
Jun 30 2017 09:10
thanks a lot @alpox I got it!
CamperBot
@camperbot
Jun 30 2017 09:10
kshitijaajaglan sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1184 | @alpox |http://www.freecodecamp.com/alpox
alpox
@alpox
Jun 30 2017 09:10
@KshitijaaJaglan :thumbsup:
surferpilgrim
@surferpilgrim
Jun 30 2017 09:12
I'm doing the sumAll algorithm challenge from freecodecamp, for the first part I'm just trying to get a range array, the problem I'm having is I can't pass in a value like [4,1], because it says invalid array length. does anyone know what I can google ? here's my code:
// jshint esversion:6
``````function sumAll(arr) {
j=arr[0];
k=arr[1];
var sumArray= Array
.apply(null,Array((k-j)+1))

return arr;

}``````
wonder
@wonder2991
Jun 30 2017 09:12
i don't think the last return will be read @KshitijaaJaglan
@surferpilgrim find the min and max first
alpox
@alpox
Jun 30 2017 09:14
@surferpilgrim `k-j` can be negative if k is smaller than j
PaweÅ‚ TargoÅ„ski
@paweltar
Jun 30 2017 09:29

hello, I think I need help with this issue. I'm doing Steamroller challenge - code outputted by my function seems to be the same as expected by test cases however tests doesn't pass. You can verify this in your console

``````function steamrollArray(arr) {
var flattened = arr.reduce(function(a, b) {
return a.concat(b);
}, []);
var outArr = [];
for (var i = 0; i < flattened.length; i++) {
if (!Array.isArray(flattened[i])) {
outArr.push(flattened[i]);
} else {
// console.log(flattened);
steamrollArray(flattened);
return;
}
}
console.log(outArr);
return outArr;
}
steamrollArray([[["a"]], [["b"]]]);
// should return ["a", "b"].
steamrollArray([1, [2], [3, [[4]]]]);
// should return [1, 2, 3, 4].
steamrollArray([1, [], [3, [[4]]]]);
// should return [1, 3, 4].
steamrollArray([1, {}, [3, [[4]]]]);
// should return [1, {}, 3, 4]``````

Do you know where is my mistake here?

JHnnis
@JHnnis
Jun 30 2017 09:30

Hey guys what is the right syntax to add the "new album" here:

``````var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}

];

Â´Â´Â´

I tried this but it seems wrong:``````

var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}

{
"artist": "John Lennon",

];

Â´Â´Â´

``````var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}

{
"artist": "John Lennon",

];``````
*
Daniel Romero
@Ranacode
Jun 30 2017 09:31
``````const points = [
[4,56],
[5,1],
[9,5]
]

console.log(points.map( ( [ x ,  y ] ) =>  { x ,  y } ) );``````
I want to convert an array of numbers to an array of objects with destructuring and enhanced object literals from ES6, but it is returning me and array of undefined values, why isn't working?
Pieter Stokkink
@forkerino
Jun 30 2017 09:33
@paweltar I think the recursion goes wrong, because you just call the function but then afterwards return. So the recursive function returns something, but then undefined is returned.
I think if you just do `return steamrollArray(flattened)` it should work
You get the right values in the console, but the return value is not always what is in the console.
because you have another return there.
@JHnnis Elements in an array are separated by what?
PaweÅ‚ TargoÅ„ski
@paweltar
Jun 30 2017 09:35
yes @forkerino it works now! Thanks a lot!
CamperBot
@camperbot
Jun 30 2017 09:36
paweltar sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2795 | @forkerino |http://www.freecodecamp.com/forkerino
surferpilgrim
@surferpilgrim
Jun 30 2017 09:37
I'm trying to get the max of this array but all i get is a return of invalid array length
``````// jshint esversion:6
function sumAll(arr) {
j=arr[0];
k=arr[1];
var max = arr.reduce(function(a,b){ return Math.max(a,b);});

var min = arr.reduce(function(a,b){return Math.min(a,b);});

return max;

}

sumAll([4, 1]);``````
Pieter Stokkink
@forkerino
Jun 30 2017 09:37
@Ranacode you have to add an extra set of ( ) around the object, otherwise JS interprets it as a code block.
@surferpilgrim in your Array() call, you need to use max and min, not j and k
JHnnis
@JHnnis
Jun 30 2017 09:38
@forkerino with a comma or am I wrong?
Pieter Stokkink
@forkerino
Jun 30 2017 09:39
@JHnnis correct!
@JHnnis so the two albums are objects, but they are inside an array. They need a comma between them.
surferpilgrim
@surferpilgrim
Jun 30 2017 09:41
@forkerino when I was using the math method i specified arr, not j and k. I don't get what you mean
Menlam Choden
@menlam
Jun 30 2017 09:41

function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr.sort(function(a, b) {
return a - b;
});

for (var i = 0; i < arr.length; i++) {
if (arr[i] >= num)
return i;
}

}

getIndexToIns([2, 5, 10], 15);
whats wrong with my code

JHnnis
@JHnnis
Jun 30 2017 09:41
@forkerino oh wow, its the small things which makes the difference right? :D thanks man
CamperBot
@camperbot
Jun 30 2017 09:41
jhnnis sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2796 | @forkerino |http://www.freecodecamp.com/forkerino
zheng
@zhengzhp
Jun 30 2017 09:41

function sumAll(arr) {
let max = Math.max.apply(null,arr);
let min = Math.min.apply(null,arr);
let len = max-min+1;
return len%2===1?(max-1+min)(len-1)/2+max:(max+min)len/2;
}

sumAll([1, 4]);

```code```
Pieter Stokkink
@forkerino
Jun 30 2017 09:42
@surferpilgrim Array((k-j)+1) will still have a negative argument at some point. Use max and min instead of j and k
zheng
@zhengzhp
Jun 30 2017 09:42
``code``
Pieter Stokkink
@forkerino
Jun 30 2017 09:43
@menlam what if none of the numbers is bigger than num? What do you return?
zheng
@zhengzhp
Jun 30 2017 09:44
``````function sumAll(arr) {
let max = Math.max.apply(null,arr);
let min = Math.min.apply(null,arr);
let len = max-min+1;
return len%2===1?(max-1+min)*(len-1)/2+max:(max+min)*len/2;
}

sumAll([1, 4]);``````
Menlam Choden
@menlam
Jun 30 2017 09:44
@forkerino 0
Pieter Stokkink
@forkerino
Jun 30 2017 09:44
@menlam undefined.
Menlam Choden
@menlam
Jun 30 2017 09:45
first index
Pieter Stokkink
@forkerino
Jun 30 2017 09:45
@menlam no
@menlam because the if will never be true in that case
Menlam Choden
@menlam
Jun 30 2017 09:46
so what am I supposed to return.. i tried i+1
Jun 30 2017 09:53
a silly question
what do you name your functions to be used in `.reduce()` in the cases when you don't define them anonymously on the spot
`reduceFunctionFoo()`?
Pieter Stokkink
@forkerino
Jun 30 2017 09:54
@menlam the length of the array?
Pethaf
@Pethaf
Jun 30 2017 09:54
@forkerino I heard you got a job.
Jun 30 2017 09:54
`reductionFoo()`?
Pieter Stokkink
@forkerino
Jun 30 2017 09:54
@Pethaf indeed
Pethaf
@Pethaf
Jun 30 2017 09:54
What kind of job, and what did they hire you on?
AlBMyName
@IshmaRey-Hool
Jun 30 2017 09:55
Can I use the open Weather API for the weather machine project
Pethaf
@Pethaf
Jun 30 2017 09:55
I am curious how much of the FCC curriculum I should complete before starting job applications.
Stephen James
@sjames1958gm
Jun 30 2017 09:55
@IshmaRey-Hool If you are in codepen which is now https only it is difficult to use openweather as it is http only if you don't pay
Pieter Stokkink
@forkerino
Jun 30 2017 09:55
@Pethaf mostly frontend in the beginning, but small team so will get to know the backend quite well too. They hired me because I can code and learn quickly.
heroiczero
@heroiczero
Jun 30 2017 09:55
@IshmaRey-Hool use dark sky
AlBMyName
@IshmaRey-Hool
Jun 30 2017 09:56
@Pethaf Until the fist certificate
Pieter Stokkink
@forkerino
Jun 30 2017 09:56
@amatayamada you can name them whatever you want, however, if it is a descriptive name, that will help people reading your code tremendously.
AlBMyName
@IshmaRey-Hool
Jun 30 2017 09:56
thanks @sjames1958gm @heroiczero
CamperBot
@camperbot
Jun 30 2017 09:56
ishmarey-hool sends brownie points to @sjames1958gm and @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1438 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 7960 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Pethaf
@Pethaf
Jun 30 2017 09:56
@IshmaRey-Hool So I have done the calculator, and the pomodoro timer.
AlBMyName
@IshmaRey-Hool
Jun 30 2017 09:57
Pethaf
@Pethaf
Jun 30 2017 09:57
I am working on the simon game at the moment. But the tic-tac-toe game, and particullarly the AI for that game looks like a massive challenge.
Pieter Stokkink
@forkerino
Jun 30 2017 09:57
@Pethaf I completed the frontend cert back in December and have been working on both backend and dataviz certs
but didn't finish the latter two
learned a lot that wasn't on the curriculum as well
Pethaf
@Pethaf
Jun 30 2017 09:58
I have some additional qualifications as well. Like an engineering degree from a university, and experience as a TA teaching programming. Plus some experience as a sys admin.
Menlam Choden
@menlam
Jun 30 2017 09:58
@forkerino why, sorry new, so don't understand
An-mode
@an-mode
Jun 30 2017 09:59
hello world ! I was trying to solve the mutations problem where i need to check if all the characters in the first string of an array are a part of the first string in the array.
wonder
@wonder2991
Jun 30 2017 09:59
start applying now. @Pethaf
An-mode
@an-mode
Jun 30 2017 10:00
I wanted to do this without using the indexof function
Pethaf
@Pethaf
Jun 30 2017 10:00
@an-mode Isn't the mutations challenge to check if all characters in the first string are present in the second string?
Pieter Stokkink
@forkerino
Jun 30 2017 10:00
@menlam because if none of the numbers in the array is bigger, you put it at the end. The last index is arr.length - 1, so it would come 1 after that.
An-mode
@an-mode
Jun 30 2017 10:01
@Pethaf second in first*
Pethaf
@Pethaf
Jun 30 2017 10:01
You could always hardcode the indexOf function.
Pieter Stokkink
@forkerino
Jun 30 2017 10:01
or use .includes() :trollface:
Alan Alickovic
@alan2207
Jun 30 2017 10:01
@forkerino have you built any of the fullstack projects within backend certification?
Pieter Stokkink
@forkerino
Jun 30 2017 10:02
@alan2207 I built three of them
But haven't done a lot since deciding to learn React/Redux
Pethaf
@Pethaf
Jun 30 2017 10:02
`for(let j=0; j!=str.length;j++) { if str[j] === target return j} } return -1;`
Alan Alickovic
@alan2207
Jun 30 2017 10:02
@forkerino did you use react on frontend?
Pieter Stokkink
@forkerino
Jun 30 2017 10:02
@alan2207 no, I didn't know react when I did frontend
Menlam Choden
@menlam
Jun 30 2017 10:03
@forkerino got it now, thanks :)
CamperBot
@camperbot
Jun 30 2017 10:03
menlam sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2797 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jun 30 2017 10:03
:+1:
Alan Alickovic
@alan2207
Jun 30 2017 10:03
@forkerino i am doing it using react, but it is much easier with any of the templating engines
Pethaf
@Pethaf
Jun 30 2017 10:04
I am not using any templating engines for the front-end challenges either. I learned a lot of CSS tricks that way.
An-mode
@an-mode
Jun 30 2017 10:04
@Pethaf I was trying to approach it by splitting two strings and running two for loops comparing each characted of the first with the second
could that work too?
Pethaf
@Pethaf
Jun 30 2017 10:04
Yes. Probably. That is basically unrolling the indexOf function. (barring that the javascript interpreter might have some hashing algorithm that makes the indexOf faster.).
An-mode
@an-mode
Jun 30 2017 10:06
sure.. I was able to execute it with the indexof, but I just like trying it without a function too. Let me chare my code because I am pretty sure I am messing the break and placement of my return

for (var i=0;i<splitArr2.length;i++)
{
for (var j=0;j<splitArr1.length;j++)
{
if (splitArr1[j]==splitArr2[i] || splitArr1[j]==splitArr2[i].toUpperCase())
{
break;
}
continue;
}

``````  return false;
}``````

return true;

Alan Alickovic
@alan2207
Jun 30 2017 10:07
@forkerino i mean frontend of the fullstack projects
Stephen James
@sjames1958gm
Jun 30 2017 10:07
@an-mode You are always going to return false. Because that is the only statement that you have after the inner for loop
Pieter Stokkink
@forkerino
Jun 30 2017 10:08
@alan2207 ah, ok. No, I learned react after doing some of the backend projects. I then decided to first learn react before going on with the backend projects.
An-mode
@an-mode
Jun 30 2017 10:08
I understand.. Could you help me understand what to change
Stephen James
@sjames1958gm
Jun 30 2017 10:09
@an-mode You need some variable that you define outside the inner loop that you change in the loop if you find a match.
Then if that variable is not changed you return false.
``````var found = false;
for () {
if match found = true;
}
if !found return false``````
An-mode
@an-mode
Jun 30 2017 10:11
@sjames1958gm I tried a flag but was unable to sort the issue.. Let me give it another go before i ask for guidance.. Thanks !
CamperBot
@camperbot
Jun 30 2017 10:11
an-mode sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7961 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm