These are chat archives for FreeCodeCamp/HelpJavaScript

3rd
Jan 2017
uriznik
@uriznik
Jan 03 2017 00:02
@lettda you're creating a function but not calling it, you could do something like weekly_data.slice(0,5).forEach(d => console.log(d));
rlaudick
@rlaudick
Jan 03 2017 00:14

Im stuck on Quoting Strings with single quotes, can anyone help? I don't understand how this isn't correct:

var myStr ='<a href="http:www.example.com" target="_blank">Link</a>';

Ryan Babka
@archimedes88
Jan 03 2017 00:18

'''
//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 (var i = 0; contacts[i].firstName = firstName; i++)
// Only change code above this line
}

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

CamperBot
@camperbot
Jan 03 2017 00:18
:bulb: to format code use backticks! ``` more info
KasehRawr
@KasehRawr
Jan 03 2017 00:18
hay everyone!
Ryan Babka
@archimedes88
Jan 03 2017 00:19
//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 (var i = 0; contacts[i].firstName = firstName; i++)
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
KasehRawr
@KasehRawr
Jan 03 2017 00:19

I'm having some trouble comprehending the switch statements, could someone please tell me what i'm doing wrong?

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val) {
case val === 1:
return "alpha";
break;

}

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

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

Ryan Babka
@archimedes88
Jan 03 2017 00:20
i need a hint here on how to format this i know i need a loop and an if else statement but not sure how to format it...
justinbarr00
@justinbarr00
Jan 03 2017 00:21
@archimedes88 You will need a For loop. In this for loop you will have an if statement to check for the firstName existance and then another one to check the prop and print it (within your first if statement).
uriznik
@uriznik
Jan 03 2017 00:22
@rlaudick try reset'ing and doing it again
rlaudick
@rlaudick
Jan 03 2017 00:23
@uriznik I've done that several times..
Ryan Babka
@archimedes88
Jan 03 2017 00:23
@justinbarr00 thank you
CamperBot
@camperbot
Jan 03 2017 00:23
archimedes88 sends brownie points to @justinbarr00 :sparkles: :thumbsup: :sparkles:
:cookie: 222 | @justinbarr00 |http://www.freecodecamp.com/justinbarr00
justinbarr00
@justinbarr00
Jan 03 2017 00:24
@archimedes88 so - For each entry in contact, check if the first name === first name. If it matches, check that property=property and print that property if it does ( If not, print the error). If it doesnt match firstName, print other error.
Good luck! It was a tough one for me
uriznik
@uriznik
Jan 03 2017 00:27
@rlaudick only remove \'s not any /'s
Skylar
@SkylarGmaker
Jan 03 2017 00:27

Can Someone tell me why the hole in one doesn't work???
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 "Change Me";
// Only change code above this line
}

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

rlaudick
@rlaudick
Jan 03 2017 00:28
@uriznik oh wow... i've been staring at it so long I didn't realize I was missing them from the http://
thanks!
Thien Nguyen
@winmintin
Jan 03 2017 00:28

'''

function nextInLine(arr, item) {
// Your code here
testArr.push(item);
var itemRemoved = testArr.shift();
return itemRemoved; // Change this line
}

// Test Setup
var testArr = [5,6,7,8,9];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
'''

CamperBot
@camperbot
Jan 03 2017 00:28
:bulb: to format code use backticks! ``` more info
Thien Nguyen
@winmintin
Jan 03 2017 00:28

,,,

function nextInLine(arr, item) {
// Your code here
testArr.push(item);
var itemRemoved = testArr.shift();
return itemRemoved; // Change this line
}

// Test Setup
var testArr = [5,6,7,8,9];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
,,,

Moisés Man
@moigithub
Jan 03 2017 00:29
@winmintin u should work with the parameters function nextInLine(arr, item) { <<
not testArr
Thien Nguyen
@winmintin
Jan 03 2017 00:29
ok let me try
@moigithub cook it work ty
CamperBot
@camperbot
Jan 03 2017 00:29
winmintin sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2409 | @moigithub |http://www.freecodecamp.com/moigithub
Skylar
@SkylarGmaker
Jan 03 2017 00:30
Nevermind it worked, I had capital letters but the assignment didn't want them
Ian Lee
@asparism
Jan 03 2017 00:30
does anyone know why none of the javascript click events are working in this codepen? https://codepen.io/Asparism/pen/ygBORr?editors=1010
*aren't working
Thien Nguyen
@winmintin
Jan 03 2017 00:33
var test = "testing";
Carlos I. Santiago
@csantiago23
Jan 03 2017 00:35
Quick question to anyone what this symbol (%) means when using it as a comparison?
Stanley Su
@cuddlycuddles
Jan 03 2017 00:36
@csantiago23 As in a mathematical comparison? It determines the remainder when the first number is divided by the second number.
soylatino24
@soylatino24
Jan 03 2017 00:36
help please with the Word Blanks lesson
CamperBot
@camperbot
Jan 03 2017 00:36
no wiki entry for: please with the word blanks lesson
Gia
@GiaGenitoVzla
Jan 03 2017 00:36
please help with this excersice
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
var myStr; "FirstLine\n\SecondLine\\rThirdLine"
Stanley Su
@cuddlycuddles
Jan 03 2017 00:37
@soylatino24 Just combine the arguments together.
soylatino24
@soylatino24
Jan 03 2017 00:37
I got that one already thanks
but now i am stucked at the word blanks
Moisés Man
@moigithub
Jan 03 2017 00:38
@GiaGenitoVzla how u ASSIGN(store/give/set) a value to a variable??
ie.. assign 4 to mynum ?
Carlos I. Santiago
@csantiago23
Jan 03 2017 00:38
Thanks @cuddlycuddles ....
CamperBot
@camperbot
Jan 03 2017 00:38
csantiago23 sends brownie points to @cuddlycuddles :sparkles: :thumbsup: :sparkles:
:cookie: 302 | @cuddlycuddles |http://www.freecodecamp.com/cuddlycuddles
soylatino24
@soylatino24
Jan 03 2017 00:39

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

Stanley Su
@cuddlycuddles
Jan 03 2017 00:40
@soylatino24 Try combining the arguments in the function and assigning it to result.
wlagos1992
@wlagos1992
Jan 03 2017 00:45
var myObj = {
  "Space Name": "Kirk",
  "More Space": "Spock"
};
myObj["Space Name"]; // Kirk
myObj['More Space']; // Spock

this is the example but when i use my code it doesnt work...


// Setup
var testObj = {
  "an entree": "hamburger",
  "my side": "veggies",
  "the drink": "water"
};

// Only change code below this line

testObj["an entree"];   // Change this line
testObj['the drink'];    // Change this line

The description doesnt give me a clear idea of what im doing, does anyone have suggestions?

Moisés Man
@moigithub
Jan 03 2017 00:47
try to refresh the browser @wlagos1992
code looks ok
wlagos1992
@wlagos1992
Jan 03 2017 00:48
Lines 11 and 12 (the last two) have Red X saying "expected an ssignment or function call and instead saw an expression"
Moisés Man
@moigithub
Jan 03 2017 00:49
soo whats the instructions ?
wlagos1992
@wlagos1992
Jan 03 2017 00:49
Read the values of the properties "an entree" and "the drink" of testObj using bracket notation and assign them to entreeValue and drinkValue respectivel
sorry ill do that better
Read the values of the properties "an entree" and "the drink" of testObj using bracket notation and assign them to entreeValue and drinkValue respectivel
Moisés Man
@moigithub
Jan 03 2017 00:49
and assign them to entreeValue and drinkValue respectivel
soo u should have 2 variables..
and assign the result of testObj["an entree"]; to entreeValue
etc..
ie
theVarTheInstructionSay = testObj["an entree"];
and the other.....
wlagos1992
@wlagos1992
Jan 03 2017 00:51
thank you @moigithub since the example didnt have the var thats where i got lost
CamperBot
@camperbot
Jan 03 2017 00:51
wlagos1992 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2410 | @moigithub |http://www.freecodecamp.com/moigithub
Damien
@okvitae
Jan 03 2017 00:52
var myCar = function(wheels, seats, engines) {
  this.wheels = wheels;
  this.seats = seats; 
  this.engines = engines;
  };

new myCar(4, 2, 1);
why in the world won't this run?
soylatino24
@soylatino24
Jan 03 2017 00:52
@cuddlycuddles give me an example please
John Calhoun
@DougCal
Jan 03 2017 00:53
I'm working on the Pomodoro Clock project and am running into a bug when the break clock runs. I still developing it, so you will find a good amount of bugs, just wondering if somebody could help me find out why negative numbers keep popping up. Before it's mentioned, I intentionally made it 100 milliseconds so I don't have to wait through the timer to find bugs. http://codepen.io/dougcal/pen/MbMvGP?editors=0010
Moisés Man
@moigithub
Jan 03 2017 00:53
when u create a new car... it return a new object.. so u need to assign it somewhere @okvitae
but looks code is incomplete?
@okvitae
Stanley Su
@cuddlycuddles
Jan 03 2017 00:53
@soylatino24
function rawr (a, b, c) { var result = a + b + c; return result; }
Moisés Man
@moigithub
Jan 03 2017 00:54
@soylatino24 do u know how to concatenate strings ??
Stanley Su
@cuddlycuddles
Jan 03 2017 00:54
^
Damien
@okvitae
Jan 03 2017 00:56
@moigithub I read the instructions wrong. It works now thanks
CamperBot
@camperbot
Jan 03 2017 00:56
okvitae sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2411 | @moigithub |http://www.freecodecamp.com/moigithub
soylatino24
@soylatino24
Jan 03 2017 00:58
with the sign
with the + sign
emr53f
@emr53f
Jan 03 2017 00:59
so the instructions are "Combine the two if statements into one statement which returns "Outside" if val is not between 10 and 20, inclusive. Otherwise, return "Inside"."

I put:
function testLogicalOr(val) {
if (val <= 9.9 || val >= 20.1 ) {
return "Outside";
}
return "Inside";
}

testLogicalOr(15);

I feel like I cheated, though, with the 9.9/20.1 numbers
soylatino24
@soylatino24
Jan 03 2017 01:01
@cuddlycuddles var result = "mynoun" + "myAdjective" + "myVerb" + "myAdverb";
Stanley Su
@cuddlycuddles
Jan 03 2017 01:01
@soylatino24 You're getting there. But something will be wrong with the output once you test it.
@emr53f You can do if (val < 10) rather than val <= 9.9.
jayisray
@jayisray
Jan 03 2017 01:05
Can someone help me figure out why my Wikipedia API call isn’t producing any results?https://jayisray.github.io/WikipediaViewer/script.js
Dan Couper
@DanCouper
Jan 03 2017 01:07
@emr53f it’s inclusive of 10 and 20, you don’t need decimal places (otherwise, what if it was 9.99 or 9.999 or 9.99999999999 and so on, there are an infinite number of numbers between 9.9 and 10)
soylatino24
@soylatino24
Jan 03 2017 01:08
I'm taking a little break-time. thanks @cuddlycuddles
CamperBot
@camperbot
Jan 03 2017 01:08
soylatino24 sends brownie points to @cuddlycuddles :sparkles: :thumbsup: :sparkles:
:cookie: 303 | @cuddlycuddles |http://www.freecodecamp.com/cuddlycuddles
uriznik
@uriznik
Jan 03 2017 01:09
@DougCal you're decrementing sessNum but should it ever be reset to something?
@jayisray check your browser console
jayisray
@jayisray
Jan 03 2017 01:10
@uriznik i did
nothing of value thre
there*
uriznik
@uriznik
Jan 03 2017 01:11
@jayisray does the alert(url) run but not the console.log in the ajax success function?
jayisray
@jayisray
Jan 03 2017 01:12
@uriznik exactly
Dan Couper
@DanCouper
Jan 03 2017 01:12
@jayisray can’t test now as going to bed (sorry!), but a. don’t dynamically add a form that then calls the function, put the form in the HTML and attach the event to ’submit’ (so the form should have a text input and a submit button), b. if you using a form, you are POSTing to Wikipedia, so the $.ajax needs a type of POST, it will default to GET otherwise, c. why is the url different inside and outside the ajax call?
if you really want the image to disappear and the form to show on click, put both in the html and hide one and show the other, and it’s easier to use CSS rather than attaching an event to it: if you are using the event, then put them both in a container element, and change class on that so the image gets hidden and the form gets unhidden; don’t dynamically generate, there’s no need and it complicates the logic substantially
WVKING20
@WVKING20
Jan 03 2017 01:16
Can someone help me with the stand in line exercise?
I understand the concept of the queue but again don't understand the websites directions
mitron6
@mitron6
Jan 03 2017 01:18
@WVKING20 Which exercise/line?
WVKING20
@WVKING20
Jan 03 2017 01:18
It's called "Stand in Line"
It says to write the function nextInLine but isn't it already there?
sunshineacid
@sunshineacid
Jan 03 2017 01:19
@WVKING20 you are writing a function that turns an array into a queue
@WVKING20 so when you add values to it, they go to the end of the array
when you remove values from it, they come off the front
WVKING20
@WVKING20
Jan 03 2017 01:21
@sunshineacid Right so I need to add a function to the problem correct?
mitron6
@mitron6
Jan 03 2017 01:21
@WVKING20 The function is there but it is not complete.
sunshineacid
@sunshineacid
Jan 03 2017 01:21
the function is there, but you need to fill in the guts
Dan Couper
@DanCouper
Jan 03 2017 01:22
@jayisray if you attach it to keypress, it will start to search as soon as you type anything, so if you typed ‘wikipedia’, it would search ‘’ (for the first keypress there will not be a value), then ‘w’ then ‘wi’ then ‘wik’ and so on (note if you do this, you should use ‘keyup’ instead to capture after someone has typed). ‘submit’ is better because at that point the user has entered what they want, and is deliberately searching. Listening for kepresses means you will make potentially a very large number of AJAX requests, which means slowness, andalso means you then need a way to handle streaming responses (just searching for ‘w’ is likely to get you hundreds of thousands of results)
WVKING20
@WVKING20
Jan 03 2017 01:23
@sunshineacid I understand what you're saying but I don't get what else to add to the function
mitron6
@mitron6
Jan 03 2017 01:24

@WVKING20

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.

Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

Dan Couper
@DanCouper
Jan 03 2017 01:24
@jayisray ah, you’re limiting it to code 13, I didn’t see that. Still, use submit, it’s what it’s there for, using keypress to mimic that behaviour is inviting problems.
sunshineacid
@sunshineacid
Jan 03 2017 01:24
@WVKING20 so, the shell that they provide you takes 2 arguments. 1) array you are modifying, 2) the item that you are adding to the array
mitron6
@mitron6
Jan 03 2017 01:25
@WVKING20 So the first task is to add the item to the end of the array.
WVKING20
@WVKING20
Jan 03 2017 01:25
it should be return item + 1; right?
WVKING20
@WVKING20
Jan 03 2017 01:27
@mitron6 @sunshineacid Wow thanks guys I don't know how i missed out on the push thing lol
CamperBot
@camperbot
Jan 03 2017 01:27
:cookie: 424 | @mitron6 |http://www.freecodecamp.com/mitron6
:cookie: 272 | @sunshineacid |http://www.freecodecamp.com/sunshineacid
wvking20 sends brownie points to @mitron6 and @sunshineacid :sparkles: :thumbsup: :sparkles:
soylatino24
@soylatino24
Jan 03 2017 01:47
@cuddlycuddles are you still here?
Stanley Su
@cuddlycuddles
Jan 03 2017 01:48
Yeah what's up my homie
soylatino24
@soylatino24
Jan 03 2017 01:48
@cuddlycuddles result = "my " + myNoun + " is " + myAdjective + " and he used to " + myVerb + " very " + myAdverb; I git it now
Stanley Su
@cuddlycuddles
Jan 03 2017 01:49
@soylatino24 So did you pass the challenge?
@soylatino24 Yeah that's partially right but the output is wrong
emr53f
@emr53f
Jan 03 2017 01:49
thank you @cuddlycuddles @DanCouper !
CamperBot
@camperbot
Jan 03 2017 01:49
emr53f sends brownie points to @cuddlycuddles and @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 432 | @dancouper |http://www.freecodecamp.com/dancouper
:cookie: 304 | @cuddlycuddles |http://www.freecodecamp.com/cuddlycuddles
Stanley Su
@cuddlycuddles
Jan 03 2017 01:49
nvm
soylatino24
@soylatino24
Jan 03 2017 01:50
@cuddlycuddles
result = "my " + myNoun + " is " + myAdjective + " and he used to " + myVerb + " very " + myAdverb;
Stanley Su
@cuddlycuddles
Jan 03 2017 01:51
wait nvm all g
Naeri Adam Fernandez
@naeri-kailash
Jan 03 2017 01:52
am doing convert celsius to fahrenheit exercise and not sure what im doing wrong but i can't see the solution .. pls help?
soylatino24
@soylatino24
Jan 03 2017 01:52
@cuddlycuddles here is the output: "my dog is big and he used to ran very quickly".
Stanley Su
@cuddlycuddles
Jan 03 2017 01:53
you don't need 'and he used to' btw
@naeri-kailash Yes
@naeri-kailash Send me your code
Naeri Adam Fernandez
@naeri-kailash
Jan 03 2017 01:53

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var celcius;
fahrenheit = (celcius * (9/5) + 32);

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

// Change the inputs below to test your code
convertToF(30);

thanks ^.^
soylatino24
@soylatino24
Jan 03 2017 01:53
@cuddlycuddles i was just wondering with more words
@cuddlycuddles thank you again.
CamperBot
@camperbot
Jan 03 2017 01:54
soylatino24 sends brownie points to @cuddlycuddles :sparkles: :thumbsup: :sparkles:
:warning: soylatino24 already gave cuddlycuddles points
Moisés Man
@moigithub
Jan 03 2017 01:55
@naeri-kailash u need to use this parameter function convertToF(celsius) { <<<
Stanley Su
@cuddlycuddles
Jan 03 2017 01:55
@naeri-kailash You don't need to declare the celcius variable.
Naeri Adam Fernandez
@naeri-kailash
Jan 03 2017 01:56
it tells me off if i dont haha, and even then wont work
ReferenceError: celcius is not defined
Stanley Su
@cuddlycuddles
Jan 03 2017 01:56
@naeri-kailash Also I am not sure if javascript uses pedmas or bodmas, but it'd be better to group together the multiplication and separate it from the addition
ok bye lunch
Moisés Man
@moigithub
Jan 03 2017 01:57
@naeri-kailash RE-read the name on the parenthesis... its NOT celcius...
jv775
@jv775
Jan 03 2017 01:59
please help. I am stuck in lesson #23 Quoting Strings with Single Quotes.
Naeri Adam Fernandez
@naeri-kailash
Jan 03 2017 02:01
it's okay i sorted it with a refresh, thanks will know to do that first thing next time
Johnny
@JohnnyBizzel
Jan 03 2017 02:02
@jv775 var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';
Rebecca
@alimily
Jan 03 2017 02:04
Profile Lookup this pass ,i have questions
hope someone can help me

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

if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop) ){
return contacts[i][prop];
}

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

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

}

jv775
@jv775
Jan 03 2017 02:05
@JohnnyBizzel thank you. I will try right now.
CamperBot
@camperbot
Jan 03 2017 02:05
jv775 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1090 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Stephen James
@sjames1958gm
Jan 03 2017 02:07
@alimily How can you return no such contact before you have looked through all the contacts?
jv775
@jv775
Jan 03 2017 02:10

@ Only remove the backslashes \ used to escape quotes.

@johnnybizzel

Rebecca
@alimily
Jan 03 2017 02:10
o,i understand what do you mean
thks
sunshineacid
@sunshineacid
Jan 03 2017 02:11
Can someone help me with my JS on the random quote generator? The code I have works locally, but won't work on codepen. I'm suspecting something codepen specific is getting in the way.
$(document).ready(function() {
    $("#getMessage").on("click", function(){
        $.getJSON("http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?", function(json) {
        document.getElementById("quote_text").innerHTML = json.quoteText;
        document.getElementById("auth").innerHTML = "-" + json.quoteAuthor;
        });
    });
});
Ryan Babka
@archimedes88
Jan 03 2017 02:14

//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 (var i = 0; i < contacts.length; i++){
    if(firstName == contacts[i].firstName && contacts[i][prop] !== undefined) {
      return  contacts[i][prop];
    }
    else if(firstName !== contacts[i].firstName) {
      return "No such contact";
    }
    else if(contacts[i][prop] === undefined){
      return "No such property";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Sherlock", "likes");
can i get a hint at what im doing wrong?
please
Ty
@Medic1
Jan 03 2017 02:16

I'm stuck with the no global myVar variable. Anybody?
function myLocalScope() {var myVar =
'use strict';

console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

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

Stephen James
@sjames1958gm
Jan 03 2017 02:16
@archimedes88 You cannot return no such contact until you have gone through all the contacts
Ryan Babka
@archimedes88
Jan 03 2017 02:17
hmmmm....ok ill figure it out thank you @sjames1958gm
CamperBot
@camperbot
Jan 03 2017 02:17
archimedes88 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5118 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jan 03 2017 02:18
@Medic1 Do what the last line says
@sunshineacid Open your devtools console and check for errors.
Ty
@Medic1
Jan 03 2017 02:19
@sjames1958gm When I do, it still has a red x next to the No global myVar variable
Stephen James
@sjames1958gm
Jan 03 2017 02:19
@Medic1 try refreshing the browser page
sunshineacid
@sunshineacid
Jan 03 2017 02:19
@sjames1958gm no errors. When I run locally, it works fine. On codepen, I can't get it to give an error or run completely through the script
Ty
@Medic1
Jan 03 2017 02:20
well that was easy...thanks
@sjames1958gm
Stephen James
@sjames1958gm
Jan 03 2017 02:20
@sunshineacid can you post your codepen URL?
Tyler Langan
@TylerL-uxai
Jan 03 2017 02:20
Hello everyone! :D
Stephen James
@sjames1958gm
Jan 03 2017 02:20
@Medic1 Probably you had defined myVar globally and then changed it and it was still there until refresh
Tyler Langan
@TylerL-uxai
Jan 03 2017 02:20
function createCustomer() { 
    Customer.create({ email: 'test@gmail.com' }); 
 }
createCustomer().then(
    getUserCallback (result) => {
    console.log('the result is ...', result);      }
Stephen James
@sjames1958gm
Jan 03 2017 02:20
@TylerL-uxai Hi
Ty
@Medic1
Jan 03 2017 02:20
@sjames1958gm makes sense
Tyler Langan
@TylerL-uxai
Jan 03 2017 02:21
It's saying "Unexpected token, expected , " where the arrow is after 'result'
Stephen James
@sjames1958gm
Jan 03 2017 02:22
@sunshineacid You cannot access http:// URL from a page loaded with https:// you can use
http://codepen.io/sunshineacid/pen/LbwgaW?editors=0011
@TylerL-uxai arrow functions are by definition anonymous
sunshineacid
@sunshineacid
Jan 03 2017 02:24
@sjames1958gm wait, using https has disabled function JS?
Stephen James
@sjames1958gm
Jan 03 2017 02:24
@sunshineacid If you open the devtools console (not the codepen one) you will see an error saying you cannot load a http:// URL from a https:// location
Tyler Langan
@TylerL-uxai
Jan 03 2017 02:25
thanks @sjames1958gm
CamperBot
@camperbot
Jan 03 2017 02:25
tylerl-uxai sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5119 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
?
Stephen James
@sjames1958gm
Jan 03 2017 02:26
@sunshineacid Yes
sunshineacid
@sunshineacid
Jan 03 2017 02:26
@gd.
@sjames1958gm thanks.
CamperBot
@camperbot
Jan 03 2017 02:26
sunshineacid sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5120 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jan 03 2017 02:26
@sunshineacid :+1:
Hbart
@Hbart
Jan 03 2017 02:31

Hi All, can someone tell me what is wrong with this code. It's for the check for palindromes problem. Here is my code:
function palindrome(str) {
var newstr = str.replace(/ /i, /./i, /_/i, '');
newstr = newstr.toLowerCase();
var arr = [];
arr = newstr.split("");
arr = arr.reverse();
var newestStr = arr.join("");
if (newstr === newestStr) {
return true;
}
return false;
}

palindrome("eye");

Dylan Hsiao
@greedylan
Jan 03 2017 02:32
Can anyone give me a hint how to rewrite collection[i].last and source.last? The property of second object in WhatIsAName would have different input.
function whatIsInAName(collection, source) {
  var arr = [];

  for(var i=0; i<collection.length; i++){
    if( collection[i].hasOwnProperty(Object.keys(source)) && 
       collection[i].last === source.last ){
      arr.push(collection[i]);
    }
  }
  return arr;
}

whatIsInAName(
  [
   { first: "Romeo", last: "Montague" }, 
   { first: "Mercutio", last: null }, 
   { first: "Tybalt", last: "Capulet" }
  ], 

  { last: "Capulet" }
);
Hasan
@MHAhmed
Jan 03 2017 02:32

hi guys im a little stuck on the profile look up section....
here is my code so far...
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {

if (firstName === contacts.firstName && contacts.hasOwnProperty(prop) === true) {
  return contacts.prop;
}   else if (firstName !== contacts.firstName) {
      return "No such contact";
}   else if (contacts.hasOwnProperty(prop) === false) {
      return "No such property";
}

}
// Only change code above this line
}

Stephen James
@sjames1958gm
Jan 03 2017 02:33
@MHAhmed How can you return no such contact before you check all the contacts
Hasan
@MHAhmed
Jan 03 2017 02:35
@sjames1958gm so i should take out the false stuff from the loop then?
so only the if statement should be in the loop and the else if statements outside the loop
Rebecca
@alimily
Jan 03 2017 02:35
hahah ,the same question with me
i also have the same problem
Stephen James
@sjames1958gm
Jan 03 2017 02:37
@MHAhmed Well, if you make it through the loop without finding the contact then you can return no such contact
sunshineacid
@sunshineacid
Jan 03 2017 02:37
@Hbart what are you getting for newstr?
Hasan
@MHAhmed
Jan 03 2017 02:39
@sjames1958gm im confused
Stephen James
@sjames1958gm
Jan 03 2017 02:43
@MHAhmed move your return for no such contact after the forr loop
Dylan Hsiao
@greedylan
Jan 03 2017 02:43
can we write a loop inside an if statement??
Stephen James
@sjames1958gm
Jan 03 2017 02:43
@greedylan sure
Alex Wagner
@alexdwagner
Jan 03 2017 02:44
hey guys, can anyone help me with the "Quoting Strings with Single Quotes" lesson? it's probably really simple, just can't seem to figure out what I'm not doing.
Manish Giri
@Manish-Giri
Jan 03 2017 02:45
@alexdwagner your code?
Alex Wagner
@alexdwagner
Jan 03 2017 02:45
var myStr = '<a href= "http://www.example.com" target="_blank">Link</a>';
CamperBot
@camperbot
Jan 03 2017 02:45
:bulb: to format code use backticks! ``` more info
Stephen James
@sjames1958gm
Jan 03 2017 02:46
@alexdwagner make sure all the spacing is the same
Alex Wagner
@alexdwagner
Jan 03 2017 02:48
oh wow. i thought the spacing was arbitrary for some reason. lesson learned. thanks!
Stephen James
@sjames1958gm
Jan 03 2017 02:48
@alexdwagner Nope string checks are exact
Joseph
@revisualize
Jan 03 2017 02:49
@alexdwagner space?
Oh someone answered that.
LOL
Hbart
@Hbart
Jan 03 2017 02:49
@sunshineacid It's returning true for my code, but I can't get it to print newstr, so I'm not sure.
Joseph
@revisualize
Jan 03 2017 02:50
@MHAhmed Let's say you were at a big business event and throughout the event you got handed 200 business cards. Now, I walk up to you at the end and ask you.. Do you have a Business Card for "Jane Smith"? Now you loop look through your stack of 200 business cards. When would you tell me that you didn't have a business card for Jane?
Hasan
@MHAhmed
Jan 03 2017 02:51
@revisualize after going through them all
@revisualize in other words once the loop ends
May
@xSpideyx
Jan 03 2017 02:52
guys I'm new to working with javascript on code pen what do I have to do first to make it appear?
Stephen James
@sjames1958gm
Jan 03 2017 02:55
@xSpideyx You aren't affecting anything in the HTML / DOM
May
@xSpideyx
Jan 03 2017 02:56
can you post a example @sjames1958gm
Joseph
@revisualize
Jan 03 2017 02:56
@MHAhmed
  // code before a for loop.
for (..........) {
  // Code inside of a for loop.
}
  // code after a for loop.
sunshineacid
@sunshineacid
Jan 03 2017 02:57
@Hbart right after you assign your final value to newstr, alert or console.log value
Joseph
@revisualize
Jan 03 2017 02:57
@MHAhmed Not ONCE the loop ends. AFTER the loop has completed.
@MHAhmed There is a difference in verbiage but, based upon programming logic what you said and what I said may mean two different things.
Rebecca
@alimily
Jan 03 2017 02:58
@sjames1958gm
Hasan
@MHAhmed
Jan 03 2017 02:58
@revisualize yes what i meant was once loop has completed
Rebecca
@alimily
Jan 03 2017 02:58

function lookUp(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){
if(contacts[i].firstName == firstName){
if(contacts[i].hasOwnProperty){
return contacts[i][prop];
}else{
return "No such property";
}
}
}
return "No such contact";

// Only change code above this line
}

now that what is wrong with those codes
Joseph
@revisualize
Jan 03 2017 02:59
@alimily if(contacts[i].hasOwnProperty){
That line isn't correct.
Rebecca
@alimily
Jan 03 2017 02:59
oh,my god
Stephen James
@sjames1958gm
Jan 03 2017 02:59
@alimily hasOwnProperty needs a property to check has ownness on
Joseph
@revisualize
Jan 03 2017 02:59
@alimily You're not supplying a property for it to check and see if it has.
Rebecca
@alimily
Jan 03 2017 02:59
i too much careless
Joseph
@revisualize
Jan 03 2017 03:00
Wow that was some crazy lag.
Rebecca
@alimily
Jan 03 2017 03:00
thanks you a lot
i really appreciate your kindness
Joseph
@revisualize
Jan 03 2017 03:01
@sjames1958gm thanks.
CamperBot
@camperbot
Jan 03 2017 03:01
:star2: 5121 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
jv775
@jv775
Jan 03 2017 03:01
in the lesson Escape Sequences in Strings, how do I write myStr with encoded text with the proper escape sequences and no spacing?
CamperBot
@camperbot
Jan 03 2017 03:01
revisualize sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
Jan 03 2017 03:02
@jv775 What is the string that you need to escape? It's in the instructions above the RUN CODE
jv775
@jv775
Jan 03 2017 03:05
@revisualize yes its in the insrtuctions.
@revisualize I got a red X for myStr should have encoded text with the proper....
Hasan
@MHAhmed
Jan 03 2017 03:05
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
for (j = 0; j < contacts[i].length; j++) {
if (firstName === contacts[i].firstname && contacts[j].hasOwnProperty(prop) === true) {
return contacts.prop;
}
}
}
Joseph
@revisualize
Jan 03 2017 03:07
@MHAhmed Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
@MHAhmed You are also not accessing the array element.
@jv775 You know.. I cant't see what is on your screen.
jv775
@jv775
Jan 03 2017 03:08
@revisualize sorry. I am new at this and don't know how to copy and paste my code for you to see
Joseph
@revisualize
Jan 03 2017 03:08
@jv775 You just copy and paste.
jv775
@jv775
Jan 03 2017 03:09
@revisualize do I right click on the black code area? I tried and it doesn't let me copy and paste
Stephen James
@sjames1958gm
Jan 03 2017 03:10
@jv775 You should be able to select from the code editor and copy then paste here -
'''
CamperBot
@camperbot
Jan 03 2017 03:10
:bulb: to format code use backticks! ``` more info
Joseph
@revisualize
Jan 03 2017 03:10
@jv775
blob
Stephen James
@sjames1958gm
Jan 03 2017 03:10
@jv775 If you click that more info link above ^^^ it will give you more info
Hasan
@MHAhmed
Jan 03 2017 03:11
this is very hard
Joseph
@revisualize
Jan 03 2017 03:11
@MHAhmed It is difficult because it is taking all of your previous knowledge and trying to work through 1 challenge.
Hasan
@MHAhmed
Jan 03 2017 03:12
i forgot to declare my variable in the for loop
Joseph
@revisualize
Jan 03 2017 03:13
I feel that a lot of people struggle with this lesson and with Record Collection because they just went through the motions of completing challenges and not actually truly understanding what they were doing or why.
@MHAhmed I don't even know why you have two for loops. You only have 1 array.
jv775
@jv775
Jan 03 2017 03:14
@revisualize I am an idiot. its not working. I will just type out my code manually: var myStr ="FirstLine\n\SecondLine\r\ThirdLine";
Joseph
@revisualize
Jan 03 2017 03:14
@jv775 You're escaping your carriage-return and backslash ... backwards.
jv775
@jv775
Jan 03 2017 03:15
@revisualize ok thanks
CamperBot
@camperbot
Jan 03 2017 03:15
jv775 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2799 | @revisualize |http://www.freecodecamp.com/revisualize
Hasan
@MHAhmed
Jan 03 2017 03:15
@revisualize i went though it very slowly took me 1 week
Paul Vu
@shamwoox
Jan 03 2017 03:15
I am stuck on the Reverse a String exercise. What am I doing wrong?
function reverseString(str) {
var array = str.split();
str.reverse();
array.join();
str = array;
return str;
}
array.reverse()*
Rebecca
@alimily
Jan 03 2017 03:17
everyone ,i have one problem ,
the answer is right, but i can submit
Joseph
@revisualize
Jan 03 2017 03:17
@shamwoox str.reverse(); that isn't correct. you can't reverse a string. You need to reverse an array.
Hasan
@MHAhmed
Jan 03 2017 03:17
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (firstName === contacts[i].firstName && contacts.hasOwnProperty(prop) === true) {
return contacts[prop];
}
}
does this look okay now?
Joseph
@revisualize
Jan 03 2017 03:17
@alimily What is your function.
Rebecca
@alimily
Jan 03 2017 03:17
do you ever happen this
Joseph
@revisualize
Jan 03 2017 03:18
@MHAhmed No.
Rebecca
@alimily
Jan 03 2017 03:18
when i change my account to submit , then submit success
and the next pass ,i also can submit success
do you know the reason
Joseph
@revisualize
Jan 03 2017 03:19
@MHAhmed Look you're doing this: contacts[i].firstName but, contacts.hasOwnand contacts[prop] ... Do you magically not the the [i] anymore?
@alimily I've had issues.
Paul Vu
@shamwoox
Jan 03 2017 03:19
I don't know what's wrong still
function reverseString(str) {
var array = str.split('');
array.reverse();
array.join();
str = array;
return str;
}
Rebecca
@alimily
Jan 03 2017 03:19

function lookUp(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){
if(contacts[i].firstName == firstName){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}else{
return "No such property";
}
}
}
return "No such contact";

// Only change code above this line
}

Joseph
@revisualize
Jan 03 2017 03:19
@alimily I copy out my function. and reset the challenge.
Rebecca
@alimily
Jan 03 2017 03:19
here is the code
Joseph
@revisualize
Jan 03 2017 03:19
Then repost.
Hasan
@MHAhmed
Jan 03 2017 03:20
@revisualize ahh i see
Rebecca
@alimily
Jan 03 2017 03:20
when i change my account , then it can be submit success
Joseph
@revisualize
Jan 03 2017 03:20
@shamwoox You're not .join()ing correctly. .join() is the opposite of .split()
@alimily Reset the challenge and try again.
It happens.
Just have to reset and paste your code again.
lunaceee
@lunaceee
Jan 03 2017 03:21
function largestOfFour(arr) {

  var largest = [];
  for(i=0;i<arr.length;i++) {
    var maxValue = -Infinity;   // ???
    for (j=0;j<arr[i].length;j++) {
      if(arr[i][j] > maxValue){
        maxValue = arr[i][j];
      }
    }  
    largest.push(maxValue);
  }
   return largest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Working on this challenge: Return Largest Numbers in Arrays. Referring to a solution online but not quite sure about this line: var maxValue = -Infinity; Any advice? Thx
Joseph
@revisualize
Jan 03 2017 03:21
@alimily OH!
Your function name isn't correct.
@alimily You have function lookUp(firstName, prop){ but, the challenge has lookUpProfile()
Hasan
@MHAhmed
Jan 03 2017 03:22
@revisualize thank you i am getting somewhere now
CamperBot
@camperbot
Jan 03 2017 03:22
mhahmed sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2800 | @revisualize |http://www.freecodecamp.com/revisualize
Rebecca
@alimily
Jan 03 2017 03:24
@revisualize what do you mean by lookUpProfile()
i never found the lookUpProfile()
Joseph
@revisualize
Jan 03 2017 03:25
@alimily lookUpProfile("Akira", "likes");
blob
That is the challenge reset.
jayisray
@jayisray
Jan 03 2017 03:26
someone please help me with the wikipediaviewer challenge lol I’m so over this api bs xD
Joseph
@revisualize
Jan 03 2017 03:27
@alimily Do your instructions state:
A lookUpProfile function that takes firstName and a property (prop) as arguments has been pre-written for you.
@alimily If so.. You're doing function lookUp(firstName, prop) Your function name isn't correct.
revisualize @revisualize leaves.
Joseph
@revisualize
Jan 03 2017 03:28
Thai food. :D
Rebecca
@alimily
Jan 03 2017 03:33
@revisualize i get it ,thks
Evan
@CodeDraken
Jan 03 2017 03:39
@revisualize :wave: how's your liver
raja3233
@raja3233
Jan 03 2017 03:39
help me with that guds
CamperBot
@camperbot
Jan 03 2017 03:39
no wiki entry for: me with that guds
emr53f
@emr53f
Jan 03 2017 03:42
arghhh this is driving me crazy:

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

function checkObj(checkProp) {
// Your Code Here
var result = "";
if(myObj.hasOwnProperty("checkProp")){
result = myObj.checkProp;
return result;}

else{
return "Not Found";
}
}

working?
why isn't
Dustin McDaniel
@dmakk767
Jan 03 2017 03:42
("checkProp") does not need ""
you are checking for that exact string by using "checkProp"
emr53f
@emr53f
Jan 03 2017 03:43
@dmakk767 hmm, that didn't seem to work :/
Dustin McDaniel
@dmakk767
Jan 03 2017 03:44
using checkProp alone will use it as a variable
emr53f
@emr53f
Jan 03 2017 03:44
as in, if (checkProp){....}?
Dustin McDaniel
@dmakk767
Jan 03 2017 03:44
also myObj[checkProp]
you have to use brackets with variables not the dot
emr53f
@emr53f
Jan 03 2017 03:45
ahhh yep, it was the brackets! thank you very much @dmakk767 !
CamperBot
@camperbot
Jan 03 2017 03:45
emr53f sends brownie points to @dmakk767 :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @dmakk767 |http://www.freecodecamp.com/dmakk767
Dustin McDaniel
@dmakk767
Jan 03 2017 03:45
yw
Joseph
@revisualize
Jan 03 2017 03:47
@emr53f Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
Dustin McDaniel
@dmakk767
Jan 03 2017 03:48
@raja3233 your code seems to work. What is the issue?
raja3233
@raja3233
Jan 03 2017 03:49
well, issue is to get the output? any hint @dmakk767
Julio Valenzuela Jr.
@juliovalen
Jan 03 2017 03:50

CAn some one help ? Im stuck on the Golf Code. THis is what I got
function golfScore(par, strokes) {
// Only change code below this line
if (4, 1) {
return "Hole-in-one";
}
else if (4, 2) {
return "Eagle";
}
else if (4, 2) {
return "Birdie";
}
else if (4, 4) {
return "Par";
}
else if (4, 5) {
return "Bogey";
}
else if (4, 6) {
return "Double Bogey";
}
else {
return "Go Home!";
}

// Only change code above this line
}

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

its not working
Joseph
@revisualize
Jan 03 2017 03:50
@juliovalen You're not using the parameters.

@juliovalen Parameters are variables that represent the values that get passed into your function from the function call.
https://cs.wellesley.edu/~cs110/lectures/L16/images/function-anatomy.png
Notice how the variables level and score in the function definition addScore are called parameters.
However, when we invoke the function like in:
addScore(3, 10) or addScore(6, 20)
the values are called arguments. Here is an important lesson:
You define a function with parameters, you call a function with arguments.

Another example of this:

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

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

Other important things to remember:
* A function can have zero parameters. You still have to use the parentheses to define it.
* A function might have no return statements. In this case we say that the function returns undefined.

From knowing that please note that technically, calling parameters variables isn't correct. Parameters are part of the function declaration and when the function is called, an execution context is formed and there parameters are variables that hold the passed arguments.

jayisray
@jayisray
Jan 03 2017 03:51
Can someone please help me fix my Wikipedia Viewer? My API call isn’t working :\
Dustin McDaniel
@dmakk767
Jan 03 2017 03:52
@raja3233 you can use console.log() and open the browsers console to see what is happening. Not sure I understand what you want to do though. The code passes the test from what I can tell.
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 03:52
@dmakk767 he hasnt done anything
Rebecca
@alimily
Jan 03 2017 03:52
@sjames1958gm
i want if you can help with my code logic
Dustin McDaniel
@dmakk767
Jan 03 2017 03:53
Oh, guess his link just opens my answer, lol
Rebecca
@alimily
Jan 03 2017 03:53
now ,it can pass with testing ,but i want to know if the logic is ok
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 03:53
lol
Rebecca
@alimily
Jan 03 2017 03:54
@sjames1958gm are you there?
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 03:54
@raja3233 read the excercise what does it ask you to do?
Julio Valenzuela Jr.
@juliovalen
Jan 03 2017 03:54
@revisualize Ok great!! Thank you so much !! :)
CamperBot
@camperbot
Jan 03 2017 03:54
juliovalen sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2801 | @revisualize |http://www.freecodecamp.com/revisualize
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 03:54
@alimily whats up?
Rebecca
@alimily
Jan 03 2017 03:55

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 03:55
put your code up
Rebecca
@alimily
Jan 03 2017 03:55
here is the condition
for(var i=0;i<contacts.length;i++){
if(contacts[i].firstName == firstName){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}else{
return "No such property";
}
}
}
return "No such contact";
Joseph
@revisualize
Jan 03 2017 03:55
@alimily You had the code correct.
Rebecca
@alimily
Jan 03 2017 03:55
here is my code
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 03:55
whats wrong with that
Joseph
@revisualize
Jan 03 2017 03:55
Nothing.
Bjorn Berg
@bjornmberg
Jan 03 2017 03:56
I am stuck and I'm not really sure where I should go next. I'm working on the "Profile Lookup" . I think I can get the first part, which is to check if the firstName and given property is a property of that contact, then returning the value of that property. However, the next two parts, checking if variable firstName doesn't correspond to any contacts, or if property doesn't correspond to any valid properties,, are stumping me. Anyone have hints on where to begin there? Here is my code so far:
f
unction lookUpProfile(firstName, prop){
// Only change code below this line

  for (i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
  } 

// Only change code above this line
}
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 03:56
lol well someone just put up the solution @bjornmberg
Bjorn Berg
@bjornmberg
Jan 03 2017 03:56
Ah, OK.
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 03:57
looks good though what you have
just need to keep going
Joseph
@revisualize
Jan 03 2017 03:57
@bjornmberg Let's say you were at a big business event and throughout the event you got handed 200 business cards. Now, I walk up to you at the end and ask you.. Do you have a Business Card for "Jane Smith"? Now you loop look through your stack of 200 business cards. When would you tell me that you didn't have a business card for Jane?
Bjorn Berg
@bjornmberg
Jan 03 2017 03:58
Thanks @HeebieGeeBee
CamperBot
@camperbot
Jan 03 2017 03:58
bjornmberg sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 428 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Bjorn Berg
@bjornmberg
Jan 03 2017 03:58
And thanks @revisualize
CamperBot
@camperbot
Jan 03 2017 03:58
bjornmberg sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2802 | @revisualize |http://www.freecodecamp.com/revisualize
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 03:58
not sure what i did but youre welcome
Joseph
@revisualize
Jan 03 2017 03:59
I know.. I asked a question that didn't get answered.
Bjorn Berg
@bjornmberg
Jan 03 2017 03:59
Well, you both pointed me in the right direction. One of you nicer than the other.
Joseph
@revisualize
Jan 03 2017 03:59
@HeebieGeeBee Look at that.. You're nicer than I am. :D WINNAR!
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:00
how do you know he meant it that way round
Rebecca
@alimily
Jan 03 2017 04:00
i want to know is the logic is ok @HeebieGeeBee
Joseph
@revisualize
Jan 03 2017 04:00
@alimily That is how I solved it.
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:01
i dont know how it could be better @alimily
Dylan Hsiao
@greedylan
Jan 03 2017 04:01
The following codes works only when I have ONE property in source object, hint for multiple properties and how to check if the property values corresponds to the ones in Object collection??
function whatIsInAName(collection, source) {
  var arr = [];
  for(var i=0; i<collection.length; i++){
    if(collection[i].hasOwnProperty(Object.keys(source)) ){
      arr.push(collection[i]);
    }
  } 
  return arr;  
}
whatIsInAName(
  [
   { first: "Romeo", last: "Montague" }, 
   { first: "Mercutio", last: null },
   { first: "Tybalt", last: "Capulet" }
  ], 
  { last: "Capulet" });
Rebecca
@alimily
Jan 03 2017 04:01
ok,thank you both
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:02
thats not an easy one @greedylan
have you looked up what the symettric difference is?
Robert Allen
@bobbidigi
Jan 03 2017 04:04

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

// Only change code below this line

var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};

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

// Change this value to test
phoneticLookup(lookup[val.charlie]);

Joseph
@revisualize
Jan 03 2017 04:04
@bobbidigi Your function has declared and initialized the variable result to "". You are not modifying result and your function is returning result. Ergo, you're returning "". You need to modify result to be the value of the property from the object that you created.
Dylan Hsiao
@greedylan
Jan 03 2017 04:05
@HeebieGeeBee no, it suggests to use .hasOwnProperty, Object.keys
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:05
you got all these on hotkeys @revisualize ?
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:06
i mean did you find out what symmetric difference is as a mathematical concept @greedylan
Ogundele Olumide
@Lumexralph
Jan 03 2017 04:06
@greedylan Object.keys(source)) you will get an array here look for way to loop through that array and check if it's a property of collection[i] like you did,
Joseph
@revisualize
Jan 03 2017 04:07
This is my life right now.
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:07
lol
Joseph
@revisualize
Jan 03 2017 04:07
20170102_200327.jpg
Dylan Hsiao
@greedylan
Jan 03 2017 04:07
@Lumexralph yes let me try that. does that mean we create another loop inside this if statement?
Joseph
@revisualize
Jan 03 2017 04:08
@raja3233 Return statements cause functions to halt.
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:08
not being funny, but everything is in the exercise information
it says that in a function it will not go any further in the function if a return is reached
so its asking you to stop the function and return undefined if any of the arguments are less that 0
raja3233
@raja3233
Jan 03 2017 04:10
yes, this could be the statement if( a || b < 0){}
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:10
almost
is that how || works
and then what are you going to return if a or b is less than 0
raja3233
@raja3233
Jan 03 2017 04:11
if(a <0 || b<0)
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:11
seems better to me
Joseph
@revisualize
Jan 03 2017 04:14
@raja3233 Human logic is able to infer ambiguity. Whereas a computer is not. You need to be expressive with your if conditions.
Computers do (does this evaluate to true) OR (does this evaluate to true)
Subroto
@Shub1427
Jan 03 2017 04:16

Hi... I am learning NodeJS from LearnYouNode.... There's a task in it called JugglingAsync, whose right code is

var http = require('http')
    var bl = require('bl')
    var results = []
    var count = 0

    function printResults () {
      for (var i = 0; i < 3; i++) {
        console.log(results[i])
      }
    }

    function httpGet (index) {
      http.get(process.argv[2 + index], function (response) {
        response.pipe(bl(function (err, data) {
          if (err) {
            return console.error(err)
          }

          results[index] = data.toString()
          count++

          if (count === 3) {
            printResults()
          }
        }))
      })
    }

    for (var i = 0; i < 3; i++) {
      httpGet(i)
    }

While I am doing something exactly same, but my Answer is different, it doesn't work in sync -

var http  = require("http");
var bl    = require("bl");

var completeData = [];
var count = 0;
for (var i = 2; i < process.argv.length; i++) {
  http.get(process.argv[i], function(res) {
    res.pipe(bl(function(err, data) {
      if (err) {
        return console.log(err);
      }
      completeData[count] = data.toString();
      count++;
      // console.log("Data: " + data.toString());
      if (count === process.argv.length-2) {
        printThemOut(completeData);
      }
    }))
  })
}

function printThemOut(data) {
  for (var i = 0; i < data.length; i++) {
    console.log(data[i]);
  }
}

Please can someone tell me where the problem is

Joseph
@revisualize
Jan 03 2017 04:16
You can't do.. Is this or this ran against that expression evaluate to true?
Ogundele Olumide
@Lumexralph
Jan 03 2017 04:16
@greedylan loop through the source array and then use your if control statement to check
Robert Allen
@bobbidigi
Jan 03 2017 04:16

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

// Only change code below this line

var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};

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

// Change this value to test
phoneticLookup("charlie");
@revisualize ....Thanks

Joseph
@revisualize
Jan 03 2017 04:17
hashtag-missing.out.on.those.brownies
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:17
ty @revisualize
CamperBot
@camperbot
Jan 03 2017 04:17
heebiegeebee sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2803 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jan 03 2017 04:17
:P
Robert Allen
@bobbidigi
Jan 03 2017 04:17
how do you send the browns
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:18
say thank you with a person tagged who you want to send brownies to
Robert Allen
@bobbidigi
Jan 03 2017 04:19
kk
Huzaifa Gadiwala
@huzaifa83
Jan 03 2017 04:30
need some for the golf code
if (4, 1){
return "Hole-in-one!";
}
else if (4, 2){
return "Eagle";
}
JMNofziger
@JMNofziger
Jan 03 2017 04:30
Hey all, I just solved the "truncate a string" challenge and I'd like some critique on my solution. Could you show me how to make this more concise/cleaner?
function truncateString(str, num) {
  if (str.length > num){
    if (num <= 3){
      str = str.slice(0, num)+ "...";
    }
    else{
      str = str.slice(0, num-3) + "...";   
    }
  }
  return str;
}
// Sample input vv
truncateString("A-tisket a-tasket A green and yellow basket", 11);
Huzaifa Gadiwala
@huzaifa83
Jan 03 2017 04:31

function golfScore(par, strokes) {
// Only change code below this line
if (4, 1){
return "Hole-in-one!";
}
else if (4, 2){
return "Eagle";
}

// Only change code above this line
}

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

i got hole in one
but unable to get eagle
Joseph
@revisualize
Jan 03 2017 04:32
@huzaifa83 You're not using the parameters
@huzaifa83 How does your if know what 4, 1 is?
JMNofziger
@JMNofziger
Jan 03 2017 04:32
why aren't you using the par and strokes parameters @huzaifa83
that way they're dynamic to the input not just statically set to numbers you set @huzaifa83
@huzaifa83 for each new hole there is a new par and the user will likely take a different number of strokes
Joseph
@revisualize
Jan 03 2017 04:35
I realized that I pasted that to someone else.

@huzaifa83 Parameters are variables that represent the values that get passed into your function from the function call.
https://cs.wellesley.edu/~cs110/lectures/L16/images/function-anatomy.png
Notice how the variables level and score in the function definition addScore are called parameters.
However, when we invoke the function like in:
addScore(3, 10) or addScore(6, 20)
the values are called arguments. Here is an important lesson:
You define a function with parameters, you call a function with arguments.

Another example of this:

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

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

Other important things to remember:
* A function can have zero parameters. You still have to use the parentheses to define it.
* A function might have no return statements. In this case we say that the function returns undefined.

From knowing that please note that technically, calling parameters variables isn't correct. Parameters are part of the function declaration and when the function is called, an execution context is formed and there parameters are variables that hold the passed arguments.

pacebook
@pacebook
Jan 03 2017 04:35
Hi, I'm solving algorithm problems. Could I see a source code of another people?
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:36
@pacebook you might need to be a bit more specific
Joseph
@revisualize
Jan 03 2017 04:36
@pacebook What?
JMNofziger
@JMNofziger
Jan 03 2017 04:37
you can find source code on the freecodecamp github account @pacebook but you should do your best to work through problems on your own
Joseph
@revisualize
Jan 03 2017 04:37
@pacebook You're solving algorithm problems and you want to see source code.
@pacebook Here's some source code:
function getName() { return "Joseph" }
var name = getName();
console.log(name);
I don't know how it helps you solve your problem. But, there you go.
JMNofziger
@JMNofziger
Jan 03 2017 04:38
@pacebook haha sorry I meant solutions explained
Joseph
@revisualize
Jan 03 2017 04:39
I don't feel that looking at people's solutions is the same as solving it for yourself.
It is part of the reason why I don't gift away answers. Studies have shown that giving people answers to problems instills an illusionary sense of learning. Because, it only puts information into short-term memory. Of which people think they are learning. Only through a little struggle and repetition that the human brain puts things into long-term memory. I don't know what your end goal. I don't know if you want to do this as a personal project, hobby, or if you want to move into industry. Because of this, I strongly feel that working with people to allow them to solve problems on their own is a far better outcome than giving away answers. But, others clearly don't agree with my methods for helping people learn.
...
ANYHOW!
This restaurant is closing and I need to leave.
pacebook
@pacebook
Jan 03 2017 04:43
I'm not familiar with the English :) Sorry, I solved "Title Case a Sentence". I wonder if the source code I wrote is efficient code, so I want to see someone else's code. Does this function in a free-code camp?
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:43
@pacebook probably better just to paste your code up and ask what others think
pacebook
@pacebook
Jan 03 2017 04:45
@HeebieGeeBee Thank you, Here it is!
function titleCase(str) {
  str_arr = str.split(" ");
  str = str_arr.map(function(str){
     return str[0].toUpperCase() + str.substring(1).toLowerCase();
  }).join(" ");
  return str;
}

titleCase("I'm a little tea pot");
CamperBot
@camperbot
Jan 03 2017 04:45
pacebook sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 429 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:46
looks good to me
pacebook
@pacebook
Jan 03 2017 04:48
Thank you. I'll go to study again.
Natalie Hutchinson
@natthegreat
Jan 03 2017 04:48
everyone is probably heaps further along than I am... I am having trouble with the finding a remainder in javascript. I just dont know what i am supposed to be writing. The whole thing has confused me :(
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:49
% is the operator for the remainder in javascript
so instead of 11/3 = 3 with a remainder of 2
Ogundele Olumide
@Lumexralph
Jan 03 2017 04:49
@natthegreat % familiar with this operator?
Natalie Hutchinson
@natthegreat
Jan 03 2017 04:49
why is the remainder 2 though?
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:49
you can just for 11%3 which = 2
Natalie Hutchinson
@natthegreat
Jan 03 2017 04:50
yeh i am
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:50
do you know about division?
Natalie Hutchinson
@natthegreat
Jan 03 2017 04:50
yep
Ogundele Olumide
@Lumexralph
Jan 03 2017 04:50
@natthegreat just normal mathematical division
@natthegreat that's what @HeebieGeeBee means
Natalie Hutchinson
@natthegreat
Jan 03 2017 04:50
as in like old school long hand division? haha im going to have to relearn that
HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 04:51
yeah
its not that complicated
Ogundele Olumide
@Lumexralph
Jan 03 2017 04:51
@natthegreat exactly. % gives you the remainder of that division e.g 3 % 2 will be 1, because after the division 1 remains, that's what modulo does, the remainder is returned and you can store the value
Natalie Hutchinson
@natthegreat
Jan 03 2017 04:54
@Lumexralph thanks.... that makes a lot more sense
CamperBot
@camperbot
Jan 03 2017 04:54
natthegreat sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 636 | @lumexralph |http://www.freecodecamp.com/lumexralph
Natalie Hutchinson
@natthegreat
Jan 03 2017 04:55
@HeebieGeeBee @Lumexralph it has been a very long time since i've done long division so i guess it threw me off a little. I am very new to all of this so apologies if i ask stupid questions.
Ogundele Olumide
@Lumexralph
Jan 03 2017 04:56
@natthegreat :+1:
if you don't ask you don't know
uriznik
@uriznik
Jan 03 2017 04:57
@Shub1427 they want it printed in the order the URLs are given and it looks like you're printing it in the order the callbacks are called
uriznik
@uriznik
Jan 03 2017 05:00
@mardisworld you have an extra space in your string
Subroto
@Shub1427
Jan 03 2017 05:01

Hi @uriznik , The original code that I've posted prints the Data after count becomes 3. My code (Second Snippet), does the same thing waits till the array gets full, i.e., count == 3 (which is process.argv.length - 2), and then prints them

The problem is both the sample codes are pretty similar, only that I am doing all the things directly in for loop, while the original code does that via looping a function....

Please tell me where I am wrong, thanks

HeebieGeeBee
@HeebieGeeBee
Jan 03 2017 05:02
@mardisworld yeah just get rid of that space at the end after the period, and should be fine
Marissa Staller
@mardisworld
Jan 03 2017 05:03
@uriznik I had two extra spaces. Thank you gentlemen.
CamperBot
@camperbot
Jan 03 2017 05:03
mardisworld sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:cookie: 432 | @uriznik |http://www.freecodecamp.com/uriznik
uriznik
@uriznik
Jan 03 2017 05:04
@Shub1427 you know that either of the 3 http.get callback functions could be called first? and then that would get stored in the first completeData? you already have an index variable, you could use that to keep order
@Shub1427 iirc you need to print the results in the same order as they're given in the arguments
@Shub1427 it's like a chess puzzle, what one change will fix the problem :)
Subroto
@Shub1427
Jan 03 2017 05:06

OK.... Thaks @uriznik , So the Original code is keeping a check by using the Index passed from the For Loop... LOL, that's clever... I dind't realize that

Thanks a lot @uriznik

CamperBot
@camperbot
Jan 03 2017 05:06
shub1427 sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:cookie: 433 | @uriznik |http://www.freecodecamp.com/uriznik
Thien Nguyen
@winmintin
Jan 03 2017 05:11
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;
var answer = "Montana";
var playerNumber = testObj[answer];       // Change this Line
var player = testObj[16];   // Change this Line
i don't know why this does not work
  • playerNumber should be a number
  • You should be using the variable playerNumber in your bracket notation
challenge 201
uriznik
@uriznik
Jan 03 2017 05:13
@winmintin testObj[16] - this will look for the property 16 in the object correct?
Thien Nguyen
@winmintin
Jan 03 2017 05:14
ya
var answer = "Montana"; var playerNumber = testObj[answer]; // Change this Line
var answer = "Montana";
var playerNumber = testObj[answer];       // Change this Line
that part need works
uriznik
@uriznik
Jan 03 2017 05:15
@winmintin you can also look up a property based on the value in another variable
AhhMclean
@AhhMclean
Jan 03 2017 05:15
pretty proud of my code for chunky monkey !
function chunkArrayInGroups(arr, size) {

 var result = [];

 for (var i=0; i<arr.length/size; i++){
   result.push(arr.slice(size*i, size*(i+1)));
 }
  return result;
}
Thien Nguyen
@winmintin
Jan 03 2017 05:16
that why i created var answer
uriznik
@uriznik
Jan 03 2017 05:16
@winmintin so instead of hardcoding 16 in testObj[16], can you use a variable to do the lookup instead?
AhhMclean
@AhhMclean
Jan 03 2017 05:16
i reckon its better than example solutions
Ogundele Olumide
@Lumexralph
Jan 03 2017 05:16
@AhhMclean :clap:
Thien Nguyen
@winmintin
Jan 03 2017 05:17
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;
var answer = "Montana";
var number = 16;
var playerNumber = testObj[answer];       // Change this Line
var player = testObj[number];   // Change this Line
  • playerNumber should be a number
  • You should be using the variable playerNumber in your bracket notation
still do not met
uriznik
@uriznik
Jan 03 2017 05:18
@winmintin You're getting closer. They specifically want you use to playerNumber as the variable
Thien Nguyen
@winmintin
Jan 03 2017 05:21
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj[playerNumber];   // Change this Line
i got it now
@uriznik ty
CamperBot
@camperbot
Jan 03 2017 05:21
winmintin sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:cookie: 434 | @uriznik |http://www.freecodecamp.com/uriznik
uriznik
@uriznik
Jan 03 2017 05:24
@winmintin do you know what testObj["Montana"] would return?
Thien Nguyen
@winmintin
Jan 03 2017 05:27
nothing, don't you have to create a var and put it in the object because it cannot accept string.
var answer = 16; testObj[answer];
uriznik
@uriznik
Jan 03 2017 05:28
@winmintin you don't have to use a variable access the property, but you would get undefined because there is no property called Montana
Thien Nguyen
@winmintin
Jan 03 2017 05:30
o i see
so you only can use variable access for the stuff on the left of the colon
it won't work the other way
uriznik
@uriznik
Jan 03 2017 05:33
Javascript will evaluate the expression in the brackets and use the resulting value as the property to look up. So you could do testObj[8* 2], testObj[16], or testObj[playerNumber], but you can't do testObj.16
Supergood
@supergoods
Jan 03 2017 05:36
Hlp @ escape sequences in string
KasehRawr
@KasehRawr
Jan 03 2017 05:36

Hey erryone! I'm having some trouble "selecting from many options with Switch Statements" could i please get some help? I really just don't know what i'm doing!

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val) {
case val === 1:
return "alpha";
break;
}

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

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

uriznik
@uriznik
Jan 03 2017 05:37
@winmintin you generally wouldn't use numbers as object properties though
@supergoods what have you got so far?
Supergood
@supergoods
Jan 03 2017 05:39
@uriznik
var myStr = "FirstLine\nSecondLine\\rThirdLine\"; // Change this line
uriznik
@uriznik
Jan 03 2017 05:40
@KasehRawr you don't need to compare against val in the case statement as you already say you're using val in the switch expression, and they probably want you to set the answer variable rather than returning straight away (though return "alpha"; would still return ok)
Kashish Goyal
@kashishcr7
Jan 03 2017 05:40

// 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((prop!==tracks)&&(value!==""))
    prop=value;
  if((prop===tracks)&&(collection.hasOwnProperty(tracks)===false))



  return collection;
}

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

Hey guys i need help regarding this...I'm really stuck for a long time now
Here's the question instructions fos this..
You are given a JSON object representing a part of your musical album collection. Each album has several properties and a unique id number as its key. Not all albums have complete information.

Write a function which takes an album's id (like 2548), a property prop (like "artist" or "tracks"), and a value (like "Addicted to Love") to modify the data in this collection.

If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.

Your function must always return the entire collection object.

There are several rules for handling incomplete data:

If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.

If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array.

If value is empty (""), delete the given prop property from the album.

uriznik
@uriznik
Jan 03 2017 05:41
@supergoods \\r - if you printed that what would get output?
Ogundele Olumide
@Lumexralph
Jan 03 2017 05:42
@KasehRawr don't return a value except that's the final value you want, case should be case 1.....not case val === 1, that'll work but we'll mess up with switch(val)....just check case for val like this case 1...etc and assign the string to result.....result = "alpha" ditto for the remaining cases
uriznik
@uriznik
Jan 03 2017 05:43
@kashishcr7 in prop!==tracks can you describe what prop and tracks are?
Ogundele Olumide
@Lumexralph
Jan 03 2017 05:44
@kashishcr7 best way to start this is to check if val is empty then delete that property from collection, can you try that?, keep in mind that collection is an object of nested objects
Supergood
@supergoods
Jan 03 2017 05:45
@uriznik the first command marks wrong...it didnt pass to next thing
Kashish Goyal
@kashishcr7
Jan 03 2017 05:46
@uriznik actually prop is the argument which compares to tracks...
@uriznik the object consists of id, prop and value of that prop
Ogundele Olumide
@Lumexralph
Jan 03 2017 05:46
@supergoods you need backslash before SecondLine
uriznik
@uriznik
Jan 03 2017 05:46
@supergoods so if \n is a newline character, what is \r ?
@kashishcr7 so prop is a variable, is tracks also a variable?
Supergood
@supergoods
Jan 03 2017 05:48
@uriznik carriage-return
uriznik
@uriznik
Jan 03 2017 05:49
@supergoods what are two backslashes equal to in a string? "\\"
KasehRawr
@KasehRawr
Jan 03 2017 05:49
@uriznik thank you!
CamperBot
@camperbot
Jan 03 2017 05:49
kasehrawr sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:cookie: 435 | @uriznik |http://www.freecodecamp.com/uriznik
Kashish Goyal
@kashishcr7
Jan 03 2017 05:50
@uriznik prop is actually a formal argument..
KasehRawr
@KasehRawr
Jan 03 2017 05:50
@Lumexralph thank you!
CamperBot
@camperbot
Jan 03 2017 05:50
kasehrawr sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 637 | @lumexralph |http://www.freecodecamp.com/lumexralph
yourpalsneakers
@yourpalsneakers
Jan 03 2017 05:50
"Seek and Destroy" - Can anybody tell me if I did this correctly? (it passes the tests, just seems like I found a weird way to do it)
function destroyer(arr) {
  // Remove all the values
  var arg1 = arguments[1];
  var arg2 = arguments[2];
  var arg3 = arguments[3];
  function filtered(val) {
    return val !== arg1 && val !== arg2 && val !== arg3; 
  }
  return arr.filter(filtered);

}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
KasehRawr
@KasehRawr
Jan 03 2017 05:51
yay! thanks again!
Ogundele Olumide
@Lumexralph
Jan 03 2017 05:53
@yourpalsneakers since argument is array-like object you can use a loop to get the values......in cases where the arguments are way more, you can't do that easily by using index manually
Joseph
@revisualize
Jan 03 2017 05:55
@yourpalsneakers The val !== arg1 Will always be true.
@yourpalsneakers An array element cannot be the whole array.
uriznik
@uriznik
Jan 03 2017 05:57
@kashishcr7 it's still basically a variable so doesn't really matter for my question - what is tracks?
Kashish Goyal
@kashishcr7
Jan 03 2017 05:58
@uriznik tracks is also a variable
Supergood
@supergoods
Jan 03 2017 05:59
@uriznik ?.?
Thien Nguyen
@winmintin
Jan 03 2017 05:59
var myDog = {
  "name": "Happy Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["Free Code Camp Campers"],
  "bark": "woof"
why do javascript use " " when declaring attributes?
Joseph
@revisualize
Jan 03 2017 06:00
@kashishcr7 Tracks is NOT a variable.
@winmintin because of spaces
yourpalsneakers
@yourpalsneakers
Jan 03 2017 06:00
@Lumexralph I was trying to loop through just the arguments greater than arguments[0] (arguments1, arguments[2], etc.) and then loop through arguments[0] and filter out the values greater than arguments[0]... would that be a better way?
Ogundele Olumide
@Lumexralph
Jan 03 2017 06:00
@yourpalsneakers val !== arg1 you're comparing array to elements of the array, it worked but it's a weird way and this is what is weird val !== arg1 && val !== arg2 && val !== arg3; but looking at the challenge name it didn't go that way, if you totally understand what your code is doing there....you'll laugh
uriznik
@uriznik
Jan 03 2017 06:01
@supergoods \\ in a string will output to a single backslash, so \\r will output to \r and not a carriage return
Thien Nguyen
@winmintin
Jan 03 2017 06:01
so name : "Happy Coder" this would be invalid because the space between e and :?
Ogundele Olumide
@Lumexralph
Jan 03 2017 06:01
@yourpalsneakers try it out, it seems a good direction to me
Joseph
@revisualize
Jan 03 2017 06:01
@winmintin No.
Supergood
@supergoods
Jan 03 2017 06:02
@uriznik
var myStr = "FirstLine\nSecondLine\\rThirdLine\"; // Change this line
Where is the error in the above syntax?
yourpalsneakers
@yourpalsneakers
Jan 03 2017 06:02
@Lumexralph I can't figure out how to JUST loop through arguments > arguments[0]
Joseph
@revisualize
Jan 03 2017 06:02
@supergoods You're not escaping the first backslash
@supergoods You're also escaping a backslash after ThirdLine .. Which is incorrect.
Ogundele Olumide
@Lumexralph
Jan 03 2017 06:03
@yourpalsneakers how do you loop through an array?
@supergoods escape backslash before secondline
Thien Nguyen
@winmintin
Jan 03 2017 06:04
so why won't this work name : "Happy Coder" vs "name": "Happy Coder" ..how would the spaces work?
uriznik
@uriznik
Jan 03 2017 06:04
@kashishcr7 so they want you to check if prop is equal to "tracks", but prop!==tracks is comparing against a variable named tracks
Joseph
@revisualize
Jan 03 2017 06:05
@winmintin I don't understand your question.
Thien Nguyen
@winmintin
Jan 03 2017 06:06
it's weird how we declare it as "name". but when we recalled it it's myDog.name not myDog."name"
Kashish Goyal
@kashishcr7
Jan 03 2017 06:06
@uriznik yes they want me to check if prop is equal to tracks as a variable
Joseph
@revisualize
Jan 03 2017 06:06
@winmintin Look.
Kashish Goyal
@kashishcr7
Jan 03 2017 06:06
@uriznik tell me if I'm wrong
Joseph
@revisualize
Jan 03 2017 06:06
@winmintin Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
Kashish Goyal
@kashishcr7
Jan 03 2017 06:07
@uriznik is tracks according to you an entity ?
Ogundele Olumide
@Lumexralph
Jan 03 2017 06:07

@winmintin both will work in object literal

so why won't this work name : "Happy Coder" vs "name": "Happy Coder" ..how would the spaces work?

Joseph
@revisualize
Jan 03 2017 06:07
@winmintin You're also using incorrect terminology.
Thien Nguyen
@winmintin
Jan 03 2017 06:08
i see
@revisualize @Lumexralph
Joseph
@revisualize
Jan 03 2017 06:08
What?
Thien Nguyen
@winmintin
Jan 03 2017 06:09
some time i have difficulty clicking enter on this chat especially when i try to insert code. shift + enter. and then click enter to submit
Ogundele Olumide
@Lumexralph
Jan 03 2017 06:09
@winmintin if you're creating an object, what you asked as key/value pair will work
uriznik
@uriznik
Jan 03 2017 06:09
@kashishcr7 prop will contain a string so you can compare directly with a string
Supergood
@supergoods
Jan 03 2017 06:10
@revisualize Can u rewrite the syntax for my understanding
Kashish Goyal
@kashishcr7
Jan 03 2017 06:11

// 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) {
  while(true)
    {
  if((prop!==tracks)&&(value!==''))
  {
    collection.id.prop=value;
    break;
  }
  if((prop===tracks)&&(collection.id.hasOwnProperty(tracks)===false))
  {
    collection.id.tracks={};
    collection.id.tracks=value;
    break;
  }
  if((prop===tracks)&&(value!==''))
  {
    collection.id.tracks=value;
    break;
  }


    }return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
@uriznik this is my latest edit..
Please tell me whats wrong in this
uriznik
@uriznik
Jan 03 2017 06:11
@supergoods put the string between two ` characters as otherwise gitter will unescape the string and it's hard to tell what it actually is
Joseph
@revisualize
Jan 03 2017 06:11
@supergoods No.
Ogundele Olumide
@Lumexralph
Jan 03 2017 06:11
@kashishcr7 you don't need a while-true loop, accessing a property on an object is a kind of loop already cos it looks for that property in objects
Joseph
@revisualize
Jan 03 2017 06:12
@kashishcr7 Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
@kashishcr7 while(true) That is useless.
Kashish Goyal
@kashishcr7
Jan 03 2017 06:13
@revisualize i used while loop to use break statement
Ogundele Olumide
@Lumexralph
Jan 03 2017 06:14
@kashishcr7 and yes you don't use variables to access an object that way as @revisualize said use []
Supergood
@supergoods
Jan 03 2017 06:14
@uriznik Cant understood
Joseph
@revisualize
Jan 03 2017 06:14
@kashishcr7 Why?
uriznik
@uriznik
Jan 03 2017 06:14
@kashishcr7 compare prop like prop==="tracks" as the function might get called like `updatedRecords(5439, "tracks", "My Track") so you need to compare if prop is equal to the literal string "tracks"
@supergoods paste your line of code between two backquote characters like `var myStr = ...`
@kashishcr7 you also need to use bracket notation to do the access the object propertiesw
Kashish Goyal
@kashishcr7
Jan 03 2017 06:16
@revisualize so that i can exit the loop as soon as the change is made
Joseph
@revisualize
Jan 03 2017 06:17
@kashishcr7 You don't need the loop.
A "loop" that only runs once .. Isn't a loop. Ergo, it isn't needed.
Kashish Goyal
@kashishcr7
Jan 03 2017 06:18
@revisualize I'll keep that in mind
Ryan Steen
@Rsteen76
Jan 03 2017 06:19
function truncateString(str, num) {
  // Clear out that junk in your trunk

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

  str=str+"...";
  return str;
}

truncateString("Absolutely Longer", 10);
I have tried testing this. I don't understand why the else statement it not working, the first two parts work, but the else is never called
uriznik
@uriznik
Jan 03 2017 06:19
@revisualize we do need some goto's and labels though :)
Joseph
@revisualize
Jan 03 2017 06:20
@uriznik What?
Md. Shadman Chowdhury
@sudiptoshadman
Jan 03 2017 06:20
Guys .pop() .shift() and stuff >> are these javascript or Jquery functions??
uriznik
@uriznik
Jan 03 2017 06:20
the loop and break were acting like a goto...
Joseph
@revisualize
Jan 03 2017 06:20
What?
Kashish Goyal
@kashishcr7
Jan 03 2017 06:21
@revisualize @uriznik these are my changes..Please give your suggestions
```

// 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((prop!=="tracks")&&(value!==''))
  {
    collection[id][prop]=value;

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

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

  }


    return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
uriznik
@uriznik
Jan 03 2017 06:22
@sudiptoshadman javascript array functions
Joseph
@revisualize
Jan 03 2017 06:22
@kashishcr7 First off. We don't need to see the object. We don't care about the object itself. It's too big and takes up too much room.
@kashishcr7 Second: Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
And I think I already told you this.
@kashishcr7 Third.. tracks isn't a variable.
@kashishcr7 Forth... {} isn't how you create an empty array.
Kashish Goyal
@kashishcr7
Jan 03 2017 06:23
@revisualize sure
Ogundele Olumide
@Lumexralph
Jan 03 2017 06:23
@sudiptoshadman javascript
Joseph
@revisualize
Jan 03 2017 06:23
@kashishcr7 Fifth.. You're overwriting and not adding anything to the array.
@kashishcr7 Sixth, You're missing some logic. You're not deleting from the collection.
andry91959
@andry91959
Jan 03 2017 06:25
If I have a js code from algorithm challenge. Where I can test it other than in this website
Joseph
@revisualize
Jan 03 2017 06:25
Ogundele Olumide
@Lumexralph
Jan 03 2017 06:26
@andry91959 repl.it too helps
andry91959
@andry91959
Jan 03 2017 06:30
thank you guysa
Julian Kaiser
@Julian194
Jan 03 2017 06:40
hey guys any idea why the lesson chainToSwitch is not working ? did anyone habe the same problem?
Fernando
@fer408
Jan 03 2017 06:40
Having some trouble with this algorithm
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
var string = str.split("");
if (string[0] == str.endsWith(target)) {
return true;
}
else
{
return false;
}
}
Liz Chen
@moist17
Jan 03 2017 06:42
Hi...get a 502 bad gateway problem on 'weather project'
i can load the location & weather api respectively. but when i want to spot the place thru geolocation api, it always failed, the console shows 'Failed to load resource: the server responded with a status of 502 (Bad Gateway)'
below is my js code. hope there's someone can help me, thanks!!
var lat;
var long;

// get location
if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
    lat = position.coords.latitude;
    long = position.coords.longitude;
    });

}

// load open weather api
    var ourRequest = new XMLHttpRequest();
    var url = 'http://api.openweathermap.org/data/2.5/weather?lat=' +lat+ '&lon=' +long+ '&appid=dca632195734b5402a9bd59fcacdbee7';
    ourRequest.open('GET', url);
    ourRequest.onload = function() {
    var ourData = JSON.parse(ourRequest.responseText);
    var city = ourData.name;
    console.log(city);
    };
    ourRequest.send();
Joseph
@revisualize
Jan 03 2017 06:45
@fer408 Do not use the built-in method .endsWith() to solve the challenge.
Kashish Goyal
@kashishcr7
Jan 03 2017 06:47
function updateRecords(id, prop, value) {
  if((prop!=="tracks")&&(value!==''))
  {
    collection[id][prop]=value;

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

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

  }


    return collection;
}
@revisualize here are some corrections based on your suggestions..
Joseph
@revisualize
Jan 03 2017 06:48
@kashishcr7 tracks is still not a variable
Kashish Goyal
@kashishcr7
Jan 03 2017 06:48
@revisualize I'm sorry but I'm still not able to get it..please tell me what to change
Joseph
@revisualize
Jan 03 2017 06:49
@kashishcr7 collection[id][tracks] ... TRACKS is not a variable.
I'm out.
Kashish Goyal
@kashishcr7
Jan 03 2017 06:52
@revisualize thanks for your help
CamperBot
@camperbot
Jan 03 2017 06:52
kashishcr7 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2804 | @revisualize |http://www.freecodecamp.com/revisualize
uriznik
@uriznik
Jan 03 2017 06:53
@moist17 FreeCodeCamp/FreeCodeCamp#7853
Shoeb Raza
@shoeblabs
Jan 03 2017 06:53

@kashishcr7

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 == '') {
return "invalid value";
}
if(collectionCopy.hasOwnProperty(id)) {
if(collectionCopy[id].hasOwnProperty(prop)) {
if(Array.isArray(collectionCopy[id][prop])) {
if(collectionCopy[id][prop].indexOf(value) == -1) {
collectionCopy[id][prop].push(value);
}
} else {

        collectionCopy[id][prop] = value; 
    }                
} else {
   return "Invalid property";
}

} else {
return "Invalid Id";
}
return collectionCopy;
}

// Alter values below to test your code
updateRecords(1245, "tracks", "ghjj");

Ibnul Ferdous
@Ibnulferdous
Jan 03 2017 06:55
Hello. I got stuck at the very basic level of javascript. "Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator."- i cant understand what it instruct me to do! can anyone help please?
Shoeb Raza
@shoeblabs
Jan 03 2017 06:55
@kashishcr7
Joseph
@revisualize
Jan 03 2017 06:55
@Ibnulferdous Remainder:
http://images.tutorvista.com/cms/images/38/remainder1.PNG
13 % 2 is 1 ... 26 % 5 is 1 ... 24 % 6 is 0
24 % 5 is 4 ... 219 % 20 is 19 ... Does that help?
Shoeb Raza
@shoeblabs
Jan 03 2017 06:56
@kashishcr7
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 == '') {
        return "invalid value";
   }    
   if(collectionCopy.hasOwnProperty(id)) {
    if(collectionCopy[id].hasOwnProperty(prop)) {
        if(Array.isArray(collectionCopy[id][prop])) {    
            if(collectionCopy[id][prop].indexOf(value) == -1) {    
                collectionCopy[id][prop].push(value);
            }    
        } else {
            collectionCopy[id][prop] = value; 
        }                
    } else {
       return "Invalid property";
    }
   } else {
       return "Invalid Id";
   }
   return collectionCopy;        
}

// Alter values below to test your code
updateRecords(1245, "tracks", "ghjj");
Kashish Goyal
@kashishcr7
Jan 03 2017 06:59
if(collectionCopy[id][prop].indexOf(value) == -1) {    
                collectionCopy[id][prop].push(value);
@shoeblabs why did u use this ?
Shoeb Raza
@shoeblabs
Jan 03 2017 07:01
@kashishcr7 if value is already present in array than it will not add a new value (it is to stop duplication in array)
Kashish Goyal
@kashishcr7
Jan 03 2017 07:01
@shoeblabs ok
Ibnul Ferdous
@Ibnulferdous
Jan 03 2017 07:07
@revisualize but what i need to do in the particular task? i cant understand their command!
Dylan Hsiao
@greedylan
Jan 03 2017 07:08
How do we give another for loop for var j?
function whatIsInAName(collection, source) {
  var arr = [];
  for(var i=0; i<collection.length; i++){
    if( collection[i].hasOwnProperty(Object.keys(source)[j]) === true){
      arr.push(collection[i]);
    } 
  } 
  return arr; 
}
whatIsInAName(
  [
   { first: "Romeo", last: "Montague" }, 
   { first: "Mercutio", last: null },
   { first: "Tybalt", last: "Capulet" }
  ], 
  { last: "Capulet" });
Rami
@RNwebdk
Jan 03 2017 07:12

Hi everyone, i have some problem creating dynamic sliders in Jquery and was hoping someone here could give me some help

I want to be able to click the plus, then a "solution" is added with a slider. It works fine when i put the HTML statically, but when added from jquery the slider won't work. please take a look here:

grantknaver
@grantknaver
Jan 03 2017 07:15
my code works and but this assignment wont let me pass
uriznik
@uriznik
Jan 03 2017 07:18
@rami add the click event handler after the element is created
Brian Mayrose
@intoro
Jan 03 2017 07:19
Thanks @Rafase282 @abhisekp @shadowfool for your help with Algorithm: Check for Palindromes
CamperBot
@camperbot
Jan 03 2017 07:19
intoro sends brownie points to @rafase282 and @abhisekp and @shadowfool :sparkles: :thumbsup: :sparkles:
:cookie: 434 | @shadowfool |http://www.freecodecamp.com/shadowfool
:star2: 3304 | @abhisekp |http://www.freecodecamp.com/abhisekp
:star2: 1434 | @rafase282 |http://www.freecodecamp.com/rafase282
Shoeb Raza
@shoeblabs
Jan 03 2017 07:19
@moist17
var lat;
var long;

// get location
if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
        lat = position.coords.latitude;
        long = position.coords.longitude;
        findCity(lat,long);
    });

}

function findCity(lat,long) {
        // load open weather api
    var ourRequest = new XMLHttpRequest();
    var url = 'http://api.openweathermap.org/data/2.5/weather?lat=' +lat+ '&lon=' +long+ '&appid=dca632195734b5402a9bd59fcacdbee7';
    ourRequest.open('GET', url);
    ourRequest.onload = function() {
    var ourData = JSON.parse(ourRequest.responseText);
    var city = ourData.name;
    console.log(city);
    };
    ourRequest.send();
}
Ryan Steen
@Rsteen76
Jan 03 2017 07:20
Hope this is an easy one. I get an error: type error: can not read property of 'push' for undefined. Is this an improper use of the array? Any help would be great. Here the code.
var newArr=[];
function chunkArrayInGroups(arr, size) {
  // Break it up.
  for(var i = 0; i < arr.length; i++){

   for(var j = 0; j < size; j++){

     newArr[i].push(arr[i]);
   } 
  }  
  return newArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Shoeb Raza
@shoeblabs
Jan 03 2017 07:21
@moist17 navigator.geolocation.getCurrentPosition() is an asynchronous request.
Dylan Hsiao
@greedylan
Jan 03 2017 07:21
@Rsteen76 just do newArr.push()? you dont need to loop it again
Supergood
@supergoods
Jan 03 2017 07:21
@anybody
var myStr = "FirstLine\nSecondLine\\rThirdLine\"; // Change this line
Rami
@RNwebdk
Jan 03 2017 07:21
@uriznik Sorry i don't get that ?
grantknaver
@grantknaver
Jan 03 2017 07:22
any ideas guys
Rami
@RNwebdk
Jan 03 2017 07:22
@uriznik isn't that what i'm already doing ?
uriznik
@uriznik
Jan 03 2017 07:23
@rami You're adding the click handlers in the ready function before solutions 2 & 3 exist. You need to add the handlers at the time you create the elements
Ryan Steen
@Rsteen76
Jan 03 2017 07:24
@greedylan But I am trying to push it to the first array, then when i increments it will push to the second.
uriznik
@uriznik
Jan 03 2017 07:24
@grantknaver you're not returning anything?
@Rsteen76 if you're making a 2d array then you would need to initialise each newArr[i] to an empty array first
Andre Goh
@Andreweijie
Jan 03 2017 07:25
Hi guys in the challenge "Condense arrays with reduce", can somebody explain the concept to me? I'm totally clueless
I understand they need the previous value and the current value to keep track where it is, but what am I to do with just an array?
Ming Lei
@dabeister
Jan 03 2017 07:26
HI team, trying the Seek and Destroy challenge, would love for someone to point me in the right direction/give some feedback on the general idea of whether what I want to achieve is possible

function destroyer(arr) {
  for (var i = 1; i < arr.length; i++) {
    for (var j = 0; j < arr[0].length; j++) {
      return arr[0][j] !== arr[i];
    }
  }
  var filtered = arr.filter(destroyer);
  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
uriznik
@uriznik
Jan 03 2017 07:26
@greedylan what challenge is that?
Dylan Hsiao
@greedylan
Jan 03 2017 07:27
@uriznik Wherefore art thou. Object.keys(source) returns an array with the properties of second argument, I need to loop it so by using .hasOwnProperty it would check if both arguments have the same object(s)?
grantknaver
@grantknaver
Jan 03 2017 07:27
I left the returns in console.logs
Ming Lei
@dabeister
Jan 03 2017 07:27
There's an error popping up that arr.filter is not a function - would love an explanation on how to go about this
grantknaver
@grantknaver
Jan 03 2017 07:27
here I will update it @uriznik
Damien
@okvitae
Jan 03 2017 07:31
hey guys. I'm trying to check for palindromes.

function palindrome(str) {
  var re = /[^A-Za-z0-9]/g;
  var lowered = str.toLowerCase().replace(re, '');
  var a = lowered.split("");
  var b = a.reverse();
  var c = b.join("");
  if (c === str) {
  return true;
  } else {
    return false;
  }
}

palindrome("A man, a plan, a canal. Panama");
what's going wrong here?
Ryan Steen
@Rsteen76
Jan 03 2017 07:32
@uriznik Thanks, that did it.
CamperBot
@camperbot
Jan 03 2017 07:32
rsteen76 sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:cookie: 436 | @uriznik |http://www.freecodecamp.com/uriznik
uriznik
@uriznik
Jan 03 2017 07:32
@grantknaver you're still not returning anything :) you return from the inner function but not the outer one
Dipak Telangre
@dipaktelangre
Jan 03 2017 07:32
@grantknaver add return before function call return checkCap();
uriznik
@uriznik
Jan 03 2017 07:33
@Rsteen76 the array slice function would be useful here...
Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:33
@okvitae comprare c with lowered
Fernando
@fer408
Jan 03 2017 07:33
having some trouble with this algorithm can anyone help? I think i am doing it correctly

function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
if (str.substring(0).split("") === target ) {
return true;
}
else
{
return false;
}

}

hariharanguru83
@hariharanguru83
Jan 03 2017 07:34
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

  for (var i = 0; i < multiplyAll.length; i++){
    for (var j = 0; j < multiplyAll.length; j++){
      product += multiplyAll(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]]);
need help
Damien
@okvitae
Jan 03 2017 07:34
@ghulamshabir wow lol. Thanks. it passes.
CamperBot
@camperbot
Jan 03 2017 07:34
okvitae sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1598 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:34
@okvitae :smile:
grantknaver
@grantknaver
Jan 03 2017 07:35
wow
that worked I knew it was done lol
Rami
@RNwebdk
Jan 03 2017 07:35
@uriznik changed the order, but still not working :(
Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:35
@fer408 split returns an array, your are comparing an array with target ?
Fernando
@fer408
Jan 03 2017 07:36
should i split target as well?
Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:37
@hariharanguru83 multiplyall is function and calling it withint the same function will result into a recursion, just access array values using i j indices then multiplay it to product and assign the result to product
Fernando
@fer408
Jan 03 2017 07:38
something like if(str.substring(0) == target.substring(0) {
return true;
}
else
{
return false;
}
uriznik
@uriznik
Jan 03 2017 07:38
@rami what's the link again
Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:38
@fer408 no, just try to substring as many letters from str from its end as in targest then compare them
Fernando
@fer408
Jan 03 2017 07:40
@ghulamshabir Like str.substring(target) == target
uriznik
@uriznik
Jan 03 2017 07:41
@greedylan add another for(var j=0; j < ...; j++) { underneath the existing for line and add matching closing brace
uriznik
@uriznik
Jan 03 2017 07:42
@greedylan then you'll need to compare j to the length of ... ? you can use var keys = Object.keys(source) to put the keys in a variable to save on a few characters
Rami
@RNwebdk
Jan 03 2017 07:42
@uriznik Thank you for taking the time to help
CamperBot
@camperbot
Jan 03 2017 07:42
rnwebdk sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:cookie: 437 | @uriznik |http://www.freecodecamp.com/uriznik
Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:42
@fer408 targest is string and subtring needs number
@RNwebdk you need two loops if you want to use loops
@fer408 Hint: negative index also works
Fernando
@fer408
Jan 03 2017 07:44
@ghulamshabir i tried str.substring(0) to iterate though the whole string
Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:46
@fer408 try using a negative index which will give a subtring from string's back, make sure you get equal number of characters as in target
hariharanguru83
@hariharanguru83
Jan 03 2017 07:48
@ghulamshabir didn't get you, can you pls explain
Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:48
@hariharanguru83 what's function name ?
hariharanguru83
@hariharanguru83
Jan 03 2017 07:49
multiplyAll
Fernando
@fer408
Jan 03 2017 07:49
@ghulamshabir could you explain what you mean by a substring from strings back like str.substring(str.length - 1)
Rami
@RNwebdk
Jan 03 2017 07:50
@uriznik @ghulamshabir i don't think that is the right solution here, when i am googling my problem, stackoverflow tells me i have a problem with binding but i am not sure. But in my case i'm not using the same event handler for every slider. In my case every slider has it's own eventlistner on #arrow, #arrow1 and #arrow2
uriznik
@uriznik
Jan 03 2017 07:50
@RNwebdk $(#arrow1).click(... is getting called immediately on the page being ready before #arrow1 has been created. Just because it is lower down in the function doesn't mean it happens later. When you click on the plus, the #addSolution click event function is triggered and then #arrow1 will be created at which point you can refer to it and add a click handler
Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:51
@fer408 that will subtract 1 from str length which will be most probly a positive number, you want to get subtring from back of string need a negative index, like -5
hariharanguru83
@hariharanguru83
Jan 03 2017 07:52
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < multiplyAll(arr).length; i++){
    for (var j = 0; j < multiplyAll(arr).length; j++){
      product += multiplyAll(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]]);
Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:52
@hariharanguru83 then calling that function inside the same function multiplyAll(arr[i][j]) what will happen ?
Fernando
@fer408
Jan 03 2017 07:53
@ghulamshabir like str.substring(-5) == target or str.substring(0, -5)
str.substring(0, -5) == target
uriznik
@uriznik
Jan 03 2017 07:54
@dabeister you'll need to use the arguments object to access the extra arguments passed to the function. You can use arr.filter but you should create a new function to pass to it rather than destroyer
Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:54
@fer408 str.substring(-target.length)
Thien Nguyen
@winmintin
Jan 03 2017 07:55
// Setup
function phoneticLookup(val) {
  var result = "";

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


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

// Change this value to test
phoneticLookup("charlie");
I hate it when i follow the sample and it does work lol
Manish Giri
@Manish-Giri
Jan 03 2017 07:56
@winmintin look at what you're returning.
Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:56
@RNwebdk sorry I mistook your problem, I thought you are in Where Art Though challenge
Fernando
@fer408
Jan 03 2017 07:57
@ghulamshabir Thanks man i got through it
CamperBot
@camperbot
Jan 03 2017 07:57
fer408 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1599 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Thien Nguyen
@winmintin
Jan 03 2017 07:57

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

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

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

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

Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:57
@fer408 :smile:
Thien Nguyen
@winmintin
Jan 03 2017 07:57
// Setup
function phoneticLookup(val) {
  var result = "";

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


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

// Change this value to test
phoneticLookup("charlie");
@Manish-Giri ?
i added " "
Manish Giri
@Manish-Giri
Jan 03 2017 07:58
@winmintin added ""?
what's that?
Fernando
@fer408
Jan 03 2017 07:58
@ghulamshabir I taught target was a string and could not be used as a number but now that i see the length method was used with it I can see how it works. Thank you
CamperBot
@camperbot
Jan 03 2017 07:58
fer408 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:warning: fer408 already gave ghulamshabir points
Manish Giri
@Manish-Giri
Jan 03 2017 07:58
@winmintin you're returning result which is an empty string, as it was set on line 1.
uriznik
@uriznik
Jan 03 2017 07:58
@RNwebdk have you used the browser developer tools before? you can sprinkle debug statements in your code to get an idea what is happening or step through it in the debugger. For example you could put a console.log("before #arrow1 click"); in the appropriate place and console.logs in other places to see the order of events
Thien Nguyen
@winmintin
Jan 03 2017 07:58
o
Manish Giri
@Manish-Giri
Jan 03 2017 07:59
@winmintin you need to return the value of the property val in the object lookup.
Rami
@RNwebdk
Jan 03 2017 07:59
@uriznik I see your point, but i have no clue how to solve that... You want me to create the event listner after this line else{ alert('Sorry you cant create more solutions'); }
Thien Nguyen
@winmintin
Jan 03 2017 07:59

the example didn't use val it confuse the heck out of me. ```
var alpha = {
1:"Z",
2:"Y",
3:"X",
4:"W",
...
24:"C",
25:"B",
26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

var value = 2;
alpha[value]; // "Y"```

Rami
@RNwebdk
Jan 03 2017 07:59
@ghulamshabir thanks for taking the time to try anyways :)
CamperBot
@camperbot
Jan 03 2017 07:59
rnwebdk sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1600 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Jan 03 2017 07:59
@fer408 you have to just think about an idea then you will find your way, google will be your best friend
Manish Giri
@Manish-Giri
Jan 03 2017 08:00
@winmintin it does, here
alpha[2]; // "Y"
alpha[24]; // "C"
var value = 2;
alpha[value]; // "Y"
it uses bracket notation and shows you in comments what the expected values are.
Dylan Hsiao
@greedylan
Jan 03 2017 08:00
@uriznik I think I also need to check if property values from both arguments match, this is what I have so far but it does not work
  var arr = [];
  var keysArr = Object.keys(source);

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

      if( collection[i].hasOwnProperty(keysArr[j]) === true && 
          collection[i]["keysArr[j]"] === source["keysArr[j]"]
        ){
        arr.push(collection[i]);

      }    
    } 
  } 
  return arr; 
}
Ghulam Shabir
@ghulamshabir
Jan 03 2017 08:00
@RNwebdk oh that makes 1600 brownies thank you too
CamperBot
@camperbot
Jan 03 2017 08:00
ghulamshabir sends brownie points to @rnwebdk :sparkles: :thumbsup: :sparkles:
:cookie: 271 | @rnwebdk |http://www.freecodecamp.com/rnwebdk
hariharanguru83
@hariharanguru83
Jan 03 2017 08:00

@ghulamshabir
```

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.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]]);


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.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]]);
Manish Giri
@Manish-Giri
Jan 03 2017 08:01

@winmintin especially this example

var value = 2;
alpha[value]; // "Y"

this is very similar to what you nee to do.

Thien Nguyen
@winmintin
Jan 03 2017 08:01
why 2?
hariharanguru83
@hariharanguru83
Jan 03 2017 08:01
I've changed the function
Manish Giri
@Manish-Giri
Jan 03 2017 08:01
@ghulamshabir congrats :+1:
Ghulam Shabir
@ghulamshabir
Jan 03 2017 08:01
@hariharanguru83 use arr[i].length in inner loop condition
@Manish-Giri thanks :smile:
CamperBot
@camperbot
Jan 03 2017 08:02
ghulamshabir sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3501 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jan 03 2017 08:02
@winmintin because 2 is a property in the object alpha
var alpha = {
1:"Z",
2:"Y",
3:"X",
4:"W",
...
24:"C",
25:"B",
26:"A"
};
whose value is Y
uriznik
@uriznik
Jan 03 2017 08:03
@RNwebdk before solution++ I guess. You may want to make the code more generic by making one or two functions that get given a solution number and return suitable html/elements to avoid repeating code
hariharanguru83
@hariharanguru83
Jan 03 2017 08:03
@ghulamshabir
Ming Lei
@dabeister
Jan 03 2017 08:03
@uriznik " you'll need to use the arguments object to access the extra arguments passed to the function. You can use arr.filter but you should create a new function to pass to it rather than destroyer" what does this actually mean? I created a new function as per your recommendation, but not sure as to why i did so:

function destroyer(arr) {
  function remover(arr) {
  for (var i = 1; i < arr.length; i++) {
    for (var j = 0; j < arr[0].length; j++) {
      return arr[0][j] !== arr[i];
    }
  }
  }  
  var filtered = arr.filter(remover);
  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
hariharanguru83
@hariharanguru83
Jan 03 2017 08:03
@ghulamshabir
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0;i<arr[i].length;i++){
    for (var j = 0; j < arr[j].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]]);
Ghulam Shabir
@ghulamshabir
Jan 03 2017 08:04

@hariharanguru83 i said arr[i].length

@hariharanguru83 use arr[i].length in inner loop condition

hariharanguru83
@hariharanguru83
Jan 03 2017 08:04
ok let me try
Ghulam Shabir
@ghulamshabir
Jan 03 2017 08:04
@hariharanguru83 do not use i in first loop condtion
Krzysztof Borowy
@Krizzu
Jan 03 2017 08:04
Morning
Happy new year :fireworks:
hariharanguru83
@hariharanguru83
Jan 03 2017 08:05
@ghulamshabir thanks
CamperBot
@camperbot
Jan 03 2017 08:05
hariharanguru83 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1601 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Jan 03 2017 08:05
@Krizzu Good Morning!
Manish Giri
@Manish-Giri
Jan 03 2017 08:05
@Krizzu to you as well :+1:
Ghulam Shabir
@ghulamshabir
Jan 03 2017 08:05
@hariharanguru83 :smile:
Krzysztof Borowy
@Krizzu
Jan 03 2017 08:05
@Manish-Giri :+1:
@ghulamshabir :wave:
Ghulam Shabir
@ghulamshabir
Jan 03 2017 08:05
@Krizzu :smile:
Thien Nguyen
@winmintin
Jan 03 2017 08:08

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

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

val = lookup;

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

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

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

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

  val = lookup;

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

// Change this value to test
phoneticLookup("charlie");
i still can't figure it out
Ming Lei
@dabeister
Jan 03 2017 08:08
@ghulamshabir any chance of a hand mate? ^_^
Thien Nguyen
@winmintin
Jan 03 2017 08:09
any other hints?
Ghulam Shabir
@ghulamshabir
Jan 03 2017 08:09
@dabeister sure :hand:
uriznik
@uriznik
Jan 03 2017 08:10
@greedylan getting there... "keysArr[j]" doesn't need to be a string, keysArr[j] will evaluate to a string (or some other type) and that will be used in the lookup
Manish Giri
@Manish-Giri
Jan 03 2017 08:11
@winmintin what do you think this does
val = lookup;
Thien Nguyen
@winmintin
Jan 03 2017 08:11
nothing lol
desperation
uriznik
@uriznik
Jan 03 2017 08:12
@greedylan You also need to keep track of whether every key has matched and only then push the object
h1tag
@h1tag
Jan 03 2017 08:12
Is it OK if I check the solutions for the challenges on Github, if I can't figure it out on my own? Because every challenge says to write your own code
Manish Giri
@Manish-Giri
Jan 03 2017 08:12
:point_up: January 3, 2017 3:01 AM
why don't you read through the example shown?
@winmintin
@fortMaximus you shouldn't need to see those solutions. Keep thinking of a solution for the given problem, if you've got doubts/qustions, you can post here and people will help you out.
@winmintin maybe this will help.
h1tag
@h1tag
Jan 03 2017 08:15
@Manish-Giri then why Freecodecamp uploaded them there? They shouldn't do that
uriznik
@uriznik
Jan 03 2017 08:15
@dabeister 1. arr isn't a 2d array 2. you need to use the arguments object to access the numbers you are supposed to remove (here's a hint, put inconsole.log(arguments[1]); at the top of your function and look in your browser console
Thien Nguyen
@winmintin
Jan 03 2017 08:17
ok i will take a look.
Manish Giri
@Manish-Giri
Jan 03 2017 08:18
@fortMaximus you can just assume the solutions don't exist and move on. Or if you want to take a look, go ahead. No one's stopping you.
Ghulam Shabir
@ghulamshabir
Jan 03 2017 08:18
@fortMaximus Good artists copy Great artists steal :smile: , though it does not mean you do everything just by copying
Chintan.Sutariya
@ChintanSutariya
Jan 03 2017 08:19

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

function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty("checkProp"))
{
return myObj.checkProp;
}

else
{
return "Not Found";
}
return "Change Me!";
}

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

what is my mistake here