These are chat archives for FreeCodeCamp/HelpJavaScript

16th
Apr 2017
Stephen James
@sjames1958gm
Apr 16 2017 00:03
@cmurphy580 res is initially input - so reduce is calling the array of functions, first on input then on the output of the previous function
Not sure input ==> part is required
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 00:06
@sjames1958gm whats the input at the end ?
oh nevermind
Stephen James
@sjames1958gm
Apr 16 2017 00:07
Ah I see this is returning a function that takes input and calls the functions on it.
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 00:07
missed parenthesis-ed
its the initial value
Stephen James
@sjames1958gm
Apr 16 2017 00:08
@cmurphy580 So input ==> is required to make the return a function
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 00:08
@sjames1958gm the level of recursivness was giving me a headache
Conor Murphy
@cmurphy580
Apr 16 2017 00:09
@sjames1958gm so res in the parameter of the 'func' function that is being reduced to input?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 00:09
i wanted to just enter loads of line in chat so i would get it off the screen so i would stop looking at it
Conor Murphy
@cmurphy580
Apr 16 2017 00:10
@sjames1958gm Thank you for the help too
CamperBot
@camperbot
Apr 16 2017 00:10
cmurphy580 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6724 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 16 2017 00:10
@cmurphy580 No each reduce pass calls the current function on the output from the previous pass, where the initial value of res is input
@cmurphy580 Didn't realize it was returning a function.
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 00:11
@cmurphy580 put it into python tutor and see if it will visualize
Conor Murphy
@cmurphy580
Apr 16 2017 00:12
@sjames1958gm alright that clears things up! thanks again for the help. @HeebieGeeBee I'll give it a try. Thank you
CamperBot
@camperbot
Apr 16 2017 00:12
cmurphy580 sends brownie points to @sjames1958gm and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1325 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:warning: cmurphy580 already gave sjames1958gm points
omarraza
@omarraza
Apr 16 2017 00:15

Random Quote project, this onclick isn't working for some reason. JS:

function tweet() {
 document.getElementById("tButton").onclick = function () {
   location.href = "https://twitter.com";
 };
}

HTML:

<button type="button" class="myButtons" id="tButton" onclick="tweet()"><i class= "fa fa-twitter"></i></button>
Stephen James
@sjames1958gm
Apr 16 2017 00:16
@omarraza If you click twice what happens?
omarraza
@omarraza
Apr 16 2017 00:16
blank page
Stephen James
@sjames1958gm
Apr 16 2017 00:16
@omarraza Not sure why you have a click handler that just adds another click handler?
omarraza
@omarraza
Apr 16 2017 00:17
oh so should I remove the onclick from the HTML?
no, rather I should remove the onclick in the JS, because the HTML onclick is needed to call the tweet() function
Stephen James
@sjames1958gm
Apr 16 2017 00:18

@omarraza

 document.getElementById("tButton").onclick = function () {
   location.href = "https://twitter.com";
 };

just do this in your js (not inside a function) and you will get the handler

anderson
@anderson2825
Apr 16 2017 00:18
a should be assigned to b with =
The answer is not a=b?
Stephen James
@sjames1958gm
Apr 16 2017 00:18
@anderson2825 Nope the other way -
@anderson2825 The value assigned to goes on the left of the =
anderson
@anderson2825
Apr 16 2017 00:20
ok thanks @sjames1958gm
CamperBot
@camperbot
Apr 16 2017 00:20
anderson2825 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6725 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
omarraza
@omarraza
Apr 16 2017 00:22
@sjames1958gm it still loads a white page instead of a new tab with twitter
I got rid of the tweet() function and the onclick in the HTML
<button type="button" class="myButtons" id="tButton"><i class= "fa fa-twitter"></i></button>
Stephen James
@sjames1958gm
Apr 16 2017 00:22
@omarraza Do you have a codepen? Any errors in console.
that's the pen
Stephen James
@sjames1958gm
Apr 16 2017 00:23
@omarraza error in console -
omarraza
@omarraza
Apr 16 2017 00:24
how did you see that? I opened the console, click the twitter button and no error msg displayed for me. Analyze JS also returned fine
Stephen James
@sjames1958gm
Apr 16 2017 00:25
@omarraza devtools console? F12 on windows chrome
@omarraza Refused to display 'https://twitter.com/' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'".
@omarraza You may want to use an anchor tag (<a>) and set the href on that with target="_blank"
omarraza
@omarraza
Apr 16 2017 00:27
ok and then have it change onclick via javascript, right?
the target=" " that is
Stephen James
@sjames1958gm
Apr 16 2017 00:28
@omarraza if its an anchor tag you don't have to have onclick - but when your quote changes you will set href on a
Mareflux
@Mareflux
Apr 16 2017 00:29
hey, how do I get a quotient of 2.2? lmao
omarraza
@omarraza
Apr 16 2017 00:29
when I set href as the quote changes, I need to include + in between each word? For example "this is my quote" would need to be "this+is+my+quote" in the href?
Stephen James
@sjames1958gm
Apr 16 2017 00:30
Saboor Malik
@MathematicsCoding
Apr 16 2017 00:30
@Mareflux you need to understand how remainder operator work
Stephen James
@sjames1958gm
Apr 16 2017 00:30
@Mareflux 4.4 / 2 ?
Saboor Malik
@MathematicsCoding
Apr 16 2017 00:31
Never mind
Mareflux
@Mareflux
Apr 16 2017 00:31
@MathematicsCoding You telling me I should skip the decimal parts?
Stephen James
@sjames1958gm
Apr 16 2017 00:32
@Mareflux or use 2.0
Saboor Malik
@MathematicsCoding
Apr 16 2017 00:32
no I thought the challenge you are working on is about remainder operator
omarraza
@omarraza
Apr 16 2017 00:33
@sjames1958gm thank you for the help
CamperBot
@camperbot
Apr 16 2017 00:33
:star2: 6726 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
omarraza sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Apr 16 2017 00:33
@omarraza yw
Vicky Lai
@vickylai
Apr 16 2017 00:37
Why's this not working?
            function loadTemp() {
                if (country == 'US') {
                    $('#tempF').show('slide', {direction: 'right'}, 1000);
                } else {
                    $('#tempC').show('slide', {direction: 'right'}, 1000);
                }
            }
            loadTemp();
country is right, and it's a string...
Ross
@rossauusa
Apr 16 2017 00:40
Hi Im mising "You should be using the variable playerNumber in your bracket notation"
Conrad Kay
@conradkay
Apr 16 2017 00:40
@rossauusa whats your current code
Ross
@rossauusa
Apr 16 2017 00:40
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
  var player = testObj [16];
// Change this Line
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 00:41
@vickylaixy shouldt all the arguments for show be inside an object?
Vicky Lai
@vickylai
Apr 16 2017 00:43

@HeebieGeeBee Elsewhere in my code it works like this...

$(function(){
    $('#showFah').on('click', function() {
        $('.weatherFah').show('slide', {direction: 'right'}, 1000);

etc

Ross
@rossauusa
Apr 16 2017 00:43
@conradkay ??
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 00:44
@vickylaixy got a codepen?
Conrad Kay
@conradkay
Apr 16 2017 00:44
what were the intructions
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 00:44
@vickylaixy what event runs that function?
Conrad Kay
@conradkay
Apr 16 2017 00:44
or what was the lesson name
Ross
@rossauusa
Apr 16 2017 00:44
@conradkay Instructions
Use the playerNumber variable to lookup player 16 in testObj using bracket notation.
Vicky Lai
@vickylai
Apr 16 2017 00:44
@HeebieGeeBee document.ready should... I'll double check
barki mustapha
@barkinet
Apr 16 2017 00:45

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line.

return Math.floor(Math.random(0.0,1) * 10);
}

Vicky Lai
@vickylai
Apr 16 2017 00:45
It's local... argh maybe I'll put it up
barki mustapha
@barkinet
Apr 16 2017 00:45
Help
Keon Samuel
@keonsam
Apr 16 2017 00:45
help what
post your code
barki mustapha
@barkinet
Apr 16 2017 00:45

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line.

return Math.floor(Math.random(0.0,1) * 10);
}

Jonathan A. M
@ontoneio
Apr 16 2017 00:46
var code = "formatted";
Keon Samuel
@keonsam
Apr 16 2017 00:46
do you see the big only change code below this line?
Victoria Zambrano
@vzambrano98
Apr 16 2017 00:46
hey guys, i'm on the roman numeral challenge, and i cannot figure out where to evens start. I looked at the hints and they don't make any sense to me. can anyone suggest any other resources?
Moisés Man
@moigithub
Apr 16 2017 00:46
to format code read more info below :point_down: @ontoneio
CamperBot
@camperbot
Apr 16 2017 00:46
:bulb: to format code use backticks! ``` more info
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 00:46
@barkinet math random doesnt need arguments
Benjamin
@XenoCoding
Apr 16 2017 00:46
Anybody here know how to access the wikipedia API?
Ross
@rossauusa
Apr 16 2017 00:47
@conradkay Lesson= Accessing Objects Properties with Variables
Conrad Kay
@conradkay
Apr 16 2017 00:47
you got the player number correct
why use the number 16 when you can use a variable that equals 16
Vicky Lai
@vickylai
Apr 16 2017 00:48
Ok. @HeebieGeeBee It's line 111 in the js.
http://codepen.io/vickylaixy/pen/jBXgeR?editors=0010
Conrad Kay
@conradkay
Apr 16 2017 00:48
also dont put a space between brackets and the object
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 00:48
@barkinet isnt there meant to be a specific range for the random whole number
Vicky Lai
@vickylai
Apr 16 2017 00:48
If anyone else has input... I don't seem to be able to make that function work
barki mustapha
@barkinet
Apr 16 2017 00:49
@HeebieGeeBee is pure value of leadership thank you
Conrad Kay
@conradkay
Apr 16 2017 00:49
@rossauusa so code should look like
var playerNumber = 16;       // Change this Line
var player = testObj[playerNumber];
CamperBot
@camperbot
Apr 16 2017 00:49
barkinet sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1326 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
anderson
@anderson2825
Apr 16 2017 00:49
var titleCaseOver=9000; titleCaseOver is not use cameCase?? How can i do ??
Ross
@rossauusa
Apr 16 2017 00:50
@conradkay I tried it that way earlier but 16 and the player number around the other way. Thanks!
CamperBot
@camperbot
Apr 16 2017 00:50
rossauusa sends brownie points to @conradkay :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @conradkay |http://www.freecodecamp.com/conradkay
barki mustapha
@barkinet
Apr 16 2017 00:53

// Example
function ourRandomRange(ourMin, ourMax) {

return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourRandomRange(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {

return Math.floor(Math.random() * (myMax - myMin + 1)) + myMin;// Change this line

}

// Change these values to test your function
var myRandom = randomRange(5, 15);

Is that correct
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 00:56

@vickylaixy

    function loadTemp() {
                if (country == 'US') {
                    $('.weatherFah').show('slide', {direction: 'right'}, 1000);
                } else {
                    $('.weatherCel').show('slide', {direction: 'right'}, 1000);
                }

                console.log(country);
            }
            loadTemp();

think this is what you want

@vickylaixy sorry took a while to look through code and see what was happening with everything
pprunesquallor
@pprunesquallor
Apr 16 2017 00:58
help! i'm at the Make Object Properties Private problem and i don't know where to start :(
Vicky Lai
@vickylai
Apr 16 2017 00:58
@HeebieGeeBee :sweat: Rookie err! Of course. Thanks!
CamperBot
@camperbot
Apr 16 2017 00:58
vickylaixy sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1327 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Vicky Lai
@vickylai
Apr 16 2017 00:58
@HeebieGeeBee Was my code pretty readable or not?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 00:58
@vickylaixy yup very nice
@barkinet is that not working?
pprunesquallor
@pprunesquallor
Apr 16 2017 01:00

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};
var Bike = function() {
// Only change code below this line.
};

var myCar = new Car();
var myBike = new Bike();

what am I supposed to do here? :(
anderson
@anderson2825
Apr 16 2017 01:00
This chat with screenshots function??
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:01
@anderson2825 yes
anderson
@anderson2825
Apr 16 2017 01:02
Where to use it?
@HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:02
@anderson2825 just paste screenshots into chat
anderson
@anderson2825
Apr 16 2017 01:03
ok thanks ! @HeebieGeeBee
CamperBot
@camperbot
Apr 16 2017 01:03
anderson2825 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1328 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:03
@pprunesquallor you need to make a two public methods for the bike constructor
like in the example
one to get the gear variable
and one to set the gear variable
juanfabrega
@juanfabrega
Apr 16 2017 01:04

Hi y'all! Would love a helping hand with a javascript challenge. I'm trying to capitalize the first letter of each word in a string, while ensure the rest of the word is left lowercase. All the test cases are working when I try them and look at the output in the console, but it's still failing to grant me a pass. Here's my code:

function titleCase(str) {
var strFinal = "";
strArray = str.split(" ");
for (i = 0; i < strArray.length; i++) {
strFinal = strFinal + strArray[i].charAt(0).toUpperCase();
for (y = 0; y < strArray[i].length; y++) {
strFinal = strFinal + strArray[i].charAt(y + 1).toLowerCase();
}
strFinal = strFinal + " ";
}
return strFinal;
}

Jonathan A. M
@ontoneio
Apr 16 2017 01:04
Need a little bit of help with lesson 197. Having a brain fart
juanfabrega
@juanfabrega
Apr 16 2017 01:05
  1. I split the string into an array.
  2. Using a
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:06
@juanfabrega youre adding a space at the end of the string
juanfabrega
@juanfabrega
Apr 16 2017 01:06
shoot
that's it. So obvious.
thanks!
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:07
@ontoneio challenges have names not numbers
juanfabrega
@juanfabrega
Apr 16 2017 01:07
Yet so difficult to catch with console output. :) Thanks @HeebieGeeBee
CamperBot
@camperbot
Apr 16 2017 01:07
juanfabrega sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1329 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
barki mustapha
@barkinet
Apr 16 2017 01:07

// Setup
var testString = "Ada Lovelace and Charles Babbage designed the first computer and the software that would have run on it.";

// Example
var expressionToGetSoftware = /software/gi;
var softwareCount = testString.match(expressionToGetSoftware).length;

// Only change code below this line.
var expression = /\band\b/gi;
var andCount = testString.match(expression).length;

// Only change code above this line

// This code counts the matches of expression in testString
var andCount = testString.match(expression).length;

pprunesquallor
@pprunesquallor
Apr 16 2017 01:10
i still don't know how to do this

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var gear;

var Bike = function(gear) {

this.getGear = function() {
return gear;
};
this.setGear = function(set_gear) {
speed = set_gear;
};
};
// Only change code below this line.

var myCar = new Car();

var myBike = new Bike();

omg sorry for that wall of code
barki mustapha
@barkinet
Apr 16 2017 01:11

// Setup
var testString = "Ada Lovelace and Charles Babbage designed the first computer and the software that would have run on it.";

// Example
var expressionToGetSoftware = /software/gi;
var softwareCount = testString.match(expressionToGetSoftware).length;

// Only change code below this line.
var expression = /\band\the/gi;
var andCount = testString.match(expression).length;

// Only change code above this line

// This code counts the matches of expression in testString
var andCount = testString.match(expression).length;

HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:14
@pprunesquallor you need to take the gear out the of function parameter in var Bike = function(gear) {and its gear = set_gear
pprunesquallor
@pprunesquallor
Apr 16 2017 01:15
@HeebieGeeBee like this?

var gear;

var Bike = function(gear) {

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

this is still not it, I know
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:16
@pprunesquallor yes but git rid of the gear as the function parameter, gear is already declared as a global variable
pprunesquallor
@pprunesquallor
Apr 16 2017 01:17
@HeebieGeeBee ok, i've now got this:
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:17
@barkinet no forward slashes onfront of band and the in the regex
pprunesquallor
@pprunesquallor
Apr 16 2017 01:17
var gear;
var Bike = function() {
this.getGear = function() {
return gear;
};
this.setGear = function() {
gear = set_gear;
};
};
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:17
@barkinet use | for or in a regex
@pprunesquallor you still needed the parameter for the this.setGear function
pprunesquallor
@pprunesquallor
Apr 16 2017 01:18
i guess i just don't understand this problem :(
is it really that difficult or am i missing some prerequisite knowledge, could be i went through the problems before too fast...
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:18
@pprunesquallor that could be a problem
maybe read up on constructor functions in javascript
pprunesquallor
@pprunesquallor
Apr 16 2017 01:19

oh ok it's like this:
var gear;

var Bike = function() {

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

this worked
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:19
and on getter and setters
pprunesquallor
@pprunesquallor
Apr 16 2017 01:19
thank you @HeebieGeeBee
CamperBot
@camperbot
Apr 16 2017 01:19
pprunesquallor sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1330 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
pprunesquallor
@pprunesquallor
Apr 16 2017 01:19
yea i definitely don't understand constructors
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:20
@pprunesquallor its pretty importing in coding so might be good to read up on
well especially in object orientated programming
important*
pprunesquallor
@pprunesquallor
Apr 16 2017 01:22
yea i can imagine it is, i'm reading about it as we type
haha your profile pic is funny :D
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:23
ppl often say that about my face
pprunesquallor
@pprunesquallor
Apr 16 2017 01:24
i don't believe you ;) but the combination of the look and the leisurely cow in the background is a win
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:25
@pprunesquallor she couldnt even be bothered to notice me
WAN35
@WAN35
Apr 16 2017 01:26
var myStr =' <a href="http://www.example.com" target="_blank">Link</a> ';
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:27
@WAN35 get read of that space at the start
after the first '
and at the end
Keon Samuel
@keonsam
Apr 16 2017 01:29
I got 3 advance challenge left that I am running from.
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:30
they arent easy
Keon Samuel
@keonsam
Apr 16 2017 01:30
all of them some kind of maths algorithm.
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:31
well alg is a clue there
jacob
@bjh2012
Apr 16 2017 01:31

Good evening, all. I was hoping someone could offer a little clarification.
In the code

for (var i=0; i<arrayOfStrings.length; i++) {
    var temporary = arrayOfStrings[i];

what exactly does the [i] do in this scenario?

HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:33
@bjh2012 its the variable that iterates
so you use it for the index
on arrayOfStrings
jacob
@bjh2012
Apr 16 2017 01:34
@HeebieGeeBee so, it refers to all of the strings in the array of strings?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:35
well the i by itself will just be 0 then 1 then 2 then 3 and so on
jacob
@bjh2012
Apr 16 2017 01:36
@HeebieGeeBee I see. but on the second line when it follows a variable, it refers to all the things the for loop iterated through?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 01:37
@bjh2012 yeah all the elements in arrayOfStrings
jacob
@bjh2012
Apr 16 2017 01:37
@HeebieGeeBee I see. I wasn't sure. thanks for the clarification
CamperBot
@camperbot
Apr 16 2017 01:37
bjh2012 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1331 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Vamp
@the-vampiire
Apr 16 2017 01:40
looking for some help with my wiki viewer. https://codepen.io/thevampiire/pen/XRbKMY?editors=1000
So currently I am using an embarassingly janky method of displaying the summary / link to each result down below
I am wondering how I can pass this format into the dropdown list from the search? so rather than display the text (data[1]) it would display the text (in link format) and summary of each live result
I am looking to do this so the user can use the built in jqueryUI keyboard functions of up and down arrows to cycle through results and select the one they are interested in
looks like you will have to open the link and run it in the browser don’t think it will work in the chat (at least it isn’t for me)
Keon Samuel
@keonsam
Apr 16 2017 01:43
what you talking about I see no JS?
Vamp
@the-vampiire
Apr 16 2017 01:45
click the JS tab..
Keon Samuel
@keonsam
Apr 16 2017 01:45
my bad
I used an unordered list for mines using Jquery to display it.
Vamp
@the-vampiire
Apr 16 2017 01:49
that is the default behavior
Keon Samuel
@keonsam
Apr 16 2017 01:49
you have to concatenate the data you get from wiki.
Vamp
@the-vampiire
Apr 16 2017 01:50
I have tried that
and receive an error for it
Uncaught TypeError: Cannot use 'in' operator to search for 'length'
Keon Samuel
@keonsam
Apr 16 2017 01:52
go back and do some debugging with console.log to see where the problem is.
Vamp
@the-vampiire
Apr 16 2017 01:52
Uncaught TypeError: Cannot use 'in' operator to search for 'length'
I have tried what I believe to be every basic approach to the problem that’s why I am here
I don’t come to the chat to waste anyone’s time
Keon Samuel
@keonsam
Apr 16 2017 01:52
oh
probably remove the s from your https
Vamp
@the-vampiire
Apr 16 2017 01:53
no
irrelevant
that is only there to remove the mixed-content error when running within codepen
Keon Samuel
@keonsam
Apr 16 2017 01:54
ok man let a pro help you.
Vamp
@the-vampiire
Apr 16 2017 01:54
codepen executes over https so any API calls must also be over https or they will not pass
here’s the error if you would like to see:
jquery.min.js:4 Mixed Content: The page at 'https://codepen.io/thevampiire/pen/XRbKMY?editors=0010' was loaded over HTTPS, but requested an insecure script 'http://en.wikipedia.org/w/api.php?callback=jQuery311033068138113390955_1492306670249&action=opensearch&format=json&search=py&_=1492306670251'. This request has been blocked; the content must be served over HTTPS.
pass https for wiki API call and it goes away.
daiwik
@daiwik
Apr 16 2017 02:10
I have a dum question

function destroyer(arr) {
  // Remove all the values
//  var first = arr.splice();
  var second = arr.splice(1);
  return second;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
why doesn't this return [2,3]
in splice doc it says specify starting index which i did as 1
but the answer is [2,3,1,2,3]
why is that
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 02:11
arr is just the first argument
which is the array
the whole point of the challenge is so you understand the arguments object
daiwik
@daiwik
Apr 16 2017 02:12
ok nvm that makes sense
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 02:12
you need to use arguments to access the 2 and the 3
daiwik
@daiwik
Apr 16 2017 02:12
yep i am dum
thanks @HeebieGeeBee
CamperBot
@camperbot
Apr 16 2017 02:12
daiwik sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1332 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Caleb Pearman
@capearman
Apr 16 2017 02:13
Hey fellow campers, I'm on the Profile Lookup Challenge. Please tear my code apart so I can get past this chalenge:

//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++) {
  return contacts[i];

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



// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Manish Giri
@Manish-Giri
Apr 16 2017 02:16
@capearman return contact should be outside loop
Omid Heravi
@omidv28
Apr 16 2017 02:17
Thanks @Rafase282 @aganita @abhisekp for your help with Challenge: Diff Two Arrays
CamperBot
@camperbot
Apr 16 2017 02:17
omidv28 sends brownie points to @rafase282 and @aganita and @abhisekp :sparkles: :thumbsup: :sparkles:
:cookie: 179 | @aganita |http://www.freecodecamp.com/aganita
:star2: 3342 | @abhisekp |http://www.freecodecamp.com/abhisekp
:star2: 1527 | @rafase282 |http://www.freecodecamp.com/rafase282
Caleb Pearman
@capearman
Apr 16 2017 02:24
@Manish-Giri but if I do that then the if is unreachable
Vicky Lai
@vickylai
Apr 16 2017 02:26
Is there a quick way to check whether the sun is up in a user's location? Something with time perhaps?
anderson
@anderson2825
Apr 16 2017 02:33

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit=0;
fahrenheit+=celsius;
fahrenheit-=celsius+22;
fahrenheit+=celsius+46;

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

// Change the inputs below to test your code
convertToF(30); convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86

What should I do with the problem?
flansolo
@flansolo
Apr 16 2017 02:34
maybe this @vickylaixy ? https://github.com/mourner/suncalc
JDW
@jd-wheaton
Apr 16 2017 02:37
how much does wikipedia api suck
" this much "
Caleb Pearman
@capearman
Apr 16 2017 02:38
Hey fellow campers, I'm on the Profile Lookup Challenge. Please tear my code apart so I can get past this chalenge:

//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++) {
  return contacts[i];

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



// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
JDW
@jd-wheaton
Apr 16 2017 02:38
I'm asking for json format and getting back something that doesn't look like json
flansolo
@flansolo
Apr 16 2017 02:38
prob sucks about as much as wikipedia does
what are you getting?
JDW
@jd-wheaton
Apr 16 2017 02:39
{
   "_body": "/**/({\"continue\":{\"picontinue\":4474,\"continue\":\"||\"},\"query\":{\"pages\":{\"736\":{\"pageid\":736,\"ns\":0,\"title\":\"Albert Einstein\",\"index\":1,\"thumbnail\":{\"source\":\"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Einstein_1921_by_…zer_-_restoration.jpg/38px-Einstein_1921_by_F_Schmutzer_-_restoration.jpg\",\"width\":38,\"height\":50},\"pageimage\":\"Einstein_1921_by_F_Schmutzer_-_restoration.jpg\"},\"4474\":{\"pageid\":4474,\"ns\":0,\"title\":\"Bose\\u2013Einstein condensate\",\"index\":6},\"188935\":{\"pageid\":188935,\"ns\":0,\"title\":\"Bose\\u2013Einstein statistics\",\"index\":9},\"18742711\":{\"pageid\":18742711,\"ns\":0,\"title\":\"Einstein family\",\"index\":2},\"424540\":{\"pageid\":424540,\"ns\":0,\"title\":\"Einstein field equations\",\"index\":8},\"644814\":{\"pageid\":644814,\"ns\":0,\"title\":\"Einstein manifold\",\"index\":4},\"599941\":{\"pageid\":599941,\"ns\":0,\"title\":\"Einstein refrigerator\",\"index\":5},\"598536\":{\"pageid\":598536,\"ns\":0,\"title\":\"Einstein ring\",\"index\":3},\"1908016\":{\"pageid\":1908016,\"ns\":0,\"title\":\"Einstein solid\",\"index\":10},\"2988445\":{\"pageid\":2988445,\"ns\":0,\"title\":\"Einstein\\u2013Szil\\u00e1rd letter\",\"index\":7}}}})",
   "status": 200,
   "ok": true,
   "statusText": "OK",
   "headers": {
      "cache-control": [
         "private",
         " must-revalidate",
         " max-age=0"
      ],
      "content-type": [
         "text/javascript; charset=utf-8"
      ]
   },
   "type": 2,
   "url": "https://crossorigin.me/https://en.wikipedia.org/w/api.php?&action=query&for…ch&gsrnamespace=0&gsrlimit=10&prop=pageimages&gsrsearch=einstein&callback=?"
flansolo
@flansolo
Apr 16 2017 02:39
but that is json
lol
JDW
@jd-wheaton
Apr 16 2017 02:39
yeah, accept I can't format it
flansolo
@flansolo
Apr 16 2017 02:39
i get what you mean though
JDW
@jd-wheaton
Apr 16 2017 02:40
Or should I say, I don't know how to disassemble that pile of garbage
flansolo
@flansolo
Apr 16 2017 02:40
why are you using crossorigin.me when its already an https request?
JDW
@jd-wheaton
Apr 16 2017 02:41
because I'm doing my dev locally, and chrome doesn't like it
flansolo
@flansolo
Apr 16 2017 02:41
i see
Dovydas Stirpeika
@Giveback007
Apr 16 2017 02:41
can anyone explain to me why this worked?
Capture.PNG
JDW
@jd-wheaton
Apr 16 2017 02:42
recursion?
Dovydas Stirpeika
@Giveback007
Apr 16 2017 02:42
I kept giving it different !== values, but only when I removed all values did it pass trough
like !== 0 && !== null
etc
flansolo
@flansolo
Apr 16 2017 02:42
it worked because the filter callback is returning the value, which will only return true items to the final array
Dovydas Stirpeika
@Giveback007
Apr 16 2017 02:43
so it can't return 0 or null?
flansolo
@flansolo
Apr 16 2017 02:44
filter will only return whatever conditions that result in a true statement
so those falsey values will be left out because returning them is a false statement
Dovydas Stirpeika
@Giveback007
Apr 16 2017 02:44
1 === true, 0 !== true ?
lol, when it worked (by accident) I felt like I got passed because of a bug.
Vamp
@the-vampiire
Apr 16 2017 02:46
@jd-wheaton what is your request?
JDW
@jd-wheaton
Apr 16 2017 02:47
I've tried several
Vamp
@the-vampiire
Apr 16 2017 02:47
@jd-wheaton seems like an odd pile of garbage, I agree. I mean you could access any of that like any JSON object but none of it looks very valuable lol
JDW
@jd-wheaton
Apr 16 2017 02:47
right now I have the values in the example
but I'm writing this in Angular v4.x
this is what I have for retrieving
search(query: string): Observable<SearchResult[]> {
    const params: string = [
      `action=query`,
      `format=json`,
      `generator=search`,
      `gsrnamespace=0`,
      `gsrlimit=10`,
      `prop=pageimages|extracts`,
      `pilimit=max`,
      `exintro`,
      `explaintext`,
      `exsentences=1`,
      `ex-limit=max`,
      `gsrsearch=${query}`,
      `callback=?`
    ].join('&');
    const queryUrl = `${this.apiUrl}&${params}`;
    return this.http.get(queryUrl)
    .map((response: Response) => {
      console.log(JSON.stringify(<any>response, null, 2));
anderson
@anderson2825
Apr 16 2017 02:49
QQ图片20170416104707.png
What should I do with the problem?
Vamp
@the-vampiire
Apr 16 2017 02:49
@jd-wheaton christ man I have no idea. I saw backticks and backed out lol
never done anything with angular
JDW
@jd-wheaton
Apr 16 2017 02:50
that's not angular, that's ES6
Vamp
@the-vampiire
Apr 16 2017 02:50
maybe try a stand JS request just to see if you have formatted the request properly?
okay in either case I don’t recognize it
in JS you’d see ‘param’:’val’ I’ve never seen this ‘param=val’ format before
JDW
@jd-wheaton
Apr 16 2017 02:51
technically it's typescript, but all typescript is a typed variable version of ES6
Vamp
@the-vampiire
Apr 16 2017 02:51
@anderson2825 conver the values using the conversion equation provided in the problem statement
Dovydas Stirpeika
@Giveback007
Apr 16 2017 02:51
ok so I just ran >> console.log(1 !== true); << and it returned true. So why does .filter() return all numbers except 0?
Caleb Pearman
@capearman
Apr 16 2017 02:52
Hey fellow campers, I'm on the Profile Lookup Challenge. Please tear my code apart so I can get past this challenge:

//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++) {
  return contacts[i];

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



// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Dovydas Stirpeika
@Giveback007
Apr 16 2017 02:53
Capture1.PNG
Dylan
@dhcodes
Apr 16 2017 02:53
@capearman I believe you're closing your for loop before using it for the if-else
anderson
@anderson2825
Apr 16 2017 02:54
@the-vampiire What should i do? Please give an example thanks!
CamperBot
@camperbot
Apr 16 2017 02:54
anderson2825 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 299 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Vamp
@the-vampiire
Apr 16 2017 02:55
@anderson2825 the example is in the problem statement man. you take the F value and convert it to C
or vice versa I dont remember the questio and your screenshot had it cut out
Caleb Pearman
@capearman
Apr 16 2017 02:55
@dhcodes okay, I understand what you're saying, but when I put the return contacts[i]; right before the if statement, the if statement becomes unreachable.
Mark
@vinarius
Apr 16 2017 02:56
@capearman try looking up a 'for in' loop on mdn
Dovydas Stirpeika
@Giveback007
Apr 16 2017 02:57
so why exactly is zero not returned and other numerals are?
Capture.PNG
Vamp
@the-vampiire
Apr 16 2017 02:57
@Giveback007 1 is equivelant to true and 0 is equivelant to false
Dylan
@dhcodes
Apr 16 2017 02:57
@capearman try removing return contacts[i]
@the-vampiire is right
Vamp
@the-vampiire
Apr 16 2017 02:58
if(1){
console.log(‘true, 1’);
}

if(0){
console.log(‘true, 0’);
}

if(!0){
console.log(‘true, not 0’);
}
// true, 1
// true, not 0
Caleb Pearman
@capearman
Apr 16 2017 02:59
@dhcodes it returns "No such contact"
Dovydas Stirpeika
@Giveback007
Apr 16 2017 02:59
why does >> console.log(1 !== true) << returns >> true <<
Vamp
@the-vampiire
Apr 16 2017 02:59
because 1 does not strictly equal true
Dovydas Stirpeika
@Giveback007
Apr 16 2017 02:59
oh...
Vamp
@the-vampiire
Apr 16 2017 02:59
;)
it is EQUIVELANT in this particular language, and some others
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:00
thank you @the-vampiire
CamperBot
@camperbot
Apr 16 2017 03:00
giveback007 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 300 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
anderson
@anderson2825
Apr 16 2017 03:00
@the-vampiire Okay, I'll try again and still thank you!
CamperBot
@camperbot
Apr 16 2017 03:00
:warning: anderson2825 already gave the-vampiire points
anderson2825 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
Vamp
@the-vampiire
Apr 16 2017 03:00
I don’t know but I would guess that 1 != true will be false
Shrey Sethi
@Shrey-S
Apr 16 2017 03:00
Hey everyone
JDW
@jd-wheaton
Apr 16 2017 03:01
@the-vampiire when I pass that response into ```
return (<any>response.json()).items.map(item => {
        return new SearchResult({
          id: item.pageid,
          title: item.title,
          description: item.extract,
          linkUrl: item.pageid
        });
      });
I get a JSON err
Dylan
@dhcodes
Apr 16 2017 03:01
@capearman which is one of your if statements
so that means its working
Vamp
@the-vampiire
Apr 16 2017 03:01
@Giveback007
console.log(1 != true); // false
console.log(1 == true); // true
console.log(1 === true); // false
Moisés Man
@moigithub
Apr 16 2017 03:02
whats <any> ? @jd-wheaton
JDW
@jd-wheaton
Apr 16 2017 03:02
typescript
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:02
can you help me to better understand the difference between strictly true and not strictly
Moisés Man
@moigithub
Apr 16 2017 03:02
ok :)
Shrey Sethi
@Shrey-S
Apr 16 2017 03:02
I'm on the Sorted Union problem, under intermediate algorithm scripting. I think there is a bug in this question. Anyone else have the same experience?
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:02
i rember that "1" == 1
Vamp
@the-vampiire
Apr 16 2017 03:02
@anderson just think of F as a variable and C as a variable. you want to turn one into the other. try writing it on a piece of paper then solving for the one you want. now conver that into code
cynthiajbuck
@cynthiajbuck
Apr 16 2017 03:02
Strictly means that the data types are the same
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:02
but "1" === 1 is false
JDW
@jd-wheaton
Apr 16 2017 03:02
@moigithub problem I'm having is with the return of a wikipedia query, it's not quite the json format I'd expected and I don't know what to do with it
Vamp
@the-vampiire
Apr 16 2017 03:03
@Giveback007 strictly means same value AND same type. non strict means same value but can be different type
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:03
ahhh
cynthiajbuck
@cynthiajbuck
Apr 16 2017 03:03
1 is a number and true is a bool even though true is 1
Vamp
@the-vampiire
Apr 16 2017 03:03
@Giveback007
1 == 1 // true (val and type)
1 == ‘1’ // true (val, but not type as LHS is int and RHS is string)
1 === 1 // true (val and type)
1 === ‘1’ // false (val, but not type)

1 == true // true (val but not type)
1 === true // false (val but not type)

to go with examples you asked earlier

sorry made correction
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:05
so... back to 0 in the .filter() case
Vamp
@the-vampiire
Apr 16 2017 03:05
0 is false
filter returns only true
return 0 —> return false —> nothing returned
flansolo
@flansolo
Apr 16 2017 03:05
yes js wtf moments ^^^
Vamp
@the-vampiire
Apr 16 2017 03:06
in the context of filter
return 0 —> return false —> skip this element and move to next index for filter test
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:07
I'm trying to connect how the strict and not strict works in terms of 0 since .filter() uses not strict
I think i got it
Capture.PNG
Vamp
@the-vampiire
Apr 16 2017 03:09
I jsut explained it to you
filter only passes TRUE
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:09
:) you did
Vamp
@the-vampiire
Apr 16 2017 03:09
0 is equivelant to false
0 will not pass
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:10
again @the-vampiire thank you
CamperBot
@camperbot
Apr 16 2017 03:10
giveback007 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:warning: giveback007 already gave the-vampiire points
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:10
you've made at least one person ever so slightly smarter today
is there a filtering method that uses strict mode of comparing?
Vamp
@the-vampiire
Apr 16 2017 03:12
to be fair I had never heard this question before
I just googled “0 !== true” and found a stackoverflow thread that discussed how 0 and 1 are equivelant to false and true in some languages including JS
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:12
well to be fair you've explained it well
Vamp
@the-vampiire
Apr 16 2017 03:12
then I tried it in my IDE then I came to explain to you
I learned as much as you my friend
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:13
you've made 2* people ever so slightly today
Vamp
@the-vampiire
Apr 16 2017 03:13
lol
when in doubt I like to just fuck around in the IDE and see what comes out. you can usually learn a lot that way
just try random things and see what happens. that’s what I love about coding
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:14
I never thought to use == instead of === that's why I was confused
Vamp
@the-vampiire
Apr 16 2017 03:14
sometimes you find out some cool stuff, other times you prove some obvious stuff. either way you learned some stuff
oh ya as a habit you should try to always use === unless you have a specific reason not to
helps you not pass any nonsense through
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:15
I wonder why they chose to have .filter use the == method of comparison
Caleb Pearman
@capearman
Apr 16 2017 03:16
Hey campers, I'm on the Profile Lookup Challenge. My code is returning "No such contact". Any idea why?

//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 (contacts.hasOwnProperty(firstName) && contacts.hasOwnProperty(prop)) {
   return contacts[prop];
 } else if (contacts.hasOwnProperty(firstName) === false) {
   return "No such contact";
 } else if (contacts.hasOwnProperty(prop) === false) {
   return "No such property";
 }
}



// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Vamp
@the-vampiire
Apr 16 2017 03:16

I wonder why they chose to have .filter use the == method of comparison

I dont see where you got that information

Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:17
I am making assumptions here
based on the lacky foundation of knowledge here
Manish Giri
@Manish-Giri
Apr 16 2017 03:17
@capearman I thought I told you
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:18
it helps me keep it all together for the moment
Manish Giri
@Manish-Giri
Apr 16 2017 03:18
move the return no such contact outside
Caleb Pearman
@capearman
Apr 16 2017 03:18
@Manish-Giri it does the same thing that it's doing now
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:19
when I say "here" i mean here in my head
Manish Giri
@Manish-Giri
Apr 16 2017 03:19
so you changed it back?
Vamp
@the-vampiire
Apr 16 2017 03:19
@Giveback007 I think that could be the issue. that is not a correct assumption
nowhere here does it claim that filter functions as you described
Peter Kay
@deuscode
Apr 16 2017 03:19
Hey friends, just finished my weather app
what do you guys think?
Saboor Malik
@MathematicsCoding
Apr 16 2017 03:20
@deuscode Nice
Vamp
@the-vampiire
Apr 16 2017 03:20
@deuscode nothing appears
Caleb Pearman
@capearman
Apr 16 2017 03:20
@Manish-Giri yes, someone else told me to. So I have it outside now and it's returning the same thing:

//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 (contacts.hasOwnProperty(firstName) && contacts.hasOwnProperty(prop)) {
   return contacts[prop];
 } else if (contacts.hasOwnProperty(firstName) === false) {
   return "No such contact";
 } else if (contacts.hasOwnProperty(prop) === false) {
   return "No such property";
 }   


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:20
@capearman I would suggest braking down each peace and testing to see what each of them return seperatley
Peter Kay
@deuscode
Apr 16 2017 03:21
@the-vampiire really you don't see anything?
Manish Giri
@Manish-Giri
Apr 16 2017 03:21
@capearman you moved everything outside the loop?
Vamp
@the-vampiire
Apr 16 2017 03:21
Screen Shot 2017-04-15 at 11.21.20 PM.png
Saboor Malik
@MathematicsCoding
Apr 16 2017 03:21
@deuscode yeah like that no temperature or anything appear
kickkick479
@kickkick479
Apr 16 2017 03:22
@capearman contacts.hasOwnProperty(firstName) is not right. contacts is an array. So you cannot use hasOwnProperty method.
Also, I reccomend you to separate firstname check and prop check.
Saboor Malik
@MathematicsCoding
Apr 16 2017 03:22
Just Date
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:22
@capearman I looked at the solution I made for the assignment and I see some diffrences
Peter Kay
@deuscode
Apr 16 2017 03:22
blob
that's odd this is what I see
kickkick479
@kickkick479
Apr 16 2017 03:22
@capearman contacts[0].hasOwnProperty(prop) is right usage.
And you should check all contacts if thye have the given firstname. So you must put firstname check and prop check inside the loop.
Saboor Malik
@MathematicsCoding
Apr 16 2017 03:23
Strange...
Peter Kay
@deuscode
Apr 16 2017 03:24
hummm that's weird, I see inconsistencies between browsers
edge makes the elements of the weather go to the back
is the z-index ignored on edge?
Vamp
@the-vampiire
Apr 16 2017 03:24
I am using chrome
Peter Kay
@deuscode
Apr 16 2017 03:24
Ah
I see chrome is not showing up
Vamp
@the-vampiire
Apr 16 2017 03:25
I wouldn’t insult you with opening it in Edge
Peter Kay
@deuscode
Apr 16 2017 03:25
only on IE and Mozilla
that's weird
hahaha @the-vampiire
Vamp
@the-vampiire
Apr 16 2017 03:25
lol
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:25
@deuscode I am also only seeing the globe on Chrome without the other stuff
Peter Kay
@deuscode
Apr 16 2017 03:25
It works on IE and Firefox, but not on chrome...
the background video apparently does not stay in the back
Vamp
@the-vampiire
Apr 16 2017 03:26
ah I thought it was a live view of the earth finding my position
I was very excited
and had a lot of questions
lol
Caleb Pearman
@capearman
Apr 16 2017 03:27
@kickkick479 okay, so my last two ifs should be in the loop?
kickkick479
@kickkick479
Apr 16 2017 03:28
@capearman Yeah, except for return "No such contact"; part. Cuz you should return that when the loop finish without matching.
Peter Kay
@deuscode
Apr 16 2017 03:29
@the-vampiire haha, that'd take up a lot of bandwidth
kickkick479
@kickkick479
Apr 16 2017 03:31
@capearman Are you OK ?
Peter Kay
@deuscode
Apr 16 2017 03:32
@the-vampiire can you check now? http://kaypeter.com/weathermachine/
Caleb Pearman
@capearman
Apr 16 2017 03:32
@kickkick479 so if I have this, how can I have the "No such contact part outside the loop?"
//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 (contacts.hasOwnProperty(firstName) === false) {
   return "No such contact";
 } else if (contacts[0].hasOwnProperty(prop) === false) {
   return "No such property";
}
 if (contacts.hasOwnProperty(firstName) && contacts[0].hasOwnProperty(prop)) {
   return contacts[prop];
 }
 }   


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Peter Kay
@deuscode
Apr 16 2017 03:32
I think I found the issue... firefox is forgiving with the css
forgot to add a position styling element
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:33
hey @capearman , I don't know if you are in the same situation I was where I was just not "getting it", this book helped a lot: https://www.amazon.com/Smarter-Way-Learn-JavaScript-technology-ebook/dp/B00H1W9I6C
Vamp
@the-vampiire
Apr 16 2017 03:33
@deuscode worked bro
Peter Kay
@deuscode
Apr 16 2017 03:33
awesome thanks for checking it out
Vamp
@the-vampiire
Apr 16 2017 03:33
icons dont appear on the weekly forecast
but the text all appears, and icon works for current
toggle works as well
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:34
about 10 exercises in java script I was not understanding why things were happening, this book has you go trough simple exercises after each 1-2 page chapter. I did a few every day, and after about 2 weeks I had no problems.
Vamp
@the-vampiire
Apr 16 2017 03:34
might I suggest dropping that background into a div with width: 100% vw and height: 100% vh and then using some bootstrap or flexboxes to align the other divs. it might work on your screen but on mine it’s a bit wonky especiall when shrinking the screen to simulate a mobile view
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:35
the basic algorithms say 50 hours but I'm already almost finished and I started yesterday, and I know it's because that book helped a lot.
Vamp
@the-vampiire
Apr 16 2017 03:35
Screen Shot 2017-04-15 at 11.35.20 PM.png
Caleb Pearman
@capearman
Apr 16 2017 03:35
Thanks for the recommendation @Giveback007 , I'll look into it
CamperBot
@camperbot
Apr 16 2017 03:35
capearman sends brownie points to @giveback007 :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @giveback007 |http://www.freecodecamp.com/giveback007
Vamp
@the-vampiire
Apr 16 2017 03:35
you can see it’s a bit misaligned
kickkick479
@kickkick479
Apr 16 2017 03:35

@capearman Place return "No such contact"; just below for block. like this.

for (var i=0; i < contacts.length; i++) {
..
}
return "No such contact";

Is that OK?
Sorry i corrected

Peter Kay
@deuscode
Apr 16 2017 03:37
@the-vampiire a little misaligned to the right ?
Vamp
@the-vampiire
Apr 16 2017 03:37
@capearman I’ll give you this, a simple question that will help you understand what’s going on here
@capearman what happens when a loop hits a return statement?
a) returns what is told to return then continues the loop, b) returns what is told to return and exits the loop, c) nothing
@deuscode you can see the picture
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:38
@the-vampiire I'm getting exited that you bring this up.
Vamp
@the-vampiire
Apr 16 2017 03:38
@deuscode misaligned horizontally and vertically causing scrolling
@Giveback007 it’s an important concept which is why you see this same question asked in here very often and why I think FCC put this question so early in the challenges
Peter Kay
@deuscode
Apr 16 2017 03:39
ahhhhh I see it
Caleb Pearman
@capearman
Apr 16 2017 03:39
@the-vampiire B
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:39
the dam return was the reason why I wasn't passing this exact problem just a couple days ago
Vamp
@the-vampiire
Apr 16 2017 03:39
@capearman correct
so given this information I have another question for you
on your first loop
you are looking for contact index 0
let’s say you do not find the contact you want in this loop, but you hit a return statement. will you proceed to checking the following contact?
JDW
@jd-wheaton
Apr 16 2017 03:41
anyone have any ideas on how to parse this?
{
  "_body": "/**/({\"batchcomplete\":\"\",\"continue\":{\"gsroffset\":10,\"continue\":\"gsroffset||\"},\"query\":{\"pages\":{\"736\":{\"pageid\":736,\"ns\":0,\"title\":\"Albert Einstein\",\"index\":1,\"thumbnail\":{\"source\":\"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Einstein_1921_by_…zer_-_restoration.jpg/38px-Einstein_1921_by_F_Schmutzer_-_restoration.jpg\",\"width\":38,\"height\":50},\"pageimage\":\"Einstein_1921_by_F_Schmutzer_-_restoration.jpg\",\"extract\":\"Albert Einstein (/\\u02c8a\\u026ansta\\u026an/; German: [\\u02c8alb\\u025b\\u0250\\u032ft \\u02c8a\\u026an\\u0283ta\\u026an]; 14 March 1879 \\u2013 18 April 1955) was a German-born theoretical physicist.\"
Vamp
@the-vampiire
Apr 16 2017 03:41
@jd-wheaton ya sure let me just pick myself up off the groun after this seizure
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:42
thank you everyone, it was a pleasure, and the help is appreciated. I hope to grow up to be just like you @the-vampiire, i'm going to try to finish the rest of the algorithms tonight
CamperBot
@camperbot
Apr 16 2017 03:42
giveback007 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:warning: giveback007 already gave the-vampiire points
JDW
@jd-wheaton
Apr 16 2017 03:42
maybe remove the escape chars
Caleb Pearman
@capearman
Apr 16 2017 03:42
@the-vampiire no...
Vamp
@the-vampiire
Apr 16 2017 03:42
but seriously maybe try filtering out the escapes
lol yea exactly @jd-wheaton
@capearman precisely
Caleb Pearman
@capearman
Apr 16 2017 03:43
@kickkick479 how do I get both returns under the loop?
Vamp
@the-vampiire
Apr 16 2017 03:43
@capearman so tell me how should you write this loop then? you want it to check through each contact without failure - so return no contact found should be inside or outside the loop?
@Giveback007 I hope not I am a miserable person. good luck man
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:44
@capearman just in case you want to visualize what @the-vampiire is saying imagine a car going down a highway(function) and it will take the first exit(return) when the condition is met
kickkick479
@kickkick479
Apr 16 2017 03:45
@capearman I think both retun statement don't need be placed outside the loop. return "No such property"; and return contacts[i][prop]; should be placed in the loop. Listen to vampiire's advice carefully and think logic of the challenge, I mean the order of code. Hang on there
Vamp
@the-vampiire
Apr 16 2017 03:45
@capearman just in case you want to visualize what @the-vampiire is saying imagine a car going down a highway(function) and it will take the first exit(return) as soon as it can because it is running out of gas
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:46
if (a === b) {
Vamp
@the-vampiire
Apr 16 2017 03:46
whenever it reaches a return it will execute it
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:46
crap
Vamp
@the-vampiire
Apr 16 2017 03:46
@capearman I will walk you through this if you give me honest answers to my questions. I promise I won’t write a line of code for you but I will stay with you until you write it yourself as long as you show effort
Im not asking to make fun of you. Im asking so you can hear your own words and learn what you should or shouldnt be doing. that’s education that lasts.
Dovydas Stirpeika
@Giveback007
Apr 16 2017 03:48
ok I promised I leave i'm realy going now :) bye
Vamp
@the-vampiire
Apr 16 2017 03:48
later
Caleb Pearman
@capearman
Apr 16 2017 03:48
@the-vampiire I got what you were saying until the running out of gas part....I get what you're saying and I'm not refusing to answer. I'm just thinking a minute. I'm still with you :smile:
Vamp
@the-vampiire
Apr 16 2017 03:48
good luck on caesar’s cypher
dont worry about this analogy
if it confuses you
@capearman so tell me how should you write this loop then? you want it to check through each contact without failure - so return no contact found should be inside or outside the loop?
this is the question to think about
Caleb Pearman
@capearman
Apr 16 2017 03:49
@the-vampiire I'm still not sure yet...
Vamp
@the-vampiire
Apr 16 2017 03:49
tell me what you think at the moment
there are no stupid answers when you are trying to learn
use what you know:
you want to loop through each contact until one is found
you know that when a return statement is reached in a loop it will exit the loop even if it has not gone through all the contacts yet (aka all the iterations of the loop)
Adebiyi Abdulmateen
@Ayandeji
Apr 16 2017 03:53
Hello house
Kindly help me with this Array function
function nextInLine(arr, item) {
arr= arr.push(item);
// Your code here
arr= arr.shift(arr[0]);
return arr.shift(arr[0]);
// Change this line
}
Vamp
@the-vampiire
Apr 16 2017 03:54
you know you have 2 checks to make and should consider how the loop impacts these checks.
1) does this contact exist (you must loop through all contacts to ensure whether or not it exists)
2) does this contact (when found) have a property I am looking for (does the loop have any effect here ONCE you have matched the contact?)
@Ayandeji
function nextInLine(arr, item) {
 arr= arr.push(item);
  // Your code here
arr= arr.shift(arr[0]);
  return arr.shift(arr[0]);  
 // Change this line
}
Adebiyi Abdulmateen
@Ayandeji
Apr 16 2017 03:54
It is meant to add the second argument to the array and then remove the first element to the array and return the element that was removed at the beginning
kickkick479
@kickkick479
Apr 16 2017 03:55
@capearman
This is a quote from another camper. I hope this will help you.
1. you need a loop to pick each objects
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                  return the value of prop in the object
                 1.1.1.2  return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
HN
@haydennorthcott
Apr 16 2017 03:56
What am I missing here:
// 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");
Adebiyi Abdulmateen
@Ayandeji
Apr 16 2017 03:57
Kidly help me with this.
function nextInLine(arr, item) {
arr= arr.push(item);
// Your code here
arr= arr.shift(arr[0]);
return arr.shift(arr[0]);
// Change this line
}
Caleb Pearman
@capearman
Apr 16 2017 03:57
@the-vampiire I still don't know man.
kickkick479
@kickkick479
Apr 16 2017 03:57
@Ayandeji Why do you assign arr.push(item) to arr? push(x) simply add the x to arr and you don't need reassign that.
Adebiyi Abdulmateen
@Ayandeji
Apr 16 2017 03:57
okay
Firdous Farith
@FirdousFarith
Apr 16 2017 03:58
Counting Cards how to do this challenge ?
Count Change Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K', 'A'
?
Caleb Pearman
@capearman
Apr 16 2017 03:58
@the-vampiire return no contact found should be inside the loop?
HN
@haydennorthcott
Apr 16 2017 03:58
@FirdousFarith build a switch statement.
Vamp
@the-vampiire
Apr 16 2017 03:59
@capearman no sir
Caleb Pearman
@capearman
Apr 16 2017 03:59
@the-vampiire return no contact found should be outside the loop. Why?
Adebiyi Abdulmateen
@Ayandeji
Apr 16 2017 03:59
@kickkick479 ..I am still not getting it
kickkick479
@kickkick479
Apr 16 2017 04:00
@Ayandeji what's the challenge?
Vamp
@the-vampiire
Apr 16 2017 04:00

@capearman you have told me when a return statement is reached in a loop the loop breaks. you have told me you must perform all iterations of the loop to confirm whetehr a contact exists.

you have told me to put the return no contact within the loop meaning at the first iteration that a contact is NOT found the loop will break and not continue through all of its iterations

JDW
@jd-wheaton
Apr 16 2017 04:01
hey, what's the regex to replace all \ { and } ?
Manish Giri
@Manish-Giri
Apr 16 2017 04:01
/[\{}]/
that?
Adebiyi Abdulmateen
@Ayandeji
Apr 16 2017 04:01
@kickkick479 The function is meant to add the item argument to the array, remove the first element and return the item that was removed
JDW
@jd-wheaton
Apr 16 2017 04:01
thanks @Manish-Giri yep
CamperBot
@camperbot
Apr 16 2017 04:01
jd-wheaton sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5170 | @manish-giri |http://www.freecodecamp.com/manish-giri
kickkick479
@kickkick479
Apr 16 2017 04:02
@FirdousFarith Inside the cc function, you need 2 parts. One part should check what the card is and count up/down with switch or for block. Second part should check the count if the count is above zero or not and return the value and text, Bet or Hold.
Vamp
@the-vampiire
Apr 16 2017 04:02
@Ayandeji you do not reassign an array when you push into it

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

arr.push(item); 
console.log(arr); // [1, 2, 3, 4, 5]
arr = arr.push(item);
console.log(arr) // 5
why that equals 5 is confusing the hell out of me, but that is the case...
kickkick479
@kickkick479
Apr 16 2017 04:04
@Ayandeji No, can you tell me the chanllenge name?
Caleb Pearman
@capearman
Apr 16 2017 04:04
my apologies @the-vampiire, it's hard to think right now because of commotion irl... it's hard for me to understand what you're getting at.
Vamp
@the-vampiire
Apr 16 2017 04:04
@capearman no problem
Gulsvi
@gulsvi
Apr 16 2017 04:05
@the-vampiire arr = 5 because .push() returns the length of the array
Hi, by the way :wave:
Vamp
@the-vampiire
Apr 16 2017 04:05
I would suggest writing pseudocode. are you familiar with this term? try writing out the code in words. what you want it to do. once you have written it out in words and the LOGIC makes sense to you THEN start to build your function and ensure after each line that you are not breaking the logic
@SkyCoder01 just realized that lol, tried removing an element and it gave 4
Adebiyi Abdulmateen
@Ayandeji
Apr 16 2017 04:06
@kickkick479 The challenge name is Stand in Line
kickkick479
@kickkick479
Apr 16 2017 04:06
THX
Caleb Pearman
@capearman
Apr 16 2017 04:07
@the-vampiire stay with me for a minute, so ... let me think...
anderson
@anderson2825
Apr 16 2017 04:08
QQ图片20170416120650.png
How to solve this problem?
Vamp
@the-vampiire
Apr 16 2017 04:08
@Ayandeji
function nextInLine(arr, item) {
 arr= arr.push(item); // do not reassign arr to this, just perform the array method on arr
  // Your code here
arr= arr.shift(arr[0]); // do not reassign arr to this and shift does not take a parameter it simply removes the first element in the array 
  return arr.shift(arr[0]);   //shift does not take a parameter it simply removes the first element in the array 
 // Change this line
}
kickkick479
@kickkick479
Apr 16 2017 04:08
@Ayandeji return arr.shift(arr[0]); is close but wrong. u can simply return arr.shift();
Yasser Hussain
@yasserhussain1110
Apr 16 2017 04:09
Vamp
@the-vampiire
Apr 16 2017 04:09
@capearman I am here just going to make a steak back in few minutes
Caleb Pearman
@capearman
Apr 16 2017 04:11
@the-vampiire I respect you for that. I'll be thinking about it.
kickkick479
@kickkick479
Apr 16 2017 04:12
@anderson2825 What's the challenge name ? I donot remember that.
Adebiyi Abdulmateen
@Ayandeji
Apr 16 2017 04:14
@kickkick479 Thanks. I have followed what you said but it isnt passsing the test
CamperBot
@camperbot
Apr 16 2017 04:14
ayandeji sends brownie points to @kickkick479 :sparkles: :thumbsup: :sparkles:
:cookie: 302 | @kickkick479 |http://www.freecodecamp.com/kickkick479
anderson
@anderson2825
Apr 16 2017 04:14
Escape Sequences in Strings @kickkick479
kickkick479
@kickkick479
Apr 16 2017 04:14
@Ayandeji So what's the whole your code now?
Moisés Man
@moigithub
Apr 16 2017 04:15
@Ayandeji shift removes an eleemnt from the array
soo if u have 3 shift.. it will remove 3 elements
Corey Pennington
@JuiceyDuecy
Apr 16 2017 04:17
hey guys
any ideas why this is returning "undefined"?
var twitchUsers = function(){
twitchArr = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
for(var i = 0; i<=twitchArr.length; i++){
}
var url = "https://wind-bow.gomix.me/twitch-api"+ twitchUsers[i] + "?callback=?";
};
oops
Adebiyi Abdulmateen
@Ayandeji
Apr 16 2017 04:17
@kickkick479 This is it
Corey Pennington
@JuiceyDuecy
Apr 16 2017 04:17
var twitchUsers = function(){ twitchArr = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"]; for(var i = 0; i<=twitchArr.length; i++){ } var url = "https://wind-bow.gomix.me/twitch-api"+ twitchUsers[i] + "?callback=?"; };
Adebiyi Abdulmateen
@Ayandeji
Apr 16 2017 04:17
function nextInLine(arr, item) {
arr.push(item); // do not reassign arr to this, just perform the array method on arr
// Your code here
arr.shift(); // do not reassign arr to this and shift does not take a parameter it simply removes the first element in the array
return arr.shift(); //shift does not take a parameter it simply removes the first element in the array
// Change this line
}
Moisés Man
@moigithub
Apr 16 2017 04:18
arrays and strings are 0 based index @JuiceyDuecy
mean it start on 0 and ends on length -1
soo ur loop should ends on i< arrr.length only
@Ayandeji shift removes an eleemnt from the array

soo if u have 3 shift().. it will remove 3 elements

Corey Pennington
@JuiceyDuecy
Apr 16 2017 04:18
I see.... @moigithub thanks... let's see if it fixes it
CamperBot
@camperbot
Apr 16 2017 04:18
juiceyduecy sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3110 | @moigithub |http://www.freecodecamp.com/moigithub
kickkick479
@kickkick479
Apr 16 2017 04:19
@anderson2825 newlinebackslash means \n and backslashcarriage-return do \r not string literals.
@Ayandeji u donot need first arr.shift(); . Just remove it and tha'ts ok. Cuz that first arr.shift() remove first index so that return arr.shift(); in that codes return original second element of the array.
Caleb Pearman
@capearman
Apr 16 2017 04:21
@the-vampiire okay, so the loop shouldn't have a return statement inside of it because it will exit prematurely. I get that now.
anderson
@anderson2825
Apr 16 2017 04:22
@kickkick479 okay, thanks;
CamperBot
@camperbot
Apr 16 2017 04:22
anderson2825 sends brownie points to @kickkick479 :sparkles: :thumbsup: :sparkles:
:cookie: 303 | @kickkick479 |http://www.freecodecamp.com/kickkick479
Adebiyi Abdulmateen
@Ayandeji
Apr 16 2017 04:24
@kickkick479 .Thanks. It is now working
CamperBot
@camperbot
Apr 16 2017 04:24
ayandeji sends brownie points to @kickkick479 :sparkles: :thumbsup: :sparkles:
:warning: ayandeji already gave kickkick479 points
kickkick479
@kickkick479
Apr 16 2017 04:24
@Ayandeji :+1: That's the way.
Adebiyi Abdulmateen
@Ayandeji
Apr 16 2017 04:25
@kickkick479 How do I send the brownie point
Peter Kay
@deuscode
Apr 16 2017 04:25
@the-vampiire http://kaypeter.com/weathermachine/ all fixed it seems, thanks again for pointing out the issues
CamperBot
@camperbot
Apr 16 2017 04:25
deuscode sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 301 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
kickkick479
@kickkick479
Apr 16 2017 04:25
I got already. It's automatic when thanks words exists and menthin someone. @Ayandeji
This message was deleted
Caleb Pearman
@capearman
Apr 16 2017 04:26
@the-vampiire so I have this. Should the if statements be inside the loop? If so, how do I do this and still keep the return statements outside of the loop so that it doesn't return prematurely?

//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 (contacts.hasOwnProperty(firstName) && contacts[0].hasOwnProperty(prop)) {
   return contacts[prop];
 } else if (contacts.hasOwnProperty(firstName) === false) {
   return "No such contact";
 } else if (contacts[0].hasOwnProperty(prop) === false) {
   return "No such property";
 }   


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Peter Kay
@deuscode
Apr 16 2017 04:27
@the-vampiire I forgot to add an 'a' at the end of background-color: rgba <----- styling was off because of that
and also made the time date absolute so that the alignment wasn't off
JDW
@jd-wheaton
Apr 16 2017 04:27
@moigithub any idea how to get rid of this error: SyntaxError: Unexpected token / in JSON at position 0
it's a widely known problem
JDW
@jd-wheaton
Apr 16 2017 04:33
yes, accept the problem is I have a forward slash in the Http Response (datatype response) the blows up json() func.
I don't want to convert it to a string and run replace on it, as I don't know how to turn it back into datatype of response
Peter Nguyen
@iampeternguyen
Apr 16 2017 04:37

i'm struggling with trying to figure out how to complete this challenge. i want to be able to automate the != target to keep adding itiself until it reaches the end of all the arguments
```

function destroyer(arr) {
// Remove all the values
var target = Array.from(arguments);
var willISurvive = target.shift();

function kill(value) {

  return value != target[0] && value != target[1];  

}

var madeIt = willISurvive.filter(kill);

return madeIt;
}

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

Himujjal Upadhyaya
@Himujjal
Apr 16 2017 04:46
$("div").append() in jQuery can almost do everything that React or Angular.js does. So why use them ??
If we are making a single page application
Peter Nguyen
@iampeternguyen
Apr 16 2017 04:53
or is something i can do with the array.map function?
Vamp
@the-vampiire
Apr 16 2017 04:54
@capearman you misunderstood. I didn’t say not to have any return statements in the loop. i said to be mindful of which should be in and which should be out

@capearman but anyways the way you have it written won’t be looping through anything.

you have defined a variable i and set it to increment under the condition that it is less than the length of your contacts. so it should increase from 0 to contact.length - 1 meaning it will have an i value for each contact. this is all good

but you have not desginated any of your conditional statements to make use of this value i. that is the purpose of a loop. to iterate through the values automatically for you
Caleb Pearman
@capearman
Apr 16 2017 04:58
@the-vampiire okay...
Vamp
@the-vampiire
Apr 16 2017 04:58
let me ask you
I have an array
arr = [2, 4, 6, 8]
var i = 0;
for(i; i < arr.length; i++){
console.log(  x   );
}
I want you to print out each value of that array, what would you write in place of X
Ken Haduch
@khaduch
Apr 16 2017 04:59
@iampeternguyen - I used .filter() in my solution for this. Check out the optional thisArg that they mention in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter - you can pass the array of filter values in as that argument and then just use it as this inside the callback function. And use .indexOf() - another hint...
kickkick479
@kickkick479
Apr 16 2017 05:00
@the-vampiire console.log(arr[i]);
Michelle Carey
@genovese28
Apr 16 2017 05:01

// Example
var changed = 0;
Call the processArg function with an argument of 7 and assign its return value to the variable processed.function change(num) {
return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 0;

function processArg(num) {
return (num + 3) / 5;
}

// Only change code below this line

can anyone help? thank you!

Vamp
@the-vampiire
Apr 16 2017 05:01
@kickkick479 come on man the question is for him to learn, obviously you know the answer
kickkick479
@kickkick479
Apr 16 2017 05:02
@the-vampiire Oops, sorry for that.
Manish Giri
@Manish-Giri
Apr 16 2017 05:02
@genovese28 did you understand this line
changed = change(10);
Michelle Carey
@genovese28
Apr 16 2017 05:03
no
Manish Giri
@Manish-Giri
Apr 16 2017 05:03
what about this function
function change(num) {
return (num + 5) / 3;
}
Caleb Pearman
@capearman
Apr 16 2017 05:03
@the-vampiire arr[i]
Vamp
@the-vampiire
Apr 16 2017 05:04
okay and why?
because on the first iteration of the loop:
i = 0,
arr[i] = arr[0] = 2
then
i = 1,
arr [i] = arr[1] = 4
until we rach the end
now
you have in your problem something similar to the array I just asked you about, an array of contacts
Michelle Carey
@genovese28
Apr 16 2017 05:05
@Manish-Giri no I guess I don't understand that either.
Vamp
@the-vampiire
Apr 16 2017 05:05
tell me how would you go about iterating through this array of contacts
@capearman using the exact loop you have already made - noting there needs to change
dont write the rest of the code just type out the loop and in the loop block what you would use to iterate through your contacts
Manish Giri
@Manish-Giri
Apr 16 2017 05:07
@genovese28 okay, I'm not sure if this would help more than the challenges on function themselves, but here goes -
Think of a function like a box containing a series of instructions, like if you wanted to do these things -
1. Feed the cat
2. Bathe the cat
3. Play with the cat
4. Pick up the things the cat dropped
5. Curse yourself for getting a cat
you could either write out these instructions one by one each time, or you could create a box that contains all these instructions, and next time if you wanted to redo the same sequence of instructions again, you'd just use the box, instead of every instruction individually
Caleb Pearman
@capearman
Apr 16 2017 05:08
@the-vampiire contacts[i]
Manish Giri
@Manish-Giri
Apr 16 2017 05:09
function lifeWithCat()  {
1. Feed the cat
2. Bathe the cat
3. Play with the cat
4. Pick up the things the cat dropped
5. Curse yourself for getting a cat
}
@genovese28
anderson
@anderson2825
Apr 16 2017 05:09
QQ图片20170416130845.png
why is false?? var myStr="FirstLinenewline\n\backslashSecondLinebackslash\carriage-return\rThirdLine";
Manish Giri
@Manish-Giri
Apr 16 2017 05:09
@genovese28 now, whenever you want to do these intructions, you'd just do
lifeWithCat()
anderson
@anderson2825
Apr 16 2017 05:10
How can I solve this problem?
Manish Giri
@Manish-Giri
Apr 16 2017 05:10
that box is a function...it does everything inside it, and you can reuse it later as many times as you'd like.
does that make sense?
@genovese28
@anderson2825 remove the words like backslash
you were meant to use the notations only
like \n etc
anderson
@anderson2825
Apr 16 2017 05:13
ok thanks! @Manish-Giri
CamperBot
@camperbot
Apr 16 2017 05:13
anderson2825 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5172 | @manish-giri |http://www.freecodecamp.com/manish-giri
Vamp
@the-vampiire
Apr 16 2017 05:13
@capearman I sent you a PM will be easier to explain
Michelle Carey
@genovese28
Apr 16 2017 05:13
@Manish-Giri yes this does make sense. thank you
CamperBot
@camperbot
Apr 16 2017 05:13
genovese28 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5173 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Apr 16 2017 05:15
@genovese28 okay, the last part to understand is that functions can not only contain a series of steps to do something, but they can also "return" a value to the thing that called the function.
Like if you'd ask "what's the weather in SF tomorrow", you'd expect a value right?
so a function that does that, should look like -
function getSFWeather() {
return 86F;
}
this function "returns" the value of 86F, and now whoever called the function, can utilize this value, one way of doing that would be to store in a variable, for use later
var weatherInSFTomorrow = getSFWeather() 
console.log("Tomorrow in SF it's " + weatherInSFTomorrow);
Caleb Pearman
@capearman
Apr 16 2017 05:17
@the-vampiire I didn't know fCC had PM, how do I access it?
Manish Giri
@Manish-Giri
Apr 16 2017 05:17
here, you stored that 86F value that was returned from the function, and then printed the value of that variable
if you got this far, the current challenge should be pretty straightforward now.
@genovese28
Vamp
@the-vampiire
Apr 16 2017 05:18
open the side bar
look for my name
or hover over my name and hit private message
Nahuel Ovejero
@NahuelOvejero
Apr 16 2017 05:28
can someone led me a quick hand? My callback is not working
https://codepen.io/volean/pen/EmjyKp
tommyluceyu
@tommyluceyu
Apr 16 2017 05:29
How do I post a screenshot of my code in this chat?
Manish Giri
@Manish-Giri
Apr 16 2017 05:31
@NahuelOvejero check out the browser console
Nahuel Ovejero
@NahuelOvejero
Apr 16 2017 05:31
you can host it and paste the url
Access to Font at 'https://production-assets.codepen.io/assets/telefon/bold/af889c53-1ee3-4868…50-3-b7a87e0fbd213943fae0c0ef5985635dd43fa9c24876b2725127a13ccaf4ab6a.woff' from origin 'https://codepen.io' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'http://codepen.io' that is not equal to the supplied origin. Origin 'https://codepen.io' is therefore not allowed access.
Himujjal Upadhyaya
@Himujjal
Apr 16 2017 05:31
is there any gui app that can let you handle node.js modules and let you create a new node.js app by selecting a folder and such. I come from a PHP/MySQL background. There with one click I start the localhost and then start hacking in htdocs
Nahuel Ovejero
@NahuelOvejero
Apr 16 2017 05:31
so, the API is blocked by code pen? @Manish-Giri
Manish Giri
@Manish-Giri
Apr 16 2017 05:32
more like by chrome
@NahuelOvejero
Dovydas Stirpeika
@Giveback007
Apr 16 2017 05:33
Hey everyone, I'm sorry I just broke free code camp
Capture.PNG
Himujjal Upadhyaya
@Himujjal
Apr 16 2017 05:33
@Giveback007 Broke?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 05:33
@Manish-Giri or anyone https://codepen.io/Geeheeb/full/MmYdEj/ got any idea why this has issue filling up the screen sometimes, if you move the size of the screen about it feels up, but other times it moves the game board below the controls, im using vh and vw for the sizing
Dovydas Stirpeika
@Giveback007
Apr 16 2017 05:33
:D
Ross
@rossauusa
Apr 16 2017 05:34
I dont really understand - Iterate Through an Array with a For Loop
Himujjal Upadhyaya
@Himujjal
Apr 16 2017 05:34
@Giveback007 woah! how did you do that! lol
Ross
@rossauusa
Apr 16 2017 05:34

// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

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

// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line

for (var i = 0; i < myArr.length; i++) {
  total = myArr[i];
}
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 05:35
@NahuelOvejero run your codepen in http
Ross
@rossauusa
Apr 16 2017 05:35
Can anyone help?
Dovydas Stirpeika
@Giveback007
Apr 16 2017 05:35
@Himujjal no idea, but I believe it's over for all of us
Nahuel Ovejero
@NahuelOvejero
Apr 16 2017 05:36
@HeebieGeeBee I try @Manish-Giri , but http:// got deleted and only codepen is left
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 05:36
@rossauusa += not =
Dovydas Stirpeika
@Giveback007
Apr 16 2017 05:36
@rossauusa double check the example
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 05:36
@NahuelOvejero when it goes it means its running in http
'
Dovydas Stirpeika
@Giveback007
Apr 16 2017 05:37
@rossauusa computers are extremely picky about every little symbol
Ross
@rossauusa
Apr 16 2017 05:37
@HeebieGeeBee then I get an answer of 46 not 20
Nahuel Ovejero
@NahuelOvejero
Apr 16 2017 05:37
XMLHttpRequest cannot load http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.
Dovydas Stirpeika
@Giveback007
Apr 16 2017 05:38
@rossauusa can you show your new code?
Ross
@rossauusa
Apr 16 2017 05:38
@Giveback007 yes i was getting 46 ??
tommyluceyu
@tommyluceyu
Apr 16 2017 05:38
alt
Nahuel Ovejero
@NahuelOvejero
Apr 16 2017 05:38
thats what it say when I use http @HeebieGeeBee
Ross
@rossauusa
Apr 16 2017 05:38
// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

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

// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line

for (var i = 0; i < myArr.length; i++) {
  total += myArr[i];
}
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 05:39
tommyluceyu
@tommyluceyu
Apr 16 2017 05:39
I can't figure this exercise out. I'm supposed to increment the the count based on if the number is positive or negative
alt
Ross
@rossauusa
Apr 16 2017 05:39
@Giveback007 ??
Nahuel Ovejero
@NahuelOvejero
Apr 16 2017 05:40
still got the same error @HeebieGeeBee , even with your link
guess I will have to download another browser
Dovydas Stirpeika
@Giveback007
Apr 16 2017 05:40
@rossauusa you are missing a variable
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 05:40
@rossauusa declare the variable before the loop and initialise it with 0
@NahuelOvejero im using chrome and dont get that error
Nahuel Ovejero
@NahuelOvejero
Apr 16 2017 05:41
so you see the quote on the console?
Dovydas Stirpeika
@Giveback007
Apr 16 2017 05:41
@rossauusa look over at the example they gave you and make sure you have the other variable for the loop
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 05:41
@NahuelOvejero yes
@NahuelOvejero well if you just console log data in console
data.content is undefined
Nahuel Ovejero
@NahuelOvejero
Apr 16 2017 05:42
ugh.... well, thank you @HeebieGeeBee @Manish-Giri , I will check the error more in depth
CamperBot
@camperbot
Apr 16 2017 05:42
nahuelovejero sends brownie points to @heebiegeebee and @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 1333 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:star2: 5174 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ross
@rossauusa
Apr 16 2017 05:43

@Giveback007 ```
// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

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

// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line
var total = 0;
for (var i = 0; i < myArr.length; i++) {
total += myArr[i];
}
```

// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

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

// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line
var total = 0;
for (var i = 0; i < myArr.length; i++) {
  total += myArr[i];
}
Thanks @Giveback007
CamperBot
@camperbot
Apr 16 2017 05:43
rossauusa sends brownie points to @giveback007 :sparkles: :thumbsup: :sparkles:
:cookie: 256 | @giveback007 |http://www.freecodecamp.com/giveback007
Dovydas Stirpeika
@Giveback007
Apr 16 2017 05:47
@rossauusa you're welcome.
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 05:59
@Manish-Giri nevermind i sorted it out
Heathercoraje
@Heathercoraje
Apr 16 2017 06:10
Hey everyone.
Can anybody give me a help?
Markus Kiili
@Masd925
Apr 16 2017 06:10
@HeebieGeeBee Did you use O(NlogN) sort ;)
Joseph
@revisualize
Apr 16 2017 06:10
hey hey!
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:11
@Masd925 @revisualize yo
Markus Kiili
@Masd925
Apr 16 2017 06:11
@HeebieGeeBee @revisualize Morning.
Joseph
@revisualize
Apr 16 2017 06:11
I use O(n^2logn^2) sorting.
Heathercoraje
@Heathercoraje
Apr 16 2017 06:11
My challenge is to return the middle character of a string. If the string's length is odd, return the middle character. If the string's length is even, return the middle 2 characters.
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:11
@Masd925 i did not
Gilbert
@gilbertp97
Apr 16 2017 06:11
how are u doing tonight coders? ;)
Dovydas Stirpeika
@Giveback007
Apr 16 2017 06:11
I just finished the basic algorithm challenges!!!! (I hope it's ok to brag)
Heathercoraje
@Heathercoraje
Apr 16 2017 06:11
I am doing a kata.
stuck :(
Gilbert
@gilbertp97
Apr 16 2017 06:12
i have a question also
Heathercoraje
@Heathercoraje
Apr 16 2017 06:12
my code is

function getMiddle(s) {

  return s.length % 2 ? s.substring((s.length / 2)-1,(s.length / 2) + 1) : s.substring( (s.length / 2), (s.length / 2) +1) ;

   }
`
It shouldn't be hard but I am just lost lol. Can anyone give me hand?
Markus Kiili
@Masd925
Apr 16 2017 06:13
@Heathercoraje So kata is a form of code vomit?
Dovydas Stirpeika
@Giveback007
Apr 16 2017 06:13
I think kata is a coding chalange
Joseph
@revisualize
Apr 16 2017 06:13
@Heathercoraje Why not just use Math.ceil()
Dovydas Stirpeika
@Giveback007
Apr 16 2017 06:13
for practice
Heathercoraje
@Heathercoraje
Apr 16 2017 06:13
@Giveback007 exactly
I am not familiar with that method let me look up
but first of all what is wrong with my code?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:14
@Heathercoraje you remember what index starts from?
Heathercoraje
@Heathercoraje
Apr 16 2017 06:15
@HeebieGeeBee is to return the middle character of a string. If the string's length is odd, return the middle character. If the string's length is even, return the middle 2 characters.
0.
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:15
yes
Heathercoraje
@Heathercoraje
Apr 16 2017 06:15
umh.?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:16
so if the length is 10
10 /2 is 5
and if you use that as an index
that will be the 6th character
Heathercoraje
@Heathercoraje
Apr 16 2017 06:16
yes.
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:18
s.substring((s.length / 2)-1,(s.length / 2) + 1) how many characters does this slice? @Heathercoraje
Joseph
@revisualize
Apr 16 2017 06:18
Do a little dance.
Make a little love
Get down tonight.
Get Down Tonight!
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:19
@revisualize dont just give her the answer
Heathercoraje
@Heathercoraje
Apr 16 2017 06:19
I know..
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:19
lol
Joseph
@revisualize
Apr 16 2017 06:19
Sorry.
I was a little too excited.
Heathercoraje
@Heathercoraje
Apr 16 2017 06:19
that's ok I know that answer but I want to fix my code.
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:20
@revisualize i could tell
Heathercoraje
@Heathercoraje
Apr 16 2017 06:20
@HeebieGeeBee I didn't get your question.
Markus Kiili
@Masd925
Apr 16 2017 06:20
@Heathercoraje I made a simple recursive solution to your kata. Do you like to see it?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:20
if asked if something is truthy do this, s.substring((s.length / 2)-1,(s.length / 2) + 1)
Joseph
@revisualize
Apr 16 2017 06:21
@Heathercoraje Where do I find that challenge? I want to submit my sweet solution.
Heathercoraje
@Heathercoraje
Apr 16 2017 06:21
@revisualize codewars.
@Masd925 maybe later
Markus Kiili
@Masd925
Apr 16 2017 06:21
@Heathercoraje ok
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:22
first put a value is s.length in that part of the code
@Heathercoraje and see what its doing
Darth Skywalker
@adityaparab
Apr 16 2017 06:22
Just a note.. A faster way to determine odd/even is to use binary and operator
function getMiddle(s) {
  var l = s.length;
  var isOdd  = s.length & 1;
  var middle = Math.floor(l/2);
  return isOdd ? s[middle] : s.substr(middle-1 , 2 );
}

getMiddle('asdfgh');
Heathercoraje
@Heathercoraje
Apr 16 2017 06:22
@HeebieGeeBee If the length is 4, it should return value from 1st till 3rd (not inclusive)
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:23
@Heathercoraje why not inclusive?
Heathercoraje
@Heathercoraje
Apr 16 2017 06:23
maybe I am wrong with the method .substring?
Joseph
@revisualize
Apr 16 2017 06:23
I got another solution!
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:24
sorry havent used substring in maybe ever
it doesnt include the index end?
nope.
Joseph
@revisualize
Apr 16 2017 06:25
@adityaparab I did this:
function getMiddle(s) {
   // return (s.length % 2 === 0) ? s.substr((s.length / 2 - 1) , 2 ) : s[Math.floor(s.length / 2)];
   return (s.length % 2 === 0) ? s[s.length / 2 - 1] + s[s.length / 2] : s[Math.floor(s.length / 2)]
}
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:26
@Heathercoraje well maybe thats why i dont use substring
cus its a dumb method when slice and substr is available
Joseph
@revisualize
Apr 16 2017 06:26
@adityaparab what does this var isOdd = s.length & 1; do?
Heathercoraje
@Heathercoraje
Apr 16 2017 06:26
Do you know what is wrong with code?
I wanted to use substr instead actually.
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:27
@Heathercoraje i think youve got your conditional the wrong way round then
Joseph
@revisualize
Apr 16 2017 06:27
(condition) ? true : false;
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:28
i thought there was also an error with the substring method but didnt think the index end wasnt inclusive
Heathercoraje
@Heathercoraje
Apr 16 2017 06:28
@HeebieGeeBee I see.
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:28
like @revisualize just said
Darth Skywalker
@adityaparab
Apr 16 2017 06:28

@revisualize It is binary and operator. Do you know how the binary operations work?

Every odd decimal (or any other system) number ends with 1. So decimal 3, for example is binary 11. If you & each of these numbers. the last 1 when &ed, becomes 1&1.. 1&1 is always 1.

Decimal 2, for example, is binary 10. 0&1 = 0 (thus even)

HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:28
^
Joseph
@revisualize
Apr 16 2017 06:29
@adityaparab I don't know how the Binary Operators work.
Darth Skywalker
@adityaparab
Apr 16 2017 06:30
It's same as decimal.. Only difference is for decimal, the base is 10. For binary, base is 2. And for hexadecimal, base is 16 and or octal , base is 8 ;)
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:30
just found out that jquery's click doesnt work as a tap on a mobile device
ffs
Darth Skywalker
@adityaparab
Apr 16 2017 06:30
@HeebieGeeBee You need to import jQuery mobile and use event call touchstart
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:30
so gotta through all the code to get the taps to work on mobile
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:30
@HeebieGeeBee They does..
Heathercoraje
@Heathercoraje
Apr 16 2017 06:30
@HeebieGeeBee
uhm.
it just worked
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:31
whats that @adityaparab ?
Darth Skywalker
@adityaparab
Apr 16 2017 06:31
the click event is detected on iOS devices... but its way slower than touch events
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:31
@Heathercoraje without changing?
Heathercoraje
@Heathercoraje
Apr 16 2017 06:31
i refreshed it and it passed the tests
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:31
Jquery click does work on phone
Heathercoraje
@Heathercoraje
Apr 16 2017 06:31
@HeebieGeeBee exactly.
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:31
magic then
Heathercoraje
@Heathercoraje
Apr 16 2017 06:31
lol
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:31
I tested my weather app on my phone and jQuery click works @HeebieGeeBee
just found out that jquery's click doesnt work as a tap on a mobile device
Darth Skywalker
@adityaparab
Apr 16 2017 06:32
@HeebieGeeBee : instead of using $(element).on('click', cb) use $(element).on('touchstart', cb)
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:32
@adityaparab what does touchstart do?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:32
@adityaparab but tthats included in the jquery libraray right?
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:32
same thing as click?
Darth Skywalker
@adityaparab
Apr 16 2017 06:33
@MathematicsCoding : Click events are way slower on mobile devices and they are not universally detected. It works on your phone doesn't mean it will work on every other phone..
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:33
oh I see
Heathercoraje
@Heathercoraje
Apr 16 2017 06:33
2
@HeebieGeeBee @revisualize @Masd925 anyways thanks guys
CamperBot
@camperbot
Apr 16 2017 06:33
heathercoraje sends brownie points to @heebiegeebee and @revisualize and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3753 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 3862 | @masd925 |http://www.freecodecamp.com/masd925
:star2: 1334 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:33
touchstart do same thing as click does but faster?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:33
@adityaparab if i replace it with touchstart
will that work for desktop browsers clicking too?
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:34
Thats what im asking
Darth Skywalker
@adityaparab
Apr 16 2017 06:34

@MathematicsCoding : clickis a combination of 2 events. mousedown and mouseup. They two together form a click.

On mobile devices, we don't have click. We have tap event.
And like click, tap is a combination of touchstart and touchend

Saboor Malik
@MathematicsCoding
Apr 16 2017 06:34
Oh I see
So touchstart wont work for desktop, PC then?
Unless they have touchscreen?
Heathercoraje
@Heathercoraje
Apr 16 2017 06:35
Skinny jeans are no good for coding.
:fire:
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:35
Arent you supposed to put tap? not touchstart
Darth Skywalker
@adityaparab
Apr 16 2017 06:35
@MathematicsCoding that again depends on the environment you're in :)
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:35
Okay thanks @adityaparab
CamperBot
@camperbot
Apr 16 2017 06:35
mathematicscoding sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:star2: 1003 | @adityaparab |http://www.freecodecamp.com/adityaparab
Darth Skywalker
@adityaparab
Apr 16 2017 06:36
@MathematicsCoding : Since we're talking about jQuery, not all version support tap. it was intriduced later. So in order to have backward compatibility, it is a well known standard to use touchstart instead of tap
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:36
learned a thing from Stewie lol
I see
Darth Skywalker
@adityaparab
Apr 16 2017 06:36
@MathematicsCoding : my pleasure :)

So touchstart wont work for desktop, PC then?

There is no straightforward way... You have to manually check if touch events are available and then use events accordingly

function is_touch_device() {
  return 'ontouchstart' in window        // works on most browsers 
      || 'onmsgesturechange' in window;  // works on IE10 with some false positives
};
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:38
Just a simple question about .concat
method
Darth Skywalker
@adityaparab
Apr 16 2017 06:39
@MathematicsCoding shoot
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:39
@adityaparab so you think touchstart is better to use than tap?
Darth Skywalker
@adityaparab
Apr 16 2017 06:39

Skinny jeans are no good for coding.

go commando!

Saboor Malik
@MathematicsCoding
Apr 16 2017 06:39
var la = "hello";
var laa = "world";
return la.concat(laa);
// hello world?
Darth Skywalker
@adityaparab
Apr 16 2017 06:39
@MathematicsCoding : yes.. but there will not be space between hello and world
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:39
So then " world"
Is there another way?
Darth Skywalker
@adityaparab
Apr 16 2017 06:40

@HeebieGeeBee

@adityaparab so you think touchstart is better to use than tap?

:point_up: This

Tanushree Samanta
@TSamanta
Apr 16 2017 06:40
@TSamanta
hi! I dunno why my font is not getting changed even after importing
https://codepen.io/T_Samanta/pen/oWgEYd/
Darth Skywalker
@adityaparab
Apr 16 2017 06:40
@MathematicsCoding : You want to strictly use .concat?
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:41
Maybe?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:41
@adityaparab yeah just getting a little more confirmation before i went through and made the changes
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:41
Im just reviewing methods
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:41
@MathematicsCoding thanks
CamperBot
@camperbot
Apr 16 2017 06:41
heebiegeebee sends brownie points to @mathematicscoding :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @mathematicscoding |http://www.freecodecamp.com/mathematicscoding
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:41
@HeebieGeeBee What did I do?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:41
@adityaparab ty
CamperBot
@camperbot
Apr 16 2017 06:41
heebiegeebee sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:star2: 1004 | @adityaparab |http://www.freecodecamp.com/adityaparab
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:42
lol so it was an accidentally
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:42
@MathematicsCoding you moved that chat up when i was about to click on darth
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:42
xD
That happened to me before
Thanks for a free cookie
var arr = [1,2,3];
return arr.indexOf[0] // 1?
Darth Skywalker
@adityaparab
Apr 16 2017 06:43
@MathematicsCoding it will give you an error
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:43
why?
Darth Skywalker
@adityaparab
Apr 16 2017 06:43
becuase of box brackets
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:44
missing semicolon?
Darth Skywalker
@adityaparab
Apr 16 2017 06:44
not error specifically.. .it will give you undefined
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:44
oh supposed to be () not []
Darth Skywalker
@adityaparab
Apr 16 2017 06:44
yes.. you need to use .indexOf(0)
which will give you -1
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:45
how..
Darth Skywalker
@adityaparab
Apr 16 2017 06:45
becuase arr doesn't have 0
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:45
Hm
so -1 means its not there?
not found*
If I do index(3) what would it return?
Darth Skywalker
@adityaparab
Apr 16 2017 06:46
indexOf[0] is valid if your arr is like
var arr = {
  1:1,
  2:2,
  3:3,
  indexOf:[1,2,3]
}

arr.indexOf[0] // 1
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:46
2?
Darth Skywalker
@adityaparab
Apr 16 2017 06:46
correct
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:46
index(3) = 2
I see
Thanks
What does 0 do?
Darth Skywalker
@adityaparab
Apr 16 2017 06:47
indexOf returns the index at which the given element is present
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:47
nvm
Darth Skywalker
@adityaparab
Apr 16 2017 06:47
if the element doesn't exist, it will return -1
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:47
Yeah I understand
I wonder why I didnt remember this filter method...
Like I have never seen it before..
Darth Skywalker
@adityaparab
Apr 16 2017 06:48
filter/find are awesome!
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:48
so filter means finding?
function isBigEnough(value) {
  return value >= 10;
}

var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);
// filtered is [12, 130, 44]
Darth Skywalker
@adityaparab
Apr 16 2017 06:49
filter returns a array of matched elements, find return first matched element
yeah, if you do find instead of filter in above code, it will give you 12
not [12, 130, 44]
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:49
so
var arr = [1,2,3]
return arr.filter;
What would happen?
undefined?
Darth Skywalker
@adityaparab
Apr 16 2017 06:50
@MathematicsCoding it will give you function.
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:50
So filter method require a function?
Darth Skywalker
@adityaparab
Apr 16 2017 06:50
filter method IS a function
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:51
var arr = [1,2,3]
return arr.filter(<2);
Darth Skywalker
@adityaparab
Apr 16 2017 06:51
if you call the filter likearr.filter()`, it will require you to pass a function as a parameter
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:51
So it return 2,3?
Darth Skywalker
@adityaparab
Apr 16 2017 06:51
No.. that's an error
syntax error
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:51
..
function isBigEnough(value) {
  return value >= 10;
}

var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);
// filtered is [12, 130, 44]
So that is only way?
filter method must have a function?
Darth Skywalker
@adityaparab
Apr 16 2017 06:52
yes... .filter expects a function
yes
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:52
I see
Darth Skywalker
@adityaparab
Apr 16 2017 06:53
what I was saying was, if you don't call the filter like return arr.filter then it will return the instance of filter method
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:53
hmm nothing seems to work for me on mobile, dont quite understand it, made plenty of stuff before with click events that worked fine
Muhammad Hasham
@MohammadHasham
Apr 16 2017 06:53
@sjames1958gm Thanks.
CamperBot
@camperbot
Apr 16 2017 06:53
mohammadhasham sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6727 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Darth Skywalker
@adityaparab
Apr 16 2017 06:53
@HeebieGeeBee you have codepen?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 06:54
nothing else will show until thats turned on
Saboor Malik
@MathematicsCoding
Apr 16 2017 06:55
function arr(value){
return value >= 10;
}
var filtered = [11,10,9,12].filter(arr);
// [11,12]?
OK thanks guys
Night
Darth Skywalker
@adityaparab
Apr 16 2017 07:01

@HeebieGeeBee

Can you try one thing please ?
In your css, add

.control{
  cursor: pointer;
}
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:01
sure
was just reading about something about that on stacked
Nahuel Ovejero
@NahuelOvejero
Apr 16 2017 07:01
@HeebieGeeBee my json worked when I change to another pc, on chrome
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:03
cool
@adityaparab that didnt seem to work and stopped me being able to click on my pc too
Darth Skywalker
@adityaparab
Apr 16 2017 07:04

@HeebieGeeBee If that doesn't work, instead of doing

onOff.on('click',function() {

do

onOff.on('click touchstart',function() {
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:04
@adityaparab now nothing works
even after deleting it
lol
Joe
@JoeVR
Apr 16 2017 07:05
hey guys, noob here. What learning flow I should learn in javascipt if I want to build website then move on to react app developement. is it Javascript>JQuery>JSON>NODE? anything else? :/
Darth Skywalker
@adityaparab
Apr 16 2017 07:05

Here is we how we used to do it in older days

var CLICK_EVENT = ("ontouchstart" in window ? "touchstart" : "click")

and then in code

onOff.on(CLICK_EVENT  ,function() {
@JoeVR get rid of JSON>NODE from your path
JS > jQ > React/angular/backbone etc
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:07
@adityaparab oops my mistake i messed up the js and didnt see the error
Joe
@JoeVR
Apr 16 2017 07:07
I see... thanks @adityaparab
CamperBot
@camperbot
Apr 16 2017 07:07
joevr sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:star2: 1005 | @adityaparab |http://www.freecodecamp.com/adityaparab
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:07
i'll try this cursor thing again
well the cursor thing still didnt work
Joe
@JoeVR
Apr 16 2017 07:07
@adityaparab but dont I need to learn node to do react?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:08
@adityaparab what the ontouchstart?
thats an event for mobile devices or summin?
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:16
@adityaparab urgh sorry i had to put it in a document ready function
Akshat Bahety
@akshatbahety
Apr 16 2017 07:17
hye
```

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

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

     product = product * arr[j];

    }

  }



  // Only change code above this line
  console.log(product);
  return product;

}
Nesting for loops i don't understand what's wrong?
Pieter Stokkink
@forkerino
Apr 16 2017 07:19
@akshatbahety you cannot multiply with a subarray, you need to access the element like so: arr[i][j]
Melissa Knapp
@MelEKn
Apr 16 2017 07:20
@MelEKn
Hi, I'm working on the Twitch.TV app. Does anyone know why an array I defined at the very beginning of my code, goes from having a value at i to being undefined at i once it's inside a $.getJSON function?
The $.getJSON function doesn't do anything with the array except try to print its value to console
Er... I don't know why that was directed at myself
Oops
Akshat Bahety
@akshatbahety
Apr 16 2017 07:20
@forkerino thanks I passed the challenge
CamperBot
@camperbot
Apr 16 2017 07:20
akshatbahety sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1772 | @forkerino |http://www.freecodecamp.com/forkerino
Akshat Bahety
@akshatbahety
Apr 16 2017 07:20
but i still don't get why wasn't arr[j] not workinh
working*
Melissa Knapp
@MelEKn
Apr 16 2017 07:21
Partial script:
for(var i = 0; i < users.length; i++){
url[i] = api + users[i] + callback;
console.log("url[i] is " + url[i]);
console.log("before getJSON, users[i] is " + users[i]);
$.getJSON(url[i], function(datax) {
  console.log("inside getJSON, users[i] is " + users[i]); 
Akshat Bahety
@akshatbahety
Apr 16 2017 07:21
@forkerino got it :)
Pieter Stokkink
@forkerino
Apr 16 2017 07:21
@akshatbahety :+1:
Melissa Knapp
@MelEKn
Apr 16 2017 07:21

and the output is:

wait, sorry, one moment

Hmm, what I changed to make it work better has it working worse :-/
Pieter Stokkink
@forkerino
Apr 16 2017 07:22
@MelEKn it is because .getJSON takes time to comes back, and by that time i will be equal to users.length
@MelEKn you can use the new let syntax in your for loop to declare the variable i, or use users.forEach
Melissa Knapp
@MelEKn
Apr 16 2017 07:25
@forkerino OK... I was going to use .forEach but when I googled it there were mostly just reasons to use a regular for loop instead of it :P
@forkerino what is the let syntax?
Pieter Stokkink
@forkerino
Apr 16 2017 07:26
@MelEKn let i = 0 is similar to var i = 0, but it preserves the value of i inside the getJSON callback.
Melissa Knapp
@MelEKn
Apr 16 2017 07:28
@forkerino Would you mind showing how it would actually be used? I mean, would I write it let (i=0, i<users.length, i++), or some other way?
or for (let i=0, i<users.length,i++)?
micojay020
@micojay020
Apr 16 2017 07:28
can someone help me
?
Melissa Knapp
@MelEKn
Apr 16 2017 07:29
@forkerino I'm googling it but the things coming up are kind of unclear
micojay020
@micojay020
Apr 16 2017 07:29
i need help on Selecting from many options switch statemens
kickkick479
@kickkick479
Apr 16 2017 07:29
@micojay020 how is your code now ?
Pieter Stokkink
@forkerino
Apr 16 2017 07:29
@MelEKn for (let i=0; i<users.length;i++) is right
Melissa Knapp
@MelEKn
Apr 16 2017 07:29
@forkerino ok thanks
CamperBot
@camperbot
Apr 16 2017 07:29
melekn sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1773 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Apr 16 2017 07:29
@MelEKn wait, you need ; instead of ,
I edited it above
Melissa Knapp
@MelEKn
Apr 16 2017 07:30
@forkerino Ok, I am heartily confused by the order in which the console has spit things back at me, but it seems to be working
Pieter Stokkink
@forkerino
Apr 16 2017 07:33
@MelEKn sometimes things come back in a different order, because the way the server handles your requests. You cannot rely on the order to be the same as the one in your array.
There are ways to handle this, but it is beyond the scope of this project, I think
Melissa Knapp
@MelEKn
Apr 16 2017 07:33
@forkerino Ok, thank you
CamperBot
@camperbot
Apr 16 2017 07:33
melekn sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: melekn already gave forkerino points
Akshat Bahety
@akshatbahety
Apr 16 2017 07:36
need help again
function lookUpProfile(firstName, prop){
// Only change code below this line
if(contacts.hasOwnProperty(firstName)  && contacts.hasOwnProperty(firstName[prop]))
{
  return contacts.firstName[prop] ;
}

  else if(contacts.hasOwnProperty(firstName) === false){

    return "No such contact";
  }

  else if (contacts.hasOwnProperty(prop) === false){
    return "No such property" ;
  }


// Only change code above this line
}
profile lookup
I think I have to practice a lot more
kickkick479
@kickkick479
Apr 16 2017 07:39
@akshatbahety hi, how do u think solve this challenge? Can you explain it in text ? It is difficult to diving into code.
Akshat Bahety
@akshatbahety
Apr 16 2017 07:40
@kickkick479 Well to solve it I have been given a list of contact with different property like address and all
Pieter Stokkink
@forkerino
Apr 16 2017 07:40
@akshatbahety be aware that contacts is an array of object. You treat it like it is an object.
you probably need a loop
micojay020
@micojay020
Apr 16 2017 07:40
can someone help?
Akshat Bahety
@akshatbahety
Apr 16 2017 07:40
@forkerino let me give it a try
Melissa Knapp
@MelEKn
Apr 16 2017 07:40

OK, so now does anyone know why I'm getting

Uncaught ReferenceError: httpswindbow is not defined
at ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=jQuery311024811…:1
(anonymous) @ ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=jQuery311024811…:1
ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1 Uncaught ReferenceError: httpswindbow is not defined
at ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1
(anonymous) @ ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1
ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1 Uncaught ReferenceError: httpswindbow is not defined
at ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1
(anonymous) @ ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1
ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1 Uncaught ReferenceError: httpswindbow is not defined
at ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1
(anonymous) @ ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1
ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1 Uncaught ReferenceError: httpswindbow is not defined
at ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1
(anonymous) @ ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1
ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1 Uncaught ReferenceError: httpswindbow is not defined
at ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1
(anonymous) @ ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1
ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1 Uncaught ReferenceError: httpswindbow is not defined
at ESL_SC2?callback=?,https://wind-bow.gomix.me/twitch-api/streams/OgamingSC2?callback=?,https://wind-…:1

Er, nevermind, dumb error
kickkick479
@kickkick479
Apr 16 2017 07:42
@akshatbahety Yes, i recommend you to check if all contact have the given firstname as first task. Iterate all contact and check if the conatact's first name matches the given parameter's first name.
Pieter Stokkink
@forkerino
Apr 16 2017 07:42
@micojay020 ask your question
and show your code if you have any
Akshat Bahety
@akshatbahety
Apr 16 2017 07:43
@kickkick479 Yes they do all have a first name let me do that
micojay020
@micojay020
Apr 16 2017 07:44
so how do i properly write a switch
mine looks like this rn
switch (num){
case value1:
"alpha";
break;
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:45
@forkerino mornin
Pieter Stokkink
@forkerino
Apr 16 2017 07:45
@HeebieGeeBee hey!
Peter Nguyen
@iampeternguyen
Apr 16 2017 07:46
hey all, i just finished caesars cipher and I was just wondering if it's really necessary to go from string to array and then back to string like i did or is there a cleaner way to get it to work?

function rot13(str) { // LBH QVQ VG!
  var array = [];
  for (i=0;i<str.length;i++){
    array.push(str.charCodeAt(i));
  }
  //65-90
  function changeVal (val){

    if (val >= 65 && val <=77){

      return val + 13;
    }
    else if (val > 77 && val <= 90){
      return val - 13;
    }
    else if (val < 65 || val > 90){
      return val;
    }
  }

  var newArray = array.map(changeVal);


 var almostDone = newArray.map(function(val){
    return String.fromCharCode(val);
  });
  return almostDone.join('');

}

// Change the inputs below to test
rot13("SERR CVMMN!");
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:46
no easter festivities in the camper ? @forkerino
micojay020
@micojay020
Apr 16 2017 07:46
houw should i do it
kickkick479
@kickkick479
Apr 16 2017 07:47
@micojay020 paste your whole code, please. It's hard to guess where you are really stacked without whole codes.
Pieter Stokkink
@forkerino
Apr 16 2017 07:47
@micojay020 value1 should be defined, I guess in this exercise it should just be case 1:. After it, you need to assign "alpha" to something. On its own line it doesn't do anything.
@HeebieGeeBee we're driving soon, empty roads ftw
kickkick479
@kickkick479
Apr 16 2017 07:48
Regarding to above code, you are missing closing curly bracket.
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:48
@iampeternguyen combine it in one expression
@forkerino nice
micojay020
@micojay020
Apr 16 2017 07:48

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

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

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

Pieter Stokkink
@forkerino
Apr 16 2017 07:49
@micojay020 your cases should look like:
case 1:
  answer = "alpha";
  break;
Martialis39
@Martialis39
Apr 16 2017 07:49
input.addEventListener('change', checkSecretWordForGuess(event));

function checkSecretWordForGuess(){


  guess = input.value;
  input.value = '';

  blanks.split('');
  for (var j = 0; j < secretWord.length; j++) {
    console.log(j);
    if (secretWord[j] == guess) {
        blanks[j] = guess;
        console.log(j);
        console.log(blanks)
    }
  }
  console.log(blanks);
  return;
}
can anyone help me with this?
it is just not executing the blanks[j] = guess; line
Pieter Stokkink
@forkerino
Apr 16 2017 07:49
@HeebieGeeBee I actually need to start packing now, so guess I'll catch you later!
Martialis39
@Martialis39
Apr 16 2017 07:50
I hope everything is self explanatory : )
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:50
@forkerino laters
have a good day
micojay020
@micojay020
Apr 16 2017 07:50
@forkerino what should i put inside the parentheses right next to swithc?
Jor
@joreyesl
Apr 16 2017 07:50
@iampeternguyen instead doing it in steps, you can run the entire process for each character.
@micojay020 it should be val the parameter for the function
Linus
@nusli
Apr 16 2017 07:51
Hey i'm trying to build the weather app. does any1 know how i can access the API data outside of the function in which i request it?
micojay020
@micojay020
Apr 16 2017 07:52
@joreyesl @forkerino Thanks :D
CamperBot
@camperbot
Apr 16 2017 07:52
micojay020 sends brownie points to @joreyesl and @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1774 | @forkerino |http://www.freecodecamp.com/forkerino
:cookie: 784 | @joreyesl |http://www.freecodecamp.com/joreyesl
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:52
@Martialis39 everything is not self explanitory
Jor
@joreyesl
Apr 16 2017 07:53
@nusli the data will be passed to the callback function, you will have to manipulate it inside that function
Linus
@nusli
Apr 16 2017 07:53
@joreyesl so there is really no other way?
Martialis39
@Martialis39
Apr 16 2017 07:54
@HeebieGeeBee right sorry, ok. addEventListener is on a form. Im trying to get the value and then loop through my secretword (in a hangman game) and see if it lines up or not. Then I try to set my variable blanks to display that letter
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:54
@Martialis39 if input is some type of form you probably want to use .value()
@Martialis39 lol ive made a hangman game
Jor
@joreyesl
Apr 16 2017 07:55
@nusli what are you trying to do? I mean you can store in a global variable, but the problem is that the ajax call is asynchronous so you won't know when the data will be returned
Peter Nguyen
@iampeternguyen
Apr 16 2017 07:55
@HeebieGeeBee and @joreyesl did you mean like this? or is there another part?
  return array.map(changeVal).map(function(val){return String.fromCharCode(val);}).join('');
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 07:56
@iampeternguyen not quite
Linus
@nusli
Apr 16 2017 07:56
@joreyesl i want to build the button which changes from fahrenheidt to celsius
Jor
@joreyesl
Apr 16 2017 07:56
@iampeternguyen what i meant is instead of calling .map() twice, why not also map the character in the first map?
Martialis39
@Martialis39
Apr 16 2017 07:57
@HeebieGeeBee Right! thanks!
CamperBot
@camperbot
Apr 16 2017 07:57
martialis39 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1335 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Peter Nguyen
@iampeternguyen
Apr 16 2017 07:59
ohhh something like this? @joreyesl

function rot13(str) { // LBH QVQ VG!
  var array = [];
  for (i=0;i<str.length;i++){
    array.push(str.charCodeAt(i));
  }

  function changeVal (val){

    if (val >= 65 && val <=77){

      return String.fromCharCode(val + 13);
    }
    else if (val > 77 && val <= 90){
      return String.fromCharCode(val - 13);
    }
    else if (val < 65 || val > 90){
      return String.fromCharCode(val);
    }
  }

  return array.map(changeVal).join('');
Jor
@joreyesl
Apr 16 2017 08:00
@nusli what problem are you running into right now?
@iampeternguyen yea, and you can even go 1 step further move that logic into the loop
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 08:01
  function changeVal (val){

    if (val.charCodeAt(0)  >= 65 && val.charCodeAt(0) <=77){

      return String.fromCharCode(val.charCodeAt(0) + 13);
    }
    else if val.charCodeAt(0)> 77 && val.charCodeAt(0) <= 90){
      return String.fromCharCode(val.charCodeAt(0)- 13);
    }
    else if (val.charCodeAt(0) < 65 || val.charCodeAt(0)> 90){
      return val;
    }
  }
@iampeternguyen
SaiChand Duppala
@saichandd
Apr 16 2017 08:02
Hey people, is there a way to reduce the image quality (to reduce the image size in bytes, for a faster load) in CSS or JS
HeebieGeeBee
@HeebieGeeBee
Apr 16 2017 08:02
well guess the last else if is not needed just return val
@iampeternguyen

 return str.split('').map(changeVal).join('');
then that
oops
Peter Nguyen
@iampeternguyen
Apr 16 2017 08:06
whoa. that's cool. thanks @HeebieGeeBee and @joreyesl for the help!
CamperBot
@camperbot