These are chat archives for FreeCodeCamp/HelpJavaScript

13th
Mar 2017
Jason Luboff
@JLuboff
Mar 13 2017 00:00
@the0ffh I was reading just the left side of the operator instead of both it and the right :joy:
Saboor Malik
@MathematicsCoding
Mar 13 2017 00:00
Sigh I dont get this
var ourArray = [3,2,1];
ourArray[0] = 1; // equals [1,2,1]
the0ffh
@the0ffh
Mar 13 2017 00:00
@JLuboff I'm doing the very same way too often :D
@MathematicsCoding what happens when you change ourArray[0] to ourArray[1]?
Jason Luboff
@JLuboff
Mar 13 2017 00:01
@MathematicsCoding With arrays, you can reassign the value of an index (index being the spot in the array) by specifing the array name, the index number (inside of brackets) and then using the assignment operator = to assign the new value on the right
Saboor Malik
@MathematicsCoding
Mar 13 2017 00:01
Nothing changed
It remain [1,2.3]
NewGismo
@NewGismo
Mar 13 2017 00:02
Hi guys, could someone explain me the difference between/\d/ and /\d+/
the0ffh
@the0ffh
Mar 13 2017 00:02
type return ourArray[0]; after ourArray[1] and type here what do you see in the output frame on the left
hold on... no! wait!
Saboor Malik
@MathematicsCoding
Mar 13 2017 00:03
...
the0ffh
@the0ffh
Mar 13 2017 00:03
return ourArray; after ourArray[1]
then give me the output
Saboor Malik
@MathematicsCoding
Mar 13 2017 00:04
lol it said "var ourArray = [3,2,1];
ourArray[0] = 1; // equals [1,2,1]"
Strange
Illegal return startement
the0ffh
@the0ffh
Mar 13 2017 00:04
dude... // is just a comment
Saboor Malik
@MathematicsCoding
Mar 13 2017 00:04
before the comment and after the ourarray?
the0ffh
@the0ffh
Mar 13 2017 00:05
@MathematicsCoding let's do it the other way round
Saboor Malik
@MathematicsCoding
Mar 13 2017 00:05
// Example
var ourArray = [1,2,3];
ourArray[1] = 3; return ourArray;
the0ffh
@the0ffh
Mar 13 2017 00:05
@MathematicsCoding what's the output?
Saboor Malik
@MathematicsCoding
Mar 13 2017 00:06
It said "Illegal return statement"
NewGismo
@NewGismo
Mar 13 2017 00:06
Appending a plus sign (+) after the selector, e.g. /\d+/g, allows this regular expression to match one or more digits.
I don't understand what they mean with "match one or more digits".
the0ffh
@the0ffh
Mar 13 2017 00:06
place return ourArray instead the return at the end of your code
@NewGismo use this as an input:
abc12345
with and without + modifier
@NewGismo and compare the results
Saboor Malik
@MathematicsCoding
Mar 13 2017 00:08
// Example
var ourArray = [1,2,3];
return ourArray[1] =3; // ourArray now equals [1,3,3].
Alex G
@glazey132
Mar 13 2017 00:08
can someone help with seek and destroy?
NewGismo
@NewGismo
Mar 13 2017 00:08
@the0ffh thx I'll try
CamperBot
@camperbot
Mar 13 2017 00:08
newgismo sends brownie points to @the0ffh :sparkles: :thumbsup: :sparkles:
:cookie: 296 | @the0ffh |http://www.freecodecamp.com/the0ffh
HeebieGeeBee
@HeebieGeeBee
Mar 13 2017 00:10
@glazey132 whats the problem?
Jason Luboff
@JLuboff
Mar 13 2017 00:10
@HeebieGeeBee You're the problem!
HeebieGeeBee
@HeebieGeeBee
Mar 13 2017 00:10
@JLuboff yo
well that goes without saying
Jason Luboff
@JLuboff
Mar 13 2017 00:10
:joy:
Saboor Malik
@MathematicsCoding
Mar 13 2017 00:10
@the0ffh What did you want me to do...
Jason Luboff
@JLuboff
Mar 13 2017 00:10
Whats happening
HeebieGeeBee
@HeebieGeeBee
Mar 13 2017 00:10
not a lot
whats happening with you?
Alex G
@glazey132
Mar 13 2017 00:11

y. It's anonymous and only takes 5 minutes.
Seek and Destroy
You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.

Remember to use Read-Search-Ask if you get stuck. Write your own code.

Here are some helpful links:

Arguments object
Array.prototype.filter()
Run tests (ctrl + enter)
Reset Help Bug

[1,2,3,1,2,3]

destroyer([1, 2, 3, 1, 2, 3], 2, 3) should return [1, 1].
destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) should return [1, 5, 1].
destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return [1].
destroyer([2, 3, 2, 3], 2, 3) should return [].
destroyer(["tree", "hamburger", 53], "tree", 53) should return ["hamburger"].

1

2
function destroyer(arr) {
3
var args = arr.slice.call(arguments);
4
for (var i = 0; i < arr.length; i++){
5
for ( var j = 0; j < args.length[i]; j++){
6
if (arr[i] === args[j]) {
7
arr = arr.filter(i);
8
}
9
}
10
}
11
return arr;
12
//return arr.filter();
13
}
14

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

sorry hold on
Jason Luboff
@JLuboff
Mar 13 2017 00:11
@HeebieGeeBee Working on this stupid simon game
Alex G
@glazey132
Mar 13 2017 00:11

function destroyer(arr) {
var args = arr.slice.call(arguments);
for (var i = 0; i < arr.length; i++){
for ( var j = 0; j < args.length[i]; j++){
if (arr[i] === args[j]) {
arr = arr.filter(i);
}
}
}
return arr;
//return arr.filter();
}

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

my bad yall
HeebieGeeBee
@HeebieGeeBee
Mar 13 2017 00:12
@JLuboff oh ok, fun?
Jason Luboff
@JLuboff
Mar 13 2017 00:12
Was watching some videos on Angular 2 last night/today. I want to learn that here soon. Fun? No..not really :D
Saboor Malik
@MathematicsCoding
Mar 13 2017 00:12
@JLuboff when you are done and give me your code for that :)
Kidding
Jason Luboff
@JLuboff
Mar 13 2017 00:12
@MathematicsCoding I was actually over thinking it....Got my logic going now
HeebieGeeBee
@HeebieGeeBee
Mar 13 2017 00:13
@glazey132 filter wont work like that
Alex G
@glazey132
Mar 13 2017 00:13
would something like delete work? @HeebieGeeBee
or how should I change that to make filter work
HeebieGeeBee
@HeebieGeeBee
Mar 13 2017 00:14
well it takesa callback function that has to return true or false
NewGismo
@NewGismo
Mar 13 2017 00:14
@the0ffh well without + he counts all the numbers, so the output is 5
with + the output is 1, does that mean he counts how many strings of numbers exists without counting the the single numbers of each string?
HeebieGeeBee
@HeebieGeeBee
Mar 13 2017 00:14
@glazey132 you need to read up in the documentation how it works
Austin Wiggins
@austinwiggins
Mar 13 2017 00:16
Can someone please guide me thru the JS Profile Lookup lesson? I am having trouble understanding it...
HeebieGeeBee
@HeebieGeeBee
Mar 13 2017 00:16
@JLuboff whats special about angular 2?
NewGismo
@NewGismo
Mar 13 2017 00:16
@austinwiggins what exactly is your problem?
Jason Luboff
@JLuboff
Mar 13 2017 00:17
@HeebieGeeBee You cna create templates for pages that are super simple but quite powerful
HeebieGeeBee
@HeebieGeeBee
Mar 13 2017 00:17
oh ok cool
Austin Wiggins
@austinwiggins
Mar 13 2017 00:18
@NewGismo I just don't understand the for loops concept in doing this/how to do this...
Ken Haduch
@khaduch
Mar 13 2017 00:18
re: :point_up: March 12, 2017 9:50 AM @relentless-coder - I am currently not working in any programming language. My most recent jobs involved farming... But my past experience was most recently supporting a large CAD design tools suite, mostly implemented in Perl. (This was at AMD, until a layoff) I was writing Perl programs (scripts) for quite a few years. Before that, it was supporting another large CAD tool system written in C, and various related tools and utilities. Before that, I was doing some hardware design work at Digital Equipment Corp. So I'm trying to get more familiar with web development (although I've been doing different learning activities with a couple short contract jobs . So I'm trying to get to a point where I feel like I can do something web-related, but freeCodeCamp is kind of a stopping point in my learning - with a couple other Udemy course in progress, etc. I have been spending a lot of time hanging around the chat rooms helping, but trying to move along with some of the projects and get the first phase of this completed.
Juan Carlos Camacho Valderrama
@camachine
Mar 13 2017 00:18
Can anyone show me the where the code is wrong for the inputs of golfscore(4,4) in the following function:
function golfScore(par, strokes) {
// Only change code below this line
if (strokes == 1) {
return "Hole-in-one!";
} else if (strokes <= par -2) {
return "Eagle";
} else if (strokes = par -1) {
return "Birdie";
} else if (strokes = par) {
return "Par";
} else if (strokes = par +1) {
return "Bogey";
} else if (strokes = par +2) {
return "Double Bogey";
} else if (strokes >= par +3) {
return "Go Home!";
}
Jason Luboff
@JLuboff
Mar 13 2017 00:19
@HeebieGeeBee Ya you should check it out when you're bored
Juan Carlos Camacho Valderrama
@camachine
Mar 13 2017 00:19
it returns birdie for par or above...ulgh
Ken Haduch
@khaduch
Mar 13 2017 00:19
@camachine - the codes like this: strokes = par should have === instead. You are doing assignments in those statements with the single =
NewGismo
@NewGismo
Mar 13 2017 00:19
@austinwiggins you need to use your for loop so that your program will check the first part of you array, then move on and check the next one
Juan Carlos Camacho Valderrama
@camachine
Mar 13 2017 00:20
awesome thanks!
Austin Wiggins
@austinwiggins
Mar 13 2017 00:20
@NewGismo I know that, I just do not know how
HeebieGeeBee
@HeebieGeeBee
Mar 13 2017 00:20
@JLuboff cant reall yspend much time on coding at the moment
Jason Luboff
@JLuboff
Mar 13 2017 00:20
@HeebieGeeBee Real life getting you?
HeebieGeeBee
@HeebieGeeBee
Mar 13 2017 00:20
yeah
NewGismo
@NewGismo
Mar 13 2017 00:21
@austinwiggins for (i = 0; i < contacts.length; i++) {//here you need to write an "if" code}
Jason Luboff
@JLuboff
Mar 13 2017 00:21
@HeebieGeeBee Well you'll get back to it at some point
Austin Wiggins
@austinwiggins
Mar 13 2017 00:21
@NewGismo I will try... be right back to tell u how it works.
Juan Carlos Camacho Valderrama
@camachine
Mar 13 2017 00:21
@khaduch Thank you
CamperBot
@camperbot
Mar 13 2017 00:21
camachine sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2622 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Mar 13 2017 00:23
@camachine - you should take note that in the editor for the golf code problem ( and others) that if you have something like the strokes = par within an if statement, it will put a red :x: in the left hand column and indicate that there is an error if you hover over it, it has a message "Expected a conditional expression and instead saw an assignment" - that means something and you should get any errors or warnings cleared up if you see them.
Alex G
@glazey132
Mar 13 2017 00:25
for seek and destroy should the callback function look something like this?
return arr.filter(function(val) {
return !args.filter(val);
});
Pagnito
@Pagnito
Mar 13 2017 00:25
var array = [1, 12, 21, 2];
array.sort(function(a, b) {
return a - b;
});
what does a, b represtn here?
Stephen James
@sjames1958gm
Mar 13 2017 00:26
@Pagnito As the internal sort routine runs it needs to compare two values. These are a and b.
@glazey132 no. you need to determine if val is contained in args, not calling filter on it.
Austin Wiggins
@austinwiggins
Mar 13 2017 00:27
@NewGismo I can't figure out what to put in the if code
NewGismo
@NewGismo
Mar 13 2017 00:27
@Pagnito these are parameters, that could be every other name like function(firstName, lastName)
Pagnito
@Pagnito
Mar 13 2017 00:27
so at first would that be 1 and 12, then 12 and 21 then 21 and 2?
yeai know they r parameters im just a bit confused when theyr used here without callin the function
Alex G
@glazey132
Mar 13 2017 00:28
@sjames1958gm OK that makes sense. does it have to be within a return?
Paul Debevec
@PaulDebevec
Mar 13 2017 00:28

I'm trying to figure out the Escape Sequences in Strings - I have

var myStr = "FirstLine \n \SecondLine\ \r ThirdLine";

but I'm not passing this one: myStr should have encoded text with the proper escape sequences and no spacing.

Assistance would be amazing, thanks!

Jason Luboff
@JLuboff
Mar 13 2017 00:28
@PaulDebevec No spaces
NewGismo
@NewGismo
Mar 13 2017 00:29
@austinwiggins you need 2 if's
Stephen James
@sjames1958gm
Mar 13 2017 00:29
@glazey132 Not necessarily, but a small filter function will probably do that
Pagnito
@Pagnito
Mar 13 2017 00:29
@sjames1958gm so at first would that be 1 and 12, then 12 and 21 then 21 and 2?
Paul Debevec
@PaulDebevec
Mar 13 2017 00:29
@JLuboff Thanks!
CamperBot
@camperbot
Mar 13 2017 00:29
pauldebevec sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1113 | @jluboff |http://www.freecodecamp.com/jluboff
Stephen James
@sjames1958gm
Mar 13 2017 00:30
@Pagnito The order of comparisons are not defined, so not necesarrily
Austin Wiggins
@austinwiggins
Mar 13 2017 00:30
@NewGismo Well then I can't figure out what to put in either of them... I will research it a little :(
NewGismo
@NewGismo
Mar 13 2017 00:30
@austinwiggins if(...) { if(...){} }
In the first if you check for the firstName
If that first If condition is true you need to check in your second if condition for the existance of the property with .hasOwnProperty
Austin Wiggins
@austinwiggins
Mar 13 2017 00:30
I will try
Pagnito
@Pagnito
Mar 13 2017 00:31
@sjames1958gm but the a and b to take the values of the array elements?
Ken Haduch
@khaduch
Mar 13 2017 00:31
@Pagnito - the sort function runs through the array and compares sequential pairs of elements to determine the sort order. There is a default sort, and you can also specify your own sort function for other cases. The two arguments that you use could have any name, they always serve the same purpose.
Stephen James
@sjames1958gm
Mar 13 2017 00:31
@Pagnito Yes, a and b will be the values from the array as needed by the internal sort routine to determine the order of the elements
Pagnito
@Pagnito
Mar 13 2017 00:31
@sjames1958gm sweet thanks
CamperBot
@camperbot
Mar 13 2017 00:31
pagnito sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6144 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Pagnito
@Pagnito
Mar 13 2017 00:32
@khaduch thanks
CamperBot
@camperbot
Mar 13 2017 00:32
pagnito sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2623 | @khaduch |http://www.freecodecamp.com/khaduch
Austin Wiggins
@austinwiggins
Mar 13 2017 00:34
@NewGismo I am actually starting to understand now. I have three of the five statements corrected by now. Thank you so much for your help and for putting up with me :).
CamperBot
@camperbot
Mar 13 2017 00:34
austinwiggins sends brownie points to @newgismo :sparkles: :thumbsup: :sparkles:
:cookie: 225 | @newgismo |http://www.freecodecamp.com/newgismo
NewGismo
@NewGismo
Mar 13 2017 00:35
@austinwiggins you're welcome ;)
Tricia
@patricia07
Mar 13 2017 00:35
var myStr;
myStr = "This is the start." + "This is the end.";
is this right?
Mitch Lembke
@mlembke1
Mar 13 2017 00:35
Convert Celsius to Fahrenheit challenge is kicking my butt. anyone?
Jason Luboff
@JLuboff
Mar 13 2017 00:36
@patricia07 It could be, although you're missing a space between your period and "This"
@mlembke1 What do you have so far?
NewGismo
@NewGismo
Mar 13 2017 00:36
@mlembke1 where is the problem?
Mitch Lembke
@mlembke1
Mar 13 2017 00:38
@JLuboff I don't have anything currently. I've tried many things but I just cleared it to start over. I know how to take a screenshot but I don't know how to include it here in the chat
Jason Luboff
@JLuboff
Mar 13 2017 00:38
@mlembke1 Okay..well for starters...whats the equation (or they put it as algorithm) to convert celsius to fahrenheit
NewGismo
@NewGismo
Mar 13 2017 00:39
@mlembke1 you can put your code between your code
Mitch Lembke
@mlembke1
Mar 13 2017 00:39
@JLuboff ""
Joseph
@revisualize
Mar 13 2017 00:39

If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format: ..... PLEASE try with a small block of code before you try to make a bigger one.
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

Mitch Lembke
@mlembke1
Mar 13 2017 00:39
@JLuboff "The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32
Jason Luboff
@JLuboff
Mar 13 2017 00:39
@mlembke1 Ok, so write that out how you would think you would for javascript
Mitch Lembke
@mlembke1
Mar 13 2017 00:41
@JLuboff "var fahrenheit = 1.8(celsius) + 32" But i know thats wrong. I'm totally new to JavaScript :worried:
Jason Luboff
@JLuboff
Mar 13 2017 00:41
@mlembke1 You're close!!
@mlembke1 ditch the var, fahrenheit is already decalred before
@mlembke1 then we just need to include * for multiplication between celsius and 1.8
Sara
@skd726
Mar 13 2017 00:42
can anyone help me with the "stand in line" task? I'm completely lost as to what it's asking
Jason Luboff
@JLuboff
Mar 13 2017 00:43
@skd726 You need to use two array methods you recently learned about (push, pop, unshift, shift) revisit those challenges and determine which two to use
Austin Wiggins
@austinwiggins
Mar 13 2017 00:43
@NewGismo Got it. Thx again
CamperBot
@camperbot
Mar 13 2017 00:43
austinwiggins sends brownie points to @newgismo :sparkles: :thumbsup: :sparkles:
:warning: austinwiggins already gave newgismo points
jacob
@bjh2012
Mar 13 2017 00:43
@the0ffh I forgot to say thanks earlier, thanks
CamperBot
@camperbot
Mar 13 2017 00:43
bjh2012 sends brownie points to @the0ffh :sparkles: :thumbsup: :sparkles:
:cookie: 298 | @the0ffh |http://www.freecodecamp.com/the0ffh
NewGismo
@NewGismo
Mar 13 2017 00:44
@austinwiggins good job ;)
Sara
@skd726
Mar 13 2017 00:44
@JLuboff okay, I will try that, thanks
CamperBot
@camperbot
Mar 13 2017 00:44
skd726 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1114 | @jluboff |http://www.freecodecamp.com/jluboff
Mitch Lembke
@mlembke1
Mar 13 2017 00:45
@JLuboff Whoe! Thanks so much! I think it is working! Now I just have to switch the inputs. Thanks man!
CamperBot
@camperbot
Mar 13 2017 00:45
:star2: 1115 | @jluboff |http://www.freecodecamp.com/jluboff
mlembke1 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
Hernan Mendez
@hernanmendez
Mar 13 2017 00:47
Hey I don't get this Challenge, Is the Escape Sequences in Strings
can someone help me?
Alex G
@glazey132
Mar 13 2017 00:48
my code says not to use a function inside a loop when I try to use filter on seek destroy. can anyone explain how filter works? How can I filter out values from an array if I cant iterate through it with a for loop?
Sara
@skd726
Mar 13 2017 00:49
@JLuboff but am I changing testArr or nextInLine?
Jason Luboff
@JLuboff
Mar 13 2017 00:49
@skd726 Neither...you're changing arr
Alex G
@glazey132
Mar 13 2017 00:49

function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);
var destroyers = args.slice(1);

for (val = i; i < args.length; i++) {
for (val - j; j < destroyers.length; j++) {
if (destroyers(j) === args(i)) {
return args.filter(function(val) {
delete args[val];
});
}
}
}
}

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

Jason Luboff
@JLuboff
Mar 13 2017 00:49
@skd726 testArr is just a placeholder and nextInLine is your function name
Sara
@skd726
Mar 13 2017 00:50
@JLuboff alright, thanks
CamperBot
@camperbot
Mar 13 2017 00:50
skd726 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:warning: skd726 already gave jluboff points
Ken Haduch
@khaduch
Mar 13 2017 00:51
@hernanmendez - do you have code that you have tried, and can you post it?
Dan Couper
@DanCouper
Mar 13 2017 00:54
@glazey132 filter goes through an array element by element, and runs the function you give it: that function has to return true or false. So it needs to iterate over arr: that's the actual array you should be filtering. destroyers is the array of things to destroy, so get rid of the loops, and inside the filter function, you will want to loop over destroyers and check whether any of the values are or are not the same as the current value
Jarod Guthrie
@jarodguthrie
Mar 13 2017 00:54
Hi Guys, what am I doing wrong here?
Hernan Mendez
@hernanmendez
Mar 13 2017 00:54
var myStr="\tFirst\tLine\n \\tSecond\tLine\\r\tThird\tLine"; // Change this line this is like my 11th try
Jarod Guthrie
@jarodguthrie
Mar 13 2017 00:54

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

function checkObj(checkProp) {
// Your Code Here
myObj.hasOwnProperty(checkProp);
if (true){
return myObj[checkProp];
} else {
return "Not Found";
}
}

// Test your code by modifying these values
checkObj("house");

Hernan Mendez
@hernanmendez
Mar 13 2017 00:55
y get everything except the first requesite
I
and I can just keep going but i'm a perfectionist soooo, I GOTTA MAKE THIS
Joseph
@revisualize
Mar 13 2017 00:58
@jarodguthrie Regarding: myObj.hasOwnProperty(checkProp); .... .hasOwnProperty() returns a true or false boolean value.
Dan Couper
@DanCouper
Mar 13 2017 00:58
@glazey132 If the current value is in thedestroyers array, return false: filter will drop any false values. If it isn't, then return true, and filter will keep it. It should look something like return arr.filter(function(value) { /* your logic here */ });. There are very compact ways to do this, but having a loop that chacks
Joseph
@revisualize
Mar 13 2017 00:58
@jarodguthrie Re: if (true){ .. You need to put your myObj.hasOwnProperty(checkProp) inside of the if condition. Because true is always true.
Dan Couper
@DanCouper
Mar 13 2017 00:58
checks if value is in destroyers is easier to start with
Jarod Guthrie
@jarodguthrie
Mar 13 2017 00:59
All good I figured it out thanks @revisualize
CamperBot
@camperbot
Mar 13 2017 00:59
jarodguthrie sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3504 | @revisualize |http://www.freecodecamp.com/revisualize
Ken Haduch
@khaduch
Mar 13 2017 00:59
@hernanmendez You should have the text of the words "FirstLine", "SecondLine", and "ThirdLine" entered exactly as they are - no \t between the words. And there should be no whitespaces in the final string. Any of the highlighted words should be replaced with the values from the able - newline should be replaced with \n, backslash with \\, etc. Again, no final whitespaces and no extra escape sequences in the string.
c0d0er2
@c0d0er2
Mar 13 2017 01:00

Can somebody please help me on Access MultiDimensional Arrays With Indexes in JavaScript? Here is my code:

// Setup

var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[1][0];

Here is the link: https://www.freecodecamp.com/challenges/access-multidimensional-arrays-with-indexes

collinhboss
@collinhboss
Mar 13 2017 01:00
var myStr = "Firstlinen\SecondLine\rThirdLine";

assign the following three lines of text into the single variable myStr using escape sequences

FirstLine
\SecondLine\
ThirdLine

help?

oh an it isnt the \n being backwards i fixed that it still doesnt work
Hernan Mendez
@hernanmendez
Mar 13 2017 01:02
@khaduch THX, i made it like that, i guess i missed some weird detail
CamperBot
@camperbot
Mar 13 2017 01:02
hernanmendez sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2624 | @khaduch |http://www.freecodecamp.com/khaduch
Joseph
@revisualize
Mar 13 2017 01:03
@collinhboss How do you escape a newline in a string?
collinhboss
@collinhboss
Mar 13 2017 01:03
\n
Joseph
@revisualize
Mar 13 2017 01:04
@collinhboss Okay. Well, you're not doing it correctly in your string.
@collinhboss How do you escape a backslash in a string?
Ronique Ricketts
@RoniqueRicketts
Mar 13 2017 01:04
@c0d0er2 the numbers in the brackets are wromg. You need number 2 bracket and number 1 figure
collinhboss
@collinhboss
Mar 13 2017 01:04
\
Alex G
@glazey132
Mar 13 2017 01:05
@DanCouper thank you for the tips! what I don't understand is how to iterate through the array with filter
CamperBot
@camperbot
Mar 13 2017 01:05
:cookie: 542 | @dancouper |http://www.freecodecamp.com/dancouper
glazey132 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
c0d0er2
@c0d0er2
Mar 13 2017 01:05
@RoniqueRicketts Thanks!
CamperBot
@camperbot
Mar 13 2017 01:05
c0d0er2 sends brownie points to @roniquericketts :sparkles: :thumbsup: :sparkles:
:cookie: 317 | @roniquericketts |http://www.freecodecamp.com/roniquericketts
Ronique Ricketts
@RoniqueRicketts
Mar 13 2017 01:05
Yw
Joseph
@revisualize
Mar 13 2017 01:05
@collinhboss Okay. You need to change the word backslash into the escape character.
Alex G
@glazey132
Mar 13 2017 01:05
@DanCouper yous aid the easiest way to start is with a loop that checks if the current value is in destroyers. but how do you loop through a filter?
@DanCouper is this the right direction?

function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);
var destroyers = args.slice(1);

return arr.filter(function(val) {
if (val === indexOf(args));
return false;
});
}

Joseph
@revisualize
Mar 13 2017 01:06
@collinhboss Also, Firstline is not the same as FirstLine
collinhboss
@collinhboss
Mar 13 2017 01:07
@revisualize oh gosh thanks lol
CamperBot
@camperbot
Mar 13 2017 01:07
collinhboss sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3505 | @revisualize |http://www.freecodecamp.com/revisualize
collinhboss
@collinhboss
Mar 13 2017 01:08

var myStr = "FirstLine\n\\SecondLine\r\\ThirdLine";
gosh it didnt work i hate myself
Ademola Ariya
@d3mola
Mar 13 2017 01:09
@c0d0er2 you access the outer array first which points to [7,8,9]. The index of that outer array is 2. Next you access the elements in side the array [7,8,9], 8 is at index 1. So your result is var myData = myArray[2][1];
collinhboss
@collinhboss
Mar 13 2017 01:09
it says
myStr should have encoded text with the proper escape sequences and no spacing.
c0d0er2
@c0d0er2
Mar 13 2017 01:09
@d3mola Thanks!
CamperBot
@camperbot
Mar 13 2017 01:09
c0d0er2 sends brownie points to @d3mola :sparkles: :thumbsup: :sparkles:
:cookie: 192 | @d3mola |http://www.freecodecamp.com/d3mola
Ademola Ariya
@d3mola
Mar 13 2017 01:09
@c0d0er2 cheers
Manish Giri
@Manish-Giri
Mar 13 2017 01:09
@collinhboss what does the order of sequences say in the question?
Joseph
@revisualize
Mar 13 2017 01:10
@collinhboss You're escaping the carriage-return and backslash out of order.
collinhboss
@collinhboss
Mar 13 2017 01:11
@Manish-Giri @revisualize thanks man i need to read closer
CamperBot
@camperbot
Mar 13 2017 01:11
collinhboss sends brownie points to @manish-giri and @revisualize :sparkles: :thumbsup: :sparkles:
:warning: collinhboss already gave revisualize points
:star2: 4724 | @manish-giri |http://www.freecodecamp.com/manish-giri
Dan Couper
@DanCouper
Mar 13 2017 01:12
@glazey132 yes, you're defo going in the right direction. Not how index of works in JS though. It should be destroyers.indexOf(val) === ... - indexOf returns either an index number, or if the value is not in the array, -1. So you should be seeing if that is equal to -1. If it is, the value isn't in the destroyers array, so you want to keep it, so return true. Otherwise, it's one of the values to destroy, so return false: filter will give you a new array (hence why you just return are.filter) with only the ones you want kept
Paul Debevec
@PaulDebevec
Mar 13 2017 01:13
Anyone here recently done the madlib one? Called Word Blanks?
Manish Giri
@Manish-Giri
Mar 13 2017 01:15
@PaulDebevec yup
Alex G
@glazey132
Mar 13 2017 01:16
@DanCouper wheeeew that was a hard one. thanks for all your help dude! definitely going to have to review that one
CamperBot
@camperbot
Mar 13 2017 01:16
:warning: glazey132 already gave dancouper points
glazey132 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
Mar 13 2017 01:17

@PaulDebevec Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

Alex
@alexlo0319
Mar 13 2017 01:20
Dude, I need assistance.
Stephen James
@sjames1958gm
Mar 13 2017 01:21
@alexlo0319 WIth what?
Alex
@alexlo0319
Mar 13 2017 01:21
Make Instances of Objects with a Constructor Function
Dan Couper
@DanCouper
Mar 13 2017 01:21
@glazey132 yeah, it's tricky. The extra values not in the function just compound the trickiness as well. Note that there's another array method called includes that makes it a bit more readable - instead of destroyers.indexOf(val) === -1, you can do destroyers.includes(val) and return false if so - you're literally saying "if the destroyers array includes the value val, return false".
Stephen James
@sjames1958gm
Mar 13 2017 01:21
@alexlo0319 Show what you have so far?
Alex
@alexlo0319
Mar 13 2017 01:22
I got this: var myCar = new Car();
missing this: The property nickname of myCar should be a string.
Stephen James
@sjames1958gm
Mar 13 2017 01:22
@alexlo0319 Then give myCar a nickname property with a string value.
@alexlo0319 myCar.turboType = "twin"; this is adding turboType property
Alex
@alexlo0319
Mar 13 2017 01:23
and how is the string?
Stephen James
@sjames1958gm
Mar 13 2017 01:24
@alexlo0319 "twin" is a string value
Paul Debevec
@PaulDebevec
Mar 13 2017 01:24

@revisualize Thanks man, I'm just struggling figuring out what I need to write it. I tried
var madLib = (myNoun + " is the " + myAdjective + " who often " + myVerb + " very " + myAdverb);

But it's not returning anything, I need to figure out how to tie madLib into the result

CamperBot
@camperbot
Mar 13 2017 01:24
pauldebevec sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3506 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 13 2017 01:24
@PaulDebevec Your function is returning.. result
Stephen James
@sjames1958gm
Mar 13 2017 01:24
@PaulDebevec Use the variable already defined (and returned) inside the function
Joseph
@revisualize
Mar 13 2017 01:25
@PaulDebevec So maybe you shouldn't do var madLib but, use the variable that's already been declared and initialized.
Alex
@alexlo0319
Mar 13 2017 01:25
I got this but is not going thru
myCar.turboType = "twin";
Stephen James
@sjames1958gm
Mar 13 2017 01:25
@alexlo0319 nickname property not turboType property
Paul Debevec
@PaulDebevec
Mar 13 2017 01:26
@sjames1958gm @revisualize THanks fellas. I really appreciate the help!
CamperBot
@camperbot
Mar 13 2017 01:26
pauldebevec sends brownie points to @sjames1958gm and @revisualize :sparkles: :thumbsup: :sparkles:
:warning: pauldebevec already gave revisualize points
:star2: 6145 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Alex
@alexlo0319
Mar 13 2017 01:26
@sjames1958gm Thanks bro
CamperBot
@camperbot
Mar 13 2017 01:26
alexlo0319 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6146 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Mar 13 2017 01:26
@alexlo0319 :+1:
@PaulDebevec :+1:
Abhijeet Singh
@abhijeetps
Mar 13 2017 01:27
Hey guys, check out my Twitch App:
http://codepen.io/aps120797/full/PWrQmM
ShadowKnight
@ShadowKnight00
Mar 13 2017 01:28
@aps120797 It looks nice, but can't click on the channels?
Abhijeet Singh
@abhijeetps
Mar 13 2017 01:29
@ShadowKnight00 Click on their details.
@ShadowKnight00 Can put on their channels too.
ShadowKnight
@ShadowKnight00
Mar 13 2017 01:30
I saw that, but the channels are separated from their details far enough it's not obvious the details belong to the channels.
Kinda tough to read some of the details, also, due to the color choices. I like the overall style, tho.
Are any of your twitch TV cahnnels actually working? (It might be my browser)
Abhijeet Singh
@abhijeetps
Mar 13 2017 01:33
@ShadowKnight00 Check again.
Made some updates.
Joseph
@revisualize
Mar 13 2017 01:35
@aps120797 That looks like they're separate non-related information blocks.
@aps120797 The Channels block looks completely un-related to the Details.
ShadowKnight
@ShadowKnight00
Mar 13 2017 01:36
@aps120797 Much easier to read!
FYI: Even though the Twitch TV API is kinda messed up, I was able to get the channels working correctly in mine by poking around on TwitchTV.
Abhijeet Singh
@abhijeetps
Mar 13 2017 01:38
@revisualize So, should I make them more close?
@ShadowKnight00 How did you do that?
Leena
@Leena8392
Mar 13 2017 01:39
Hey Guys. I am stuck this question(Iterate Odd Numbers With a For Loop). i tried to put var i=1 instead of i=0. but it doesn't work. Anybody ca help me where i am wrong?
ShadowKnight
@ShadowKnight00
Mar 13 2017 01:39
@aps120797 Personally, I'd make one large box with the related data together, maybe each channel in a box with it's details?
@Leena8392 Sure, can you post a link to your challenge?
Abhijeet Singh
@abhijeetps
Mar 13 2017 01:39
@ShadowKnight00 The twitch App was the most difficult JSON task. Why? Simply because it had a confusing API.
@ShadowKnight00 Okay. Will fix that.
@ShadowKnight00 But personally, this UX looks beautiful.
Joseph
@revisualize
Mar 13 2017 01:41
@aps120797 The UX doesn't feel "beautiful" I was confused by it when I first loaded the page.
Leena
@Leena8392
Mar 13 2017 01:41
@ShadowKnight00. freecodecamp link?
Abhijeet Singh
@abhijeetps
Mar 13 2017 01:42
@revisualize Okay. Will change it. Thanks. :smile:
CamperBot
@camperbot
Mar 13 2017 01:42
aps120797 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3507 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 13 2017 01:42
@aps120797 The UX and UI are different. You may like the background image but, the way the content was displayed confused me.
@aps120797 The way the information is displayed the feel completely un-related.
Abhijeet Singh
@abhijeetps
Mar 13 2017 01:43
@revisualize What's the difference between UX and UI?
ShadowKnight
@ShadowKnight00
Mar 13 2017 01:43
@Leena8392 The link to the page with your challenge, so I can see the code. (I don't rmemeber all of them, lol)
@aps120797 I'm trying to remember how exactly I solved the API issue by looking through my project code. If you like, I can post a link to my project that you can save and look at after yours is done.
Manish Giri
@Manish-Giri
Mar 13 2017 01:46
what API issue?
ShadowKnight
@ShadowKnight00
Mar 13 2017 01:47
@Leena8392 The loop you made is pushing to ourArray instead of myArray
Leena
@Leena8392
Mar 13 2017 01:47
oho yes. lol. I didn't see that. Thank you @ShadowKnight00
CamperBot
@camperbot
Mar 13 2017 01:47
leena8392 sends brownie points to @shadowknight00 :sparkles: :thumbsup: :sparkles:
:cookie: 343 | @shadowknight00 |http://www.freecodecamp.com/shadowknight00
ShadowKnight
@ShadowKnight00
Mar 13 2017 01:47
@Manish-Giri The TwitchTV API didn't work the way they said it should, so none of the Twitch TV channels worked until I did it differently than the way they said to use it.
@Leena8392 You're welcome. :) Good luck!
Manish Giri
@Manish-Giri
Mar 13 2017 01:48
@ShadowKnight00 um, they require the use of an API key now, did you add it?
My twitch app also stopped working because of this change...
then I had to sign up for the key, and redo it..
ShadowKnight
@ShadowKnight00
Mar 13 2017 01:49
@Manish-Giri Nope. I didn't use a key.
Joseph
@revisualize
Mar 13 2017 01:49
@aps120797 User Interface vs User Experience.
ShadowKnight
@ShadowKnight00
Mar 13 2017 01:50
Joseph
@revisualize
Mar 13 2017 01:50
@aps120797 User Experience is all about the experience with the site. How elements are access. User Interface is all about the interface. How you format data and information.
ShadowKnight
@ShadowKnight00
Mar 13 2017 01:50
@Manish-Giri I know what they said, but mine still works. Like I said, their documentation sucks.
Manish Giri
@Manish-Giri
Mar 13 2017 01:50
@ShadowKnight00 well yeah because you're not using twitch..
you don't need the key for using gomix @ShadowKnight00
ShadowKnight
@ShadowKnight00
Mar 13 2017 01:51
How am I not using twitch?
Manish Giri
@Manish-Giri
Mar 13 2017 01:51
'https://wind-bow.gomix.me/twitch-api/streams/freecodecamp?callback=?'
isn't twitch
this is the passthrough
Joseph
@revisualize
Mar 13 2017 01:51
@aps120797 All of this conversation about your Project should actually be over in the https://gitter.im/FreeCodeCamp/CodeReview channel.
ShadowKnight
@ShadowKnight00
Mar 13 2017 01:52
(Had to look through my code, as it's been awhile.) Right, gomix was what FCC recommended for that project , if I remember right.
Ronald Johnson
@ronnieg1988
Mar 13 2017 01:56
function golfScore(par, strokes) {
  // Only change code below this line
  if ( par<=4 && strokes ==1) {
    return "Hole-in-one!";
  }
  else if (par<=4  && strokes <=2) {
    return "Eagle";
  }
  else if (par<=5 && strokes <=2){
    return "Eagle";
  }
  else if (par<=4 && strokes <= 3) {
    return "Birdie";
  }
  else if (par <=4 && strokes <= 4) {
    return "Par";
  }
  else if (par <=5 && strokes <= 5) {
    return "Par";
  }
  else if (par <=4 && strokes <=5) {
    return "Bogey";
  }
  else if (par <=4 && strokes <=6) {
    return "Double Bogey";
  }
  else if(par <=4 && strokes <=7){
    return "Go Home!";
  }
  else if (par >=5 && strokes >=9){
    return "Go Home!";
  }
  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(10, 10);
why is bogey wrong?
suppose to be 4, 5
golfScore(4, 5) should return "Bogey"
ShadowKnight
@ShadowKnight00
Mar 13 2017 01:58
@ronnieg1988 It looks like 4,5 would return Par right now.
Joseph
@revisualize
Mar 13 2017 01:59
@ronnieg1988 You're just supposed to compare strokes to the par value.
strokes <= par - 2
strokes === par - 1
Ronald Johnson
@ronnieg1988
Mar 13 2017 01:59
all the others are correct except that one
Joseph
@revisualize
Mar 13 2017 01:59
strokes >= par + 3
jacob
@bjh2012
Mar 13 2017 02:15
" Add the number to the end of the array, " arr.push(item); got it.
" then remove the first element of array. " .shift(); what am I missing?
I can't seem to make them happen at the same time as the instructions require
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:18
@bjh2012 Can you post a link to your challenge?
jacob
@bjh2012
Mar 13 2017 02:19
Stand in Line
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:20
If you post a link it will show the code you have currently entered as well.
jacob
@bjh2012
Mar 13 2017 02:20
@ShadowKnight00 ok
@ShadowKnight00 sorry, i don't know if i did that right
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:21
@bjh2012 You did it right. :smile:
You're currently returning the item you added to the array, instead of the item you removed from the array.
(as well as not actually removing anything from the array so far)
the0ffh
@the0ffh
Mar 13 2017 02:24
@bjh2012 no problem ;)
jacob
@bjh2012
Mar 13 2017 02:25
@ShadowKnight00 I'm so new to this, it's hard for me to think in those terms. I was told to use two of the array methods, i'm just not sure how
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:26
@bjh2012 No worries. Do them in separate steps. Step 1: Add new item to the array. Step 2: Remove item from the front of the array (and capture it) Step 3: Return the removed item.
jacob
@bjh2012
Mar 13 2017 02:26
I need to add the number to the end of the array @ShadowKnight00
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:27
.push() will do that
jacob
@bjh2012
Mar 13 2017 02:27
@ShadowKnight00 so i guess my return statement in incorrect?
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:27
yes
You have the right command [ array.push(newItem) ], but that isn't what you should be returning.
jacob
@bjh2012
Mar 13 2017 02:28
arr.push(item)?
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:28
Yep
That's step 1
jacob
@bjh2012
Mar 13 2017 02:28
@ShadowKnight00 do i put it within the function?
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:28
So for step 2, you need to remove the first item from the array
Yes, on line 4
(or line 3)
jacob
@bjh2012
Mar 13 2017 02:30
arr.shift(arr)? @ShadowKnight00
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:32
No, you don't need to pass anything to the shift() function, so just arr.shift()
arr.shift() will remove the first item from array arr and return it, so you need to then return (from the function) the value returned by the shift function.
jacob
@bjh2012
Mar 13 2017 02:34
@ShadowKnight00 I have arr.push(item); on line 4 and arr.shift(); on line 5
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:35
Good so far. That will add an item and then remove an item, but you also need to return that removed item from the function, using the return statement.
jacob
@bjh2012
Mar 13 2017 02:36
@ShadowKnight00 so, i need to replace item?
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:37
No
jacob
@bjh2012
Mar 13 2017 02:37
@bjh2012 I'm sorry. I'm such a noob
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:37
arr.shift() removes the first item from the array, and also returns that item, but it doesn't return it from the function unless you use the return keyword.
@bjh2012 No worries! We were all noobs once!
the0ffh
@the0ffh
Mar 13 2017 02:40
Okay..my turn. The 'tribute page'. ;)
http://codepen.io/the0ffh/full/dvXqgJ/
Jarod Guthrie
@jarodguthrie
Mar 13 2017 02:40

Hi guys, I'm stuck on "Profile Look-up":
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){

if (contacts.hasOwnProperty(firstName)){
return firstName;
} else{
return "No such contact";
}

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

// Only change code above this line
}

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

ShadowKnight
@ShadowKnight00
Mar 13 2017 02:40
@the0ffh LOL. "While sacrificing thousands"
the0ffh
@the0ffh
Mar 13 2017 02:41
@ShadowKnight00 Isn't it true? ;)
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:41
@jarodguthrie So what problem are you having?
jacob
@bjh2012
Mar 13 2017 02:41
@ShadowKnight00 i'm still not clear on how to do that. i know the code says: return item; //Change this Line, I'm just not sure what to change it to
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:42
@the0ffh I don't rmember, honestly. It's funny either way.
Jarod Guthrie
@jarodguthrie
Mar 13 2017 02:42
I need to find and return the first name value (eg Akira) but its saying no such contact
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:43
@bjh2012 Can you post a link to your challenge? (I don't rmember all the instuctions for each one)
@the0ffh I like your tribute page, though, except the font is a little bit hard to read.
Saboor Malik
@MathematicsCoding
Mar 13 2017 02:43
Sneeze
Jarod Guthrie
@jarodguthrie
Mar 13 2017 02:43
Haha yeah I don't think batman ever sacrificed thousands?
Saboor Malik
@MathematicsCoding
Mar 13 2017 02:43
I'm sorry
Jarod Guthrie
@jarodguthrie
Mar 13 2017 02:43
Good page though
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:44
@the0ffh I think you did a good job on it, though. :)
Saboor Malik
@MathematicsCoding
Mar 13 2017 02:44
... Average times is 10 hours to complete basic javascript but for me... it's more than that
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:44
@bjh2012 Sorry, got confused on which person needed what. :) You're very close.
the0ffh
@the0ffh
Mar 13 2017 02:45
@ShadowKnight00 : Unfortunately I have to code on a veeeeery old pc/monitor set and have no option to correct it in a close future. As soon as I will be able to exchange the set up I will update everything. [Thanks btw ;) ]
Saboor Malik
@MathematicsCoding
Mar 13 2017 02:46
@ShadowKnight00 help me please?
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:46
Line 5 says arr.shift() which removes the first item from the array and returns it, but then line 6 says return item which is returning the item you were adding, instead of the item you removed.
@MathematicsCoding Sure, what do you need?
Saboor Malik
@MathematicsCoding
Mar 13 2017 02:46
I need you to get me
Up in the tower
near my "father's castle"
You could be my knight!
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:47
@MathematicsCoding ?? LOL
Saboor Malik
@MathematicsCoding
Mar 13 2017 02:47
Get it? Im the princess
You are knight and have come to save me!
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:47
It took me a second. You had me confused!! LOL
the0ffh
@the0ffh
Mar 13 2017 02:47
Okay - i'm off. Time to hit the bed. Good luck guys!
and .. have fun!
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:48
cya!
Saboor Malik
@MathematicsCoding
Mar 13 2017 02:48
Anyway I hate being cooped in this stupid tower
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:48
@bjh2012 Are you still stuck on it?
Saboor Malik
@MathematicsCoding
Mar 13 2017 02:48
Was programming whole time I hate it its so boring here
Jarod Guthrie
@jarodguthrie
Mar 13 2017 02:48

How do I get my function here to return the objects i want to find in this array?

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

function lookUpProfile(firstName, prop){
// Only change code below this line

if (contacts.hasOwnProperty(firstName)){
return firstName;
} else{
return "No such contact";
}

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

// Only change code above this line
}

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

ShadowKnight
@ShadowKnight00
Mar 13 2017 02:48
@MathematicsCoding Just hit the escape key!
jacob
@bjh2012
Mar 13 2017 02:48
@ShadowKnight00 lol. yes
Saboor Malik
@MathematicsCoding
Mar 13 2017 02:48
@ShadowKnight00 no it's the truth
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:49
@jarodguthrie Well, when your function finds the firstName, it returns it and exits the function, so nothing after it is going to run if it finds that firstName.
Saboor Malik
@MathematicsCoding
Mar 13 2017 02:49
I work in trump tower What part do you not understand?
I want to quit but...
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:49
@bjh2012 On line 6 you say return item which returns the item you were adding to the array instead of returning the item you removed from the array.
Saboor Malik
@MathematicsCoding
Mar 13 2017 02:50
Line 5 says arr.shift() which removes the first item from the array and returns it, but then line 6 says return item which is returning the item you were adding, instead of the item you removed.
Wait a minute..
I can just contact the police through the internet
Perfect
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:51
@bjh2012 You're very close to solving it!
jacob
@bjh2012
Mar 13 2017 02:51
@ShadowKnight00 I removed the number one from the array, but I don't know the proper syntax
Saboor Malik
@MathematicsCoding
Mar 13 2017 02:51
@ShadowKnight00 Im sorry but I do not need you and you might not be real knight after all
KatSaldivar
@KatSaldivar
Mar 13 2017 02:51
I'm working on the chunky monkey algorithm and I'm not seeing what I'm doing wrong here. What do you all see?
blob
jacob
@bjh2012
Mar 13 2017 02:51
@ShadowKnight00 to return it, that is
Jarod Guthrie
@jarodguthrie
Mar 13 2017 02:52
@ShadowKnight00 will using console.log instead of return solve that?
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:52
@bjh2012 you used the proper syntax to remove the item, but you also need to return the item. No, you need to use return to return the right data from your function.
@bjh2012 The confusing thing here is the word return ismeaning 2 different things here.
KatSaldivar
@KatSaldivar
Mar 13 2017 02:53
nvm. figured it out
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:53
#1 : arr.shift() is returning the item you removed, but you're not doing anything with the data returned by that function.
achudoz
@achudoz
Mar 13 2017 02:54

Hi, can anyone help me by spotting the problem? I just don't see it. It's for the last AA challenge "Pairwise" and the code is supposed to take an array of numbers and and argument such as this:

pairwise([1, 4, 2, 3, 0, 5], 7)

and then find pairs of numbers that, when added, sum up to the argument. In this case, the result would be [4,3,2,5], because 4+3=7 and 2+5=7. BUT, then there is the harder part, that you are supposed to add their indexes in the original array, and those indexes can never repeat. So the final result of this case above would be 11, because the indexes in original array are 1(4), 3(3), (2)2 and 5(5) -> 1+3+2+5 = 11.
Ok, so that's the rather complicated assignment. My problem is, that my code works great, in all cases except one (of the tested ones at least). Thanks to my console.log() checkpoints, I think i found out, that in the case of

pairwise([1, 1, 1], 2);

, the code isn't working, because apparently the IF conditions aren't met. I just don't see why. I managed to solve the challenge by hardcoding it, but you know, that feels like cheating and I really want to understand what's going on.Here is the code:


function pairwise(arr, arg) {
  var remnant = arr,
      pairs = [],
      result = 0;
  if (arr.length<2) return 0;
  //if (arr.length==3) return 1; - this is cheating!

  remnant.map(function(sup) {
    console.log("1checkpoint - 1st .map");
    remnant.map(function(sub) {
      console.log("2checkpoint - 2nd .map");
      if (sup+sub==arg && 
          pairs.indexOf(remnant.indexOf(sup) < 0) && 
          pairs.indexOf(remnant.indexOf(sub) < 0) && 
          remnant.indexOf(sup)!==remnant.indexOf(sub)) {
        console.log("3checkpoint - all IF conditions met");
        pairs.push(remnant.indexOf(sup),remnant.indexOf(sub));
        //pairs.push(sup,sub);
        delete remnant[remnant.indexOf(sup)];
        delete remnant[remnant.indexOf(sub)];
      }
    });
  });
 console.log("4checkpoint - trying to return .reduce of " + pairs);
  return pairs.reduce(function(a,b) {
    return a+b;
  });
}

pairwise([1, 4, 2, 3, 0, 5], 7);
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:54
#2: the return keyword is sending data back from your function, bit it's not sending back the item you removed.
achudoz
@achudoz
Mar 13 2017 02:54
Sorry for the wall of text, but the challenge is rather complicated by itself
Saboor Malik
@MathematicsCoding
Mar 13 2017 02:54
My bad...
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:55
@bjh2012 check the private chat
jacob
@bjh2012
Mar 13 2017 02:55
@ShadowKnight00 yes, i'm sorry. i'm not sure what to ask
ShadowKnight
@ShadowKnight00
Mar 13 2017 02:55
@achudoz As soon as I'm done helping jacob, I'll take a look.
achudoz
@achudoz
Mar 13 2017 02:55
@ShadowKnight00 thanks!
CamperBot
@camperbot
Mar 13 2017 02:55
achudoz sends brownie points to @shadowknight00 :sparkles: :thumbsup: :sparkles:
:cookie: 344 | @shadowknight00 |http://www.freecodecamp.com/shadowknight00
Jor
@joreyesl
Mar 13 2017 02:56
@achudoz which test is failing?
achudoz
@achudoz
Mar 13 2017 02:57
@joreyesl pairwise([1, 1, 1], 2); this one
Moisés Man
@moigithub
Mar 13 2017 03:01
 if (sup+sub==arg && 
          pairs.indexOf(remnant.indexOf(sup) < 0) && 
          pairs.indexOf(remnant.indexOf(sub) < 0) &&
why u using remnant.indexOf(sup) ? @achudoz
achudoz
@achudoz
Mar 13 2017 03:01
@joreyesl ha, I just noticed that and it can be safely removed.
Moisés Man
@moigithub
Mar 13 2017 03:02
if pairwise([1, 1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], 2);
sup and sub will be 1... soo which one that indexOf will refer to ??
the first 1 ? or the 5th 1 ?
achudoz
@achudoz
Mar 13 2017 03:04
@moigithub in your example, all of them except one will be used (because there are 17 ones, and each pair must consist of two)
Moisés Man
@moigithub
Mar 13 2017 03:04
map should not be used as simple iterator... u can use forEach or a simple for/loop
and map and foreach callback accept/is called with multiple argumetns... one of em are index... so u no need to use indexOf
Jor
@joreyesl
Mar 13 2017 03:08
@achudoz pairs.indexOf(remnant.indexOf(sup) < 0) this is not doing what you think it is. you are checking for the indexOf for the value remnant.indexOf(sup) < 0 that is a comparison, true/false and will not be in pairs so it will always be -1`
achudoz
@achudoz
Mar 13 2017 03:09
@moigithub I don't think I understand. I don't think my problem is the use of indexOf, that seems perfectly legit to me. How would the use of a for loop make it different.?
Jor
@joreyesl
Mar 13 2017 03:10
@achudoz both forEach and map run a loop, but they are used for different purposes. Here you are using .map as a .forEach
Moisés Man
@moigithub
Mar 13 2017 03:10
if u have this
arr=[1,1,1]
sup=1; sub=1;
what arr.indexOf(sup) will return ? @achudoz
and what arr.indexOf(sub) will return ?
achudoz
@achudoz
Mar 13 2017 03:12
@moigithub @joreyesl ooooh. So what you're saying is that my .map doesn't distinguish the ones from each other? I thought that map goes through each of the elements without regard for their value
@moigithub well but they should have different indexes because of this condition remnant.indexOf(sup)!==remnant.indexOf(sub))
Moisés Man
@moigithub
Mar 13 2017 03:13
map will iterate on each value.. just like a for or foreach
yep.. above both indexOf will return 0
and since u adding a !== condition... mean the whole IF wil lbe evaluated as false
Jor
@joreyesl
Mar 13 2017 03:15

@achudoz
change this

 if (sup+sub==arg && 
          pairs.indexOf(remnant.indexOf(sup) < 0) && 
          pairs.indexOf(remnant.indexOf(sub) < 0) &&

to this

 if (sup+sub==arg)

and you will see the logic/result doesn't change. Those statements aren't doing anything

achudoz
@achudoz
Mar 13 2017 03:15
@joreyesl yeah i already noticed that and removed them.
Moisés Man
@moigithub
Mar 13 2017 03:16
arr=[1a, 1b, 1c]
first map loop: sub = 1a, sup = 1a
IF will not be executed.. cuz !== false
second loop: sub=1a, sup = 1b
IF will not be executed.. cuz !== false
third loop: sub=1a, sup = 1c
IF will not be executed.. cuz !== false
why? cuz indexOf will always return the first 1 match
(added a,b,c to differentiate the 1's)
achudoz
@achudoz
Mar 13 2017 03:19
@moigithub I still don’t follow. What I thought that the code does is that it goes over the array, of ones. Lets call them x,y,z , and each represents a "1". The first .map takes X as its SUP and starts the second .map. The second map takes X as its SUB, but since they have the same index, it moves on to making Y its SUB. Since SUB+SUP=2 and indexesOf X(SUP) and Y(SUB) are different in the REMNANT array, all aconditions are met, X and Y are pushed into PAIRS array and removed from REMNANT.
@moigithub oh we just wrote the same thing
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:20
Hey all.
achudoz
@achudoz
Mar 13 2017 03:20
@moigithub I mean I believe you, I just don't see why
gmr90
@gmr90
Mar 13 2017 03:20
Hi , i built the portfolio page . want to attach the project image in place of thumbnails.. how you guys attached the project image src
achudoz
@achudoz
Mar 13 2017 03:20
@moigithub i mean the index of 1b is 1, while index of 1a is 0
Jor
@joreyesl
Mar 13 2017 03:21
@achudoz now for trying to figure out which indexes have been used. I would suggest either an obj/map or a parallel array. you can add another argument to the map/forEach function, like function(sup, supi) to keep track of the index for that value instead of using indexOf. Then you can just push that value to pairs and mark that index as used.
Ex:
var used = {};
var arr = [1,2,3];
var pairs = [];

arr.forEach(function(sup, supi) {
  if(!used[supi]) {
    pairs.push(supi);
    used[supi] = true;
  }
};
Moisés Man
@moigithub
Mar 13 2017 03:21
since x(sup) and y(sup) are 1
[1,1,1,1].indexOf(1) return 0 on both cases
and ur !== will make the whole condition false
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:21
@gmr90 You have to upload them somewhere, but you can't upload files to codepen unless you pay for a premium account.
Moisés Man
@moigithub
Mar 13 2017 03:21
IF indexOf(1) return 0 for sup
and 1 for sub.. what would be different
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:21
@gmr90 You could upload them to your github page, or to facebook or anywhere else you have online storage.
Moisés Man
@moigithub
Mar 13 2017 03:22
but indexOf always start from first value (unless u tell not, second param if i recall)
but there are another way.. which is using the callback argument (index)
gmr90
@gmr90
Mar 13 2017 03:22
@ShadowKnight00 can i upload it in github and link to it ?
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:22
@gmr90 yep
gmr90
@gmr90
Mar 13 2017 03:22
thank you
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:22
@ShadowKnight00 You're welcome. Good luck!
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:23
@ShadowKnight00
Moisés Man
@moigithub
Mar 13 2017 03:23
map, filter, forEach accept multiple parameters (predefined).. but we usually only use first one (the value).. but internally it always called with 3.. (value, index, array) check the documentation @achudoz
or check @joreyesl example above
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:23
Help?
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:24
@MathematicsCoding Sure, what do you need?
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:24
I need you to get me...
Help with this challenge
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:24
LOL. Do you need something code related?
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:24
Yeah i guess
This challenge
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:25
ok....what's the problem?
Sam Felder
@sf8193
Mar 13 2017 03:25
hey guys any idea why this code is wrong?
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:26
How do I get myData to equal to 8?
Moisés Man
@moigithub
Mar 13 2017 03:27
3 backticks on top and bottom on its own line, exactly as example below
```
code
```
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:27
@MathematicsCoding Well, the first index (myArray[x]) will select from each top level array, such as [1,2,3] and [4,5,6]
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:27
So do I need to put 7 in [] to equal 8?
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:28
@MathematicsCoding and the second index myArray[index1][index2] will select from a 2nd level array, so myArray[0][0] would equal 1, while myArray[1][0] would equal 4.
Jor
@joreyesl
Mar 13 2017 03:28
formatCode.gif
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:29
Strange
I actually guessed and passed..
Sam Felder
@sf8193
Mar 13 2017 03:29
var greatest=[];

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

        if(arr[i][j]>greatest){
          greatest=arr[i];
        }
      }
    }

  return greatest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Moisés Man
@moigithub
Mar 13 2017 03:29
codeformat
bigger :D
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:29
But I want to understand why [2][1] equal 8?
Sam Felder
@sf8193
Mar 13 2017 03:29
greatest always returns as an empty array
achudoz
@achudoz
Mar 13 2017 03:29

@moigithub ok, I just checked it with

console.log("indexOf sup: " + remnant.indexOf(sup));
console.log("indexOf sub: " + remnant.indexOf(sub));

also I totally didn't realize .map supports index. I guess I just need to be checking the documentation more often. I never remember it on the first read.

Jor
@joreyesl
Mar 13 2017 03:29
@moigithub :thumbsup: XD
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:29
@MathematicsCoding In that example, myArray[2] = [7,8,9]
achudoz
@achudoz
Mar 13 2017 03:29
@moigithub @joreyesl thanks!
CamperBot
@camperbot
Mar 13 2017 03:29
achudoz sends brownie points to @moigithub and @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 591 | @joreyesl |http://www.freecodecamp.com/joreyesl
:star2: 2847 | @moigithub |http://www.freecodecamp.com/moigithub
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:29
oh
So [2] [1] means 3 and 5
5+3 = 8?
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:30
No, the second index chooses which element of the array [7,8,9]
so, [2][0] would have been 7, while [2][1] = 8, and [2][2] = 9
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:31
Yeah...
Garo
@Garabed96
Mar 13 2017 03:31
Guys all the JSON explanations have baffled me even further, can anyone give me a good reference. (Its for the quote generator project)
Moisés Man
@moigithub
Mar 13 2017 03:32
@sf8193
i is a number for(var i=0; i<a u declared here
nubmbers dont have length for(var j=0; j<i.length;
soo i guess u wanted to say arr[i].length instead
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:32
Because [2] means 3 from [1,2,3] and
[0] means 4 from [4,5,6] which is 4+3 = 7
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:32
OK, if the array were to be [a,b,c,d], how would you select the second element, the b?
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:32
Is that how it works?
a
[a]
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:32
No, it's not math at all.
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:33
But...
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:33
to select the second element from the array [a,b,c,d], you would use [1] since all arrays start at zero.
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:33
I think my theory is correct...
[2][1] = 3 +5 = 8
Whats wrong with that?
Sam Felder
@sf8193
Mar 13 2017 03:33
are there any tips to debug the javascript algorithm section? It seems console.log isn't working... (or i dont know where to look?)
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:34
There's nothing wrong with your math, but that's not how array work.
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:34
oh
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:34
myArray[2] selected the second element from the whole array. That element happened to be another array, which was [7,8,9]
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:34
So If I wanted to pick b and would I have to use [a]? or [0]
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:35
Let's try a private chat
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:35
okay
Moisés Man
@moigithub
Mar 13 2017 03:35

@sf8193 also greatest=arr[i]; arr[i] is a subarray like [13, 27, 18, 26]
but arr[i][j] is a single number like 27

 if(arr[i][j]>greatest){
          greatest=arr[i];
        }

u should compare numbers vs numbers... and store the biggest num on a new array

rdollent
@rdollent
Mar 13 2017 03:36
hello. I am about to start the TicTacToe game challenge. Can anyone point me to the right direction? I don't wanna be googling "JS tictactoe how to"...
Sam Felder
@sf8193
Mar 13 2017 03:38
@moigithub I tried doing that but moved to this because I just get 0 and here i get an empty array. I think it's an issue with variables inside for loops in java script but i'm having trouble debugging
achudoz
@achudoz
Mar 13 2017 03:44
@Garabed96 First make sure you are getting the JSON data correctly and then navigate it like you would navigate an object. If you can't work it out, try navigating, until you pull at least some piece of data and then adjust the path that got you it, until you navigate to the information that you want. If you can't even get the raw JSON, read documentation/try googling the API, until you find the solution. They usually have few often occurring problems, that are well described somewhere.
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:45
@rdollent If you're looking for game logic, you can look up minimax, but I'm not sure killer game logic is actually required.
You can make an unbeatable computer player by following that, though.
Good luck on it!
@sf8193 console.log will output to the browser console which you have to open (it's different for each browser)
Which browser are you using?
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:49
Now I completed 6 challenges since this morning...
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:49
(codepen has a built in browser console as well)
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:49
165 to 171
sigh
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:49
Good work :)
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:50
When I first doing basic javascript and I was like "I think i will finish basic javascript in a day or two"
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:50
Taking longer for a challenge isn't a bad thing. Usually you learn the concepts better when it's harder for you.
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:50
Yeah
To be honest I just wanna reach to 200 lol
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:51
You will need all your javascript knowledge for a lot of projects down the road, so take your time and learn it well!
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:51
Yeah..
Which is why I adding notes on docs or paper
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:51
I'm on 342, and I'm using a LOT of javascript still.
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:51
xD
@ShadowKnight00
Do me a favor
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:52
?
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:52
Can you say thanks @myname?
CamperBot
@camperbot
Mar 13 2017 03:52
mathematicscoding sends brownie points to @myname :sparkles: :thumbsup: :sparkles:
:warning: @myname's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:52
lol, sure. thanks, @MathematicsCoding
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:52
...
just thanks myname lol
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:52
thanks @MathematicsCoding
CamperBot
@camperbot
Mar 13 2017 03:52
shadowknight00 sends brownie points to @mathematicscoding :sparkles: :thumbsup: :sparkles:
:cookie: 172 | @mathematicscoding |http://www.freecodecamp.com/mathematicscoding
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:52
:cookie: 200 | @mathematicscoding |http://www.freecodecamp.com/mathematicscoding
Ok i'm done
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:53
Sometimes camperbot is a little slow, lol.
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:53
Thanks @ShadowKnight00 :p
CamperBot
@camperbot
Mar 13 2017 03:53
mathematicscoding sends brownie points to @shadowknight00 :sparkles: :thumbsup: :sparkles:
:cookie: 345 | @shadowknight00 |http://www.freecodecamp.com/shadowknight00
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:53
:cookie: 199 | @shadowknight00 |http://www.freecodecamp.com/shadowknight00
Joseph
@revisualize
Mar 13 2017 03:53
@MathematicsCoding Thanks.
CamperBot
@camperbot
Mar 13 2017 03:53
revisualize sends brownie points to @mathematicscoding :sparkles: :thumbsup: :sparkles:
:cookie: 173 | @mathematicscoding |http://www.freecodecamp.com/mathematicscoding
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:53
Woo! Im higher than you!
173...
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:54
Nice!
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:54
So "thanks" actually counts
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:54
Yep, so helping people is kinda rewarded.
Sam Felder
@sf8193
Mar 13 2017 03:55
using chrome, found the dev tools thanks!
@ShadowKnight00
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:55
:cookie: 56784636876907874624356487587906785745634557485969856745634527548596 | @mathematicscoding |http://www.freecodecamp.com/mathematicscoding
Yay
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:55
@sf8193 :) Hopefully that helps you!
Joseph
@revisualize
Mar 13 2017 03:55
@MathematicsCoding The number in the upper right corner isn't the lesson that you're on. It's the number of brownie points that you've earned.
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:56
Yeah someone told me :p
Joseph
@revisualize
Mar 13 2017 03:56
@MathematicsCoding You get a brownie point by completing a lesson or by getting a thank you in chat.
CamperBot
@camperbot
Mar 13 2017 03:56
:warning: revisualize already gave mathematicscoding points
revisualize sends brownie points to @mathematicscoding :sparkles: :thumbsup: :sparkles:
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:56
whoops, lol.\
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:56
lol?
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:57
I guess I was wrong. I should known.
Joseph
@revisualize
Mar 13 2017 03:57
These math lessons are killing me.
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:57
lol
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:57
I'm on the last project in react, in the data visualization section.
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:57
I love math :p
react.js?
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:58
yep
It would have been nice if FCC actually had some react lessons, but they don't yet.
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:58
Yeah
FCC is finally offering computer science lessons but haven't come out yet
Ronald Johnson
@ronnieg1988
Mar 13 2017 03:59
function golfScore(par, strokes) {
  // Only change code below this line
  if ( par<=4 && strokes ==1) {
    return "Hole-in-one!";
  }
  else if (par<=4  && strokes <=2) {
    return "Eagle";
  }
  else if (par<=5 && strokes <=2){
    return "Eagle";
  }
  else if (par<=4 && strokes <= 3) {
    return "Birdie";
  }
  else if (par <=4 && strokes <= 4) {
    return "Par";
  }
  else if (par <=5 && strokes <= 5) {
    return "Par";
  }
  else if (par <=4 && strokes <=5){
    return "Bogey";
  }

  else if (par <=4 && strokes <=6) {
    return "Double Bogey";
  }
  else if(par <=4 && strokes <=7){
    return "Go Home!";
  }
  else if (par >=5 && strokes >=9){
    return "Go Home!";
  }
  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(10, 10);
im still stuck on here i have changed bogey to every form of greater than or less than
ShadowKnight
@ShadowKnight00
Mar 13 2017 03:59
Instead I had to go out in the big bad world and find some. It was very scary.
Joseph
@revisualize
Mar 13 2017 03:59
@ronnieg1988 I'd recommend using www.pythontutor.com/javascript.html
Saboor Malik
@MathematicsCoding
Mar 13 2017 03:59
My school offer CS and I will probably take next semseter but I wanna self-studying first
Joseph
@revisualize
Mar 13 2017 03:59
@ronnieg1988 I'd also recommend changing your if conditions.
ShadowKnight
@ShadowKnight00
Mar 13 2017 04:00
@ronnieg1988 You need to change your approach. You should beusing formulas to compare strokes to par, not hardcoding each separate one.
Shantanu Lawande
@Shantanu337
Mar 13 2017 04:00
This code works fine except for the second example
function largestOfFour(arr) {
// You can do this!
var myArray = [];
var num=0;
for(var i=0;i<arr.length;i++){ for(var j=0;j<arr[i].length;j++){ if(arr[i][j]>num){
num = arr[i][j];
}
}
myArray.push(num);
}
return myArray;
}
Ronald Johnson
@ronnieg1988
Mar 13 2017 04:00
i got all of them green beside the bogey one
Saboor Malik
@MathematicsCoding
Mar 13 2017 04:01
Well cya
Good night guys
ShadowKnight
@ShadowKnight00
Mar 13 2017 04:03
@Shantanu337 Can you post a link to your challenge?
Goodnight, Saboor.
Brian
@BrianCodes33
Mar 13 2017 04:05
someone help me w/ lowest common multiple
Jor
@joreyesl
Mar 13 2017 04:05
@Shantanu337 you need to reset num before the nested for loop. Otherwise num will contain the largest from the previous subarray
ShadowKnight
@ShadowKnight00
Mar 13 2017 04:05
@BrianCodes33 That one was tough. What are you having a problem with?
heroiczero
@heroiczero
Mar 13 2017 04:06
@BrianCodes33 try to use: https://en.wikipedia.org/wiki/Least_common_multiple#Reduction_by_the_greatest_common_divisor the greatest common divisor to find it
Joseph
@revisualize
Mar 13 2017 04:06
@BrianCodes33 I'm on that same challenge.
Brian
@BrianCodes33
Mar 13 2017 04:08
@revisualize maybe we can work on it together
Shantanu Lawande
@Shantanu337
Mar 13 2017 04:08
@joreyesl ..thanks ...i needed to reset num....
CamperBot
@camperbot
Mar 13 2017 04:08
shantanu337 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 592 | @joreyesl |http://www.freecodecamp.com/joreyesl
ShadowKnight
@ShadowKnight00
Mar 13 2017 04:09
@BrianCodes33 I tried using a formula to find all permutations and using combinatorics to get the answer, but in the end, I just filled arrays with all multiples and searched through them.
aaaand I can't spell tonight.
Brian
@BrianCodes33
Mar 13 2017 04:10
comina WHO?
Joseph
@revisualize
Mar 13 2017 04:10
@BrianCodes33 I'm not good at this kind of math.
ShadowKnight
@ShadowKnight00
Mar 13 2017 04:10
combinatorics...dont' worry about it. It was a dead end for me that I wasted days on.
Brian
@BrianCodes33
Mar 13 2017 04:11
i dont even get this question
Joseph
@revisualize
Mar 13 2017 04:11
@BrianCodes33 I think I'm going to need to factor a bunch of prime numbers.
Brian
@BrianCodes33
Mar 13 2017 04:11
poorly worded
ShadowKnight
@ShadowKnight00
Mar 13 2017 04:11
I was sure there was a formula that would get me the answer, but my math-fu just wasn't strong enough.
Joseph
@revisualize
Mar 13 2017 04:12
@BrianCodes33 I think I'm going to go the prime factorization route.
@BrianCodes33 I already know how to create an array of prime numbers to 50
Even though, technically because of the lesson requirements. I am pretty sure I only need to go up to 24
Actually, that's what I'm going to do.
Joseph
@revisualize
Mar 13 2017 04:20
This is going to be a bunch of crazy objects in objects. LOL!
Roy Alnashef
@RoyAlnashef
Mar 13 2017 04:28
Hey guys, I'm building my card counter and the code seems to break during my else if statement. Does anyone have an idea of what I'm doing wrong here?
var count = 0;

function cc(card) {
  // Only change code below this line
 if (card < 10) {
  return count + " Hold";
 } else if (card < 7) {
   count++;
   return count + " Bet";
 } else {
   count--;
   return count + " Hold";
 }
  // Only change code above this line
}

cc(6);
Joseph
@revisualize
Mar 13 2017 04:29

@RoyAlnashef Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.

Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.

@RoyAlnashef You should be increasing or decreasing the value of count based upon the value of the card.
@RoyAlnashef You then return based upon the value of count
Jake
@neozane1
Mar 13 2017 04:31
hello world
Joseph
@revisualize
Mar 13 2017 04:31
hi
Rhys
@105ron
Mar 13 2017 04:31
Hello everyone...
Jake
@neozane1
Mar 13 2017 04:31
hey im trying to use jquery to setup a twitter tweet button and i cant seem to get it to work
hell
hello
Rhys
@105ron
Mar 13 2017 04:32
I'm trying to do this and I can't get it done
Roy Alnashef
@RoyAlnashef
Mar 13 2017 04:32
@revisualize It seems like I'm doing all those things in my code? Is there another way I should be doing it?
heroiczero
@heroiczero
Mar 13 2017 04:32
@neozane1 try looking at this https://dev.twitter.com/web/tweet-button
Rhys
@105ron
Mar 13 2017 04:32
I feel your pain @neozane1
Garo
@Garabed96
Mar 13 2017 04:33
@achudoz ya this is fairly confusing to even just get data to get through it
thank you
been trying to pass all the quotes through before ever trying to get it to pick a specific one
Joseph
@revisualize
Mar 13 2017 04:35
@RoyAlnashef You're not.
@RoyAlnashef You're returning based on the value of the card
Garo
@Garabed96
Mar 13 2017 04:36
http://codepen.io/CapGaro/pen/JWNOoE?editors=0010 anyone know why the getJSON isn't working here
^ very simple if you know how to use getJSON not trying to burn anyones valuable time
Joseph
@revisualize
Mar 13 2017 04:37

@RoyAlnashef Also with this logic:

 if (card < 10) {
  return count + " Hold";
 }

2 is less than 10. So, it just returns.

@RoyAlnashef You need to change your logic.
Jake
@neozane1
Mar 13 2017 04:38
$(".#btn").click(function(event) {
var width = 575,
height = 400,
left = ($(window).width() - width) / 2,
top = ($(window).height() - height) / 2,
url = this.href,
opts = 'status=1' +
',width=' + width +
',height=' + height +
',top=' + top +
',left=' + left;
window.open(url, 'twitter', opts);

return false;
Roy Alnashef
@RoyAlnashef
Mar 13 2017 04:38
@revisualize There's also an else if statement that covers anything less than 7, and an else to catch anything that isn't under 10
Joseph
@revisualize
Mar 13 2017 04:39
@RoyAlnashef But, that else if block doesn't get reached.
@RoyAlnashef Is 2 < 10 true or false?
Roy Alnashef
@RoyAlnashef
Mar 13 2017 04:40
@revisualize Ah, I see. The first return stops the function.
Joseph
@revisualize
Mar 13 2017 04:40
@RoyAlnashef Also, your code doesn't take into account J, Q, K, A
Roy Alnashef
@RoyAlnashef
Mar 13 2017 04:41
@revisualize I don't really need to, do I?
Joseph
@revisualize
Mar 13 2017 04:41
@RoyAlnashef Yes, you do.
Soumyojyoti Majumdar
@SoumyoNawab8
Mar 13 2017 04:45

One of the simplest and most widely known ciphers is a Caesar cipher, also known as a shift cipher. In a shift cipher the meanings of the letters are shifted by some set amount.

A common modern use is the ROT13 cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on.

Write a function which takes a ROT13 encoded string as input and returns a decoded string.

All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

my code

~~~

function rot13(str) { // LBH QVQ VG!
var ops;
var arr=[];
for(var j=0;j<str.length;j++){ var demp=str.charCodeAt(j)+13; if(demp>90){
ops=demp-90;
ops+=64;
arr+=String.fromCharCode(ops);
}
else if(demp<65){
arr+=str[j];
}
else{
arr+=String.fromCharCode(demp);
}
}
return arr;
}

// Change the inputs below to test
rot13("SERR YBIR?");


function rot13(str) { // LBH QVQ VG!
  var ops;
  var arr=[];
  for(var j=0;j<str.length;j++){
  var demp=str.charCodeAt(j)+13;
  if(demp>90){
   ops=demp-90; 
   ops+=64;
  arr+=String.fromCharCode(ops);  
  }
    else if(demp<65){
      arr+=str[j];
    }
    else{
      arr+=String.fromCharCode(demp);
    }
 }
  return arr;
}

// Change the inputs below to test
rot13("SERR YBIR?");
causing 1 error
rot13("SERR YBIR?") should decode to "FREE LOVE?"
the output is coming
FREE LOVEL
Rhys
@105ron
Mar 13 2017 04:46
Seems like the question mark is being shifted to me
Joseph
@revisualize
Mar 13 2017 04:46
@Soumyoahona200 You're shifting the ? as well.
Rhys
@105ron
Mar 13 2017 04:46
You were informed not to shift such characters
Soumyojyoti Majumdar
@SoumyoNawab8
Mar 13 2017 04:47
I am not shifting ? mark
or space or any other symbolic character
Joseph
@revisualize
Mar 13 2017 04:48
@Soumyoahona200 Well, let's see what you're doing.
Rhys
@105ron
Mar 13 2017 04:48
How does it turn into an L?
Joseph
@revisualize
Mar 13 2017 04:48
@Soumyoahona200 https://goo.gl/TTOI8k
Rhys
@105ron
Mar 13 2017 04:50
? is 63 and L is 76
Soumyojyoti Majumdar
@SoumyoNawab8
Mar 13 2017 04:50
yup
Rhys
@105ron
Mar 13 2017 04:50
That's 13 numbers apart. I think you may have shifted it...
Jor
@joreyesl
Mar 13 2017 04:50
@Soumyoahona200 the very first thing you do in your loop is var demp=str.charCodeAt(j)+13; You are adding +13 to all characters including ? Before shifting anything you should check to make sure is a letter.
Joseph
@revisualize
Mar 13 2017 04:51
@Soumyoahona200 Walk through your code from that link that I provided.
Soumyojyoti Majumdar
@SoumyoNawab8
Mar 13 2017 04:51
@joreyeslok
Shantanu Lawande
@Shantanu337
Mar 13 2017 04:52
The code is repeating the given string 'num' times, still the challenge is unsolved

var str2 = "";
function repeatStringNumTimes(str, num) {
// repeat after me
for(var i=0;i<num;i++){
str2 = str2.concat(str);
}
return str2;
}

repeatStringNumTimes("abc",3);

Joseph
@revisualize
Mar 13 2017 04:53
@Shantanu337 Global variables are not reset during the FreeCodeCamp test runs.
@Shantanu337 Put var str2 = ""; inside of your function.
Rhys
@105ron
Mar 13 2017 04:54
thanks @revisualize
CamperBot
@camperbot
Mar 13 2017 04:54
105ron sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3508 | @revisualize |http://www.freecodecamp.com/revisualize
Shantanu Lawande
@Shantanu337
Mar 13 2017 04:54
@revisualize ...thanks...it worked
CamperBot
@camperbot
Mar 13 2017 04:54
shantanu337 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3509 | @revisualize |http://www.freecodecamp.com/revisualize
Soumyojyoti Majumdar
@SoumyoNawab8
Mar 13 2017 04:56
@revisualize @joreyesl Thanks a lot it worked
CamperBot
@camperbot
Mar 13 2017 04:56
soumyoahona200 sends brownie points to @revisualize and @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 593 | @joreyesl |http://www.freecodecamp.com/joreyesl
:star2: 3510 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 13 2017 04:56
@Soumyoahona200 Did Pythontutor.com help?
Rhys
@105ron
Mar 13 2017 04:57
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/filter If I want to use this code inside my function for this challenge... https://www.freecodecamp.com/challenges/wherefore-art-thou Could someone help explain how to use the arguments to filter the collection for the objects that match the source?
Jake
@neozane1
Mar 13 2017 05:05
https://codepen.io/neozane1/pen/WRYaJW what yall think of this
Jor
@joreyesl
Mar 13 2017 05:07
@105ron yea you can use .filter(), it will loop though the elements of the collection and pass them to the callback 1 at a time. Now inside the callback function you will need to check if the current obj has all the properties/values of source. If it does, then return true, else return false. After .filter() is done, the array returned should only contain those objects that have all properties/values of source
Rhys
@105ron
Mar 13 2017 05:07
That's awesome @neozane1
Jake
@neozane1
Mar 13 2017 05:08
@105ron thanks i had some help with the box using twitter documentation but it came out pretty good
CamperBot
@camperbot
Mar 13 2017 05:08
neozane1 sends brownie points to @105ron :sparkles: :thumbsup: :sparkles:
:cookie: 246 | @105ron |http://www.freecodecamp.com/105ron
Rhys
@105ron
Mar 13 2017 05:09
Thanks @joreyesl . So collection is there as value in the callback function. How do I pass source into it as well So I can compare the two?
CamperBot
@camperbot
Mar 13 2017 05:09
105ron sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 594 | @joreyesl |http://www.freecodecamp.com/joreyesl
achudoz
@achudoz
Mar 13 2017 05:09
hi, can anyone explain to me, why my function is behaving weird? this is my console.log():
// (stuff happening above correctly)
recursion with [null,null,1]  //this is correct - in previous run, the first two values were deleted, hence the nulls
1checkpoint - 1st .map - indP = 2, sup = 1  // this is correct - .map takes the remaining 1, with the index of 2  as its value
2checkpoint - indexes are: 2 2 - different? false // this is correct - the indexes the 1st and 2nd(nested) . map are the same, which is unacceptable
2checkpoint - indexes are: 0 2 - different? true // this is weird, i thought .map only moves to the right, so how could index 2 become an index 0? but whatevs, it isn't fatal for my function
3checkpoint - all IF conditions met  // - this is WRONG -  one of the IF conditions is, that the values under the indexes sum up to number 2. But since index 0 is now NULL and index 2 is 1, it shouldn't  pass the condition since null(0?)+1 is oh so obviously not 2. 
pushing 0 2 // - pushing indexes whose values do not meet the condition because fuck you achudoz :D
recursion with [null, null, null] // restarting the function again
4checkpoint - trying to return .reduce of 0,1,0,2 // now it correctly didn't follow through the function again, but moves on to final result. but the finel .reduce should be done on only 0,1
and this is the code :

function pairwise(arr, arg) {
  var remnant = arr,
      pairs = [],
      result = 0;
  if (arr.length<2) return 0;
  //if (arr.length==3) return 1; - this is cheating!
function indexer(remnant) {  
  remnant.map(function(sup,indP) {
    console.log("1checkpoint - 1st .map - indP = " + indP + ", sup = " + sup);
    remnant.map(function(sub,indB) {
      console.log("2checkpoint - indexes are: " + indP + " " + indB + " - different? " + (indP!==indB));

      if (sup+sub==arg &&
          indP!==indB) {
        console.log("3checkpoint - all IF conditions met");
        pairs.push(indP,indB);
        console.log("pushing " + indP + " " + indB);
        delete remnant[indB];
        delete remnant[indP];
        console.log("recursion with " + remnant);
        indexer(remnant);
      }
    });
  });
}
  indexer(remnant);
 console.log("4checkpoint - trying to return .reduce of " + pairs);
  return pairs.reduce(function(a,b) {
    return a+b;
  });
}

pairwise([1, 1, 1], 2);
Jor
@joreyesl
Mar 13 2017 05:14
@105ron you dont pass anything to the callback function yourself, .filter() will pass each element from the array you call it on. In this case you want to call it on collection. Reference the docs for more details on using .fiter(). As for how to use source, you can access it inside the callback function, it will be within scope of the callback function.
Rhys
@105ron
Mar 13 2017 05:16
Of course @joreyesl . I forgot about scopes in JavaScript with a function inside a function. That solves that problem for me. Thank you.
CamperBot
@camperbot
Mar 13 2017 05:16
105ron sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: 105ron already gave joreyesl points
Xavier Corena
@corenaxavier
Mar 13 2017 05:19
Hello all
Question. On challenge "Increment a # with java"
JenimDacket
@JenimDacket
Mar 13 2017 05:19

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i<arr.length; iproduct){
for (var j=0; j<arr[i].length;j
product){console.log(arr[i][j]);}}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Nesting for loops
Xavier Corena
@corenaxavier
Mar 13 2017 05:20
var myVar =87 / I have attempted to add with myVar= i++; but it seems it doesnt work
Any brilliant suggestions?
JenimDacket
@JenimDacket
Mar 13 2017 05:20
I do not understand this at all. Help?
Brian
@BrianCodes33
Mar 13 2017 05:24
you need to loop through outer
than inner
JenimDacket
@JenimDacket
Mar 13 2017 05:24
I don't know what that means
Sergey Lukin
@not-a-cylon
Mar 13 2017 05:25
@corenaxavier u can increment with either myVar++ or myVar+=i depending on what you're trying to accomplish.
JenimDacket
@JenimDacket
Mar 13 2017 05:25
@BrianCodes33 Could you explain the relationship between i and j and then what the inner/outer thing is?
Joseph
@revisualize
Mar 13 2017 05:25

@corenaxavier

var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8

See how the one for getting num from 7 to 8 doesn't use the assignment operator (=)?
The lesson is requesting that you recreate that process so that you know how to increment and decrement a number with short notation.

Brian
@BrianCodes33
Mar 13 2017 05:26
the outer array at i or array[i] is the whole loop
Joseph
@revisualize
Mar 13 2017 05:26
@JenimDacket I can.
Brian
@BrianCodes33
Mar 13 2017 05:26
think of an excel spreadsheet
JenimDacket
@JenimDacket
Mar 13 2017 05:26
<3
@JenimDacket Look at that.. I already wrote it all out.
How thoughtful of me. :P
:sparkles:
:glitter:
put the code in there and see what it does
Joseph
@revisualize
Mar 13 2017 05:28
This message was deleted
:dizzy:
Here's a good one :tada:
:confetti_ball: :tada: :confetti_ball: :tada: :confetti_ball: :tada: :confetti_ball: :tada:
LOL
I'm done.
Jameel Matin
@cutiepatootiebear
Mar 13 2017 05:29
Could anyone help me with this section? Generate Random Fractions with JavaScript

function randomFraction() {

  // Only change code below this line.
    math.random()
  return 0;

  // Only change code above this line.
}
Roy Alnashef
@RoyAlnashef
Mar 13 2017 05:30

@revisualize So, instead of returning based on each card in the sequence, I need to run the function that will run for each card in the sequence, incrementing and decrementing the count variable, and only return once after the last card in the sequence?

@RoyAlnashef You're returning based on the value of the card

JenimDacket
@JenimDacket
Mar 13 2017 05:31
@revisualize This is GENIUS!
@revisualize THANK YOU
CamperBot
@camperbot
Mar 13 2017 05:31
jenimdacket sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3512 | @revisualize |http://www.freecodecamp.com/revisualize
JenimDacket
@JenimDacket
Mar 13 2017 05:31
Also, there is a spelling error on line 41. Just wanted to let you know
badalsaibo
@heyDante
Mar 13 2017 05:32
@yassbetch why returning 0 ?
Joseph
@revisualize
Mar 13 2017 05:33
@JenimDacket Oh?
@JenimDacket Fixed.
Jameel Matin
@cutiepatootiebear
Mar 13 2017 05:33
@heyDante lol thanks!
CamperBot
@camperbot
Mar 13 2017 05:33
yassbetch sends brownie points to @heydante :sparkles: :thumbsup: :sparkles:
:cookie: 570 | @heydante |http://www.freecodecamp.com/heydante
Joseph
@revisualize
Mar 13 2017 05:33
@JenimDacket Thanks.
JenimDacket
@JenimDacket
Mar 13 2017 05:34
@revisualize Glad to give you something in return. =) So, now I understand the fundamentals of what is actually happening here.
can you break down writing the loop within a loop for me, so I can tie it mentally to what is actually occurring
Joseph
@revisualize
Mar 13 2017 05:35
@JenimDacket Sure.
@JenimDacket Here you go: https://goo.gl/eHtg41
@JenimDacket Just slowly click next.
JenimDacket
@JenimDacket
Mar 13 2017 05:39
I GET IT
=D
Rhys
@105ron
Mar 13 2017 05:39
@JenimDacket your movements are being monitored :laughing:
JenimDacket
@JenimDacket
Mar 13 2017 05:40
"i" indicates which array is being selected in the greater object, and then "j" cycles through the actual parameters of each array, automatically pushing back to "i" after each subarray has been fully listed!
Lingo is probably way off, but that is the idea, right?
@revisualize
Jim
@JLOSS1
Mar 13 2017 05:42
Anyone got a second? having trouble with 'using objects for lookups'. I guess i'm just not understanding this. I have // Only change code below this line "alpha": "Adams", "bravo": "Boston", "charlie": "Chicago", "delta": "Denver", "echo": "Easy", "foxtrot": "Frank"; }
Joseph
@revisualize
Mar 13 2017 05:50
@JenimDacket I know. You need to know.
@JLOSS1 I don't understand that line either.
@JLOSS1 Is there more to it?
Jim
@JLOSS1
Mar 13 2017 05:51
my apologies just a sec @revisualize
Shantanu Lawande
@Shantanu337
Mar 13 2017 05:51
@JLOSS1 ..that was a toughie
Jim
@JLOSS1
Mar 13 2017 05:52

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

``` // Only change code below this line
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank";
}

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

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

Joseph
@revisualize
Mar 13 2017 05:52
@JLOSS1 Okay. Your code block doesn't actually do anything.
Jim
@JLOSS1
Mar 13 2017 05:52
@Shantanu337 yeah going on a half hour
Joseph
@revisualize
Mar 13 2017 05:53
@JLOSS1 You're supposed to be creating an object.
@JLOSS1 How do you create an object?
crap. i need to go to bed soon.
Jim
@JLOSS1
Mar 13 2017 05:54
@revisualize so are the integers important? I thought an object was stated using var?
Shantanu Lawande
@Shantanu337
Mar 13 2017 05:54
@JLOSS1 ..i actually came up with a not so elegant approach
result = (val=="bravo")?lookup.bravo:null||
(val=="charlie")?lookup.charlie :null ||(val=="delta")?lookup.delta :null ||
(val=="echo")?lookup.echo :null || (val=="foxtrot")?lookup.foxtrot :null ||
(val=="")?lookup.default :null ||(val =="alpha")?lookup.alpha:null;
Joseph
@revisualize
Mar 13 2017 05:54
@Shantanu337 That's actually the wrong approach.
Jim
@JLOSS1
Mar 13 2017 05:54
hmm...
Shantanu Lawande
@Shantanu337
Mar 13 2017 05:54
@revisualize ..yes i did realized that
Joseph
@revisualize
Mar 13 2017 05:55
@Shantanu337 I mean. It works but damn.
Shantanu Lawande
@Shantanu337
Mar 13 2017 05:55
@revisualize ..yes ...it's not the correct way..but i got stuck for far too long
Joseph
@revisualize
Mar 13 2017 05:56
@JLOSS1 Okay how do you create a basic object?
Jim
@JLOSS1
Mar 13 2017 05:56
@revisualize is that with the if statement/
?
Joseph
@revisualize
Mar 13 2017 05:56
@JLOSS1 No.
f2001340
@f2001340
Mar 13 2017 05:56
@HeebieGeeBee
function palindrome(str) {
  var origStr = str.replace(/[^a-z]/gi,'').toLowerCase();
  var reversedStr = '';
  reversedStr = str.replace(/[^a-z]/gi,'')
    .split('').reverse().join('').toLowerCase();
  return (origStr === reversedStr);
}

palindrome("1 eye for of 1 eye.");
Travis Fry
@definistrate1ster
Mar 13 2017 05:56
Would someone pleeeeeeeaaassse help me? This challenge is driving me crazy. "Convert Celsius to Fahrenheit"
Joseph
@revisualize
Mar 13 2017 05:57
@f2001340 You're supposed to keep the numbers
Roson Tan
@rosontan
Mar 13 2017 05:57

var count = 0;

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

for(i=0;i<card.length;i++){ if (card[i]>=2 && card[i]<=6){
count+=count;
}
else if(card[i]==10 ||card[i]=="J" ||card[i]=="Q"||card[i]=="K"||card[i]=="A"){
count-=count;
}
}
if(count>0){
return count+" Best";
}
else if(count<=0){
return count+" Hold";
}
// Only change code above this line
}

Travis Fry
@definistrate1ster
Mar 13 2017 05:57

function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line


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

// Change the inputs below to test your code
convertToF(30);
Someone please help me to convert Celsius to Farenheit. :(
Joseph
@revisualize
Mar 13 2017 05:57
@rosontan umm... card isn't an array.
Shantanu Lawande
@Shantanu337
Mar 13 2017 05:58
@revisualize ..how should I've solved it? Any suggestion please..
Jim
@JLOSS1
Mar 13 2017 05:58
@revisualize shoot... okay.
I think if I maybe change the variable?
Joseph
@revisualize
Mar 13 2017 05:59
@rosontan Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
f2001340
@f2001340
Mar 13 2017 05:59
@revisualize Thank you very much. I had them before, but removed later !!!! This is the new code and it passes.
function palindrome(str) {
  var origStr = str.replace(/[^a-z0-9]/gi,'').toLowerCase();
  var reversedStr = '';
  reversedStr = str.replace(/[^a-z0-9]/gi,'')
    .split('').reverse().join('').toLowerCase();
  return (origStr === reversedStr);
}

palindrome("1 eye for of 1 eye.");
CamperBot
@camperbot
Mar 13 2017 05:59
f2001340 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3513 | @revisualize |http://www.freecodecamp.com/revisualize
Ivan Korochentsev
@Porock
Mar 13 2017 06:00
@definistrate1ster f =c*1.8+32
Joseph
@revisualize
Mar 13 2017 06:00
@Shantanu337 I'm going to PM you.
Shantanu Lawande
@Shantanu337
Mar 13 2017 06:01
@revisualize Okay.
ShadowKnight
@ShadowKnight00
Mar 13 2017 06:02
@Shantanu337 something like this should work: var myObject = { 'alpha':whatever,'beta':'whateverelse'}; return myObject[val]
f2001340
@f2001340
Mar 13 2017 06:02
@definistrate1ster
fahrenheit = celsius * 9/5 + 32;
Joseph
@revisualize
Mar 13 2017 06:02
@Shantanu337 I only sent it as a PM because I didn't want to disrupt chat. I don't respond to PMs.
Jim
@JLOSS1
Mar 13 2017 06:02
@revisualize @Shantanu337 thanks guys, i think i figured it out after some re reading and back tracking
CamperBot
@camperbot
Mar 13 2017 06:02
jloss1 sends brownie points to @revisualize and @shantanu337 :sparkles: :thumbsup: :sparkles:
:star2: 3514 | @revisualize |http://www.freecodecamp.com/revisualize
:cookie: 248 | @shantanu337 |http://www.freecodecamp.com/shantanu337
Joseph
@revisualize
Mar 13 2017 06:02
@JLOSS1 Here.
How do you modify the variable result? (Simple answer)
How do you access an object property value?
What if you need to access the object property value with a variable?
You need to re-assign the variable result the the object property value of the object that you created lookup. (As per the instructions)
With this code: function phoneticLookup(val) { } you have a function declaration with a function name of phoneticLookup and a parameter val.
When you make the function call: phoneticLookup("charlie"); You are calling the function by name and passing the argument of "charlie" to the function parameter of val as a value.
You'll need to use bracket notation to access your object (lookup) property value. Note: Parameters are used inside of your function just like variables.
You need to assign the value of the object property to the variable result.
Then when your function phoneticLookup returns result it will return the correct object property value.
@JLOSS1 Save that text and reference it.
I need to get to bed.
Jim
@JLOSS1
Mar 13 2017 06:05
@revisualize thanks! alright man, good night!
CamperBot
@camperbot
Mar 13 2017 06:05
jloss1 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: jloss1 already gave revisualize points
Shantanu Lawande
@Shantanu337
Mar 13 2017 06:09
@revisualize Okay. Thanks a lot.
CamperBot
@camperbot
Mar 13 2017 06:09
shantanu337 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3515 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 13 2017 06:10
And.. My beer is done.
It's 11:11pm here in Seattle.
Time for me to hit the :zzz:
Oh, if you're here you should get your free book from https://www.packtpub.com/packt/offers/free-learning
Roy Alnashef
@RoyAlnashef
Mar 13 2017 06:11
Ok. I got the Card Counter code to work the way it should. However, I don't understand how the code knows to run multiple times (for multiple cards) and only returns once. Is there a fundamental idea here that I've missed?
function cc(card) {
  // Only change code below this line

  switch(card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 7:
    case 8:
    case 9:  
    count = count + 0;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break;
  }

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

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Joseph
@revisualize
Mar 13 2017 06:11
@RoyAlnashef Okay ... the ; is a statement terminator.
cc(2); cc(3); cc(7); cc('K'); cc('A'); is actually 5 function calls to cc
Roy Alnashef
@RoyAlnashef
Mar 13 2017 06:12
@revisualize So why aren't there 5 returns?
Joseph
@revisualize
Mar 13 2017 06:13
There are.
Just FCC doesn't really output them based upon the tests.
The FCC webpage is funny. It doesn't do everything it should sometimes.
Roy Alnashef
@RoyAlnashef
Mar 13 2017 06:13
@revisualize How can I see them all?
Joseph
@revisualize
Mar 13 2017 06:14
@RoyAlnashef console.log each of the function calls.
@RoyAlnashef https://repl.it/GSNS/0
Like that.
MrityunjaiMishra
@MrityunjaiMishra
Mar 13 2017 06:15

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


function lookUpProfile(firstName, prop){
// Only change code below this line
var i=0;
  while(i<contacts.length){
    if(contacts[i].hasOwnProperty(prop)){
      if(firstName===contacts[i][prop]){
        return contacts[i][prop];
      }
    }
    i++;
  }

  if(contacts[i].hasOwnProperty(prop)!==true){
    return "No such property";
  }
  else if(firstName!==contacts[i][prop]){
    return "No such contact";
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
i cant figure out whats wrong with my code
Roy Alnashef
@RoyAlnashef
Mar 13 2017 06:16
@revisualize Awesome, thank you
CamperBot
@camperbot
Mar 13 2017 06:16
royalnashef sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3516 | @revisualize |http://www.freecodecamp.com/revisualize
JAY PRAKASH THAKUR
@jay-thakur
Mar 13 2017 06:17
getting correct output but still test case is not passed . why ? var myArray = [];
function reverseString(str) {
for(var i = str.length-1; i >= 0; i--){
myArray.push(str[i]);
}
return myArray.join('');
}
reverseString("hello");
Roy Alnashef
@RoyAlnashef
Mar 13 2017 06:18
@revisualize Just out of curiosity, why doesn't counter return to 0 each time the function runs?
Joseph
@revisualize
Mar 13 2017 06:19
@RoyAlnashef Because FCC doesn't reset globals.
@RoyAlnashef Also, count is a global variable not inside of the function. It isn't reset on each iteration of the function.
@RoyAlnashef If count was inside of the function. It would reset each time the function ran.
...
damn I hope to get a job as a developer one of these days.
Roy Alnashef
@RoyAlnashef
Mar 13 2017 06:21
@revisualize I see. So count = 0 is just a starting point for the first time the function runs
@revisualize lol, I hope you do to brother
Roson Tan
@rosontan
Mar 13 2017 06:24

What's wrong with my answer?

var count = 0;

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

if (card>=2 && card<=6){
count+=count;
}
else if(card==10 ||card=="J" ||card=="Q"||card=="K"||card=="A"){
count-=count;
}

if(count>0){
return count+" Best";
}
else if(count<=0){
return count+" Hold";
}
// Only change code above this line
}

eeflores
@eeflores
Mar 13 2017 06:26
count += count is adding count to itself eg count = count * 2
you're probably looking for count++
and count--
Joseph
@revisualize
Mar 13 2017 06:26
@rosontan You should be just adding or subtacting 1
@eeflores :wave: :bye:
eeflores
@eeflores
Mar 13 2017 06:27
bye @revisualize
Joseph
@revisualize
Mar 13 2017 06:27
:zzz: ... :sailboat: ... :zzz: ... :sailboat: :sunrise: ... :zzz: ... :sailboat: :tropical_fish: :sunrise: ... :zzz: ... :sailboat: :tropical_fish: :dolphin: :whale2: :sunrise: ... :zzz:
eeflores
@eeflores
Mar 13 2017 06:27
:sheep: :sheep: :sheep:
Travis Fry
@definistrate1ster
Mar 13 2017 06:28
Hi. I'm still stuck on "Convert Celsius to Fahrenheit"
I put in the code:
farenheit = celsius * 9/5 +32;
but it doesn't do anything. Could someone please look at my code and tell me what's wrong? Thanks.
```
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line
    farenheit = celsius * 9/5 +32;


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

// Change the inputs below to test your code
convertToF(30);
eeflores
@eeflores
Mar 13 2017 06:29
@definistrate1ster you've got fahrenheit and farenheit
h missing in assignment
Travis Fry
@definistrate1ster
Mar 13 2017 06:31
@eeflores thanks man. i feel like a moron. that fixed everything. :)
CamperBot
@camperbot
Mar 13 2017 06:31
definistrate1ster sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 953 | @eeflores |http://www.freecodecamp.com/eeflores
sakshamsandhu
@sakshamsandhu
Mar 13 2017 06:38
how to assign a to b with =
ShadowKnight
@ShadowKnight00
Mar 13 2017 06:38
a=b
sakshamsandhu
@sakshamsandhu
Mar 13 2017 06:38
?
Joseph
@revisualize
Mar 13 2017 06:38
How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
@sakshamsandhu ^^
@ShadowKnight00 That's backwards. Goof.
ShadowKnight
@ShadowKnight00
Mar 13 2017 06:39
I realized it about the time you posted, so didn't figure it was worth fixing at that point, lol.
sakshamsandhu
@sakshamsandhu
Mar 13 2017 06:40
@ShadowKnight00 how Assign the contents of a to variable b.
Joseph
@revisualize
Mar 13 2017 06:40
@sakshamsandhu Did you not read when I just posted?
ShadowKnight
@ShadowKnight00
Mar 13 2017 06:40
Joseph ( @revisualize ) just explained it pretty well.
sakshamsandhu
@sakshamsandhu
Mar 13 2017 06:40
didn't get
Joseph
@revisualize
Mar 13 2017 06:41
Well.. I should have been in bed 30min ago.
GOODNIGHT!
ShadowKnight
@ShadowKnight00
Mar 13 2017 06:41
Goodnight
@sakshamsandhu Example: To assign 7 to variable x: x=7;
Manish Giri
@Manish-Giri
Mar 13 2017 06:42
@sakshamsandhu variables are assigned values from right to left (kind of), so like var x = 10; puts the value 10 in the variable named x.
MrityunjaiMishra
@MrityunjaiMishra
Mar 13 2017 06:43
how to access an obj in array