8th
Jun 2016
Sophia
@theothersophie
Jun 08 2016 00:00
help
CamperBot
@camperbot
Jun 08 2016 00:00

# CamperBot

### Basic Commands:

• `find TOPIC` find all entries about topic. e.g. `find js`
• `wiki TOPIC` show contents of topic page
• `thanks @username` send brownie points to another user
• `about @username` shows info on that user
• `Algorithm BONFIRENAME` info on a Algorithm

meet CamperBot in

Sophia
@theothersophie
Jun 08 2016 00:00
find js
@vegemouse
Jun 08 2016 00:02
@Chrono79 What in the code is multiplying them then?
``````
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr[i].length; j++) {
product *= arr[i][j];

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);``````
here’s my code again...
Diego Mayer
@Chrono79
Jun 08 2016 00:03
@vegemouse product = product * arr [i][j]; is the same as
product *= arr [i][j];
@vegemouse
Jun 08 2016 00:04
okay. so the for statements are pretty much only used to access the numbers then right?
Diego Mayer
@Chrono79
Jun 08 2016 00:04
@vegemouse in this case, yes
@vegemouse
Jun 08 2016 00:04
okay that makes sense. thank you @Chrono79 for your help with this
CamperBot
@camperbot
Jun 08 2016 00:04
vegemouse sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1079 | @chrono79 |http://www.freecodecamp.com/chrono79
Sophia
@theothersophie
Jun 08 2016 00:05
guys im on find the longest word in a string
@vegemouse
Jun 08 2016 00:05
@theothersophie whats your code look like?
Sophia
@theothersophie
Jun 08 2016 00:05

function findLongestWord(str) {
var longWord=0;
var words = str.split(' ');

for (var i=0;i<words.length;i++) { if (words[i].length>longWord) {
longWord = words[i].length;

``} ``

}
return longWord.length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");

Andrew Weld
@Andrew-Weld
Jun 08 2016 00:06

Hey everyone! I'm working on a project with these instructions:

Create a function called whichChild that takes one paramater: a child's name.
When passed in 'Dave' return 'Oldest'
When passed in 'Michelle' return 'Middle'
When given any other value return 'Not my kid!"

Here's my code for it:
var whichChild = function (name) {
return "Dave"
return "Michelle"

if (whichChild = "Dave")
{
console.log("Oldest");
}
if (whichChild = "Michelle")
{
console.log("Middle");
else
{
console.log("Not my kid!")
}
}

code pen doesn't exactly tell me

Sophia
@theothersophie
Jun 08 2016 00:06
eh how do i format it to look like code
Diego Mayer
@Chrono79
Jun 08 2016 00:06
help format
CamperBot
@camperbot
Jun 08 2016 00:06

# Multi line Code

```js ⇦ Type 3 backticks and then press `[shift + enter ⏎]` (type js or html or css)

``````<paste your code here>,
then press [shift + enter ⏎]``````

``` ⇦ Type 3 backticks, then press `[enter ⏎]`

# Single line Code

This an inline ``<paste code here>`` code formatting with a single backtick(`) at _start_ and _end_ around the`code`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

chegnar
@chegnar
Jun 08 2016 00:06
Hey guys I am still stuck on the Basic Javascript challenge called "Word Blanks". Can somebody please assist me with what I should do
Diego Mayer
@Chrono79
Jun 08 2016 00:07
@theothersophie you have to return longWord, it's a number so .length is not right
Moisés Man
@moigithub
Jun 08 2016 00:07
@Cameron-Burkholder problem with MUTATING the array u iterate is.. while u removing elements ur indice keep increasing.. (it dont reset) soo.. it skip elements
Diego Mayer
@Chrono79
Jun 08 2016 00:08
Review this challenge too: https://www.freecodecamp.com/challenges/constructing-strings-with-variables
Sophia
@theothersophie
Jun 08 2016 00:08
thanks @Chrono79
CamperBot
@camperbot
Jun 08 2016 00:08
theothersophie sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1080 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 08 2016 00:09
@theothersophie that's how you format the code :point_up: 7 de junio de 2016 21:06
Sophia
@theothersophie
Jun 08 2016 00:09
ah i meant in the chat
Diego Mayer
@Chrono79
Jun 08 2016 00:09
I meant that too
Sophia
@theothersophie
Jun 08 2016 00:10
orly
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:10
@theothersophie @Chrono79 ```var whichChild = function (name) { return "Dave" return "Michelle" if (whichChild = "Dave") { console.log("Oldest"); } if (whichChild = "Michelle") { console.log("Middle"); else { console.log("Not my kid!") } }```
Sophia
@theothersophie
Jun 08 2016 00:10
'''
dfsfsdf
'''
CamperBot
@camperbot
Jun 08 2016 00:10
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:10
dangit i tried
Sophia
@theothersophie
Jun 08 2016 00:10
wtf is backticks
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:10
hang on
Diego Mayer
@Chrono79
Jun 08 2016 00:10
@Andrew-Weld use the ```instead of single backticks
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:11
``var whichChild = function (name) { return "Dave" return "Michelle" if (whichChild = "Dave") { console.log("Oldest"); } if (whichChild = "Michelle") { console.log("Middle"); else { console.log("Not my kid!") } }``
Sophia
@theothersophie
Jun 08 2016 00:11
``fdafsdfafadf``
Diego Mayer
@Chrono79
Jun 08 2016 00:11
:clap:
E-Tank
@E-Tank
Jun 08 2016 00:12
Hello all. Working on Return Largest Number in Arrays and found a function I was trying to use to complete it with a simpler code. Unfortunately either I'm screwing it up, as usual, or I'm not supposed to use this function yet, so it doesn't work.
Sophia
@theothersophie
Jun 08 2016 00:12
yay
E-Tank
@E-Tank
Jun 08 2016 00:12
``````function largestOfFour(arr) {
// You can do this!
var bigNumbers = [];
for(var i = 0; i < arr.length; i++){
for(var x = 0; x < i.length; x++){
bigNumbers.push(Math.max(x));
}
}
return bigNumbers;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);``````
Diego Mayer
@Chrono79
Jun 08 2016 00:13
@E-Tank x is a single number, Math.max will return the same number. You'll end up with a single 1d array
i.length <- ?
Riston Denaux
@ToccataN
Jun 08 2016 00:13
when I manually input the numbers for the index, it works, but in the iteration its like it gets stuck
Moisés Man
@moigithub
Jun 08 2016 00:14

@Cameron-Burkholder adding a -- to ur indice will fix

`````` if (waters[j] == .....// waters uses j indice
waters.splice(j, 1);
j--;   // fix the indice... wonders if this is bad practice :P``````

another way to do the exercise is filter + indexOf

E-Tank
@E-Tank
Jun 08 2016 00:14
Ah, yeah. I was worried it wouldn't know to find the maximum of the array, instead requiring the arguments.
Moisés Man
@moigithub
Jun 08 2016 00:14
@E-Tank if u use math.max u only need 1 looop
Andrew Schmidthuber
@calicode
Jun 08 2016 00:15
@E-Tank also you are not checking the array elements themselves, just the iterator variable x
Moisés Man
@moigithub
Jun 08 2016 00:15
Math.max(4, 5, 1, 3) --- return 5
E-Tank
@E-Tank
Jun 08 2016 00:15
Ah.
I should do arr.[x]?
Chris Cullen
@123xylem
Jun 08 2016 00:15
``````
``````
``````
function convertHTML(str) {
str=str.split("");

for(i=0;i<str.length;i++)

{switch(str) {

case  "&" :

str[i]= "&amp;";
break;

case  "<":
str[i]= "&lt;";
break;

case ">":
str[i]= "&gt;";
break;

}
}
// &colon;&rpar;
return str;
}

convertHTML("Dolce & Gabbana");``````
ANy idea why this switch doesnt work with &
?
Moisés Man
@moigithub
Jun 08 2016 00:16
@123xylem switch(str) { <---
str is "Dolce & Gabbana"
Chris Cullen
@123xylem
Jun 08 2016 00:16
Moisés Man
@moigithub
Jun 08 2016 00:16
probably u mean str[i] whch is a single character (not the whole string)
Chris Cullen
@123xylem
Jun 08 2016 00:16
ahh
E-Tank
@E-Tank
Jun 08 2016 00:16
Well, I removed the x, and now it just gives me 0, 1, 2, 3.
Presumably because it's counting how many subarrays are in Arr
Chris Cullen
@123xylem
Jun 08 2016 00:17
@moigithub la genius... thanks
CamperBot
@camperbot
Jun 08 2016 00:17
123xylem sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1382 | @moigithub |http://www.freecodecamp.com/moigithub
Diego Mayer
@Chrono79
Jun 08 2016 00:17
@moigithub he used split, but he needs to use an index
E-Tank
@E-Tank
Jun 08 2016 00:17
One second, going to refresh this window. It's having weird lag.
There we go
much better
Andrew Schmidthuber
@calicode
Jun 08 2016 00:18
arr[x] arrays use bracket notation
E-Tank
@E-Tank
Jun 08 2016 00:18
``````unction largestOfFour(arr) {
// You can do this!
var bigNumbers = [];
for(var i = 0; i < arr.length; i++){
bigNumbers.push(Math.max(arr[i]));
}

return bigNumbers;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);``````
returns [null, null, null, null]
Diego Mayer
@Chrono79
Jun 08 2016 00:19
@E-Tank the argument of Math.max is a serie of numbers, comma separated, you can use it with arrays but with some weird notation
skipperhi
@skipperhi
Jun 08 2016 00:20
For the checking palindromes challenge, how do I ignore all non-alphanumeric characters?
E-Tank
@E-Tank
Jun 08 2016 00:20
So it wouldn't work with an array at all?
Andrew Schmidthuber
@calicode
Jun 08 2016 00:20
you can do it using a spread operator
chegnar
@chegnar
Jun 08 2016 00:21
@Chrono79 I have read it several times. I know what the game entails but I do not know what my assignment for the sentence should be if i should use "result =" or if I should use "myResult" or "myString" . I am genuinely stuck
E-Tank
@E-Tank
Jun 08 2016 00:21
Alright.
Andrew Schmidthuber
@calicode
Jun 08 2016 00:21
you can also do this challenge without Math.max, just keep track of the largest number found in each array
Diego Mayer
@Chrono79
Jun 08 2016 00:21
@chegnar result = ... is ok, it's what the function is returning after all
@E-Tank like this: Math.max.apply( Math, array );
E-Tank
@E-Tank
Jun 08 2016 00:23
``````
function largestOfFour(arr) {
// You can do this!
var bigNumbers = [];
for(var i = 0; i < arr.length; i++){
bigNumbers.push(Math.max(Math, arr));
}

return bigNumbers;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);``````
Returns Null, null, null, null.
Moisés Man
@moigithub
Jun 08 2016 00:23
apply u forgot
Riston Denaux
@ToccataN
Jun 08 2016 00:24
``````function permAlone(str) {
var a = str.split("");
var array =[];
//swap function
var swap = function(arr, i, j){
var m= arr;
var c= m[j];
m[j]= m[i];
m[i]=c;
return m;
};
//length variable for iteration
var len = a.length;
//nested for-loops
for (var i=0;i< len; i++){
for (var j=0; j<len; j++){
//should push different variations to array
array.push(swap(a, 0, 1));
return array;
}

}
//should return an array containing nine different permutations

}

permAlone('aab');``````
David
@doyon6578
Jun 08 2016 00:24
how do you post your code here?
E-Tank
@E-Tank
Jun 08 2016 00:24
Okay, altered it to Math.max.apply(Math, arr)) and get the same response.
You use the Tilde key and shift.
Erm
without shift.
Moisés Man
@moigithub
Jun 08 2016 00:24
arr[i]
E-Tank
@E-Tank
Jun 08 2016 00:25
Thank you @moigithub , that one has been giving me fits for a while. I'm close to just giving up and resigning myself to the fact that I'm too stupid to code.
CamperBot
@camperbot
Jun 08 2016 00:25
e-tank sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1383 | @moigithub |http://www.freecodecamp.com/moigithub
Diego Mayer
@Chrono79
Jun 08 2016 00:25
@E-Tank
``````function largestOfFour(arr) {
// You can do this!
var bigNumbers = [];
for(var i = 0; i < arr.length; i++){
bigNumbers.push(Math.max.apply(Math, arr[i]));
}

return bigNumbers;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);``````
Riston Denaux
@ToccataN
Jun 08 2016 00:25
yes, the return array is currently not in the right position, I am using it to test.
Moisés Man
@moigithub
Jun 08 2016 00:25
arr is this `[[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]`
arr[i] is a single sub array `[4, 5, 1, 3]`
skipperhi
@skipperhi
Jun 08 2016 00:25
Can anyone tell me how I can ignore non-alphanumeric characters???
E-Tank
@E-Tank
Jun 08 2016 00:25
Regex
Luis Carlos Garcia Barajas
@Luiko
Jun 08 2016 00:26
@doyon6578 (Ctrl + shift + m) for markdow help
Riston Denaux
@ToccataN
Jun 08 2016 00:26
/[^a-zA-Z0-9]/g, ""
@skipperhi
str.replace(/[^a-zA-Z0-9]/g, "")
skipperhi
@skipperhi
Jun 08 2016 00:27
@ToccataN Kinda confusing, lol, but thanks!
CamperBot
@camperbot
Jun 08 2016 00:27
skipperhi sends brownie points to @toccatan :sparkles: :thumbsup: :sparkles:
Riston Denaux
@ToccataN
Jun 08 2016 00:28
np man
I have that memorized by now, lol it comes in handy
chegnar
@chegnar
Jun 08 2016 00:28
@Chrono79 hey man I have it like this, and its still failing. What could be the problem here? result = "I chased my" + myAdjective + "beautiful" + myNoun + "as he" + myVerb + "very" + myAdverb + "after the cat";
Diego Mayer
@Chrono79
Jun 08 2016 00:29
@chegnar spaces between words missing
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:29
Looking any better?
``````var whichChild = function (name) {
return "Middle"
return "Oldest"

if (name="Dave") {
console.log("Oldest");
}
if (name="Michelle") {
console.log("Middle");
}
else {
console.log("Not my kid!");
}

};``````
Diego Mayer
@Chrono79
Jun 08 2016 00:30
@Andrew-Weld if your first line is return something, the rest is never read
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:30
would i seperate with comma's then?
eeflores
@eeflores
Jun 08 2016 00:30
use `===` for comparison
chegnar
@chegnar
Jun 08 2016 00:31
@Chrono79 Sill nothing :/
eeflores
@eeflores
Jun 08 2016 00:31
the `whichChild` function will return at the first statement
Diego Mayer
@Chrono79
Jun 08 2016 00:32
@chegnar it should be like this:
`result = "I chased my " + myAdjective + " beautiful " + myNoun + " as he " + myVerb + " very " + myAdverb + " after the cat";`
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:32
@eeflores not quite sure what you mean
Stephen
@stephepush
Jun 08 2016 00:32
This is for the truncate string algo. It passes all of the tests except for the last one:
``truncateString("Absolutely Longer", 2) should return "Ab...".``
``````function truncateString(str, num) {
// Clear out that junk in your trunk
if (str.length>num && str.length>3){
str = str.slice(0, num-3) + "...";
} else if (num <= 3) {
str = str.slice(0, num) + "...";
//} else if (num <= 3 && num === 2) {
//str = str.slice(0, 2) + "...";
}
return str;
}

Andrew Weld
@Andrew-Weld
Jun 08 2016 00:33
do the if statements need to be `if(whichChild==="Dave")`
chegnar
@chegnar
Jun 08 2016 00:33
@Chrono79 yes, that's what I changed it to =)
eeflores
@eeflores
Jun 08 2016 00:33
@Andrew-Weld the first line after the declaration of `var whichChild = function(name)` is `return "Middle"` which means that nothing else in the function will be run
Diego Mayer
@Chrono79
Jun 08 2016 00:34
@chegnar did it work?
chegnar
@chegnar
Jun 08 2016 00:34
@Chrono79 Nope
eeflores
@eeflores
Jun 08 2016 00:34
@Andrew-Weld that's correct about the `if` statement
Diego Mayer
@Chrono79
Jun 08 2016 00:34
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:34
@eeflores okay should I then delete all the returns under `var whichChild = function (name)`
William Coleman
@wcski
Jun 08 2016 00:35
Trying to debug my solution to the Make Object Properties Private challenge
eeflores
@eeflores
Jun 08 2016 00:35
@Andrew-Weld yes, I think so
William Coleman
@wcski
Jun 08 2016 00:35
``````var Bike = function() {

// Only change code below this line.
var gear = 1;

this.getGear = function() {
return gear;
};

this.setGear = function(change) {
if (gear < change) {
gear += change;
} else if (gear > change){
gear -= change;
}
};
};``````
I know the else if is unnecessary and i could just use else there
eeflores
@eeflores
Jun 08 2016 00:36
@wcski I think in the setGear function you just assign change to gear
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:36
@eeflores this is what i'm getting ```Function returned undefined instead of Oldest when passed "Dave"```
William Coleman
@wcski
Jun 08 2016 00:36
but something else is wrong
ohhh
Diego Mayer
@Chrono79
Jun 08 2016 00:36
@chegnar or copy that, refresh your browser, reset and try again, because I've tried with that and it worked
William Coleman
@wcski
Jun 08 2016 00:36
that's much more simple
eeflores
@eeflores
Jun 08 2016 00:36
@Andrew-Weld change the `console.log` to `return`
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:37
full code
``````var whichChild = function (name) {

if (whichChild==="Dave") {
console.log("Oldest");
}
if (whichChild==="Michelle") {
console.log("Middle");
}
else {
console.log("Not my kid!");
}

};``````
skipperhi
@skipperhi
Jun 08 2016 00:37
Can someone tell me why my palindrome code isn't working?
``````function palindrome(str) {
str.replace(/[^a-zA-Z0-9]/g,"");
var palin = str.toLowerCase().split("").reverse().join();

if (palin === str) {
return true;
} else if (pal !== str) {
return false;
}
}``````
eeflores
@eeflores
Jun 08 2016 00:37
@Andrew-Weld yep, change the `console.log("txt");` to `return "txt";` (as an example)
@vegemouse
Jun 08 2016 00:38
Can anyone give me a hand with the Profile loopup challenge? I almost got it…
``````
//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
for (i = 0; i < contacts.length; i++) {      // Runs through contacts
if (firstName == contacts[i].firstName) {  // Checks if firstName is contact's first name
if (contacts[i].hasOwnProperty(prop) === true) { // checks if prop is an actual property
return contacts[i][prop];   // if it is actual property, return it
} else return "No such property"; // if it is not an actual property, return "no such property"
} else return "No such contact";  // if it is not a contact, return "No such contact"
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");``````
I’m returning “No such contact”
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:39
@eeflores `Unexpected token return`
eeflores
@eeflores
Jun 08 2016 00:39
@Andrew-Weld code now?
skipperhi
@skipperhi
Jun 08 2016 00:40
eeflores
@eeflores
Jun 08 2016 00:40
@vegemouse there are instances where you'll need to iterate through the whole array
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:40
@eeflores
``````var whichChild = function (name) {

if (whichChild==="Dave") {
console.log(return "Oldest");
}
if (whichChild==="Michelle") {
console.log(return "Middle");
}
else {
console.log(return "Not my kid!");
}

};``````
Yi
@ycoding007
Jun 08 2016 00:40
hey, everyone, I have a question about the challenge 236 profile lookup....why I CANNOT combine two conditions together?
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i<contacts.length; i+=1) {
if (contacts[i].firstName===firstName && contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
else {
return "No such contact";
}
}
@vegemouse
Jun 08 2016 00:41
@eeflores i’m not sure i understand
Diego Mayer
@Chrono79
Jun 08 2016 00:41
@vegemouse No such contact should be returned after you've checked all the contact list
eeflores
@eeflores
Jun 08 2016 00:41
@vegemouse you should only return "No such contact" if the contact is not in the array
@Andrew-Weld eg `return "Oldest";`
@Andrew-Weld no `console.log`
Diego Mayer
@Chrono79
Jun 08 2016 00:42
@skipperhi you have to lowercase str too, and the join needs a param (the same as split uses)
@vegemouse
Jun 08 2016 00:43
@eeflores how would i check that? Isn’t that what the
`if (firstName == contacts[i].firstName) { // Checks if firstName is contact's first name` is doing?
eeflores
@eeflores
Jun 08 2016 00:43
@skipperhi str may still have upper case chars in it, palin is all lowercase
Diego Mayer
@Chrono79
Jun 08 2016 00:43
@ycoding007 you can, but you have to repeat one in another if
skipperhi
@skipperhi
Jun 08 2016 00:43
@Chrono79 @eeflores Thanks guys
CamperBot
@camperbot
Jun 08 2016 00:43
skipperhi sends brownie points to @chrono79 and @eeflores :sparkles: :thumbsup: :sparkles:
:star2: 1081 | @chrono79 |http://www.freecodecamp.com/chrono79
eeflores
@eeflores
Jun 08 2016 00:43
@vegemouse put `No such contact` outside the for loop
Syntax Ninja
@SyntaxNinjas
Jun 08 2016 00:44
Hello Helpjavascript can I post a problem I am having issues with? Anyone wanna help please mention me and we can look at it together
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:44

@eeflores okay, full code

``````var whichChild = function (name) {

if (whichChild==="Dave") {
return "Oldest"
}
if (whichChild==="Michelle") {
return "Middle"
}
else {
return "Not my kid!"
}

};``````

and i'm getting

``````Function returned
Not my kid!
Oldest
when passed
"Dave"``````
eeflores
@eeflores
Jun 08 2016 00:44
@Andrew-Weld `if(name ==== "Dave") {`
Diego Mayer
@Chrono79
Jun 08 2016 00:45
Andrew Weld
@Andrew-Weld
Jun 08 2016 00:45
@eeflores that's exactly right! tried that just before you chimed in. thank you so much for taking the time =)
CamperBot
@camperbot
Jun 08 2016 00:45
andrew-weld sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
eeflores
@eeflores
Jun 08 2016 00:45
well done @Andrew-Weld
Yi
@ycoding007
Jun 08 2016 00:45
@Chrono79 , hi, Diego, could you provide more detail, thank you
CamperBot
@camperbot
Jun 08 2016 00:45
ycoding007 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1082 | @chrono79 |http://www.freecodecamp.com/chrono79
@vegemouse
Jun 08 2016 00:47
``````
function lookUpProfile(firstName, prop){
// Only change code below this line
if (firstName == contacts[i].firstName) {  // Checks if firstName is contact's first name
for (i = 0; i < contacts.length; i++) {      // Runs through contacts
if (contacts[i].hasOwnProperty(prop) === true) { // checks if prop is an actual property
return contacts[i][prop];   // if it is actual property, return it
} else return "No such property"; // if it is not an actual property, return "no such property"
}
} else return "No such contact";  // if it is not a contact, return "No such contact"

// Only change code above this line
}``````
like this?
eeflores
@eeflores
Jun 08 2016 00:48
@vegemouse the for loop is typically the outer most block
``````for()
{
if() ...
}
return "No such contact";``````
Diego Mayer
@Chrono79
Jun 08 2016 00:49
@ycoding007 yes, in your first if, you can put both conditions, but in the else (or another if) you have to check for firstName again
Riston Denaux
@ToccataN
Jun 08 2016 00:50
``````function permAlone(str) {
var a = str.split("");
var array =[];
//swap function
var swap = function(arr, i, j){
var m= arr;
var c= m[j];
m[j]= m[i];
m[i]=c;
return m;
};
//length variable for iteration
var len = a.length;
//nested for-loops
for (var i=0;i< len; i++){
for (var j=0; j<len; j++){
//should push different variations to array
array.push(swap(a, i,j));
}
}
//should return an array containing nine different permutations
return array;

}

permAlone('aab');``````
@vegemouse
Jun 08 2016 00:50
Ohh why does it go outside of the for loop then?
eeflores
@eeflores
Jun 08 2016 00:50
@vegemouse you will want to compare `firstName` against each element in `contacts` which you would do with a for loop
@vegemouse
Jun 08 2016 00:51
Ohh so you don’t need the for loop if the contact doesnt exist correct?
Riston Denaux
@ToccataN
Jun 08 2016 00:51
ok, i really have no idea why this is only producing one version of permutation. Is the for-loop somehow affecting the data structure of the array?
bitgrower
@bitgrower
Jun 08 2016 00:52
@vegemouse -- no, you need the for loop to determine if the contact doesn't exist ...
@vegemouse
Jun 08 2016 00:52
then why do i return “contact does not exist” outside of the for loop?
eeflores
@eeflores
Jun 08 2016 00:52
@vegemouse you use the for loop to compare `firstName` against each contacts.firstName:
``````for (var i = 0; i < contacts.length; i++) {
if(firstName === contacts[i].firstName) {
}
}``````
Diego Mayer
@Chrono79
Jun 08 2016 00:53
@vegemouse because you have to go through the full list before you can say the contact doesn't exist
bitgrower
@bitgrower
Jun 08 2016 00:53
@vegemouse -- because you have to check each element of your array to see if that is the contact ... only after you check EACH one do you know the contact doesn't exist ...
@vegemouse
Jun 08 2016 00:53
okay now thats starting to make sense. thanks so much @Chrono79 @bitgrower @eeflores
CamperBot
@camperbot
Jun 08 2016 00:53
:warning: vegemouse already gave chrono79 points
vegemouse sends brownie points to @chrono79 and @bitgrower and @eeflores :sparkles: :thumbsup: :sparkles:
:star2: 1088 | @bitgrower |http://www.freecodecamp.com/bitgrower
Wendy Medeiros
@wendyr21
Jun 08 2016 00:56
He
Help mutation
CamperBot
@camperbot
Jun 08 2016 00:56

# Algorithm Mutations

### Problem Explanation:

• Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
Yi
@ycoding007
Jun 08 2016 00:58
@Chrono79 , i modified in this way, but still doesnt work T_T...
``````function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i<contacts.length; i+=1) {
if (contacts[i].firstName===firstName && contacts[i].hasOwnProperty(prop)===true) {
return contacts[i][prop];
}
else if ((contacts[i].firstName!==firstName || contacts[i].hasOwnProperty(prop)===false)){
return "No such contact";
}
}``````
Diego Mayer
@Chrono79
Jun 08 2016 01:01
@ycoding007 this condition should be the same: contacts[i].firstName===firstName
and the return isn't right, you should return there "No such property"
For where you should return No such contact, read this: :point_up: 7 de junio de 2016 21:41and below
Andrew Weld
@Andrew-Weld
Jun 08 2016 01:03

next challenge: ```
Create a function called sum that returns the sum of two numbers passed in as parameters

``````
``````

var sum = function(number) {
return number + number;
};

number(2,3);
```

``````var sum = function(number) {
return number + number;
};

number(2,3);``````
efeselgr
@efeselgr
Jun 08 2016 01:03
I am stuck at Counting Cards problem,i don't understand what it wants from me,my code is currently
``````
var count = 0;

function cc(card) {
// Only change code below this line
if(card<7&&card>1){
count += count;
}
else if(card ===10 || card=="J"|| card=="K"|| card=="Q"|| card=="A"){

count -=count;
}

// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');``````
Diego Mayer
@Chrono79
Jun 08 2016 01:04
@efeselgr you have to evaluate count following the instructions and return accordingly
efeselgr
@efeselgr
Jun 08 2016 01:05
@Chrono79 what i understand is,it wants to call the function 5 times,and only return once.
@Chrono79 do i get it right?should i set a counter for it?
tron04
@tron04
Jun 08 2016 01:06
@efeselgr try using count++; and count--;
kunno
@kunno
Jun 08 2016 01:06
Hi everyone
efeselgr
@efeselgr
Jun 08 2016 01:06
@tron04 thanks but i don't care about those right now
CamperBot
@camperbot
Jun 08 2016 01:06
efeselgr sends brownie points to @tron04 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for tron04
kunno
@kunno
Jun 08 2016 01:07
I need help with the Stand in Line challenge
my question is as follows: Why should the condition nextInLine([], 1) return 1 shouldn't it return null since nothing was removed to begin with?
efeselgr
@efeselgr
Jun 08 2016 01:08
ah i get it now
it returns 5 times only last return is what matters
pretty easy then
Thomas Nguyen
@thomasnguyen
Jun 08 2016 01:09
``````\$("#tres").click(function(){

for (var x = 0 ; x > itemsPerPage; x++){
\$('#one').append('magicNum');
}
});``````
its perfectly ok to use a for loop in jQuery right?
tron04
@tron04
Jun 08 2016 01:09
@efeselgr you have to return the count + a string
efeselgr
@efeselgr
Jun 08 2016 01:09
@tron04 very informative thank you tron
CamperBot
@camperbot
Jun 08 2016 01:09
efeselgr sends brownie points to @tron04 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for tron04
efeselgr
@efeselgr
Jun 08 2016 01:10
@tron04 i don't know if you are trying to be helpful but i am aware about that too
tron04
@tron04
Jun 08 2016 01:10
@betamedium
Jun 08 2016 01:10

// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "" && prop !== "tracks") {
collection[id][prop] = value;
} if (prop == "tracks" && value !== "") {
collection[id].tracks.push(value);
} if (value === "") {
delete collection[id][prop];
}
return collection;
}

// Alter values below to test your code
updateRecords(5439, "tracks", "Take a Chance on Me");

efeselgr
@efeselgr
Jun 08 2016 01:10
@tron04 nothing nailed it
@betamedium
Jun 08 2016 01:10
whats the best way to paste code here?
Diego Mayer
@Chrono79
Jun 08 2016 01:11
@efeselgr make a separate if block where you evaluate count value and return count + something or count + another thing
efeselgr
@efeselgr
Jun 08 2016 01:11
@tron04 forgot a space before string
tron04
@tron04
Jun 08 2016 01:11
ok cool :+1:
kunno
@kunno
Jun 08 2016 01:11
@tron04 would you mind helping me?
tron04
@tron04
Jun 08 2016 01:11
I found it much easier using switch for card counting
rather than a bunch of or's
efeselgr
@efeselgr
Jun 08 2016 01:12
@tron04 watch my code and say it again
``````
var count = 0;

function cc(card) {
// Only change code below this line
if(card<7&&card>1){
count++;
}
else if(card ===10 || card=="J"|| card=="K"|| card=="Q"|| card=="A"){

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

// Note: Only the last will display
cc(2); cc(3); cc(7); cc(3); cc('A');``````
Diego Mayer
@Chrono79
Jun 08 2016 01:12
@betamedium edit your post and add ``` before and after the code in a line where the backticks are the only thing in the line
tron04
@tron04
Jun 08 2016 01:12
@efeselgr pretty clean
@betamedium
Jun 08 2016 01:13
@Chrono79 thanks
CamperBot
@camperbot
Jun 08 2016 01:13
betamedium sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1083 | @chrono79 |http://www.freecodecamp.com/chrono79
tron04
@tron04
Jun 08 2016 01:13
@kunno
what do you need help with
Diego Mayer
@Chrono79
Jun 08 2016 01:13
@betamedium no problem, another thing, there is a case that won't work with your code, read the error, look at that object and compare it with the others
kunno
@kunno
Jun 08 2016 01:14
@tron04 the Stand in Line challenge
@tron04 for the first condition it says nextInLine([], 1) should return 1 but shouldn't it return null since the array was empty to begin with
@betamedium
Jun 08 2016 01:15
@Chrono79 yep…im getting a typeError: Cannot read property ‘push’ of undefined
Diego Mayer
@Chrono79
Jun 08 2016 01:15
@kunno order matters, first you add, then you remove
Thomas Nguyen
@thomasnguyen
Jun 08 2016 01:15
``````\$("#tres").click(function(){

for (var x = 0 ; x > itemsPerPage; x++){
\$('#one').append('magicNum');
}
});``````
is there a reason why this doesn't work
efeselgr
@efeselgr
Jun 08 2016 01:16
@toshiru `<`
@toshiru goes on and on keeps incrementing
@toshiru `x < itemsPerPage;`is what you intended i am guessing
Syntax Ninja
@SyntaxNinjas
Jun 08 2016 01:17
@Chrono79 I am trying to solve a problem off coderbyte. I am supposed to write a function that upon being called outputs the value of a factorial
kunno
@kunno
Jun 08 2016 01:17
@Chrono79 that's what I did. I pushed item into the array and then returned splice if array length > 1
@betamedium
Jun 08 2016 01:17
``````// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "" && prop !== "tracks") {
collection[id][prop] = value;
} if (prop == "tracks" && value !== "") {
collection[id].tracks.push(value);
} if (value === "") {
delete collection[id][prop];
}
return collection;
}

// Alter values below to test your code
updateRecords(5439, "tracks", "Take a Chance on Me");``````
Could someone help me out with this? Totaly lost…
Norman Dela Cruz
@dcnr
Jun 08 2016 01:17
oh Stand In Line got renamed!
Syntax Ninja
@SyntaxNinjas
Jun 08 2016 01:18
@Chrono79 Here is the code I wrote on JS bin
tron04
@tron04
Jun 08 2016 01:18
@kunno no need for an if statement, you can use shift()
Diego Mayer
@Chrono79
Jun 08 2016 01:18
@kunno well, no need for the length check, but fine, you add 1 to an empty array, the array becomes `[1]`, then you use shift and the returned value is 1
Syntax Ninja
@SyntaxNinjas
Jun 08 2016 01:18
If you could give some tips on how to approach this I would be eternally grateful
@Chrono79 If you could give some tips on how to approach this I would be eternally grateful
kunno
@kunno
Jun 08 2016 01:20
@tron04 @Chrono79 thank you! I forgot about shift
CamperBot
@camperbot
Jun 08 2016 01:20
kunno sends brownie points to @tron04 and @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for tron04
:star2: 1084 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 08 2016 01:20
@SyntaxNinjas here in fcc you have a challenge that is making a factorial function
Yi
@ycoding007
Jun 08 2016 01:21
@Chrono79 finally. working..........one more question, right after the 2nd elseif, why i cannot write else {return No such contact}, it won't work out..
``````function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i<contacts.length; i+=1) {

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

}
return "No such contact";

// Only change code above this line
}``````
Thomas Nguyen
@thomasnguyen
Jun 08 2016 01:21
@efeselgr thanks you are right
CamperBot
@camperbot
Jun 08 2016 01:21
toshiru sends brownie points to @efeselgr :sparkles: :thumbsup: :sparkles:
efeselgr
@efeselgr
Jun 08 2016 01:21
Diego Mayer
@Chrono79
Jun 08 2016 01:22
@ycoding007 :point_up: 7 de junio de 2016 21:53
tron04
@tron04
Jun 08 2016 01:24
@ycoding007 it will terminate the function function and not move to the next contact[i]
Yi
@ycoding007
Jun 08 2016 01:24
@Chrono79 : thank you very very much, now i understand, one last question before i move on :), why i have to write contacts[i][prop], but NOT contacts[i].prop, from the previous lessons, i learned that if the property name has no space, we can use dot to access the property
CamperBot
@camperbot
Jun 08 2016 01:24
ycoding007 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: ycoding007 already gave chrono79 points
Diego Mayer
@Chrono79
Jun 08 2016 01:25
@ycoding007 using a var as property name also requires bracket notation, after all, the var contains a string
efeselgr
@efeselgr
Jun 08 2016 01:25
@ycoding007 thanks
CamperBot
@camperbot
Jun 08 2016 01:25
efeselgr sends brownie points to @ycoding007 :sparkles: :thumbsup: :sparkles:
Yi
@ycoding007
Jun 08 2016 01:26
@efeselgr not a problem
@Chrono79 you know, initially i thought about nesting two if together, but i didn't.... so how to tell which way is the best?
Diego Mayer
@Chrono79
Jun 08 2016 01:27
I prefer the nested, less writing
Yi
@ycoding007
Jun 08 2016 01:28
@Chrono79 obviously the nesting has fewer code, but in the future, when i am faced a problem, how do i quickly tell "yaaa, i should use nesting"
Diego Mayer
@Chrono79
Jun 08 2016 01:29
when you need the same condition in more than one if, nesting is natural
Yi
@ycoding007
Jun 08 2016 01:30
@Chrono79 got it!!
owenkosnen
@owenkosnen
Jun 08 2016 01:30
Hi, I need some help for "Escape Sequences in Strings" challenge
I don't understand what is the task
Diego Mayer
@Chrono79
Jun 08 2016 01:31
wiki Escape Sequences in Strings
CamperBot
@camperbot
Jun 08 2016 01:31

# Challenge Escape Sequences in Strings

Quotes are not the only characters that can be escaped inside a string. Here is a table of common escape sequences:

Code Output
\' single quote
\" double quote
\ backslash
\n new line
\r carriage return
\t tab
\b backspace
\f form feed

Note that the backslash itself must be escaped in order to display as a backslash.

binalfew mecuriaw
@bmecuria
Jun 08 2016 01:31
@owenkosnen paste the question
efeselgr
@efeselgr
Jun 08 2016 01:32
i am not sure but i think the third thing on that table is wrong
\
owenkosnen
@owenkosnen
Jun 08 2016 01:32
@bmecuria I've done it. I think it requires me to put backslash somewhere..
Micah Bales
@micahbales
Jun 08 2016 01:32
Hi everyone! I have a quick question: Any idea why the click event on JS line 72 isn't firing? http://codepen.io/micahbales/pen/MegRqm?editors=0010
Nathan
@N-Upchurch
Jun 08 2016 01:33
Hey guys, stuck on record collection. Everything works except "After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element." Any ideas?
tron04
@tron04
Jun 08 2016 01:34
binalfew mecuriaw
@bmecuria
Jun 08 2016 01:34
@owenkosnen ya use \n two cut strings
@betamedium
Jun 08 2016 01:34
@N-Upchurch same here
Nathan
@N-Upchurch
Jun 08 2016 01:34

// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "") {
var isTrack = prop === "tracks" ? collection[id][prop].push(value) : collection[id][prop] = value;
} else {
delete collection[id][prop];
}
return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

tron04
@tron04
Jun 08 2016 01:35
Nathan
@N-Upchurch
Jun 08 2016 01:35

'''
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "") {
var isTrack = prop === "tracks" ? collection[id][prop].push(value) : collection[id][prop] = value;
} else {
delete collection[id][prop];
}
return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
'''

CamperBot
@camperbot
Jun 08 2016 01:35
tron04
@tron04
Jun 08 2016 01:35
think you used forward ticks
Nathan
@N-Upchurch
Jun 08 2016 01:36

```
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "") {
var isTrack = prop === "tracks" ? collection[id][prop].push(value) : collection[id][prop] = value;
} else {
delete collection[id][prop];
}
return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

tron04
@tron04
Jun 08 2016 01:36
you need 3 at the end of your code as well
Nathan
@N-Upchurch
Jun 08 2016 01:36
``````// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "") {
var isTrack = prop === "tracks" ? collection[id][prop].push(value) : collection[id][prop] = value;
} else {
delete collection[id][prop];
}
return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");``````
tron04
@tron04
Jun 08 2016 01:36
:+1:
Nathan
@N-Upchurch
Jun 08 2016 01:36
thank christ
sorry
Thomas Nguyen
@thomasnguyen
Jun 08 2016 01:37
``````function addItems(state,perPage){
var magicNumber = (state * perPage);

for (var x = 0; x < perPage; x++){
}

}
}

\$("#tres").click(function(){

});``````
is this how you call a function???
Syntax Ninja
@SyntaxNinjas
Jun 08 2016 01:37
Anyone know what I am doing wrong? Trying to write a function that can calculate a factorial here is the code ```function FirstFactorial(num) {
for (var i=1; i<num; i++){
if (num!==i){
var outputnum=1;
outputnum = (num*(num-i));
console.log(outputnum);
return outputnum;
}else{
return 1;
}
}
}
```function FirstFactorial(num) {
for (var i=1; i<num; i++){
if (num!==i){
var outputnum=1;
outputnum = (num*(num-i));
console.log(outputnum);
return outputnum;
}else{
return 1;
}
}
}
Diego Mayer
@Chrono79
Jun 08 2016 01:39
@SyntaxNinjas you have at least 2 ways of doing the factorial, using a loop or using recursivity
@betamedium
Jun 08 2016 01:39
@SyntaxNinjas you need to switch to compose mode to add ``` i think.
Syntax Ninja
@SyntaxNinjas
Jun 08 2016 01:40
@betamedium @Chrono79 Sorry new to this how do I switch to compose mode?
Diego Mayer
@Chrono79
Jun 08 2016 01:40
help format
CamperBot
@camperbot
Jun 08 2016 01:40

# Multi line Code

```js ⇦ Type 3 backticks and then press `[shift + enter ⏎]` (type js or html or css)

``````<paste your code here>,
then press [shift + enter ⏎]``````

``` ⇦ Type 3 backticks, then press `[enter ⏎]`

# Single line Code

This an inline ``<paste code here>`` code formatting with a single backtick(`) at _start_ and _end_ around the`code`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

@betamedium
Jun 08 2016 01:40
@SyntaxNinjas cmd + / if on a mac
Diego Mayer
@Chrono79
Jun 08 2016 01:41
look at the 2 dialog baloons at the right
Syntax Ninja
@SyntaxNinjas
Jun 08 2016 01:41
```function FirstFactorial(num) {
for (var i=1; i<num; i++){
if (num!==i){
var outputnum=1;
outputnum = (num*(num-i));
console.log(outputnum);
return outputnum;
}else{
return 1;
}
}
}
@betamedium Thanks
``````function FirstFactorial(num) {
for (var i=1; i<num; i++){
if (num!==i){
var outputnum=1;
outputnum = (num*(num-i));
console.log(outputnum);
return outputnum;
}else{
return 1;
}
}
}``````
CamperBot
@camperbot
Jun 08 2016 01:41
syntaxninjas sends brownie points to @betamedium :sparkles: :thumbsup: :sparkles:
Diego Mayer
@Chrono79
Jun 08 2016 01:42
@SyntaxNinjas in every loop, you set outputnum = 1
Syntax Ninja
@SyntaxNinjas
Jun 08 2016 01:43
@Chrono79 yeah what should I have set it to?
Diego Mayer
@Chrono79
Jun 08 2016 01:43
num is fixed, `outputnum = (num*(num-i));` let's say num is 5, you're doing `5*4`, the next time 5*3, etc
Nathan
@N-Upchurch
Jun 08 2016 01:44
I think I may need to somehow check if the object has an existing "tracks" property, and add it first if it doesn't?
Diego Mayer
@Chrono79
Jun 08 2016 01:45
@N-Upchurch yes
Simon Cordova
@gbsimon87
Jun 08 2016 01:46
Unless I am mistakenyou should use strict comparison for that
Diego Mayer
@Chrono79
Jun 08 2016 01:46
@SyntaxNinjas outside the loop create a var and store the result in that var
Emerson Aquino
@emeraquino
Jun 08 2016 01:46
@micahbales Did you figure out your problem?
Simon Cordova
@gbsimon87
Jun 08 2016 01:46
hey @Chrono79 what's happening!
Diego Mayer
@Chrono79
Jun 08 2016 01:47
yo
Matias Glasner
@mglasner
Jun 08 2016 01:47

hi guys, can someone help me please

is an error in this peace of code:

function lookUpProfile(firstName, prop) {
// Only change code below this line
for (var i; i < contacts.length; i++) {
if (contacts[i].firstName === firstName) {
return 'is a contact';
}
}
return 'is not a contact';
// Only change code above this line
}

contacts is an array of objects ..

Syntax Ninja
@SyntaxNinjas
Jun 08 2016 01:48
@Chrono79 Ok giving that a try now will let you know
Diego Mayer
@Chrono79
Jun 08 2016 01:48
@mglasner you have to initialize i in the for loop definition
Syntax Ninja
@SyntaxNinjas
Jun 08 2016 01:48
@Chrono79 Thanks
CamperBot
@camperbot
Jun 08 2016 01:48
syntaxninjas sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1085 | @chrono79 |http://www.freecodecamp.com/chrono79
Matias Glasner
@mglasner
Jun 08 2016 01:49
@Chrono79 XD
@Chrono79 thanks .. i am an idiot haha
CamperBot
@camperbot
Jun 08 2016 01:49
mglasner sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1086 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 08 2016 01:50
@mglasner no problem, I hope those strings are for testing purposes, aren't they?
Matias Glasner
@mglasner
Jun 08 2016 01:51
@Chrono79 yes, for testing .. i was looking for the error half an hour at least .. haha
Diego Mayer
@Chrono79
Jun 08 2016 01:52
1ety
@1ety
Jun 08 2016 01:53
Why the following does 't return lower Case

function palindrome(str) {
str.toLowerCase();

return str;
}

palindrome("EYe");

Diego Mayer
@Chrono79
Jun 08 2016 01:54
@1ety str = str.toLowerCase();
Moisés Man
@moigithub
Jun 08 2016 01:54
@1ety tolowercase dont mutate the string.. u need to reassign
1ety
@1ety
Jun 08 2016 01:55
Thank you @Chrono79 and @moigithub
CamperBot
@camperbot
Jun 08 2016 01:55
1ety sends brownie points to @chrono79 and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1087 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 1384 | @moigithub |http://www.freecodecamp.com/moigithub
Emerson Aquino
@emeraquino
Jun 08 2016 02:00
@micahbales Still there? The click event handler is not firing because somehow theres something on top of the button... What I mean is that even though the button is visible, when you click it you are not really clicking the actual button. I defined a "z-index: 1" css attribute to your #center-circle class and it solved the problem.
Nathan
@N-Upchurch
Jun 08 2016 02:01

Tried a different approach, still having the issue: ```
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "") {
if (prop === "tracks" && prop === ""){
collection[id][prop] = value;
} else if (prop === "tracks" && prop !== "") {
collection[id][prop].push(value);
} else {
collection[id][prop] = value;
}
} else {
delete collection[id][prop];
}
return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA"); ```

``````// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "") {
if (prop === "tracks" && prop === ""){
collection[id][prop] = value;
} else if (prop === "tracks" && prop !== "") {
collection[id][prop].push(value);
} else {
collection[id][prop] = value;
}
} else {
delete collection[id][prop];
}
return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");``````
Any ideas @Chrono79 ?
Diego Mayer
@Chrono79
Jun 08 2016 02:03
@N-Upchurch this is wrong: prop === "tracks" && prop === ""
Nathan
@N-Upchurch
Jun 08 2016 02:03
Spotted that a sec ago. Fixed with same results :/
Diego Mayer
@Chrono79
Jun 08 2016 02:04
@N-Upchurch this too: prop === "tracks" && prop === ""
if prop isn't tracks, set or update the property
Nathan
@N-Upchurch
Jun 08 2016 02:05
``````// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "") {
if (prop === "tracks" && value === ""){
collection[id][prop] = value;
} else if (prop === "tracks" && value !== "") {
collection[id][prop].push(value);
} else {
collection[id][prop] = value;
}
} else {
delete collection[id][prop];
}
return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");``````
still broken
Diego Mayer
@Chrono79
Jun 08 2016 02:05
@N-Upchurch delete value from these 2 ifs:
`````` if (prop === "tracks" && value === ""){
collection[id][prop] = value;
} else if (prop === "tracks" && value !== "") {``````
@betamedium
Jun 08 2016 02:05
``````
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "" && prop !== "tracks" ) {
collection[id][prop] = value;
} if (prop == "tracks" && value !== "") {
collection[id].tracks.push(value);
} if (value == "") {
delete collection[id][prop];
}

return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");``````
Here is my take… rewritten this like 10 diferent times with no result
Diego Mayer
@Chrono79
Jun 08 2016 02:07
@betamedium @N-Upchurch let's make a 2x1 combo
@betamedium code is better than @N-Upchurch, he's missing a test case where tracks doesn't exist
Krishna
@krisskb
Jun 08 2016 02:07
Hello Friends, I am working on pairwise challenge. Here I have an issue with one of the test case: pairwise([0, 0, 0, 0, 1, 1], 1) should return 10.
As per the below instruction rule it should return 4.
If multiple pairs are possible that have the same numeric elements but different indices, return the smallest sum of indices.
Moisés Man
@moigithub
Jun 08 2016 02:09
0,0,0,0,1,1 -- elements
0,1,2,3,4,5 -- indices
0+4 indices sum 1
1+5 sum 1
4+1+5 = 10
Diego Mayer
@Chrono79
Jun 08 2016 02:10
@krisskb first: pair the first 0 = index is 0 and the first one, index is 4, sum 4
second pair: the second 0 = index 1 and the second 1 = index 5 sum 6
4 + 6 = 10
Cameron Burkholder
@Cameron-Burkholder
Jun 08 2016 02:11
I am working on Caesar's Cipher and my code works for some letters, but others it is off by a couple.
``````
function rot13(str) { // LBH QVQ VG!
var holder = [];
var final = [];
for (var i = 0; i < str.length; i++) {
if (str[i] != " ") {
if (str[i].charCodeAt(0) - 13 < 65) {
var x = str[i].charCodeAt(0) - 65;
holder.push(90 - x);
} else {
holder.push(str[i].charCodeAt(0) - 13);
}
} else {
holder.push(str[i]);
}
}

for (var j = 0; j < holder.length; j++) {
if (holder[j] != " ") {
final.push(String.fromCharCode(holder[j]));
} else {
final.push(holder[j]);
}
}

var fin = final.join("");
return fin;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");``````
Sai Rahul
@rhhhhl
Jun 08 2016 02:13
var myStr = \'<a href="http://www.example.com" target="_blank">Link</a>'\;
var myStr; // Change this line
Diego Mayer
@Chrono79
Jun 08 2016 02:14
@rhhhhl remove the backslashes and delete var myStr; // Change this line
Sai Rahul
@rhhhhl
Jun 08 2016 02:14
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
Diego Mayer
@Chrono79
Jun 08 2016 02:14
that's another challenge
Sai Rahul
@rhhhhl
Jun 08 2016 02:15
hi @Chrono79 can't figure out this challenge
Diego Mayer
@Chrono79
Jun 08 2016 02:15
use the table to encode that string
myStr = "...";
Sai Rahul
@rhhhhl
Jun 08 2016 02:15
myStr = "\ \"; ?
for backslash ?
Diego Mayer
@Chrono79
Jun 08 2016 02:16
if it was only tab tab it'll be `myStr = "\t \t";`
Porfirio Agramonte
@Porfiproduces
Jun 08 2016 02:16
Hello world
CamperBot
@camperbot
Jun 08 2016 02:16

## welcome to FreeCodeCamp @Porfiproduces!

dposse
@dposse
Jun 08 2016 02:16
This message was deleted
CamperBot
@camperbot
Jun 08 2016 02:16
dposse
@dposse
Jun 08 2016 02:16

hey guys, quick question - for "everything be true" algorithm", I originally just had

``````function truthCheck(collection, pre) {
// Is everyone being true?
return collection.every(function (item) {
return item.hasOwnProperty(pre);
});
}``````

but why do you need to do this instead

`` return item.hasOwnProperty(pre) && Boolean(item[pre]);``

?

Diego Mayer
@Chrono79
Jun 08 2016 02:16
for backslash, you have to escape it too, so double backslash @rhhhhl
Porfirio Agramonte
@Porfiproduces
Jun 08 2016 02:17
here I am about to ask if a Callback is a function used as an arguement and you guys are figuring out Ceaser's Cipher :worried:
Cameron Burkholder
@Cameron-Burkholder
Jun 08 2016 02:18
Are you way ahead of Caesar's? @Porfiproduces
Porfirio Agramonte
@Porfiproduces
Jun 08 2016 02:18
I'm way behind lol @Cameron-Burkholder
Cameron Burkholder
@Cameron-Burkholder
Jun 08 2016 02:18
Oh dangit I need help lol @Porfiproduces
What do you need help with? @Porfiproduces
Porfirio Agramonte
@Porfiproduces
Jun 08 2016 02:20
I'm just trying to figure out callbacks....I'm noticing vocabulary terms are becoming a block for me
I have a callback just being a function used as an arguement
I'm just not sure if that's correct
dposse
@dposse
Jun 08 2016 02:22
jk i got it guys :P
Nathan
@N-Upchurch
Jun 08 2016 02:22
tried again, no result.
``````// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "" && prop != "tracks") {
collection[id][prop] = value;
} else if (value !== "" && prop === "tracks" && collection[id][prop] === "") {
collection[id][prop] = value;
} else if (value !== "" && prop === "tracks" && collection[id][prop] !== ""){
collection[id][prop].push(value);
} else {
delete collection[id][prop];
}
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");``````
Sai Rahul
@rhhhhl
Jun 08 2016 02:22
@Chrono79 var myStr = "\ \ \t \t \t \t \r \r \n \n"; this passed through complier but not able to exit the challenge
Diego Mayer
@Chrono79
Jun 08 2016 02:22
@rhhhhl too many things there
@betamedium
Jun 08 2016 02:22
@N-Upchurch just done the record collection after like 3 or 4 hours =) you need to check if the album has empty “tracks” array, and create it if it doesnt
Porfirio Agramonte
@Porfiproduces
Jun 08 2016 02:23
@Chrono79 I was just reading that! lol sidebar....Chrono Trigger = my childhood
Diego Mayer
@Chrono79
Jun 08 2016 02:23
;)
@betamedium
Jun 08 2016 02:23
@N-Upchurch I did it by nesting another if statement
Cameron Burkholder
@Cameron-Burkholder
Jun 08 2016 02:23

Essentially that is correct. It would be used in a way similar to this:

``````function generatePersonality(color, name, generateAge, ageRange) {
var favColor = color;
var personsName = name;
var age = generateAge(ageRange);
}

function generateAge() {
// some code that generates a random number as an age from a range.
}``````

@Porfiproduces

Nathan
@N-Upchurch
Jun 08 2016 02:24
That's what I tried to accomplish :/
NewtonXu
@NewtonXu
Jun 08 2016 02:25
Hey guys is there an opposite of onClick? i want my button to apply a class when the mouse is pressed down but when they release it reverts
@betamedium
Jun 08 2016 02:25
@N-Upchurch
``` ```
Diego Mayer
@Chrono79
Jun 08 2016 02:25
@N-Upchurch if the property doesn't exist, it's value is undefined, not empty string
@betamedium
Jun 08 2016 02:25
@N-Upchurch
```
if (prop == "tracks") {
if (collection[id][prop]) {
collection[id][prop].push(value);
} else {
collection[id][prop] = [];
collection[id][prop].push(value);
}
``````if (prop == "tracks") {
if (collection[id][prop]) {
collection[id][prop].push(value);
} else {
collection[id][prop] = [];
collection[id][prop].push(value);
}``````
Porfirio Agramonte
@Porfiproduces
Jun 08 2016 02:25
I'm more confused now @Cameron-Burkholder I Don't see where a function was used as an arguement
Diego Mayer
@Chrono79
Jun 08 2016 02:25
This message was deleted
``````if (prop == "tracks") {
if (!collection[id].hasOwnProperty(prop) {
collection[id][prop] = [];
}
collection[id][prop].push(value);
}``````
Nathan
@N-Upchurch
Jun 08 2016 02:28
Accomplished with:
```// Only change code below this line function updateRecords(id, prop, value) { if (value !== "" && prop != "tracks") { collection[id][prop] = value; } else if (value !== "" && prop === "tracks" && collection[id][prop] === undefined) { collection[id][prop] = []; collection[id][prop].push(value); } else if (value !== "" && prop === "tracks" && collection[id][prop] !== undefined){ collection[id][prop].push(value); } else { delete collection[id][prop]; } return collection; }```
Cameron Burkholder
@Cameron-Burkholder
Jun 08 2016 02:28
So what i did was write a function that generates someones personal info. So I give a color, a name, a function that creates an age, and an age range. So the persons favorite color, and name, are directly from the parameters of the functions (stuff in parenthese). Then, we use a function that generates an age, and an age range. Inside the function, the age function creates an age using the given range. Really simply, it is where a function uses another function. Sorry if that was confusing lol @Porfiproduces . It gets easier to understand as you progress in Js
Nathan
@N-Upchurch
Jun 08 2016 02:28
```// Only change code below this line function updateRecords(id, prop, value) { if (value !== "" && prop != "tracks") { collection[id][prop] = value; } else if (value !== "" && prop === "tracks" && collection[id][prop] === undefined) { collection[id][prop] = []; collection[id][prop].push(value); } else if (value !== "" && prop === "tracks" && collection[id][prop] !== undefined){ collection[id][prop].push(value); } else { delete collection[id][prop]; } return collection; }```
Sai Rahul
@rhhhhl
Jun 08 2016 02:28
@Chrono79 myStr = "\ \"; what should i assign it to ? Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
Diego Mayer
@Chrono79
Jun 08 2016 02:28
use triple `when pasting multiline code
Nathan
@N-Upchurch
Jun 08 2016 02:28
Thanks for the help!
Diego Mayer
@Chrono79
Jun 08 2016 02:29
no problem
Nathan
@N-Upchurch
Jun 08 2016 02:29
@Chrono79 your solution is much neater.
Diego Mayer
@Chrono79
Jun 08 2016 02:29
you can clean your code too once it works @N-Upchurch eliminating repetitions and so on
Nathan
@N-Upchurch
Jun 08 2016 02:29
will do
@betamedium
Jun 08 2016 02:29
@Chrono79 thanks.
CamperBot
@camperbot
Jun 08 2016 02:29
betamedium sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1088 | @chrono79 |http://www.freecodecamp.com/chrono79
Porfirio Agramonte
@Porfiproduces
Jun 08 2016 02:30
gotcha and the function call for generateAge was hoisted....aha.....Thank you @Cameron-Burkholder
Cameron Burkholder
@Cameron-Burkholder
Jun 08 2016 02:30
No problem @Porfiproduces
Diego Mayer
@Chrono79
Jun 08 2016 02:31
@rhhhhl `myStr = "\\ \t \t ... ";` put the ones missing there
Moisés Man
@moigithub
Jun 08 2016 02:31
@Cameron-Burkholder Ur calc is wrong :)
if u have an "E" u wanna decode...
instead of doing E - 13...
u doing Z - 13..
u not counting D,C,B,A
``````//R    S    T    U   V   W   X   Y   Z   A   B   C   D   E
//-13  -12  -11  -10 -9  -8  -7 -6  -5  -4  -3   -2  -1  0``````
`holder.push(91 - 13+ x);` <------------------
/me :cry: .. no brownies
Sai Rahul
@rhhhhl
Jun 08 2016 02:37
@Chrono79 got it working after some tweeks... thank you :slight_smile:
CamperBot
@camperbot
Jun 08 2016 02:37
rhhhhl sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1089 | @chrono79 |http://www.freecodecamp.com/chrono79
dennixin
@dennixin
Jun 08 2016 02:38
Hello
Sai Rahul
@rhhhhl
Jun 08 2016 02:38
@mizujin got it working after some tweeks... thank you :slight_smile:
CamperBot
@camperbot
Jun 08 2016 02:38
rhhhhl sends brownie points to @mizujin :sparkles: :thumbsup: :sparkles:
Rémi Fortier
@mizujin
Jun 08 2016 02:39
@rhhhhl No problems :)
Krishna
@krisskb
Jun 08 2016 02:41
@Chrono79 what about this instruction : If multiple pairs are possible that have the same numeric elements but different indices, return the smallest sum of indices.
0, 4 and 1, 5 elements have value of 0,1. So as I understand smallest sum is 4
Diego Mayer
@Chrono79
Jun 08 2016 02:42
@krisskb it means the first 0 with the last 1 for example, you have to use the first 0 with the first 1 instead
I know it's not clear, but it works like that
Josh Carlisle
@Jroc561
Jun 08 2016 02:48
Sup guys, just finished basic javascript feeling pretty good. Except I skipped 4 assignments and I am stuck on each one. Super stuggle
Expiratio
@Expiratio
Jun 08 2016 02:51
what did you skip
i'm not done yet but maybe i can help
Krishna
@krisskb
Jun 08 2016 02:54
@Chrono79 then for test case ([1,1,1],2) should return 1. Possible pairs are [0,1][1,2] here sum will become 4
Diego Mayer
@Chrono79
Jun 08 2016 02:54
@krisskb no, you only can use a number one time, once used you can't use it for other pair
Krishna
@krisskb
Jun 08 2016 02:56
@Chrono79 okay now seems to be clear.
Christian
Jun 08 2016 02:56
how do you ask the camperbot for help
Diego Mayer
@Chrono79
Jun 08 2016 02:57
CamperBot
@camperbot
Jun 08 2016 02:57
Krishna
@krisskb
Jun 08 2016 02:57
many thanks @Chrono79
CamperBot
@camperbot
Jun 08 2016 02:57
krisskb sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1090 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 08 2016 02:57
@krisskb no problem
Christian
Jun 08 2016 02:57
the current problem I'm on
Diego Mayer
@Chrono79
Jun 08 2016 02:58
just write help and the name of the challenge
Christian
Jun 08 2016 02:58
help "check for palindromes"
CamperBot
@camperbot
Jun 08 2016 02:58

# Algorithm Check for Palindromes

### Explanation:

Our goal for solving this problem is tidying up the string passed in, and checking whether it is in fact a palindrome.

• If you are unsure of what a palindrome is, it is a word or phrase that when reversed spells the same thing forwards or backwards. A simple example is `mom`, when you reverse the letters, it spells the same thing! Another example of a palindrome is `race car`. When we take out anything that is not a character it becomes `racecar` which is the same spelled forwards or backwards!

Once we have determined whether it is a palindrome or not we want to return either `true` or `false` based on our findings.

Diego Mayer
@Chrono79
Jun 08 2016 02:59
good night
Sai Rahul
@rhhhhl
Jun 08 2016 03:00
@camperbot thanks :fire:
CamperBot
@camperbot
Jun 08 2016 03:00
rhhhhl sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 1848 | @camperbot |http://www.freecodecamp.com/camperbot
GGvibes
@GGvibes
Jun 08 2016 03:00
help "Global Scope and Functions"
CamperBot
@camperbot
Jun 08 2016 03:00

# Challenge Global Scope and Functions

In JavaScript, `scope` refers to the visibility of variables. Variables which are defined outside of a function block have `Global` scope. This means, they can be seen everywhere in your JavaScript code.

Variables which are used without the `var` keyword are automatically created in the `global` scope. This can create unintended consequences elsewhere in your code or when running a function again. You should always declare your variables with `var`.

William Cabell
@wbac88
Jun 08 2016 03:12
help "Selecting from many options with Switch Statements"
CamperBot
@camperbot
Jun 08 2016 03:12

# Challenge Selecting from many options with Switch Statements

If you have many options to choose from, use a `switch` statement. A `switch` statement tests a value and can have many `case` statements which defines various possible values. Statements are executed from the first matched `case` value until a `break` is encountered.

Here is a `pseudocode` example:

``````switch (num) {
case value1:
statement1;
break;
case value2:
statement2;
break;
...
case valueN:
statementN;
break;
}``````
William Cabell
@wbac88
Jun 08 2016 03:13
OK, that wasn't very helpful, anyone have any insight on this challenge, I'm stuck. This is my code:
``````
function caseInSwitch(val) {
// Only change code below this line

case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;

}
// Only change code above this line
}``````
Coy Sanders
@coymeetsworld
Jun 08 2016 03:14
@wbac88 you want to switch on val, not answer
val is what you're checking for a value, answer is what you're populating as a result. Since answer is blank none of those cases will work
William Cabell
@wbac88
Jun 08 2016 03:16
@coymeetsworld OK, thank you that did it! So, if you don't mind, can you identify what "val" and "answer" are respectively in terms of argument, statement, etc.? I am having a lot of difficulty being able to pin those terms down. Or point me to where I can get a better idea.
CamperBot
@camperbot
Jun 08 2016 03:16
wbac88 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1093 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
kelyjames
@kelyjames
Jun 08 2016 03:17
``````// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

if(value !== ""){
if(prop == "album" || prop == "artist" )
collection[id][prop]=value;
else if(prop == "tracks"){
collection[id][prop].push(value);
}}
else delete collection[id][prop];

return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");``````
I have tired this several times different ways and there is one test that does not respond correctly to the push and one test that does
Coy Sanders
@coymeetsworld
Jun 08 2016 03:17
val is the parameter of the function caseInSwitch()
so when you call caseInSwitch(1). Val will be set to 1
Eric
@Brehmolition
Jun 08 2016 03:17
can a human or Bot help me with this error message, 'TypeError: 0 is read-only'
Coy Sanders
@coymeetsworld
Jun 08 2016 03:18
answer is a local variable inside that caseInSwitch statement that you want to set a value to depending on what val is
JonesFuego
@JonesFuego
Jun 08 2016 03:18
guys how can i paste the challenge here
im stuck
Coy Sanders
@coymeetsworld
Jun 08 2016 03:18
since it depends on what val is, thats what you want to check for values @wbac88
William Cabell
@wbac88
Jun 08 2016 03:18
@JonesFuego You mean the actual code block?
JonesFuego
@JonesFuego
Jun 08 2016 03:18
@wbac88 yes
Coy Sanders
@coymeetsworld
Jun 08 2016 03:19
kelyjames
@kelyjames
Jun 08 2016 03:19
the tick marks ```
Coy Sanders
@coymeetsworld
Jun 08 2016 03:19
help format
CamperBot
@camperbot
Jun 08 2016 03:19

# Multi line Code

```js ⇦ Type 3 backticks and then press `[shift + enter ⏎]` (type js or html or css)

``````<paste your code here>,
then press [shift + enter ⏎]``````

``` ⇦ Type 3 backticks, then press `[enter ⏎]`

# Single line Code

This an inline ``<paste code here>`` code formatting with a single backtick(`) at _start_ and _end_ around the`code`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

William Cabell
@wbac88
Jun 08 2016 03:19
@JonesFuego Ha, there you go.
JonesFuego
@JonesFuego
Jun 08 2016 03:19
guys this is the code look

var count = 0;

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

}

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

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

i cant get this right
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"
Eric
@Brehmolition
Jun 08 2016 03:20
I'm doing the capitilize first letter excercise and was trying this line str[0][0]= str[0][0].toUpperCase();
Manuela J.
@ManuelaJa
Jun 08 2016 03:20
help! stuck on finding a remainder in javascript.
CamperBot
@camperbot
Jun 08 2016 03:20
no wiki entry for: `stuck on finding a remainder in javascript`
Coy Sanders
@coymeetsworld
Jun 08 2016 03:20
@JonesFuego you can't put cases together like that
William Cabell
@wbac88
Jun 08 2016 03:20
@coymeetsworld Thank you for taking the time! I appreciate it. That is helpful, I think once that sinks in, it'll go a long way to being able to think about these problems. New language, indeed.
CamperBot
@camperbot
Jun 08 2016 03:20
wbac88 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: wbac88 already gave coymeetsworld points
Coy Sanders
@coymeetsworld
Jun 08 2016 03:20
also you don't want to return values like that
JonesFuego
@JonesFuego
Jun 08 2016 03:20
lel
Coy Sanders
@coymeetsworld
Jun 08 2016 03:20
the switch statement should just be modifying the count variable, thats all
JonesFuego
@JonesFuego
Jun 08 2016 03:20
welp how can i do it
Thieu van Dijk
@Thieuvandijk
Jun 08 2016 03:20
good morning!
Is there anybody who can help me with my heaps algorithm?
JonesFuego
@JonesFuego
Jun 08 2016 03:21
i cant put breaks they are unreachable
William Cabell
@wbac88
Jun 08 2016 03:21
@coymeetsworld Was that aimed at me? What do you mean, I don't want to return values like that?
Coy Sanders
@coymeetsworld
Jun 08 2016 03:21
no that was for @JonesFuego
Thieu van Dijk
@Thieuvandijk
Jun 08 2016 03:21
I'm doing something wrong but I can't figure out what it is....
William Cabell
@wbac88
Jun 08 2016 03:21
Ah, ok, sorry!
Ivan Miranda
@ivannash23
Jun 08 2016 03:21

function convert(num) {
var r = "";
var decimals = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
var roman = ["M", "CM", "D", "CD", "C", "XC", "L", 'XL', 'X', 'IX', 'V', 'IV', 'I'];

``````for(var i = 0; i < decimals.length; i++){
while(num >= decimals[i]){
r = r + roman[i];
num = num - decimals[i];
}
}
return r;``````

}
convert(6);

Coy Sanders
@coymeetsworld
Jun 08 2016 03:21
what do you mean you cant put breaks?
efeselgr
@efeselgr
Jun 08 2016 03:21
@coymeetsworld try to put @name before you talk to someone coy
JonesFuego
@JonesFuego
Jun 08 2016 03:21
they are unreachable
Ivan Miranda
@ivannash23
Jun 08 2016 03:21
i dont know what i did wrong!!
JonesFuego
@JonesFuego
Jun 08 2016 03:21
because there are returns
Coy Sanders
@coymeetsworld
Jun 08 2016 03:21
I did @efeselgr when i first talked to him, thanks
CamperBot
@camperbot
Jun 08 2016 03:21
coymeetsworld sends brownie points to @efeselgr :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
Jun 08 2016 03:22
@JonesFuego you don't want the returns there
JonesFuego
@JonesFuego
Jun 08 2016 03:22
@coymeetsworld ye but
@coymeetsworld how can i fix it
@coymeetsworld i cant get that one right
Coy Sanders
@coymeetsworld
Jun 08 2016 03:23
first you need to fix your case statements, you can't do a range like that
look back at how to construct case/switch statements
efeselgr
@efeselgr
Jun 08 2016 03:23
@JonesFuego that code is completely wrong jones
Coy Sanders
@coymeetsworld
Jun 08 2016 03:23
@efeselgr i got it
efeselgr
@efeselgr
Jun 08 2016 03:23
@coymeetsworld alright
Ivan Miranda
@ivannash23
Jun 08 2016 03:23
@efeselgr can you help me out?
Expiratio
@Expiratio
Jun 08 2016 03:23
@kelyjames it's likely you're trying to push in an object where "tracks" doesn't exist, in which case you need to define it first.
JonesFuego
@JonesFuego
Jun 08 2016 03:23
welp i dunno what im doing wrong
efeselgr
@efeselgr
Jun 08 2016 03:23
@ivannash23 on what ivan?
Coy Sanders
@coymeetsworld
Jun 08 2016 03:23
@JonesFuego next all you want to do is modify the count variable inside
JonesFuego
@JonesFuego
Jun 08 2016 03:24
can i do it with an if / else
Coy Sanders
@coymeetsworld
Jun 08 2016 03:24
then after that you print out the count, and either Bet or Hold depending on its value
Ivan Miranda
@ivannash23
Jun 08 2016 03:24
my roman converter is not working for some reason and i can't figure it out

function convert(num) {
var r = "";
var decimals = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
var roman = ["M", "CM", "D", "CD", "C", "XC", "L", 'XL', 'X', 'IX', 'V', 'IV', 'I'];

``````for(var i = 0; i < decimals.length; i++){
while(num >= decimals[i]){
r = r + roman[i];
num = num - decimals[i];
}
}
return r;``````

}

JonesFuego
@JonesFuego
Jun 08 2016 03:24
how do i include the ocunt var there ?? ? ?
cout*
count*
Coy Sanders
@coymeetsworld
Jun 08 2016 03:24
the challenge i believe requires you to do case/switch @JonesFuego, at least for modifying count
look back at your previous challenges on case/switch
see how you did it there
thats the key part first is getting that figured out
JonesFuego
@JonesFuego
Jun 08 2016 03:25
aight ty for your time man
Coy Sanders
@coymeetsworld
Jun 08 2016 03:25
np
Ivan Miranda
@ivannash23
Jun 08 2016 03:25

@efeselgr @ivannash23
my roman converter is not working for some reason and i can't figure it out
function convert(num) {
var r = "";
var decimals = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
var roman = ["M", "CM", "D", "CD", "C", "XC", "L", 'XL', 'X', 'IX', 'V', 'IV', 'I'];

``````for(var i = 0; i < decimals.length; i++){
while(num >= decimals[i]){
r = r + roman[i];
num = num - decimals[i];
}
}
return r;``````

}

JonesFuego
@JonesFuego
Jun 08 2016 03:25
appreaciated
Coy Sanders
@coymeetsworld
Jun 08 2016 03:25
ill be on later if you still need help but there's other
JonesFuego
@JonesFuego
Jun 08 2016 03:25
ty man
efeselgr
@efeselgr
Jun 08 2016 03:26
@ivannash23 what is the "num" there?
@ivannash23 ah i see sec
Manuela J.
@ManuelaJa
Jun 08 2016 03:26
help with remainder
CamperBot
@camperbot
Jun 08 2016 03:26
no wiki entry for: `with remainder`
Coy Sanders
@coymeetsworld
Jun 08 2016 03:26
@ManuelaJa what do you have so far?
Manuela J.
@ManuelaJa
Jun 08 2016 03:28
nothing first time learning it and i dont quite understand how its explaining it to me
efeselgr
@efeselgr
Jun 08 2016 03:28
@ivannash23 i don't really know the roman numerals
Thieu van Dijk
@Thieuvandijk
Jun 08 2016 03:28
@coymeetsworld Hi Coy, do you know something about the heaps algorithm?
Syntax Ninja
@SyntaxNinjas
Jun 08 2016 03:28
Heydoes anyone know how to write a loop to solve a factorial in javascript
I have been racking my brain for 2 days now
with no progress
Coy Sanders
@coymeetsworld
Jun 08 2016 03:29
if you look at the example @ManuelaJa, 5%2 = 1
Ivan Miranda
@ivannash23
Jun 08 2016 03:29
@efeselgr alright, thanks man, i appreciate the help.
CamperBot
@camperbot
Jun 08 2016 03:29
ivannash23 sends brownie points to @efeselgr :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
Jun 08 2016 03:29
thats because 1 is the remainder of when you divide 5 into 2
so if you want to assign the remainder of 5 %2 you set that equal to a variable
i.e.
``````var myRemainder = 5 %2;
// myRemainder will be equal to 1``````
JonesFuego
@JonesFuego
Jun 08 2016 03:32
hello again
Coy Sanders
@coymeetsworld
Jun 08 2016 03:32
@SyntaxNinjas what do you have so far?
JonesFuego
@JonesFuego
Jun 08 2016 03:32

var count = 0;

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

}

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

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

is thsi going better
David Halls
@DavidHalls
Jun 08 2016 03:32
@ivannash23 it looks like it is working to me
Coy Sanders
@coymeetsworld
Jun 08 2016 03:32
you still need to fix the case statements @JonesFuego, cant group multiple values like that
JonesFuego
@JonesFuego
Jun 08 2016 03:32
sorry i dunno how to paste the block
OOOh
i get it what are you saying
so you mean
Case 1 :
case 2 :
all alone
aight
Coy Sanders
@coymeetsworld
Jun 08 2016 03:33
yes, case is singular
JonesFuego
@JonesFuego
Jun 08 2016 03:33
ty for the tip
Coy Sanders
@coymeetsworld
Jun 08 2016 03:33
also you don't want to return anything inside of there
return comes later
ALMY91
@ALMY91
Jun 08 2016 03:35
`````` a=['ant','Bug','cat','Dog'];
console.log(a.sort()); //case-sensitive sort: ['Bug','Dog','ant','cat']
console.log(a.sort( function(s,t) {
var a =s.toLowerCase();
var b =t.toLowerCase();
if (a<b) return -1;
if (a>b) return  1;
return 0}
));``````
JonesFuego
@JonesFuego
Jun 08 2016 03:35
yep
ty
let me see how it turnst out
ALMY91
@ALMY91
Jun 08 2016 03:35
Hi can anybody tell me whats the point of this? im not seeing anything in my console with regards to the return values
Coy Sanders
@coymeetsworld
Jun 08 2016 03:35
np ill be back later
efeselgr
@efeselgr
Jun 08 2016 03:39
@SyntaxNinjas are you there?
Solved it.
``````var a = 1;
function factorial(num) {
for(var i=num;i>1;i--){

a=a*i;
}
return a;
}
factorial(5);``````
GGvibes
@GGvibes
Jun 08 2016 03:40
help "stand in line"
CamperBot
@camperbot
Jun 08 2016 03:40

# Challenge Stand In Line

In Computer Science a queue is an abstract Data Structure_ where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the _queue.

Instructions

Write a function nextInLine which takes an "array" and an "item" as arguments.

Add the item onto the end of the array, then remove the first element of the array.

The nextInLine function should return the element that was removed.

efeselgr
@efeselgr
Jun 08 2016 03:41
@GGvibes remember the shift,unshift,push and pop
Syntax Ninja
@SyntaxNinjas
Jun 08 2016 03:44
@efeselgr Thank you so much your awesome!!!
CamperBot
@camperbot
Jun 08 2016 03:44
syntaxninjas sends brownie points to @efeselgr :sparkles: :thumbsup: :sparkles:
efeselgr
@efeselgr
Jun 08 2016 03:44
@SyntaxNinjas i hope that's helpful,but try to solve the algorithm problems yourself and reach for help if you really can't.
Connor Hastey-Palindat
@cpalindat
Jun 08 2016 03:44
Can anyone here help me with the Twitch.TV api? Specfically, how to get information when the user is offline since the api will just return null?
Syntax Ninja
@SyntaxNinjas
Jun 08 2016 03:45
@efeselgr Yeah I will I have just been trying for about 2 days straight
@efeselgr will give it a run now.
Said Meku
@saidmeku
Jun 08 2016 03:46

```js
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for ( var i = 0; i < arr.length; i++){

``````for (var j = 0; j <arr[i].length; j++){
console.log(arr[i][j]);
}``````

}

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

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

GGvibes
@GGvibes
Jun 08 2016 03:46
Ahh ok thanks for the help @efeselgr . I know this one's probably really simple but I'm just having trouble understanding it. Is queue itself being used? (challenge is Stand in Line)
CamperBot
@camperbot
Jun 08 2016 03:46
ggvibes sends brownie points to @efeselgr :sparkles: :thumbsup: :sparkles:
efeselgr
@efeselgr
Jun 08 2016 03:46
@SyntaxNinjas mark this challenge and come back to it after 3-4 days,delete/solve again
Said Meku
@saidmeku
Jun 08 2016 03:47

~~~js
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for ( var i = 0; i < arr.length; i++){

``````for (var j = 0; j <arr[i].length; j++){
console.log(arr[i][j]);
}``````

}

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

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

efeselgr
@efeselgr
Jun 08 2016 03:47
@GGvibes i don't even know if queue is something in javascript,i did not use it in that challenge.
@saidmeku what does it want in the challenge?
Said Meku
@saidmeku
Jun 08 2016 03:48
``````
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for ( var i = 0; i < arr.length; i++){

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

}

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

// Modify values below to test your code
multiplyAll([[2,3],[3,4],[6,7,8]]);``````
GGvibes
@GGvibes
Jun 08 2016 03:49
ok. it says it's an abstract data structure so that makes sense not actually being used. I will use shift, unshift, push, pop as you said! @efeselgr
Syntax Ninja
@SyntaxNinjas
Jun 08 2016 03:49
@coymeetsworld I have found the solution. @efeselgr helped out. Gotta go sit down and digest what he did right. I think I need to go study loops again.
Said Meku
@saidmeku
Jun 08 2016 03:50
@GGvibes it needs to input the multiple arrays using the for loop
efeselgr
@efeselgr
Jun 08 2016 03:51
@saidmeku could you name the challenge ?
Manuela J.
@ManuelaJa
Jun 08 2016 03:51
finally passes that section thank you @coymeetsworld
CamperBot
@camperbot
Jun 08 2016 03:51
manuelaja sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1094 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Said Meku
@saidmeku
Jun 08 2016 03:52
@efeselgr challenge 238
efeselgr
@efeselgr
Jun 08 2016 03:52
@saidmeku not the id,the name of it
Said Meku
@saidmeku
Jun 08 2016 03:53
@efeselgr Nesting For Loops
efeselgr
@efeselgr
Jun 08 2016 03:54
@saidmeku you seem like already reached the arrays,put a 1 there to multiply them.
Said Meku
@saidmeku
Jun 08 2016 03:55
@efeselgr put 1 where?
efeselgr
@efeselgr
Jun 08 2016 03:56

Try this and tell me if it works

`````````js

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for ( var i = 0; i < arr.length; i++){

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

}

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

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

```

@saidmeku and check the "Notice here." note there that i left for you.
@saidmeku first value gets multiplied by 1,then they get multiplied one by one.
Said Meku
@saidmeku
Jun 08 2016 03:57
@efeselgr Thanks
CamperBot
@camperbot
Jun 08 2016 03:57
saidmeku sends brownie points to @efeselgr :sparkles: :thumbsup: :sparkles:
Said Meku
@saidmeku
Jun 08 2016 03:58
@efeselgr It worked like a water to thirst.
efeselgr
@efeselgr
Jun 08 2016 03:58
@saidmeku Np
Man i love helping js
Quoc Anh Nguyen
@quocanh261997
Jun 08 2016 03:59
Hey guys, I'm stuck on the Falsy Bouncer challenge, any suggestion?
``````function bouncer(arr) {
for (var a  =0; a<arr.length; a++){
var num = 0;
if (arr[a].indexOf(false||null||0||""||undefined||NaN)>0){
num = arr[a].indexOf(false||null||0||""||undefined||NaN);
arr.splice(num,1);
num = 0;
}
}
return arr;
}

bouncer([7, "ate", "", false, 9]);``````
efeselgr
@efeselgr
Jun 08 2016 04:00
@quocanh261997 try to use for loop and a function with (!yourvalue) in it
andreyorlov33
@andreyorlov33
Jun 08 2016 04:01
Hey guys i could use some help. Im trying to .push a local value into a global array... but for some reason the array is not populating and is coming out as empty...
``````var follows = []; // ARRAY I AM TRYING TO POPULATE//
var status, info;

var fcc = {

fccstatus: function(status, info) {
\$.getJSON('https://api.twitch.tv/kraken/streams/freecodecamp?callback=?', function(fccdata) {
if (fccdata.stream === null) {
info = "Offline",
status = "offline";
} else {
info = fccdata.stream.game,
status = "online";
}

(function() {
\$.getJSON('https://api.twitch.tv/kraken/channels/freecodecamp?callback=?', function(fccdata1) {

var fcclogo = fccdata1.logo,
program = fccdata1.display_name,
name = fccdata1.display_name,
fccbanner = fccdata1.profile_banner,
description = fccdata1.status;

html = '<div style="background-image: url(' + fccbanner + ')" class="row ' +
status + '"><div class="col-xs-2 col-sm-1" id="icon"><img src="' +
fcclogo + '" class="logo"></div><div class="col-xs-10 col-sm-3" id="name"><a href="' +
fccdata1.url + '" target="_blank">' +
name + '</a></div><div class="col-xs-10 col-sm-8" id="streaming"><span class="hidden-xs">' +
description + '</span></div></div>';
\$("#fcc").append(html);

});
\$.getJSON('https://api.twitch.tv/kraken/users/freecodecamp/follows/channels?callback=?', function(data2) {
for (var i = 0; i < data2.follows.length; i++) {
follows.push(data2.follows[i].channel.display_name);
// PUSHING THE VALUE HERE //
}

});

})();
})
},

};

fcc.fccstatus();

});``````
Quoc Anh Nguyen
@quocanh261997
Jun 08 2016 04:03
@efeselgr i don't understand the (!yourvalue) part, can you explain further?
efeselgr
@efeselgr
Jun 08 2016 04:03
@quocanh261997 let me try to solve this for few sec/min,i didn't finish that challenge
GGvibes
@GGvibes
Jun 08 2016 04:08
figured it out @saidmeku !! thanks
CamperBot
@camperbot
Jun 08 2016 04:08
ggvibes sends brownie points to @saidmeku :sparkles: :thumbsup: :sparkles:
efeselgr
@efeselgr
Jun 08 2016 04:08
@quocanh261997
``````
``````
@quocanh261997
``````
function bouncer(arr) {
// Don't show a false ID to this bouncer.
for(i=0;i<arr.length;i++){
if(!arr[i]){
//Remove that arr[i] here

}

}

return arr;
}

bouncer([7, "ate", "", false, 9]);``````
@quocanh261997 Do you want me to finish it?
ALMY91
@ALMY91
Jun 08 2016 04:13
hello guys is anybody able to help me out here
Katie McTigue
@kaitlinmctigue
Jun 08 2016 04:13
Hi guys, I'm having trouble with the record collection challenge. It's saying that the array I'm trying to push onto is undefined.
Could anyone take a look? Thanks!
ALMY91
@ALMY91
Jun 08 2016 04:15
helllooo?
DJ
@qualitymanifest
Jun 08 2016 04:17
Katie McTigue
@kaitlinmctigue
Jun 08 2016 04:17

// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "") {

``````if (prop !== "tracks") {
collection[id][prop] = value;
}

else if (prop == "tracks") {
collection[id].tracks.push([value]);
}``````

}

else {
delete collection[id][prop];

}

return collection;
}

// Alter values below to test your code
updateRecords(5439, "tracks", "a song");

DJ
@qualitymanifest
Jun 08 2016 04:17
ALMY91
@ALMY91
Jun 08 2016 04:18
@qualitymanifest i always don get responses even after posting hence the reason..
According to my book: Returned array contains elements specified by first argument, and all subsequent elements up to, but not including second argument . What i got in my console : an array excluding first argument but including second argument @qualitymanifest
this is my code
``````var a =[1,2,3,4,5];
console.log(a.slice(0,3)) //Returns [1,2,3]
console.log(a.slice(3)) //Returns [4,5]
console.log(a.slice(1,-1)) //Returns [2,3,4]
console.log(a.slice(-3,-2)) //Returns [3]``````
Katie McTigue
@kaitlinmctigue
Jun 08 2016 04:22
@qualitymanifest sorry my code sample looks wacky. How do I put it in the neat little box?
DJ
@qualitymanifest
Jun 08 2016 04:22
help format
CamperBot
@camperbot
Jun 08 2016 04:22

# Multi line Code

```js ⇦ Type 3 backticks and then press `[shift + enter ⏎]` (type js or html or css)

``````<paste your code here>,
then press [shift + enter ⏎]``````

``` ⇦ Type 3 backticks, then press `[enter ⏎]`

# Single line Code

This an inline ``<paste code here>`` code formatting with a single backtick(`) at _start_ and _end_ around the`code`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

ALMY91
@ALMY91
Jun 08 2016 04:22
@qualitymanifest What i understood from my book was that it is suppose to include the first argument but exclude the second. However my console states otherwise, not too sure what went wrong
DJ
@qualitymanifest
Jun 08 2016 04:22
@kaitlinmctigue :point_up: i'm taking a look at it though
@ALMY91 ill check yours out in a few minutes if no one else has responded
ALMY91
@ALMY91
Jun 08 2016 04:23
@qualitymanifest alright!
SHREYA GUPTA
@shreyag020
Jun 08 2016 04:23

// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if(value!==""&& prop!=="tracks"){
collection[id][prop] = value;
}
else if(value!==""&& prop==="tracks"){
if (collection[id].hasOwnProperty("tracks")) {
collection[id].tracks.push(value);
} else {
collection[id].tracks = value;
}

}
else if(value===""){
delete collection.id.prop;
}
return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

efeselgr
@efeselgr
Jun 08 2016 04:24
@quocanh261997 And the crowd goes wild.
``````

function bouncer(arr) {

// Don't show a false ID to this bouncer.
for(i=0;i<arr.length;i++){
if(!arr[i]){
arr.splice(i,1);
i=-1;
}

}

return arr;
}

bouncer([false, null, 0, NaN, undefined, ""]);``````
shawn
@shawnk723
Jun 08 2016 04:31
can somebody tell me what's wrong with this code?

function largestOfFour(arr) {
// You can do this!
arr2=[];
var i;
var j;
var largest=0;
for(i=0;i<arr.length;i++)
{
for(j=0;j<arr[i].length;j++)
{
if (largest<arr[i][j])
{
largest=arr[i][j];
}
} arr2[i]=largest;

``}``

return arr2;
}

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

DJ
@qualitymanifest
Jun 08 2016 04:32
@kaitlinmctigue oh i see it now. you altered the function call to say `updateRecords(5439, "tracks", "a song");` right? take a look at `collection.5439` - there's no `tracks` property, so you can't push where there isn't an array
shawn
@shawnk723
Jun 08 2016 04:34
largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]) should return [27,5,39,1001]. I'm keep on getting [27,27,39,1001] for this instead of [27,5,39,1001]...:(
any idea?
it's called "Return Largest Numbers in Arrays" from basic algorithm scripting section
DJ
@qualitymanifest
Jun 08 2016 04:36
@ALMY91 yeah, slice starts slicing at the first index provided and ends at the second argument. for example if you take `[1,2,3,4,5];` and `slice(0,3)` index 0 === 1 and index 3===4, so you get 1, 2, and 3, from the array, and it stops before it reaches the 4
given that you have 5 console.logs there i'm not sure if you were confused about a specific one or all of them
@shawnk723 sounds like you're not resetting your `largest` (or whatever you're calling it) variable before you start each sub-array
@ydeepk
Jun 08 2016 04:38

Hi fellas, I need your help. So, help me guys .

Working on Challenge Twitch tv API.

Please refer this codepen url [ http://codepen.io/ydeepk/pen/gMOVbj ]

My working Idea was to divide code in three parts:
1.) Get user Data and store it in a Object say dataRecevied = { }
-> Is this correct to store data in object for every user within the same function in which I'm calling " userData( ) ". ( All suggestions welcome. )

2.) Get user Status using function " userStatus( ) ", Here i'm having problem when I call this inside function " userData( ) ".
-> I get status 404 errors in console, other wise when I run independently userStatus( ) function, no error.

3.) Search user function , which searches users on input.

only need help with the first two parts. Please take few minutes help me with this.

shawn
@shawnk723
Jun 08 2016 04:39
hmm..
Katie McTigue
@kaitlinmctigue
Jun 08 2016 04:40
thank you @qualitymanifest and @shreyag020 !
CamperBot
@camperbot
Jun 08 2016 04:40
kaitlinmctigue sends brownie points to @qualitymanifest and @shreyag020 :sparkles: :thumbsup: :sparkles:
:star2: 1189 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
Katie McTigue
@kaitlinmctigue
Jun 08 2016 04:40
I understand now, but I still have an issue
FM
@mafelix
Jun 08 2016 04:40
@ydeepk open your developer console. you're getting errors
Jeff
@meankraken
Jun 08 2016 04:40
@shawnk723 Hey Shawn, its simply because of a classic loop mistake.. you forgot to reset "largest" back to 0 when you go through each array
FM
@mafelix
Jun 08 2016 04:40
@ydeepk searchTwitch is not defined and a whole bunch of 404 responses
Katie McTigue
@kaitlinmctigue
Jun 08 2016 04:41
@qualitymanifest I don't have this requirement fulfilled, but that is added on when I test: "After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element."
shawn
@shawnk723
Jun 08 2016 04:41
so Jeff. how am i supposed to reset the variable?
Jeff
@meankraken
Jun 08 2016 04:42
easiest way is just to do it after you call " arr2[i]=largest;" just do a largest=0; you want to check the largest of each array uniquely, you don't want to keep largest from the last array if that makes sense
shawn
@shawnk723
Jun 08 2016 04:43
let me see... got it
thanks man! :)
Omar Curiel
@Ocuriel97
Jun 08 2016 04:43
howdy, I need some assistance on the Stand in Line challenge. I can't figure out how to get the function to return the element that was removed.
FM
@mafelix
Jun 08 2016 04:43
@ydeepk what is the json you're getting back from twitch api?
Jeff
@meankraken
Jun 08 2016 04:43
Np
SHREYA GUPTA
@shreyag020
Jun 08 2016 04:43

function updateRecords(id, prop, value) {
if(value!==""&& prop!=="tracks"){
collection[id][prop] = value;
}
else if(value!==""&& prop==="tracks"){
if (collection[id].hasOwnProperty("tracks")) {
collection[id].tracks.push(value);
} else {
collection[id].tracks = value;
}

}
else if(value===""){
delete collection.id.prop;
}

what is wrong in this
shawn
@shawnk723
Jun 08 2016 04:44
@meankraken thank you.:)
CamperBot
@camperbot
Jun 08 2016 04:44
shawnk723 sends brownie points to @meankraken :sparkles: :thumbsup: :sparkles:
shawn
@shawnk723
Jun 08 2016 04:44
@Jeff thank you. :)
CamperBot
@camperbot
Jun 08 2016 04:44
:warning: could not find receiver for jeff
shawnk723 sends brownie points to @jeff :sparkles: :thumbsup: :sparkles:
SHREYA GUPTA
@shreyag020
Jun 08 2016 04:48
Coy Sanders
@coymeetsworld
Jun 08 2016 04:48
@shreyag020 if the property is tracks and the value is not empty, you need to first check if the record has a tracks property or not
if it doesn't, you need to create it
DJ
@qualitymanifest
Jun 08 2016 04:49
@kaitlinmctigue looks like they changed this one since i did it and didnt really add to the description. you will need to add a check to see if the tracks property exists, if it doesn't create it and assign it [value], if it does, push value to it
Katie McTigue
@kaitlinmctigue
Jun 08 2016 04:49
@shreyag020 I'm on the same one- which of the requirements do you have left?
DJ
@qualitymanifest
Jun 08 2016 04:49
jinx
Coy Sanders
@coymeetsworld
Jun 08 2016 04:49
@qualitymanifest yeah they changed it recently
@ydeepk
Jun 08 2016 04:49
Coy Sanders
@coymeetsworld
Jun 08 2016 04:49
found that out yesterday lol, had to change my solution to get it to work
SHREYA GUPTA
@shreyag020
Jun 08 2016 04:51
@kaitlinmctigue 2,3,5
Coy Sanders
@coymeetsworld
Jun 08 2016 04:51
@shreyag020 your nested else statement also needs work
``````else {
collection[id].tracks = value;
}``````
this only will get here if the property is not tracks
so you don't want to hardcode that here
DJ
@qualitymanifest
Jun 08 2016 04:52
@shreyag020 also here `delete collection.id.prop;` remember to use bracket notation when using variables
Coy Sanders
@coymeetsworld
Jun 08 2016 04:52
has to be something esle
yes you can't use dot notation w/ variables
Katie McTigue
@kaitlinmctigue
Jun 08 2016 04:54
``````js
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "") {

if (prop !== "tracks") {
collection[id][prop] = value;
}

else if (prop == "tracks") {
if (collection[id].hasOwnProperty("tracks")) {
collection[id].tracks.push(value);
}
else {
collection[id].tracks = value;
}
}
}

else {
delete collection[id][prop];

}

return collection;
}

// Alter values below to test your code
updateRecords(5439, "tracks", "Take a Chance on Me");``````
@qualitymanifest thanks for that, that solved one of my problems but I still have req 2 problems, not sure why
CamperBot
@camperbot
Jun 08 2016 04:54
kaitlinmctigue sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:warning: kaitlinmctigue already gave qualitymanifest points
Coy Sanders
@coymeetsworld
Jun 08 2016 04:56
look what we said above @kaitlinmctigue, we both said same answer although mine was directed at @shreyag020
Katie McTigue
@kaitlinmctigue
Jun 08 2016 04:56
Coy Sanders
@coymeetsworld
Jun 08 2016 04:57
oh wait i see
Katie McTigue
@kaitlinmctigue
Jun 08 2016 04:57
is that not what I'm doing in the else statement?
Coy Sanders
@coymeetsworld
Jun 08 2016 04:57
so what you need to do is set tracks to an empty array, not value
DJ
@qualitymanifest
Jun 08 2016 04:57
or set it to [value[
whoops
[value]
Coy Sanders
@coymeetsworld
Jun 08 2016 04:57
then push value onto it just like you would if it had the tracks property
or yeah that too @qualitymanifest
Nick Ang
@nickangtc
Jun 08 2016 04:58
Hey guys, I'm stuck at the weather challenge... been going at it (at a very basic level by now) for a full day and I don't know what's wrong. Can someone here try clicking "Get Location" on my codepen project and see if it can obtain and display your geolocation?
http://codepen.io/nickang/full/oLjPGz/
Katie McTigue
@kaitlinmctigue
Jun 08 2016 04:59
oh! hmm how would I set an empty array?
Coy Sanders
@coymeetsworld
Jun 08 2016 04:59
var emptyArr = [];
Katie McTigue
@kaitlinmctigue
Jun 08 2016 04:59
something like collection.id.tracks[] ?
Coy Sanders
@coymeetsworld
Jun 08 2016 04:59
thats how you would set the variable emptyArr to an empty array
Nick Ang
@nickangtc
Jun 08 2016 05:00
My guess after having a crack at it (with a number of console.logs) is that my browser permissions are messed up and don't allow navigator.geolocation to obtain my location... but I've checked my Chrome settings and allowed codepen
Coy Sanders
@coymeetsworld
Jun 08 2016 05:00
but you can also set it to initialize w/ a value in it as @qualitymanifest
archan6le
@archan6le
Jun 08 2016 05:00

Why does nothing log to the console:

```

var arr = [
[1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
console.log(arr[i][j]);
}
}

Coy Sanders
@coymeetsworld
Jun 08 2016 05:00
by doing emptyArr = [value]; instead, which w/ how you wrote your code may work better
less code this way, dont have to push on a separate line
Katie McTigue
@kaitlinmctigue
Jun 08 2016 05:00
okay so @coymeetsworld 's way: collection.id.tracks = []; ?
Coy Sanders
@coymeetsworld
Jun 08 2016 05:00
that and then push value just like you did before
i actually have my code separated differently I can pm you what I have after you pass to show you why I do it that way
Katie McTigue
@kaitlinmctigue
Jun 08 2016 05:01
and @qualitymanifest 's way something like: collection.id.tracks = [value]; ?
DJ
@qualitymanifest
Jun 08 2016 05:02
collection[id].tracks = value, yeah. just gotta use bracket notation for id since its a variable
Coy Sanders
@coymeetsworld
Jun 08 2016 05:02
yes, but in my version you would also need to push value after initializing empty array
Jeff
@meankraken
Jun 08 2016 05:02
@nickangtc Hey Nick, problem was way simpler.. in your jquery you're targetting locationmessage as a class; it's an id in the HTML
Katie McTigue
@kaitlinmctigue
Jun 08 2016 05:02
ok I passed using @coymeetsworld 's way, thanks! And I would love to see how you set it up
CamperBot
@camperbot
Jun 08 2016 05:02
kaitlinmctigue sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1095 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Nick Ang
@nickangtc
Jun 08 2016 05:03
@meankraken ooh, I've corrected that - thanks. But still can't get location :(
CamperBot
@camperbot
Jun 08 2016 05:03
nickangtc sends brownie points to @meankraken :sparkles: :thumbsup: :sparkles:
Katie McTigue
@kaitlinmctigue
Jun 08 2016 05:03
But @qualitymanifest I'm trying to understans the other way also
Jeff
@meankraken
Jun 08 2016 05:04
@nickangtc I get a location on my end, so yeah probably something wrong locally
Coy Sanders
@coymeetsworld
Jun 08 2016 05:04
I sent you a PM @kaitlinmctigue
Katie McTigue
@kaitlinmctigue
Jun 08 2016 05:04
oh nvm I got it to work that way too. Thanks everyone!
Jeff
@meankraken
Jun 08 2016 05:04
maybe try resetting cache/cookies? or a different browser entirely?
Nick Ang
@nickangtc
Jun 08 2016 05:04
Oh you did? NICE. That destroyed a lot of other suspicions
Yep I'm going to do that now. Thanks a lot for trying it out and the feedback
Gonna start by seeing if chrome needs to be updated
SHREYA GUPTA
@shreyag020
Jun 08 2016 05:05
else if(value!==""&& prop==="tracks"){
if (collection[id].hasOwnProperty("tracks")) {
collection[id].tracks.push(value);
} else {
collection[id].tracks = value;
}
@coymeetsworld i have done that still there is problem
Coy Sanders
@coymeetsworld
Jun 08 2016 05:06
that else statement still needs work as I said before @shreyag020
oh wait it is a little different
well we were kind of talking about it before with @kaitlinmctigue, but if it doesn't have that property you need to initialize tracks to an array
you're just assigning tracks to a value, but what you need to do is make it an array with value as the first element in it
DJ
@qualitymanifest
Jun 08 2016 05:07
@meankraken im guessing you're not using chrome?
Jeff
@meankraken
Jun 08 2016 05:08
@qualitymanifest Using firefox
DJ
@qualitymanifest
Jun 08 2016 05:08
@nickangtc :point_up: thats why

if you check your console you will get:

getCurrentPosition() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.

SHREYA GUPTA
@shreyag020
Jun 08 2016 05:10
@coymeetsworld
else {
collection[id].tracks = [value];
}
Coy Sanders
@coymeetsworld
Jun 08 2016 05:10
yeah that should work
SHREYA GUPTA
@shreyag020
Jun 08 2016 05:10
no, it doesn't
Coy Sanders
@coymeetsworld
Jun 08 2016 05:10
which tests fail?
also show entire code again please
SHREYA GUPTA
@shreyag020
Jun 08 2016 05:10

function updateRecords(id, prop, value) {
if(value!==""&& prop!=="tracks"){
collection[id][prop] = value;
}
else if(value!==""&& prop==="tracks"){
if (collection[id].hasOwnProperty("tracks")) {
collection[id].tracks.push(value);
} else {
collection[id].tracks = [value];
}

}
else if(value===""){
delete collection.id.prop;
}

Coy Sanders
@coymeetsworld
Jun 08 2016 05:11
is that all of the function? wheres your return statement?
SHREYA GUPTA
@shreyag020
Jun 08 2016 05:12
yes
Coy Sanders
@coymeetsworld
Jun 08 2016 05:12
i don't see a return statement
SHREYA GUPTA
@shreyag020
Jun 08 2016 05:12

function updateRecords(id, prop, value) {
if(value!==" "&& prop!=="tracks"){
collection[id][prop] = value;
}
else if(value!==" "&& prop==="tracks"){
if (collection[id].hasOwnProperty("tracks")) {
collection[id].tracks.push(value);
} else {
collection[id].tracks = [value];
}

}
else if(value===" "){
delete collection.id.prop;
}
return collection;
}

Coy Sanders
@coymeetsworld
Jun 08 2016 05:13
`if(value!==" "&& prop!=="tracks"){`
shouldn't be a space there
SHREYA GUPTA
@shreyag020
Jun 08 2016 05:14
how space createany problem
Coy Sanders
@coymeetsworld
Jun 08 2016 05:14
because "" and " " are not the same
"" is empty, " " has a space
youre supposed to check if value is non-blank, per the instructions
SHREYA GUPTA
@shreyag020
Jun 08 2016 05:15
okay i removed it but problem is still there
Coy Sanders
@coymeetsworld
Jun 08 2016 05:16
you have it here too `else if(value===" "){`
SHREYA GUPTA
@shreyag020
Jun 08 2016 05:16
yups remove it from every place
Coy Sanders
@coymeetsworld
Jun 08 2016 05:17
SHREYA GUPTA
@shreyag020
Jun 08 2016 05:18
done but...
Zach
@Moose1551
Jun 08 2016 05:18

This code:

``````function rot13(str) {
var newString = '';

for (var i = 0; i < str.length; i++) {
newString += str[i].charCodeAt(0) + " ";
} return newString;
}

rot13("SERR PBQR PNZC");``````

returns 83 69 82 82 32 80 66 81 82 32 80 78 90 67

Is there any way to add 13 to anything <= the number 78? For example, how would I go about adding 13 to 69 so that I get 82?

Markus Kiili
@Masd925
Jun 08 2016 05:20
@Moose1551 You could get the charcode of the looped character and check with if whether it needs changing.
Zach
@Moose1551
Jun 08 2016 05:22

so

``````if (fromCharCode() <= 78) {
return fromCharCode() + 13
}``````

?

SHREYA GUPTA
@shreyag020
Jun 08 2016 05:24
Gautham Chander
@Gauthamchander
Jun 08 2016 05:24

function testLogicalOr(val) {
// Only change code below this line

if (val >=10 || val <= 20) {
return "Inside";
}
// Only change code above this line
return "Outside";
}

// Change this value to test
testLogicalOr(15);
testLogicalOr(10);
testLogicalOr(0);
testLogicalOr(19);
testLogicalOr(20);
testLogicalOr(9);

testLogicalOr(0) should return "Outside"
testLogicalOr(9) should return "Outside"
Coy Sanders
@coymeetsworld
Jun 08 2016 05:24
Gautham Chander
@Gauthamchander
Jun 08 2016 05:24
getting this error pls help
Coy Sanders
@coymeetsworld
Jun 08 2016 05:24
last thing you wrote was but, then you were asking for help in the other chat...
Kay
@PandaProgrammer
Jun 08 2016 05:24

Hey I could use some help. I don't see what I am doing wrong here ...

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!";
}

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

// Change these values to test
golfScore(5, 4);

Gautham Chander
@Gauthamchander
Jun 08 2016 05:25
im not getting the value outside
SHREYA GUPTA
@shreyag020
Jun 08 2016 05:25
@coymeetsworld problem not solved
Coy Sanders
@coymeetsworld
Jun 08 2016 05:26
what is it failing on?
Markus Kiili
@Masd925
Jun 08 2016 05:26
@Moose1551 It is certain range of charcodes that need changing.
fearofshorts
@fearofshorts
Jun 08 2016 05:27
Hey, is anyone able to help me with "Record Collection"?
I can't seem to see what is wrong with my code...
function updateRecords(id, prop, value) {
```if (value !== "") { if (prop != "tracks") { collection[id][prop] = value; } else { collection[id].tracks.push(value); } } else { delete collection[id][prop]; } }```
Hmm... that markdown didn't seem to work there either...
Evgueni
@Redoras
Jun 08 2016 05:28
Does bootstrap or css have built in weather icons or do I how to import them somehow?
Kay
@PandaProgrammer
Jun 08 2016 05:28
nevermind I figured out my problem. Thanks anyway!
Zach
@Moose1551
Jun 08 2016 05:28
@Masd925 , I've been stuck on this for 2 weeks. I'm going to bag it and go through basic java for the third time. I have no idea when any of this is going to click, haha.
Gautham Chander
@Gauthamchander
Jun 08 2016 05:28

function testLogicalOr(val) {
// Only change code below this line

if (val >=10 || val <=20) {
return "Inside";
}
// Only change code above this line
return "Outside";
}

// Change this value to test
testLogicalOr(15);
testLogicalOr(10);
testLogicalOr(0);
testLogicalOr(19);
testLogicalOr(20);
testLogicalOr(9);

SHREYA GUPTA
@shreyag020
Jun 08 2016 05:28
@coymeetsworld 3& 5
Gautham Chander
@Gauthamchander
Jun 08 2016 05:28
testLogicalOr(0) should return "Outside"
testLogicalOr(9) should return "Outside"