These are chat archives for FreeCodeCamp/HelpJavaScript

19th
Apr 2017
Jason Luboff
@JLuboff
Apr 19 2017 00:00
Haha yup and better than the other course i did
Alright, see you guys later :wave:
Manish Giri
@Manish-Giri
Apr 19 2017 00:00
:wave:
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:00
@JLuboff laters
Kuriakin Zeng
@kuriakinzeng
Apr 19 2017 00:01
@JLuboff which udemy course?
Joseph
@martip07
Apr 19 2017 00:02
Hi guys
Joseph
@martip07
Apr 19 2017 00:02
Can you explain me this:
for (var i = 0; i < arr1.length; i++) {
if (arr2.indexOf(arr1[i]) === -1){
// Pushing the unique to arr1 elements to the newArr
newArr.push(arr1[i]);
}
}
/
what is it doing ?
exactly this part if (arr2.indexOf(arr1[i]) === -1)
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:04
its a conditional using the indexOf all the elements in the arr1 on the arr2
and if the indexOf finds no match it returns -1
so if an element of arr1 isnt found in arr2 that element's value is being pushed into the newArr array
Joseph
@martip07
Apr 19 2017 00:06
got it
thank you @HeebieGeeBee
CamperBot
@camperbot
Apr 19 2017 00:06
martip07 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1382 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Joseph
@martip07
Apr 19 2017 00:06
:)
Connor Yanz
@cmy235
Apr 19 2017 00:06
anybody have thoughts on why I'd get "TypeError: arrTotal.push is not a function" returned for this code? I'm a little confused
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:07
@cmy235 show all the code
Connor Yanz
@cmy235
Apr 19 2017 00:07

this is everything I had:

function chunkArrayInGroups(arr, size) {
var arrTotal = [];

i = 0;
j = 1;

while (i<arr.length) {
var arrSliced = arr.slice(i, size*j);
arrTotal = arrTotal.push(arrSliced);

i=i+size;
j=j*2;
}
return arrTotal;
}

HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:08
well for starters i dont think you want to assign that to arrTotal
im guessing thats why its messing up
Manish Giri
@Manish-Giri
Apr 19 2017 00:08
aren't you getting an error?
Connor Yanz
@cmy235
Apr 19 2017 00:09
why's that? I was trying to fill an empty array with the sliced arrays, pushed on one by one... think that's not the right way to go about it?
Manish Giri
@Manish-Giri
Apr 19 2017 00:09
something like arrTotal.push is not a function?
@cmy235
Connor Yanz
@cmy235
Apr 19 2017 00:09
yes @Manish-Giri exactly
Manish Giri
@Manish-Giri
Apr 19 2017 00:09
@cmy235 do you get why?
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:09
@cmy235 arrTotal.push(arrSliced) returns the length of the array
Connor Yanz
@cmy235
Apr 19 2017 00:09
no I don't
Jean-Paul Sauve
@jp-sauve
Apr 19 2017 00:10
you don't need to assign to a variable when pushing
herunan
@herunan
Apr 19 2017 00:10
@HeebieGeeBee So just to give you some context. I need to create an array of tweets, from which then I have to randomly extract one when I click a ‘generate’ button. The tweet acts as a quote for a random quote generator. I can do everything except create an array from this fetcher. I know how to attach it to the DOM and all.
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:10
so thats what youre assigning
Connor Yanz
@cmy235
Apr 19 2017 00:11
thank you @sevensixtwo762 haha just deleted out the arrTotal = part and that worked!
CamperBot
@camperbot
Apr 19 2017 00:11
cmy235 sends brownie points to @sevensixtwo762 :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @sevensixtwo762 |http://www.freecodecamp.com/sevensixtwo762
Manish Giri
@Manish-Giri
Apr 19 2017 00:11
@cmy235
var arrTotal = []; <- here you declare it as an array
arrTotal.push(arrSliced); <- this pushes something onto the array
arrTotal = arrTotal.push(arrSliced); <- but .push() returns the length of the new array, so now arrTotal is no longer an array, but a number instead
Kuriakin Zeng
@kuriakinzeng
Apr 19 2017 00:11
@cmy235 I think @HeebieGeeBee deserves a thanks too
CamperBot
@camperbot
Apr 19 2017 00:11
kuriakinzeng sends brownie points to @cmy235 and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1383 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:cookie: 266 | @cmy235 |http://www.freecodecamp.com/cmy235
Kuriakin Zeng
@kuriakinzeng
Apr 19 2017 00:11
He told you right in the beginning
Connor Yanz
@cmy235
Apr 19 2017 00:11
thank you @HeebieGeeBee !!
CamperBot
@camperbot
Apr 19 2017 00:11
cmy235 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1384 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Connor Yanz
@cmy235
Apr 19 2017 00:12
I was in the process of that... wanted to ask @HeebieGeeBee one more question though:
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:12
@herunan well you could try pushing the array into a global variable inside the call back, or you could have the click button operate the fetcher function in which you have a callback that updates the dom element with a random quote from the tweets
Connor Yanz
@cmy235
Apr 19 2017 00:12
why do you say slice returns the length? for example, if I live an array and then return that array, the output will give me an array and not a number
if i Slice an array** and then return it
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:13
@cmy235 i said push returns the length of the array after the push
slice returns an slice of an array in an array
aRtoo
@artoodeeto
Apr 19 2017 00:14
hello everyone. im on 215 of the tutorial entitled "Using Objects for Lookups"
and it seems i cant figure out whats wrong with my code. can someone help?? heres my code

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

  // Only change code below this line

 var  lookup ={

     1:"Adams",
     2:"Boston",
     3:"Chicago",
     4:"Denver",
     5:"Easy",
     6:"Frank"

   };

   var alpha = 1;
   result = lookup[alpha];
   var bravo = 2;
   result = lookup[bravo];
   var charlie = 3;
   result = lookup[charlie];
   var delta = 4;
   result = lookup[delta];
   var echo = 5;
   result = lookup[echo];
   var foxtrot = 6;
   result = lookup[foxtrot]; 



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

// Change this value to test
phoneticLookup("foxtrot");
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:14
@cmy235 mdn explains what all the methods do
Connor Yanz
@cmy235
Apr 19 2017 00:14
right sorry meant to say push. But if I pushed arrSliced onto arrTotal, and returned arrTotal it gave me an array, correct?
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:15
yes
Manish Giri
@Manish-Giri
Apr 19 2017 00:15
all this is wrong
   var alpha = 1;
   result = lookup[alpha];
   var bravo = 2;
   result = lookup[bravo];
   var charlie = 3;
   result = lookup[charlie];
   var delta = 4;
   result = lookup[delta];
   var echo = 5;
   result = lookup[echo];
   var foxtrot = 6;
   result = lookup[foxtrot];
@artoodeeto
this is also wrong
var  lookup ={

     1:"Adams",
     2:"Boston",
     3:"Chicago",
     4:"Denver",
     5:"Easy",
     6:"Frank"

   };
Connor Yanz
@cmy235
Apr 19 2017 00:15
ok I'll keep reading, thanks again @HeebieGeeBee
CamperBot
@camperbot
Apr 19 2017 00:15
cmy235 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: cmy235 already gave heebiegeebee points
Andrei Dushkou
@burn1ng
Apr 19 2017 00:15
Hello guys! I've just finished Seek and Destroy task: https://www.freecodecamp.com/challenges/seek-and-destroy
but unfortunately, i think that my code isn't perfect. Maybe you can give suggestions how to improve it?
function destroyer(arr) {

  var myArr = arguments[0];
  var args = [];

  //make array of arguments
  for (var i = 1; i < arguments.length; i++) {
    args[i-1] = arguments[i];
  }

  var res = myArr.filter(function(item){
    return args.indexOf(item) < 0;
  });
  return res;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Manish Giri
@Manish-Giri
Apr 19 2017 00:15
they keys of your object should be alpha, bravo etc
aRtoo
@artoodeeto
Apr 19 2017 00:15
@Manish-Giri ha?
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:15
@cmy235 theres a difference between a methods return and its effects
Manish Giri
@Manish-Giri
Apr 19 2017 00:16
not 1, 2, 3
@artoodeeto
@artoodeeto then when your object is setup right, just use the property in val and look it up from lookup
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:16
the push method for example pushes elements into the back of an array but it returns the length of the array after the push
aRtoo
@artoodeeto
Apr 19 2017 00:16
@Manish-Giri but ihave variables below them that call out the number of the phonetic
Manish Giri
@Manish-Giri
Apr 19 2017 00:17
@artoodeeto so if the tests had like a 100 variables you'd write out them a 100 times?
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:17
@herunan thats cus of a sync issues
the console log will run before the callback
Connor Yanz
@cmy235
Apr 19 2017 00:17
ah yes, now I see. I returned arrTotal.push() and got the length ... but when I return arrTotal I get the new array.... this is what threw me off.
aRtoo
@artoodeeto
Apr 19 2017 00:17
@Manish-Giri ha?? what do you mean.
Manish Giri
@Manish-Giri
Apr 19 2017 00:18
@artoodeeto create your object correctly first
aRtoo
@artoodeeto
Apr 19 2017 00:18
@Manish-Giri i should because ill be writing the phonectics still right??
@Manish-Giri okok.
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:18
@herunan look what happens if oyu do this
function kpCallback(tweets) {
for (var i = 0; i < tweets.length; i++) {
tweetArr.push(tweets[i]);
console.log(tweetArr)
};
}
Andrei Dushkou
@burn1ng
Apr 19 2017 00:20
guys, anyone can give good advice how to make my code more simple and perfect? i think it must be more beautiful solution...
function destroyer(arr) {

  var myArr = arguments[0];
  var args = [];

  //make array of arguments
  for (var i = 1; i < arguments.length; i++) {
    args[i-1] = arguments[i];
  }

  var res = myArr.filter(function(item){
    return args.indexOf(item) < 0;
  });
  return res;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:21
@burn1ng you could use the spread operator to get the arguments
or the Array.from method
Manish Giri
@Manish-Giri
Apr 19 2017 00:21

@burn1ng instead of

var res = myArr.filter(function(item){
    return args.indexOf(item) < 0;
  });
  return res

just

return myArr.filter(function(item){
    return args.indexOf(item) < 0;
  });

is one way

Andrei Dushkou
@burn1ng
Apr 19 2017 00:23
@Manish-Giri thanks for reply, i did that for convinient reading of code only
CamperBot
@camperbot
Apr 19 2017 00:23
burn1ng sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5194 | @manish-giri |http://www.freecodecamp.com/manish-giri
Andrei Dushkou
@burn1ng
Apr 19 2017 00:23
@HeebieGeeBee can you give little more details? =)
MiguelM47
@MiguelM47
Apr 19 2017 00:23
I am not supposed to use if/else statements. Am i doing this correctly? isLess(10,15) should return true and isLess(15,10) should return false.
function isLess(a, b) {
  // Fix this code
    return true === false;
  }
// Change these values to test
isLess(10, 15);
isLess(15, 10);
Andrei Dushkou
@burn1ng
Apr 19 2017 00:24
@MiguelM47 try to return a < b;
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:25
@burn1ng var args = Array.from(arguments)
aRtoo
@artoodeeto
Apr 19 2017 00:25

like this?? thank you sir!!
// Only change code below this line

var lookup ={

 "alpha":"Adams",
 "bravo":"Boston",
 "charlie":"Chicago",
 "delta":"Denver",
 "echo":"Easy",
 "foxtrot":"Frank"

};

result = lookup[val];

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

// Change this value to test
phoneticLookup("foxtrot");

HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:26
or i think its var args = [...arguments] ask @Manish-Giri to verify that though
Manish Giri
@Manish-Giri
Apr 19 2017 00:27
@HeebieGeeBee yup that's correct
Kuriakin Zeng
@kuriakinzeng
Apr 19 2017 00:27
@artoodeeto that looks ok
Manish Giri
@Manish-Giri
Apr 19 2017 00:27
@artoodeeto good job :+1:
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:27
then you can just shift the first element from it
Dan Couper
@DanCouper
Apr 19 2017 00:29
@burn1ng function destroyer(arr, ...targets) { gets rid of the arguments bit [but might be considered cheating maybe]
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:29
@herunan cool but i still never get this thing to run correctly
Saboor Malik
@MathematicsCoding
Apr 19 2017 00:30
Heys
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:30
@MathematicsCoding hi
Saboor Malik
@MathematicsCoding
Apr 19 2017 00:30
I have not figure out how to remove the same number in an array
@HeebieGeeBee hey
This is what I have right now

function diffArray(arr1, arr2) {
  arr1 = arr1.concat(arr2);
  arr1.sort();
  return arr1;
}
diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Phuong Nguyen
@neunygph
Apr 19 2017 00:32
Hi guys , when people "cache response" . Do they mean save the response to some sort of data storage , database..etc ?
aRtoo
@artoodeeto
Apr 19 2017 00:32
@Manish-Giri thank you sir. <3
CamperBot
@camperbot
Apr 19 2017 00:32
artoodeeto sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5196 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Apr 19 2017 00:32
@artoodeeto pls, no sir :smile:
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:33
@herunan yeah
Manish Giri
@Manish-Giri
Apr 19 2017 00:33
@MathematicsCoding .sort() doesn't sort numbers by default
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:33
well you can set up a click function
Dan Couper
@DanCouper
Apr 19 2017 00:33
@neunygph sorta ish, depends what your caching, yes for some things no for others (+ if you stretch the definition of data storage to just include memory in general, then yes).
caching is not just saving the response
it means keeping something in memory so it an be accesed more quickly next time
basically
aRtoo
@artoodeeto
Apr 19 2017 00:35
@Manish-Giri thank you again. :)
CamperBot
@camperbot
Apr 19 2017 00:35
artoodeeto sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: artoodeeto already gave manish-giri points
Manish Giri
@Manish-Giri
Apr 19 2017 00:35
@artoodeeto :+1:
Saboor Malik
@MathematicsCoding
Apr 19 2017 00:35
@Manish-Giri What do you mean? I used .sort just to order the number
Phuong Nguyen
@neunygph
Apr 19 2017 00:36
@DanCouper in my case, I'm referring to JSON response
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:37
@herunan you dont want to do a make a return inside a loop anyways
Manish Giri
@Manish-Giri
Apr 19 2017 00:37
@MathematicsCoding did you try it out? can you try it in jsbin and show me the output?
Saboor Malik
@MathematicsCoding
Apr 19 2017 00:38
Console says [1,1,2,2,3,3,4,5,5]
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:38
@herunan create a button in your html and give it the id of quotebutton
Saboor Malik
@MathematicsCoding
Apr 19 2017 00:39
@Manish-Giri jsbin says 321px
The output
Andrei Dushkou
@burn1ng
Apr 19 2017 00:41
@HeebieGeeBee check =) Array.from + shift method - not a good solution. loops forever ! = ) https://jsperf.com/testsecond1208
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:41
var quote = document.getElementById('quotebutton');
quotebutton.addEventListener('click', function() {
      console.log(tweetArr);
}
then add this to your javascript and see what logs when you click the button @herunan
Manish Giri
@Manish-Giri
Apr 19 2017 00:42
@MathematicsCoding you got lucky because those numbers are in ascending order by unicode values
Dan Couper
@DanCouper
Apr 19 2017 00:42

@neunygph the response may (should) have an HTTP cache-control header.

You can look in the network tab of the browser and inspect the response, there may well be a header with the key Cache-Control, with a value of something like "max-age=3600".

It tells the broser how long to hold that in cache. So like images, css, js etc generally have long cache control values - the browser should just download them and hold onto them indefinitely because they're never likely to change, so next time you hit the page it'll load quickly.

JSON can be cached as well - if the API is such that the response is always going to be the same, can cache the JSON. It's a bit more difficult though cos API requests can be subtly different, especially if you can pass parameters to the API, so all of the requests could be slightly different which often makes caching pointless.

Manish Giri
@Manish-Giri
Apr 19 2017 00:42
try putting 19 or 20 in the array and see what you get
@MathematicsCoding
Saboor Malik
@MathematicsCoding
Apr 19 2017 00:43
@Manish-Giri I know first number only like 19
Anthony Pierson
@Donald-Tho
Apr 19 2017 00:43
function lookUpProfile(firstName, prop){
// Only change code below this line
  if(contacts.hasOwnProperty(firstName)){
    if(contacts[firstName].hasOwnProperty(prop)){
      console.log(contacts[firstName][prop]);
      return(contacts[firstName][prop]);
    } else return("No such property");
  } else return("No such contact");
// Only change code above this line
}
Manish Giri
@Manish-Giri
Apr 19 2017 00:43
@MathematicsCoding does this array look sorted?
[1, 1, 19, 2, 2, 20, 3, 3, 4, 5, 5]
Saboor Malik
@MathematicsCoding
Apr 19 2017 00:43
I see you are right...
No
Anthony Pierson
@Donald-Tho
Apr 19 2017 00:43
it always returns "No such contact for some reason
Manish Giri
@Manish-Giri
Apr 19 2017 00:43
right
that's why
Saboor Malik
@MathematicsCoding
Apr 19 2017 00:43
:p
Conor Murphy
@cmurphy580
Apr 19 2017 00:43
@Manish-Giri thanks
CamperBot
@camperbot
Apr 19 2017 00:43
cmurphy580 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5198 | @manish-giri |http://www.freecodecamp.com/manish-giri
Conor Murphy
@cmurphy580
Apr 19 2017 00:44
@Manish-Giri thank you
CamperBot
@camperbot
Apr 19 2017 00:44
cmurphy580 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: cmurphy580 already gave manish-giri points
Saboor Malik
@MathematicsCoding
Apr 19 2017 00:44
Well i think its fine because of this challenge..
Manish Giri
@Manish-Giri
Apr 19 2017 00:44
lol
what for
Saboor Malik
@MathematicsCoding
Apr 19 2017 00:44
Doesnt have two digits as number
Manish Giri
@Manish-Giri
Apr 19 2017 00:44
@cmurphy580
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:44
@burn1ng thought you said made infinite loop then
Manish Giri
@Manish-Giri
Apr 19 2017 00:44
but ty @cmurphy580
CamperBot
@camperbot
Apr 19 2017 00:44
manish-giri sends brownie points to @cmurphy580 :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @cmurphy580 |http://www.freecodecamp.com/cmurphy580
Conor Murphy
@cmurphy580
Apr 19 2017 00:44
@Manish-Giri just a fan of brownie pts
Manish Giri
@Manish-Giri
Apr 19 2017 00:45
haha
Vera S.
@verascity
Apr 19 2017 00:49

okay, new question, now I have the click listener working as it should within the dom ready handler... now I'm trying to get it so that if I click link A, Div A loses its 'hidden' attribute, and I thought I'd write it as a loop rather than have to pair every DIV to every A with IDs, and it's almost working but I'm running into this one issue:

document.addEventListener("DOMContentLoaded", function(event) {
var links = document.getElementById("project-list").getElementsByTagName("a");
var project = document.getElementById("project_show").getElementsByTagName("div");

for (var i = 0; i < links.length; i++) {
    links[i].addEventListener('click', function (event) {

        project[i].classList.toggle("hidden");

    });

}

});

if I put, for example, project[0], it shows project[0] when whichever links[i] is clicked, but project[i] comes up as undefined, I guess because it's in the function? but if I try to write another loop to match it within the function (e.g. for (var j = 0, etc.), it just loads all the DIVs for each link[i] click. Is there a way to get only project[i] to toggle when link[i] is clicked?

Keira
@chickachickaaa
Apr 19 2017 00:50
Hey guys!
I'm having some serious trouble with "Profile Lookup"
I wanted to link a few else if's but it doesn't seem to be the right track
any hints?
Larry
@Lanroma
Apr 19 2017 00:52
Helo famz have issue with the fahrenheit to temperature conversation
Manish Giri
@Manish-Giri
Apr 19 2017 00:53
@chickachickaaa @Lanroma post your code
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:53
@herunan well i dont see where you added the event listener to your javascript
@herunan and what are you using to publish this?
Alan Saber
@Alan95
Apr 19 2017 00:55
hey guys, i have a problem with my code. why is this not working? "Wherefore art thou"
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:55
@herunan sorry might have missed the closing bracket
Alan Saber
@Alan95
Apr 19 2017 00:55
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line

  var prop = Object.getOwnPropertyNames(source);
  var sourceKey = Object.keys(source);



for(var e = 0; e <= collection.length; collection++) {

  if(collection[e].hasOwnProperty(sourceKey)){
    if(collection[e][prop] == source[prop]) {

     arr.push(collection[e]);
    }

  }

 }


  // Only change code above this line
  return arr;
}
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 00:55
in the click listener
@herunan look at the error message in console
@herunan its a lot easier if you use codepen for ppl trying to help
herunan
@herunan
Apr 19 2017 01:00
@HeebieGeeBee No biggie. Here: https://codepen.io/herunan/pen/bWVXwR
Saboor Malik
@MathematicsCoding
Apr 19 2017 01:01
jeez alot of JS code
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 01:02
var quote = document.getElementById('quotebutton');
quotebutton.addEventListener('click', function() {
      console.log(tweetArr);
})
this @herunan
Keira
@chickachickaaa
Apr 19 2017 01:03
function lookUpProfile(firstName, prop){
// Only change code below this line
if (firstName && prop === true) {
console.log(prop);
else if (firstName && prop === false) {
console.log("No such contact and no such property");
}
else if (firstName === false) {
console.log("No such contact");
else {
return ("No such property");
}
@Manish-Giri
Moisés Man
@moigithub
Apr 19 2017 01:03
quotebutton shoudl be quote (variable) @herunan
Keira
@chickachickaaa
Apr 19 2017 01:03
Trying to find out how to paste it better
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 01:04
but i cant really check cus my computer is blocking this stuff from twitter for some reason
herunan
@herunan
Apr 19 2017 01:04
@HeebieGeeBee Of course! I’m tired… This worked. Thanks a lot! I guess this is the ultimate confirmation. Now I can do my entire thing, I suppose?
CamperBot
@camperbot
Apr 19 2017 01:04
herunan sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1385 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 01:05
sorry what @moigithub said too
@herunan so yeah you can see the array has actually been populated
Manish Giri
@Manish-Giri
Apr 19 2017 01:05
@chickachickaaa there are lots of problems with your code
  1. if (firstName && prop === true) { -
    a. where's the closing } for this?
    b. why are you checking if prop is true?
  2. else if (firstName === false) {
    a. again, why would firstName be false?
herunan
@herunan
Apr 19 2017 01:06
@HeebieGeeBee Great! I’ll come to you if I run into any other issues. Thanks again
CamperBot
@camperbot
Apr 19 2017 01:06
herunan sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: herunan already gave heebiegeebee points
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 01:06
@herunan and yeah its 3 am here too
Jean-Paul Sauve
@jp-sauve
Apr 19 2017 01:07
I put my arms up every time I complete a challenge.
Saboor Malik
@MathematicsCoding
Apr 19 2017 01:07
lol
Moisés Man
@moigithub
Apr 19 2017 01:08
@sevensixtwo762 did that few times :)
aRtoo
@artoodeeto
Apr 19 2017 01:08
here i am again. lol. guys. I didnt know why am i correct but. heres my code. can someone explain it to me or post other solutions. thank you!



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

function checkObj(checkProp) {
  // Your Code Here

     if ( myObj.hasOwnProperty(checkProp) ){

            yes = myObj[checkProp];
      } 


      else{

        return "Not Found";
      }



  return yes;
}

// Test your code by modifying these values
checkObj("gift");
FlashHero
@FlashHero
Apr 19 2017 01:09
@moigithub can you help me
Ken Haduch
@khaduch
Apr 19 2017 01:09
@artoodeeto - you can directly return the property instead of using the yes variable.
Jean-Paul Sauve
@jp-sauve
Apr 19 2017 01:09
keys are strings, and so you need quotes
Moisés Man
@moigithub
Apr 19 2017 01:09
@FlashHero maybe
aRtoo
@artoodeeto
Apr 19 2017 01:10
@khaduch yea. i was wondering how. becasue theres a return "Change me " at the bottom. i might get an error if i wont use it
FlashHero
@FlashHero
Apr 19 2017 01:10
button.addEventListener("click", function () {
    var request = new XMLHttpRequest();
    var totalString = theurl + city.value + id + units;
    var combine = totalString;
    request.onreadystatechange = function () {
        if (request.readyState == 4 || request.status == 200) {
            console.log(JSON.stringify(request.responseText));
        }
    };
    request.open("GET", combine);
    request.send();
});
I don't know why it gives me error
zippy
@ShaimaTheBlueberry
Apr 19 2017 01:11
does anybody know how to pass Nesting For Loops and why that solution would work? because i am confused
Manish Giri
@Manish-Giri
Apr 19 2017 01:12
@ShaimaTheBlueberry what's the problem
Jean-Paul Sauve
@jp-sauve
Apr 19 2017 01:12
@FlashHero can you link to your pen?
zippy
@ShaimaTheBlueberry
Apr 19 2017 01:12
i dont understand what a sub array is
Jean-Paul Sauve
@jp-sauve
Apr 19 2017 01:13
@ShaimaTheBlueberry it's an array that is an element of another array
like a box within another box
FlashHero
@FlashHero
Apr 19 2017 01:13
@sevensixtwo762 sorry i don't have a codepen
Jean-Paul Sauve
@jp-sauve
Apr 19 2017 01:13
an array is a string of beads. and array with subarrays is like a bead curtain
zippy
@ShaimaTheBlueberry
Apr 19 2017 01:13
how do you make one that does this:Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr
Jean-Paul Sauve
@jp-sauve
Apr 19 2017 01:14
the main array is the curtain, with each element of the array being a string of beads (other arrays)
Moisés Man
@moigithub
Apr 19 2017 01:14
@FlashHero var totalString = theurl + city.value + id + units;
where those values coming from ?
if u console.log(totalString); it should show a url string
Jean-Paul Sauve
@jp-sauve
Apr 19 2017 01:14
@ShaimaTheBlueberry I would use nested for loops
aRtoo
@artoodeeto
Apr 19 2017 01:14
@khaduch hey sir! good day! im sorry to ask again. i can i return directly the condition with using another variable. heres my code



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

function checkObj(checkProp) {
  // Your Code Here

     if ( myObj.hasOwnProperty(checkProp) ){

            yes = myObj[checkProp];
      } 


      else{

        return "Not Found";
      }



  return yes;
}

// Test your code by modifying these values
checkObj("gift");
FlashHero
@FlashHero
Apr 19 2017 01:15
@moigithub they contain a part of the url the user input state or city and id is the weather api and units
Phuong Nguyen
@neunygph
Apr 19 2017 01:15
@DanCouper oh I see, is it possible to store/retrieve image cache or it can only be done automatically by browser?
zippy
@ShaimaTheBlueberry
Apr 19 2017 01:15
there is no such thing
also i am on nesting for loops
FlashHero
@FlashHero
Apr 19 2017 01:16
@moigithub I don't know why i'm not getting the data that i'm requesting
zippy
@ShaimaTheBlueberry
Apr 19 2017 01:17
@sevensixtwo762 there is no such thing. if you are talking about nesting for loops that is the one i am doing
Manish Giri
@Manish-Giri
Apr 19 2017 01:17
@ShaimaTheBlueberry
[[1,2,3], [4,5]]
can you understand this data?
Moisés Man
@moigithub
Apr 19 2017 01:17
@FlashHero after this
var totalString = theurl + city.value + id + units;
add
console.log(totalString);
OR
alert(totalString);
it should show a valid url address
on console or a popup window (alert)
zippy
@ShaimaTheBlueberry
Apr 19 2017 01:17
nope i am just a starter
@Manish-Giri
Manish Giri
@Manish-Giri
Apr 19 2017 01:18
then perhaps you should do the JS lessons on codeacademy first
@ShaimaTheBlueberry
zippy
@ShaimaTheBlueberry
Apr 19 2017 01:18
k thx
Jean-Paul Sauve
@jp-sauve
Apr 19 2017 01:19
@ShaimaTheBlueberry there is no such thing as nested for loops?
FlashHero
@FlashHero
Apr 19 2017 01:19
@moigithub i got the url but i'm not getting the data any idea why?
Larry
@Lanroma
Apr 19 2017 01:19
Freecodecamp or codeacademy which has more complex lessons
Jean-Paul Sauve
@jp-sauve
Apr 19 2017 01:20
for (i=0;i<1000;i++){for (j=0;j<1000;j++){{}}
Moisés Man
@moigithub
Apr 19 2017 01:20
@FlashHero can u paste the url here ?
if u use that url on ur browser it should show something
Jean-Paul Sauve
@jp-sauve
Apr 19 2017 01:20
oops. there's some extra bracket in there.
Larry
@Lanroma
Apr 19 2017 01:20
@Manish-Giri Is dere anyway of chatting u private outside dz platform
herunan
@herunan
Apr 19 2017 01:21
@HeebieGeeBee http://codepen.io/herunan/pen/bWVXwR This didn’t do it somehow… :(
Manish Giri
@Manish-Giri
Apr 19 2017 01:21
@Lanroma not really, gitter is the only way
Larry
@Lanroma
Apr 19 2017 01:22
I cant send my codes wit my phone
FlashHero
@FlashHero
Apr 19 2017 01:23
Moisés Man
@moigithub
Apr 19 2017 01:23
@FlashHero thats what console.log shows ?
var totalString = theurl + city.value + id + units;
add
console.log(totalString); <---
FlashHero
@FlashHero
Apr 19 2017 01:24
that's the javascript api i'm using
Larry
@Lanroma
Apr 19 2017 01:24
@artoodeeto how do u share ur code
aRtoo
@artoodeeto
Apr 19 2017 01:24

@Lanroma like this

``` <-- start

paste code here

```<-- end

Moisés Man
@moigithub
Apr 19 2017 01:25
@FlashHero i wanna know if city.value or id have valid strings or its undefined
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 01:25
@herunan you havent loaded jquery
Object.values("“" + tweetArr[randomN] + "”") but not sure what this is going to do anyways
herunan
@herunan
Apr 19 2017 01:26
@HeebieGeeBee Ah yes. Forgot from copying and pasting. Thanks!
CamperBot
@camperbot
Apr 19 2017 01:26
herunan sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: herunan already gave heebiegeebee points
FlashHero
@FlashHero
Apr 19 2017 01:26
@moigithub it does i get the value when the button is clicked
herunan
@herunan
Apr 19 2017 01:26
It did it but now I have to get rid of the reduntant html
FlashHero
@FlashHero
Apr 19 2017 01:27
@moigithub api.openweathermap.org/data/2.5/weather?q=california
after this url i have the api key and the units
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 01:27
ok cool
wittyfans
@wittyfans
Apr 19 2017 01:27

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

// Only change code below this line.

/*request:

  • mydata should be 8;
  • you should use brackets to get value,but I'm not sure it requests square brackets or round brackets...
    */

//This is my code
myArray[0][0] = 8;
var myData = myArray[0][0];

//mydata is 8,but it says that you should use brackets to get the value, but I do use brackets,why I can't run tests? can anybody help me?

Manish Giri
@Manish-Giri
Apr 19 2017 01:28
what is myArray[0][0]; @wittyfans
?
stevemax22
@stevemax22
Apr 19 2017 01:28
Howdy. I'm having some trouble on the Replacing If Else Chains with Switch challenge. I need to turn an if/if else statement to a switch statement.
Manish Giri
@Manish-Giri
Apr 19 2017 01:29
lol
sorry, cbot was being derpy again
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 01:30
lol no worries
wittyfans
@wittyfans
Apr 19 2017 01:30
myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
Vera S.
@verascity
Apr 19 2017 01:30
ignore my earlier question, "let" is a godsend
wittyfans
@wittyfans
Apr 19 2017 01:30
Then should be 1
silver537
@silver537
Apr 19 2017 01:30
No.
Its that array
wittyfans
@wittyfans
Apr 19 2017 01:31
Then should be 8 ,soory
silver537
@silver537
Apr 19 2017 01:31
At the zeroeth index
wittyfans
@wittyfans
Apr 19 2017 01:31
sorry
silver537
@silver537
Apr 19 2017 01:32
myArray[0] right.
FlashHero
@FlashHero
Apr 19 2017 01:32
@moigithub you there?
silver537
@silver537
Apr 19 2017 01:32
?
wittyfans
@wittyfans
Apr 19 2017 01:33
myArray[0] is wrong,I tested.The value is correct,but it says I should use brackets to get the value...
I don't know how to do
Moisés Man
@moigithub
Apr 19 2017 01:34
http://codepen.io/MMan/pen/RVWXBo?editors=1010 @FlashHero
F12 to open devtools then check on console it shows something there from the api
Ken Haduch
@khaduch
Apr 19 2017 01:34

@artoodeeto - instead of doing this:

yes = myObj[checkProp];

You can just immediately do this:

return myObj[checkProp];

Since you know that you will eventually return that anyway. It just saves the extra variables and code.

aRtoo
@artoodeeto
Apr 19 2017 01:34
@khaduch then the return below will be useless?
Maile
@mailevalentine
Apr 19 2017 01:35
@stevemax22 what trouble are you having with it?
aRtoo
@artoodeeto
Apr 19 2017 01:35
@khaduch because it says right there return"change me"
Ken Haduch
@khaduch
Apr 19 2017 01:35
@artoodeeto - yes, you do not need that return below.
aRtoo
@artoodeeto
Apr 19 2017 01:35
@khaduch ohhh. ok2. thank you sir
CamperBot
@camperbot
Apr 19 2017 01:35
artoodeeto sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2755 | @khaduch |http://www.freecodecamp.com/khaduch
FlashHero
@FlashHero
Apr 19 2017 01:36
@moigithub the result i get from combining everything is valid when i paste that in url it shows the data but the XMLHTTPrequest is not giving me the data
wittyfans
@wittyfans
Apr 19 2017 01:37
This is the FCC link
FlashHero
@FlashHero
Apr 19 2017 01:37
when I do request.responseText nothing shows but i'm expecting to get the data
aRtoo
@artoodeeto
Apr 19 2017 01:38

hello maam and sir. isn't it this way to add a property with value to an object?? heres my code. help please.


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

  // Add record here


];


myMusic.artist = "jroa";
myMusic.title = "Ulit-ulit";
myMusic.release_year = "2017";
myMusic.formats = ["CS", "8T", "LP"];
myMusic.gold = "Totaly";


console.log(myMusic);

but when put it inside the myMusic array im getting an error. but i checked it with console.log everything i add is in the myMusic.

Manish Giri
@Manish-Giri
Apr 19 2017 01:39
@artoodeeto see the comment // Add record here
you add it under that
just an object literal
like the one itself
 {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
@HeebieGeeBee this is so annoying
  constructor(props) {
        super(props);
        this.handleRecipeNameChange = this.handleRecipeNameChange.bind(this);
        this.handleRecipeIngredientsChange = this.handleRecipeIngredientsChange.bind(this);
        this.handleRecipeTagsChange = this.handleRecipeTagsChange.bind(this);
    }
aRtoo
@artoodeeto
Apr 19 2017 01:41
@Manish-Giri it says add. but isnt it the right way to add??
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 01:41
@Manish-Giri seems it whats it mean to be?
Manish Giri
@Manish-Giri
Apr 19 2017 01:42
@artoodeeto you'll overwrite the existing values that way
@HeebieGeeBee but it's so redundant and annoying
aRtoo
@artoodeeto
Apr 19 2017 01:44
@Manish-Giri ohh. thats why when i console.log it only shows what i added
Moisés Man
@moigithub
Apr 19 2017 01:44
@FlashHero
make sure u use http:// on ur url only (NOT https) cuz openweather free version only use http
check ur browser devtools console if u have any error
to test.. place the complete valid url directly on request.open("GET", "http://a valid url here with all parameters");
it should work.. (works here )
if placing the full url directly on the code works.. then the problem is on ur variables
FlashHero
@FlashHero
Apr 19 2017 01:46
@moigithub the url works if i paste in the browser and you know how it says you need api key i have that in my url and everything is valid
barki mustapha
@barkinet
Apr 19 2017 01:46
I need help

it shows this

{\"coord\":{\"lon\":22.57,\"lat\":51.25},\"weather\":[{\"id\":500,\"main\":\"Rain\",\"description\":\"light rain\",\"icon\":\"10n\"}],\"base\":\"stations\",\"main\":{\"temp\":274.472,\"pressure\":1005.57,\"humidity\":96,\"temp_min\":274.472,\"temp_max\":274.472,\"sea_level\":1034.93,\"grnd_level\":1005.57},\"wind\":{\"speed\":7.69,\"deg\":87.0071},\"rain\":{\"3h\":0.115},\"clouds\":{\"all\":92},\"dt\":1492565702,\"sys\":{\"message\":0.0529,\"country\":\"PL\",\"sunrise\":1492572354,\"sunset\":1492623166},\"id\":765876,\"name\":\"Lublin\",\"cod\":200}"

SOO its working

barki mustapha
@barkinet
Apr 19 2017 01:47

function steamrollArray(arr,flatArr) {
// I'm a steamroller, baby
var answer = ["a", "b"];
if (arr == [[["a"]], [["b"]]]) {
return answer;
}

if (!flatArr) {
flatArr =[];
}

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

  } else if (Array.isArray(arr[i])) {
    steamrollArray(arr[i],flatArr);
  } else {
    flatArr.push(arr[i]);
  }

}

return flatArr;
}

steamrollArray([[["a"]], [["b"]]]);

I got a without b
FlashHero
@FlashHero
Apr 19 2017 01:49
@moigithub I'm trying to insert whatever the user enters in the state/city
so it will change every time the user puts new state/city
Moisés Man
@moigithub
Apr 19 2017 01:51
soo whats ur code to "get" the user input ? @FlashHero
FlashHero
@FlashHero
Apr 19 2017 01:51
var theurl = "api.openweathermap.org/data/2.5/weather?q=";
var appid = "&appid=f61163b796236f1d47db88f505a78a18";
var units = "&units=metric";
var city = document.getElementById('theinput');
var button = document.getElementById('thebutton');
button.addEventListener("click", function () {
    var request = new XMLHttpRequest();
    var totalString = theurl + city.value + appid + units;
    var combine = totalString;
    request.onreadystatechange = function () {
        if (request.readyState == 4 || request.status == 200) {
            console.log(JSON.stringify(request.responseText));
        }
    };
    request.open("GET", combine);
    request.send();
});
Stephen James
@sjames1958gm
Apr 19 2017 01:52
@barkinet (arr == [[["a"]], [["b"]]]) this will never be true as arrays compare by reference
@FlashHero don't you need http:// at the front of your URL?
Moisés Man
@moigithub
Apr 19 2017 01:54
@FlashHero add // to ur url as @sjames1958gm said
else it will be treated as relative address
FlashHero
@FlashHero
Apr 19 2017 01:54
@sjames1958gm oh yeah that's what i needed thanks
CamperBot
@camperbot
Apr 19 2017 01:54
flashhero sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6796 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 19 2017 01:55
@FlashHero :+1:
FlashHero
@FlashHero
Apr 19 2017 01:55
@moigithub thanks man thank you so much for putting so much effort to explain
CamperBot
@camperbot
Apr 19 2017 01:55
flashhero sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3127 | @moigithub |http://www.freecodecamp.com/moigithub
FlashHero
@FlashHero
Apr 19 2017 01:57
@moigithub I appreciate your help man thank you so much
CamperBot
@camperbot
Apr 19 2017 01:57
flashhero sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: flashhero already gave moigithub points
Manish Giri
@Manish-Giri
Apr 19 2017 01:57
any react folks around?
Abi H
@westminsterabi
Apr 19 2017 02:01
i'm working on the mutations and I'm having trouble. this is my code, I can't understand why it won't return false for false instances
function mutation(arr) {
  a = arr[0].toLowerCase;
  b = arr[1].toLowerCase;
  for(var i = 1; i <= b.length; i++){
    if(a.indexOf(b.charAt(i)) == -1){
      return false;
    }
  } return true;
}
Manish Giri
@Manish-Giri
Apr 19 2017 02:02
@westminsterabi why is i starting at 1?
CamperBot
@camperbot
Apr 19 2017 02:02

freeCodeCamp Wiki:

:point_right: The freeCodeCamp wiki can be found on our forum.
Please follow the link and search there.
Stephen James
@sjames1958gm
Apr 19 2017 02:03
@vickylaixy isn't pages an object - you are looping over as array?
Abi H
@westminsterabi
Apr 19 2017 02:03
@Manish-Giri no reason, it was just one of the things i started fiddling with to try to make it work
Jean-Paul Sauve
@jp-sauve
Apr 19 2017 02:04
Dang. Falsy bouncer took longer than it should have. If (I===dummy){this.feels="d'oh";}
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 02:05
@vickylaixy change your ajax to 'GET' not 'POST'
Jean-Paul Sauve
@jp-sauve
Apr 19 2017 02:05
I should have read the helpful links first. The answer was right there.
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 02:06
@sjames1958gm you seemed to have aged a bit
Stephen James
@sjames1958gm
Apr 19 2017 02:06
@vickylaixy
            for (var val in pages) {
                console.log('Second loop!');
                var title = pages[val].title;
                var extract = pages[val].extract;
                console.log(title,extract);
                makeResultLine(title, extract);
            }
@HeebieGeeBee Alec Guiness was only 5 years older than I when he played Obi Wan
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 02:08
but living was harder backthen
Stephen James
@sjames1958gm
Apr 19 2017 02:09
@westminsterabi You for loop should be i = 0 i < b.length
@HeebieGeeBee lol
Maile
@mailevalentine
Apr 19 2017 02:11
function lookUpProfile(firstName, prop){
// Only change code below this line
var answer = 0;
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        answer = contacts[i][prop];
        } 
        else {
          return "No such property"; 
        }
      } 
    }
  return answer;
}
Vicky Lai
@vickylai
Apr 19 2017 02:11
@sjames1958gm Yes! Thank you. That got me through my loop. There I go overthinking things again...
CamperBot
@camperbot
Apr 19 2017 02:11
vickylaixy sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6797 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Maile
@mailevalentine
Apr 19 2017 02:11
This passes all but one of the tests. Can't figure out where to put the return statement "No such contact" in order for it to fully work
It's the Profile Lookup challenge
Manish Giri
@Manish-Giri
Apr 19 2017 02:12
@mailevalentine outside the loop
Stephen James
@sjames1958gm
Apr 19 2017 02:13
@vickylaixy :checkered_flag:
Maile
@mailevalentine
Apr 19 2017 02:14

@Manish-Giri like this:

```

function lookUpProfile(firstName, prop){
// Only change code below this line
var answer = 0;
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        answer = contacts[i][prop];
        } 
        else {
          return "No such property"; 
        }
      } 
    return "No such contact";
    }
  return answer;
}
? that makes the first 3 test fail
Manish Giri
@Manish-Giri
Apr 19 2017 02:14
nope
Stephen James
@sjames1958gm
Apr 19 2017 02:14
@mailevalentine If you change answer = contacts[i][prop]; to return contacts[i][prop];
Then the only way the loop can complete is there is no such contact
Manish Giri
@Manish-Giri
Apr 19 2017 02:15
change answer = contacts[i][prop]; to return contacts[i][prop];
@mailevalentine
then it should be fine
Stephen James
@sjames1958gm
Apr 19 2017 02:15
@mailevalentine then replace return answer with return "No such contact";
@westminsterabi toLowerCase is a function and you are not calling it.
Maile
@mailevalentine
Apr 19 2017 02:18
@sjames1958gm @Manish-Giri thank you!! Is there anything worth more than brownie points?! This one has been bugging me for way too long!
CamperBot
@camperbot
Apr 19 2017 02:18
mailevalentine sends brownie points to @sjames1958gm and @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5201 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 6798 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Maile
@mailevalentine
Apr 19 2017 02:20
BTW, if you misspell "contact" in the return statement, it will still fail. Picky, picky! :)
Stephen James
@sjames1958gm
Apr 19 2017 02:20
@mailevalentine :+1:
Manish Giri
@Manish-Giri
Apr 19 2017 02:20
@mailevalentine good job!
Lin Grayson
@awakenedlin
Apr 19 2017 02:29
Hello guys! I had a question regarding the first big project in JavaScript, converting celsius to fahrenheit.
David Miller
@DavidMillerFL
Apr 19 2017 02:30
Oh maybe I can help, I just did that one a few days ago.
Lin Grayson
@awakenedlin
Apr 19 2017 02:30
I got the answer correct according to the compiler but I feel like I could have simplified the code using += and /=
This is what I got -> fahrenheit = (celsius * 9/5 + 32);
Thoughts?
Abi H
@westminsterabi
Apr 19 2017 02:37
@sjames1958gm great, fixed. thanks!
CamperBot
@camperbot
Apr 19 2017 02:37
westminsterabi sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6799 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Hossein Ghanaati
@Hossein-Ghanaati
Apr 19 2017 02:37
hi everyone i am working on "No repeats please" algorithm i am trying to right a function to add chars o previous chars in order to make permutations but for some odd reason i trap in an infinite loop can some one tell me why? this is my pen
Brian Montellano
@bmontellano
Apr 19 2017 02:41
guys i have no clue here, can you help?
i need to " Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

// Setup
function abTest(a, b) {
// Only change code below this line
Math.sqrt(a) + Math.sqrt(b);

// Only change code above this line

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

// Change values below to test your code
abTest(-2,2);

thats my code
Hossein Ghanaati
@Hossein-Ghanaati
Apr 19 2017 02:43
you want to do this : "Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined."
Brian Montellano
@bmontellano
Apr 19 2017 02:45
yes, i get that, so I try to do this, and I get "null" as a return

function abTest(a, b) {
// Only change code below this line
console.log(Math.sqrt(a) + Math.sqrt(b));

// Only change code above this line

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

// Change values below to test your code
abTest(-2,2);

Hossein Ghanaati
@Hossein-Ghanaati
Apr 19 2017 02:45
@bmontellano did you read conditionals? you should write an "if" statement to check a< 0 || b < 0 if it was true return undefined;
Brian Montellano
@bmontellano
Apr 19 2017 02:46
mmm let me see
i tried if ( a || b < 0).......
Steven Bland
@StevieB21
Apr 19 2017 02:46
could someone here help me with some css :/
Brian Montellano
@bmontellano
Apr 19 2017 02:46
but i will try the seperately
Hossein Ghanaati
@Hossein-Ghanaati
Apr 19 2017 02:46
you should do separately
@StevieB21 whats the problem?
Steven Bland
@StevieB21
Apr 19 2017 02:47
https://gyazo.com/e7190954bf09c4afe9557c71c7c5b08c
@Hossein-Ghanaati not sure what im doing wrong
Brian Montellano
@bmontellano
Apr 19 2017 02:48
@Hossein-Ghanaati you are the best!!
thank you :D
it worked if i did seperately
Hossein Ghanaati
@Hossein-Ghanaati
Apr 19 2017 02:48
np
@StevieB21 it doesnt open
Brian Montellano
@bmontellano
Apr 19 2017 02:49
i wonder why it didnt work on its own like if ((a||b) <0) { ......
lemme try something
Steven Bland
@StevieB21
Apr 19 2017 02:49
https://gyazo.com/a2cb039949c355da0871368a852eee76
@Hossein-Ghanaati what about this
Brian Montellano
@bmontellano
Apr 19 2017 02:51
no it will not work, you have to do them separately, I'll keep in mind for the next time
Hossein Ghanaati
@Hossein-Ghanaati
Apr 19 2017 02:51
@StevieB21 ok it opens but i steal dont know what is the problem?
Steven Bland
@StevieB21
Apr 19 2017 02:51
im supposed to do what they instruct at the top,my code is below: im supposed to change text to white and bg in black
Hossein Ghanaati
@Hossein-Ghanaati
Apr 19 2017 02:53
they say alpha 1 but you put 255 i think
Steven Bland
@StevieB21
Apr 19 2017 02:55
ohhhhhhhh
i got it :D @Hossein-Ghanaati
Hossein Ghanaati
@Hossein-Ghanaati
Apr 19 2017 02:56
also for background wright solid black;
anyone know why i trap in infinite loop in this function?

function insertChar (arr, char) {
var tempArr = [];
var temp;
for (i = 0; i < arr.length; i++) {
for (j = 0; j <arr[i].length + 1; j++) {
temp = arr[i];
console.log(temp);
temp.splice(j, 0, char);
console.log(temp);
tempArr.push(temp);
console.log(tempArr);

  }

}

return tempArr;

}

anderson
@anderson2825
Apr 19 2017 03:04
How to solve this problem!
Ogundele Olumide
@Lumexralph
Apr 19 2017 03:11
@Hossein-Ghanaati j <arr[i].length + 1 that's the cause for the infinite loop, `arr[i].length keeps increasing by 1 at every inner loop iteration, so it doesn't stop
intcreate
@intcreate
Apr 19 2017 03:14

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

` function convertToF(celsius) {
var fahrenheit;
fahrenheit = 0;
fahrenheit = -30 + 8;
fahrenheit = -10 + 24;

// Only change code below this line

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

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

can any1 help me
function convertToF(celsius) { var fahrenheit; fahrenheit = 0; fahrenheit = -30 + 8; fahrenheit = -10 + 24; // Only change code below this line // Only change code above this line return fahrenheit; } // Change the inputs below to test your code convertToF(30);
BigData95
@BigData95
Apr 19 2017 03:19
@intcreate You have to use the formula
.
@intcreate fahrenheit = (1.8*celsius)+32;
intcreate
@intcreate
Apr 19 2017 03:24
what does the formula do?
how did u get 1.8 and 32
barki mustapha
@barkinet
Apr 19 2017 03:28
I need help

function steamrollArray(arr,flatArr) {
// I'm a steamroller, baby
var answer = ["a", "b"];
if (arr == [[["a"]], [["b"]]]) {
return answer;
}

if (!flatArr) {
flatArr =[];
}

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

  } else if (Array.isArray(arr[i])) {
    steamrollArray(arr[i],flatArr);
  } else {
    flatArr.push(arr[i]);
  }

}

return flatArr;
}

steamrollArray([[["a"]], [["b"]]]);

Vicky Lai
@vickylai
Apr 19 2017 03:30
My Wiki search is working: https://codepen.io/vickylaixy/pen/xdGRjp?editors=1001
Except that the results replace each other instead of appending one after the other. Can I achieve the result I want using Javascript objects? Or is there something else much simpler?
LeSean Johnson
@leseanbiz
Apr 19 2017 03:34
Is there a particular quotes api anyone would recommend?
Vicky Lai
@vickylai
Apr 19 2017 03:36
@leseanbiz I found this one easy to work with, but you won't get any CORS errors challenges... 'https://random-quote-generator.herokuapp.com/api/quotes/random'
LeSean Johnson
@leseanbiz
Apr 19 2017 03:39
what do you mean CORS errors challenges?
Ogundele Olumide
@Lumexralph
Apr 19 2017 03:40
@leseanbiz i see people use forismatic api
Moisés Man
@moigithub
Apr 19 2017 03:40
id recommend openweather map :) soo u get cors error and mixed content error
Ogundele Olumide
@Lumexralph
Apr 19 2017 03:41
@intcreate use the celsius parameter with the formula and assign it to the fahrenheit variable
LeSean Johnson
@leseanbiz
Apr 19 2017 03:41
@moigithub will it return quotes about the weather? lol
Moisés Man
@moigithub
Apr 19 2017 03:42
...better get exposed to those now.. while u learning , so u know how to solve it later
Ogundele Olumide
@Lumexralph
Apr 19 2017 03:42
@intcreate c * 9/5 + 32 that's how 1.8 was derived
Vicky Lai
@vickylai
Apr 19 2017 03:43
@leseanbiz If you use an API served with http you'll run into more challenges that you can learn to solve.
LeSean Johnson
@leseanbiz
Apr 19 2017 03:44
ok, thanks
Vicky Lai
@vickylai
Apr 19 2017 03:44
I misspoke earlier; the divs are all being created in my wiki search page, but the results keep replacing the first div only.
David Amanze
@GodKingShogun
Apr 19 2017 03:51
koko no mina mina sama :smile:
Moisés Man
@moigithub
Apr 19 2017 03:58
@vickylaixy ID's should/must be unique
barki mustapha
@barkinet
Apr 19 2017 03:58

Help please function steamrollArray(arr,flatArr) {
// I'm a steamroller, baby
var answer = ["a", "b"];
if (arr == [[["a"]], [["b"]]]) {
return answer;
}

if (!flatArr) {
flatArr =[];
}

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

  } else if (Array.isArray(arr[i])) {
    steamrollArray(arr[i],flatArr);
  } else {
    flatArr.push(arr[i]);
  }

}

return flatArr;
}

steamrollArray([[["a"]], [["b"]]]);

Vicky Lai
@vickylai
Apr 19 2017 03:59
@moigithub Yeah I just figured that... I'm currently working on something like this mess: extractP.setAttribute('id', ('Title'.concat(pageID))
@barkinet Would be helpful if you let us all know what challenge you're working on, and what problem you're specifically having :)
barki mustapha
@barkinet
Apr 19 2017 04:01
It's steamroller challenge
I'm near to resolve it
@vickylaixy
Moisés Man
@moigithub
Apr 19 2017 04:02

@vickylaixy also if u use vanilla JS u could do something like

    titleP.setAttribute('id', 'pageTitle');
    titleP.innerHTML = title;

or use titleP.textContent = title
or use jQuery for the whole thing

srohal04
@sr004
Apr 19 2017 04:03
in algorithm challenge i am having propblem to prove palindromes " 0_0 (: / - \ : ) 0-0" can anyone help
Vicky Lai
@vickylai
Apr 19 2017 04:03
Oh! Good one! @moigithub I'll run with that and see
Sandesh Shrestha
@UnovaXan
Apr 19 2017 04:03
Can anyone help me with the Seek and Destroy algorithm?
Vicky Lai
@vickylai
Apr 19 2017 04:05
@moigithub Yes! Works. Thank you!
CamperBot
@camperbot
Apr 19 2017 04:05
vickylaixy sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3128 | @moigithub |http://www.freecodecamp.com/moigithub
Vicky Lai
@vickylai
Apr 19 2017 04:06
There I go overthinking again when I could've skipped the extra steps :sweat:
Stef
@nestorst
Apr 19 2017 04:14
On 'Everything Be True', my isNaN keeps returning true, can somebody tell me why?

function truthCheck(collection, pre) {
  // Is everyone being true?
  var a = true;

  for (var i = 0; i < collection.length; i++) {
    if (collection[i].hasOwnProperty(pre) === false) {
      a = false;
    } else if ( collection[i][pre] === 0 ||  collection[i][pre] === null || isNaN(collection[i][pre]) ) {
      a = false;

    }
  }
  return a;
}

  truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
Parth-g
@Parth-g
Apr 19 2017 04:25

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

FirstLine
\SecondLine\
ThirdLine

var myStr="FirstLine\n\SecondLine\nThirdLine\r"; // Change this line
what is wrong in this
?
Stef
@nestorst
Apr 19 2017 04:30
@Parth-g it doesn't look like you have the second backslash for the SecondLine written in
james umali
@indefinite0212
Apr 19 2017 04:30
Use \r after SecondLine
@Parth-g
Parth-g
@Parth-g
Apr 19 2017 04:31
what's the meaning of \r
james umali
@indefinite0212
Apr 19 2017 04:32
Look at the table
LeSean Johnson
@leseanbiz
Apr 19 2017 04:38
does .forEach work in codepen?
Sandesh Shrestha
@UnovaXan
Apr 19 2017 04:48
@sr004 you will need to use a regular expression to replace the special characters used in the test
Amanda
@amandaphoenix
Apr 19 2017 04:54

Is someone willing to explain this one to me...

https://www.freecodecamp.com/challenges/testing-objects-for-properties

:(
2 days now...
devpaaji
@devpaaji
Apr 19 2017 05:04
@amandaphoenix
did you read the instructions
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
So the analogy here is simple
ask the object - do you have this property.
Object will then check using a method hasOwnProperty
to test, If I have the property name that you are requestion
If Obj has the property it will say- hey yes, I have that value
Amanda
@amandaphoenix
Apr 19 2017 05:10
interesting okay
i've been trying to wrap my head around this. in normal human speak
and it just hit me like a roadblock, though to be honest I think the rest of javascript I'm still not sure how I got here haha but Im determined to learn
David Miller
@DavidMillerFL
Apr 19 2017 05:15
Hello everyone. Something funny is happening.
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes = 1)

  return "Hole-in-one!";
  // Only change code above this line
}
Markus Kiili
@Masd925
Apr 19 2017 05:15
@nestorst A simple test for property key existing and value being truthy is if(obj[key]){...}
@DavidMillerFL = is for assignment and === for comparing.
David Miller
@DavidMillerFL
Apr 19 2017 05:16
Wait, nevermind I fixed it!
Yes thank you @Masd925
CamperBot
@camperbot
Apr 19 2017 05:16
davidmillerfl sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3871 | @masd925 |http://www.freecodecamp.com/masd925
abdi rahman
@abdiezy
Apr 19 2017 05:20
hello campers how is you day?
need help with this.
function fearNotLetter(str) {

  str=str.split('');

  var stat = str[0].charCodeAt();

  for(var i = 1; i <= str.length; i++){
    stat = stat + i;

    if(String.fromCharCode(stat) !== str[i]){
      return String.fromCharCode(stat);
    }   else{
      return undefined;
    }
  }

}

fearNotLetter("abce");
Markus Kiili
@Masd925
Apr 19 2017 05:22
@abdiezy You don't need to split into a character array here. You can read and loop characters without it.
devpaaji
@devpaaji
Apr 19 2017 05:22
@amandaphoenix that is fine
go slow do small things
do stuff that makes you happy and confident
abdi rahman
@abdiezy
Apr 19 2017 05:23
@Masd925 so will it wotk if i dont split
devpaaji
@devpaaji
Apr 19 2017 05:23
programming in general and web development in particular has steep learning curve.
Environment in web world is rapidly changing.
Markus Kiili
@Masd925
Apr 19 2017 05:24
@abdiezy You need to do some slight changes. str.charCodeAt(0) etc
kelnsteff
@kelnsteff
Apr 19 2017 05:25

Can anyone help in the Nesting for Loops challenge? Not sure what is wrong.
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < arr.length; i++) {
for (var k=0; k < arr[i].length; k++) {
console.log(arr[i][k]);
}

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

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

Aizaz Shahid
@aizazshahid
Apr 19 2017 05:25
@kelnsteff what is the name of the challenge ?
Markus Kiili
@Masd925
Apr 19 2017 05:25
@kelnsteff You need to multiply product, not just console.log
kelnsteff
@kelnsteff
Apr 19 2017 05:26
Nesting for Loops in Basic Java Script
Sanket Chaudhari
@sanket143
Apr 19 2017 05:27
var count = 0;

function cc(card) {

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

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
what should I put result = ?
kelnsteff
@kelnsteff
Apr 19 2017 05:27
@Masd925 something like this? product* = [i][k];
Aizaz Shahid
@aizazshahid
Apr 19 2017 05:27
@kelnsteff ok i am looking at it ! wait
Sandesh Shrestha
@UnovaXan
Apr 19 2017 05:27
@kelnsteff yep
Markus Kiili
@Masd925
Apr 19 2017 05:27
@kelnsteff You need to use arr there too.
Sandesh Shrestha
@UnovaXan
Apr 19 2017 05:27
arr[i][k]
kelnsteff
@kelnsteff
Apr 19 2017 05:27
ok without the console.log?
Markus Kiili
@Masd925
Apr 19 2017 05:28
@sanket143 count+=1 and count-=1
Sandesh Shrestha
@UnovaXan
Apr 19 2017 05:28
@sanket143 you have to check the count value and return the desired string
check the instructions
it's given there what should be returned
has anyone done the seek and destroy algorithm yet?
Markus Kiili
@Masd925
Apr 19 2017 05:31
@UnovaXan Yes.
kelnsteff
@kelnsteff
Apr 19 2017 05:32
Thank you!!
devpaaji
@devpaaji
Apr 19 2017 05:33
@Masd925 gm friend
how are you
one imp thing I seen in most JS code samples
is use of map.call
var sortedTexts = Array.prototype.map.call(getId,function(node){ return node.textContent; })
like the one you suggested
so here
map is a callback fn
Aizaz Shahid
@aizazshahid
Apr 19 2017 05:35
@kelnsteff did you pass it ?
devpaaji
@devpaaji
Apr 19 2017 05:35
function(node) is this passed param for map ?
Aizaz Shahid
@aizazshahid
Apr 19 2017 05:35
@kelnsteff i have tried it also:
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for(var i=0; i < arr.length; i++) {

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

      product = product * arr[i][j];

    }

  }
  // Only change code above this line
  return product;
}
Markus Kiili
@Masd925
Apr 19 2017 05:35
@devpaaji function(node){ return node.textContent; } is the map callback function. node is just a parameter name on that function expression.
Manish Giri
@Manish-Giri
Apr 19 2017 05:37
@forwebtech it's not working?
devpaaji
@devpaaji
Apr 19 2017 05:37
so in combination with map
we can use call
to set the value
for map to iterate
Aizaz Shahid
@aizazshahid
Apr 19 2017 05:37
@Manish-Giri its working on my side !
devpaaji
@devpaaji
Apr 19 2017 05:37
correct
Aizaz Shahid
@aizazshahid
Apr 19 2017 05:38
@Manish-Giri reset your page and then try it !
Manish Giri
@Manish-Giri
Apr 19 2017 05:38
@devpaaji var squaredNumbers = [1, 2, 3, 4].map(number => Math.pow(number, 2));
Markus Kiili
@Masd925
Apr 19 2017 05:40
@devpaaji With call you can set the value of this inside the callback (the calling object here) and pass an argument to map (the callback function here). Using call also allows using array methods on array-like object, like here we use map on a nodelist.
help please
Markus Kiili
@Masd925
Apr 19 2017 05:41
@devpaaji No need to turn the nodelist into an array first.
devpaaji
@devpaaji
Apr 19 2017 05:42
calling object is getId
Markus Kiili
@Masd925
Apr 19 2017 05:42
Yes.
devpaaji
@devpaaji
Apr 19 2017 05:43
passed arguement here is function(node) which is like an element in each array iteration
this is for map
Markus Kiili
@Masd925
Apr 19 2017 05:43
@devpaaji Map method passes array elements into that callback function.
devpaaji
@devpaaji
Apr 19 2017 05:44
so does map knows about getID
Array.prototype.map.call(getId,function(node)
Femi Adewuyi
@femi5ezekiel
Apr 19 2017 05:45

// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "J"; // Fix Me

myStr = "Hello World";

Markus Kiili
@Masd925
Apr 19 2017 05:45
@devpaaji That tells map to iterate getId.
Femi Adewuyi
@femi5ezekiel
Apr 19 2017 05:45
help me please iam stuck
Sanket Chaudhari
@sanket143
Apr 19 2017 05:45
var count = 0;

function cc(card) {

  // Only change code below this line

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

  }

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc('J'); cc(9); cc(2); cc(7);
What's wrong here..
devpaaji
@devpaaji
Apr 19 2017 05:46
why do we need call here
can that not be directly ieterated
Markus Kiili
@Masd925
Apr 19 2017 05:46
@devpaaji It allows using array methods on array-like objects. Another way is to first turn the nodelist into an array and then use map.
Manish Giri
@Manish-Giri
Apr 19 2017 05:47
@sanket143 why are you setting count to 0?
case 7:
    case 8:
    case 9:
      count = 0;
      break;
Markus Kiili
@Masd925
Apr 19 2017 05:47
@devpaaji A nodelist doesn't have map method.
devpaaji
@devpaaji
Apr 19 2017 05:47
correct yes i know that
arguements is an array like obj
Sanket Chaudhari
@sanket143
Apr 19 2017 05:48
so may I not mention case 7,8 &9 ?? @Manish-Giri
Markus Kiili
@Masd925
Apr 19 2017 05:49
@devpaaji String wrappers are too. So you can use call to use array methods on all of those or array-like objects you make yourself.
Sandesh Shrestha
@UnovaXan
Apr 19 2017 05:49
@Masd925 i can't seem to get it right
devpaaji
@devpaaji
Apr 19 2017 05:50
I feel querySelector is a great way fo doing so
Manish Giri
@Manish-Giri
Apr 19 2017 05:50
@sanket143 yeah you don't need to
sudip chhetri
@SudipChhetri
Apr 19 2017 05:51
is there anybody to tell me what is wrong in my code
Sanket Chaudhari
@sanket143
Apr 19 2017 05:51
Thanks @Manish-Giri
CamperBot
@camperbot
Apr 19 2017 05:51
sanket143 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5202 | @manish-giri |http://www.freecodecamp.com/manish-giri
sudip chhetri
@SudipChhetri
Apr 19 2017 05:53
hey friend plz help me i am stuck
please help me with the code
Manish Giri
@Manish-Giri
Apr 19 2017 05:55
@femi5ezekiel myStr[0] = "H";
you still have this line
Sandesh Shrestha
@UnovaXan
Apr 19 2017 05:55
you can't change the individual letters in a string @femi5ezekiel
so yo uhave to remove that myStr[0] = "H" line
that's what string immutability means
you have to create a new one if you want to change the string
Femi Adewuyi
@femi5ezekiel
Apr 19 2017 05:57
@Manish-Giri @UnovaXan I am not getting it
Sandesh Shrestha
@UnovaXan
Apr 19 2017 05:57
@femi5ezekiel the string that was created was mispelled to "Jello World"
you can't change just the first letter of the string by using str[0]
you could do that if it were an array of characters
but it's not
so you have to create a new string with the value of "Hello World" to correct it
therefore making it str = "Hello World"
trying to change the individual letters will throw an error
as is evident in the console on your left
Manish Giri
@Manish-Giri
Apr 19 2017 06:00

@femi5ezekiel this is your code

myStr[0] = "H"; // Fix Me



myStr = "Hello World";

you assigned a new string to myStr but this line is still there
myStr[0] = "H"; // Fix Me

delete it
Sandesh Shrestha
@UnovaXan
Apr 19 2017 06:01
@Manish-Giri How far off are you on the challenges?
Femi Adewuyi
@femi5ezekiel
Apr 19 2017 06:01
@UnovaXan Thanks It works. but it gave me problem
CamperBot
@camperbot
Apr 19 2017 06:01
femi5ezekiel sends brownie points to @unovaxan :sparkles: :thumbsup: :sparkles:
sudip chhetri
@SudipChhetri
Apr 19 2017 06:01
@UnovaXan plz help me
Sandesh Shrestha
@UnovaXan
Apr 19 2017 06:01
@SudipChhetri I haven't reached the pomodoro part yet
maybe @Manish-Giri can help you?
CamperBot
@camperbot
Apr 19 2017 06:02
api offline
Sandesh Shrestha
@UnovaXan
Apr 19 2017 06:02
@femi5ezekiel What problem?
Femi Adewuyi
@femi5ezekiel
Apr 19 2017 06:02
@Manish-Giri Thanks It works.
CamperBot
@camperbot
Apr 19 2017 06:02
femi5ezekiel sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
sudip chhetri
@SudipChhetri
Apr 19 2017 06:02
@Manish-Giri plz help me
CamperBot
@camperbot
Apr 19 2017 06:02
:star2: 5204 | @manish-giri |http://www.freecodecamp.com/manish-giri
Sergii
@Doomkrat
Apr 19 2017 06:04
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val){
    case 1:
      return "alpha";
      break;
    case 2:
      return "beta";
      break;
      case 3:
      return "gamma";
      break;
      case 4:
      return "delta";
      break;
  }


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

// Change this value to test
caseInSwitch(1);
Sandesh Shrestha
@UnovaXan
Apr 19 2017 06:04
@femi5ezekiel Try playing around with the code after reading the instructions carefully. You'll make mistakes but you'll learn. And even if you do accidentally get the tests right, try going back to your code and figure out how that worked. Don't jump to the help section immediately. :D As the motto goes read-search-ask
@Doomkrat you shouldn't be returning in the cases
only assign the value to answer
Manish Giri
@Manish-Giri
Apr 19 2017 06:05
@UnovaXan sorry missed your post, I'm finishing up on the recipe box challenge
Sergii
@Doomkrat
Apr 19 2017 06:05
guys help me please: error alert :unreachable break after returns
Manish Giri
@Manish-Giri
Apr 19 2017 06:05
@SudipChhetri problem?
sudip chhetri
@SudipChhetri
Apr 19 2017 06:05
@Manish-Giri plz help me
Sandesh Shrestha
@UnovaXan
Apr 19 2017 06:05
@Doomkrat have answer="blah blah"
instead of return
sudip chhetri
@SudipChhetri
Apr 19 2017 06:06
@Manish-Giri my javascript is not resuming after clicking the button
Sandesh Shrestha
@UnovaXan
Apr 19 2017 06:06
return terminates the whole loop
Sergii
@Doomkrat
Apr 19 2017 06:07
thanks Sandesh Shrestha
Manish Giri
@Manish-Giri
Apr 19 2017 06:08
@SudipChhetri here
  if(document.getElementById("start").value = "pause"){
you probably want to use == or ===
because you're comparing values.
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 06:09
mornin
Markus Kiili
@Masd925
Apr 19 2017 06:09
@HeebieGeeBee Yo.
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 06:09
@Masd925 hey yo
sudip chhetri
@SudipChhetri
Apr 19 2017 06:11
@Manish-Giri still not working
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:12
@SudipChhetri what is start ??
rugano
@rugano
Apr 19 2017 06:12
Good morning campers
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:12
@SudipChhetri make sure it is an ID
@rugano Welcome !
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 06:14
@SudipChhetri i believe the onclick attribute only allows for one function to be assigned to it and looks like youre assigning two to it
@SudipChhetri you should use add event listener instead of onclick
sudip chhetri
@SudipChhetri
Apr 19 2017 06:15
@forwebtech start is butoon and my id are correct
rugano
@rugano
Apr 19 2017 06:15
I am still battling with the counting cards challenge,i am on day three,
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:16
@SudipChhetri did you know the point where you stuck ??
@SudipChhetri for code clearance one advice is that you should to get your id's object into variable
sudip chhetri
@SudipChhetri
Apr 19 2017 06:17
@forwebtech my button is not resuming
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:17
like:
var variable1 = document.getElementById("btext");
then use it multiple times
sudip chhetri
@SudipChhetri
Apr 19 2017 06:18
@forwebtech from next I will do so
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:18
ok !
@SudipChhetri what do you mean by resuming ??
sudip chhetri
@SudipChhetri
Apr 19 2017 06:18
@forwebtech my button is not starting after pause
after next click
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:19
@SudipChhetri only one time its working ??
sudip chhetri
@SudipChhetri
Apr 19 2017 06:19
yap
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:19
@SudipChhetri ok sorting it out ...
sudip chhetri
@SudipChhetri
Apr 19 2017 06:19
what should i sort @forwebtech
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:20
@SudipChhetri try to call console.log("test") into your function that is called by the start button
and check whether it is printing that value at second time or not
Manish Giri
@Manish-Giri
Apr 19 2017 06:20
it's not
I tested
document.getElementById("start").onclick = function(){
  console.log("started");
  if(document.getElementById("start").value === "start"){
  document.getElementById("start").value = "pause";

    var ssec = document.getElementById("stext").value*60-1;
    var bsec = document.getElementById("btext").value*60-1;
   var run = setInterval(function(){
      var stime = ssec--;
      if(stime>-1){
  document.getElementById("sessionArea").innerHTML = stime + " Seconds";
      }
      if(stime<0){
         var btime = bsec--;

        if(btime>-1){
  document.getElementById("breakArea").innerHTML = btime + " Seconds";
        }
        if(btime <= 0){
          ssec = document.getElementById("stext").value*60-1;
          bsec = document.getElementById("btext").value*60-1;
        }
      }
    }, 1000);
  }

  else{
    document.getElementById("start").value = "start"; 
  }
  document.getElementById("start").onclick = function(){
    if(document.getElementById("start").value === "pause"){
      console.log("paused");
      clearInterval(run);
    document.getElementById("start").value = "start"; 
      console.log(document.getElementById("start").value);



    }
  }
}
started
paused
start
this is the output
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:22
@SudipChhetri let me check it !
sudip chhetri
@SudipChhetri
Apr 19 2017 06:22
@forwebtech ok
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:24
@SudipChhetri i think you have made wrong syntax, addEventListener() is a method
document.getElementById("id").addEventListener("click", function(){
    body.....
});
it can't be
document.getElementById("id").addEventListener = function(){
    body.....
};
may be, am at wrong ?
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 06:25
buying a tub of nutella was mis guided
rugano
@rugano
Apr 19 2017 06:26
var count = 0;
function cc(card){
//only change code below this line
if(card == 2,3,4,5,6){
count++;
}else if(card == 10,'J','Q','K','A'){
count--;
if(count++){
return "cc+ Bet";
}else if(count--){
return "cc+ Hold";
}
//only change code above this line
}
}
//add/remove calls to test your function
//Note:only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Markus Kiili
@Masd925
Apr 19 2017 06:26
@rugano It needs to be if(card===10 || card==='J' || ...)
You also need to test if(count>0)
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:28
@Masd925 is it the right syntax ?
document.getElementById("id").addEventListener = function() {

body...
}
Markus Kiili
@Masd925
Apr 19 2017 06:29
@forwebtech No.
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:29
@SudipChhetri first change that mistake then we will check
sudip chhetri
@SudipChhetri
Apr 19 2017 06:30
@forwebtech ok
Sandesh Shrestha
@UnovaXan
Apr 19 2017 06:30
i'm still waiting for help with seek and destroy lol XD
Markus Kiili
@Masd925
Apr 19 2017 06:30
@forwebtech addEventListener needs to be called as a method. Not overwritten.
@UnovaXan Post your question again.
Darth Skywalker
@adityaparab
Apr 19 2017 06:31
@forwebtech No.. Right syntax is
document.getElementById("id").addEventListener('click', function(){
  //body
})
Ming Zhu
@chocobrownie
Apr 19 2017 06:32
Hi I'm trying to return largest numbers in array, but this code gives me error "cannot set property '0' of undefined. I think problem is at setting "largestNumber=0", but not sure why.
function largestOfFour(arr) {
  // You can do this!
  var largestNumber;
  var resultArray;
  for (i=0;i<arr.length;i++){
    largestNumber=0;
    for (j=0;j<arr[i].length;j++){
      if (arr[i][j]>largestNumber){
        largestNumber=arr[i][j];
        resultArray[i]=largestNumber;
      }
    }

  }
  return resultArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:32
@adityaparab yes, my bad, i forgot to type that
@SudipChhetri this is the correct syntax:
document.getElementById("id").addEventListener('click', function(){
  //body
})
Darth Skywalker
@adityaparab
Apr 19 2017 06:33
@chocobrownie you got it almost right...
For resultArray[i] to work, your resultArray must be an array. Change your var resultArray; to var resultArray = []; and you should be good
sudip chhetri
@SudipChhetri
Apr 19 2017 06:33
@forwebtech my button is not clicking now
Ming Zhu
@chocobrownie
Apr 19 2017 06:34
Oh god I don't recall I need to define array in another way, let me try
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:34
@SudipChhetri ok, let me check!
Ming Zhu
@chocobrownie
Apr 19 2017 06:35
@adityaparab It works, you saved me hours checking this bug... thanks
CamperBot
@camperbot
Apr 19 2017 06:35
chocobrownie sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:star2: 1011 | @adityaparab |http://www.freecodecamp.com/adityaparab
sudip chhetri
@SudipChhetri
Apr 19 2017 06:35
@forwebtech ok
Ming Zhu
@chocobrownie
Apr 19 2017 06:36
@adityaparab Btw I just had a look back at the toturial, it looks like FCC did not introduce how to create a blank array. So this might be common among new coders.
Heathercoraje
@Heathercoraje
Apr 19 2017 06:37
Hello everyone
Ming Zhu
@chocobrownie
Apr 19 2017 06:38
Hi u look awesome @Heathercoraje
Heathercoraje
@Heathercoraje
Apr 19 2017 06:38
Thx
Markus Kiili
@Masd925
Apr 19 2017 06:38
@chocobrownie How about me. Is my nose pretty.
Heathercoraje
@Heathercoraje
Apr 19 2017 06:38
@Masd925
haha
i like your nose for sure.
Sandesh Shrestha
@UnovaXan
Apr 19 2017 06:39
i like your glasses though @Masd925 XD
Heathercoraje
@Heathercoraje
Apr 19 2017 06:39
@Masd925 Could you give me a hand?
Markus Kiili
@Masd925
Apr 19 2017 06:39
@Heathercoraje Sure.
Ming Zhu
@chocobrownie
Apr 19 2017 06:39
@Masd925 remarkably yes
Shashank Shekhar
@ashwamegh
Apr 19 2017 06:39
Anybody, who can clarify what Promises are..?
Sandesh Shrestha
@UnovaXan
Apr 19 2017 06:40
What am i doing wrong here? @chocobrownie @Manish-Giri

function destroyer(arr) {
  var newArray = [];
  for(var i = 1;i<arguments.length;i++) {
    newArray = arr.filter(function (val) {
      if(val != arr[i]) {
        return val;
      }
    });
  }
  return newArray;

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
devpaaji
@devpaaji
Apr 19 2017 06:40
@Masd925 is a fan of Roger Federer
for all who do not know
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:40
@SudipChhetri are you there !
Markus Kiili
@Masd925
Apr 19 2017 06:40
@UnovaXan You need to return true/false from the callback function.
Heathercoraje
@Heathercoraje
Apr 19 2017 06:40
I am trying to do this challenge called Mexican wave. I want the input string, for example, "hello" to be [ "Hello", "hEllo", "heLlo", "helLo", "hellO"]
Sandesh Shrestha
@UnovaXan
Apr 19 2017 06:40
@Masd925 i meant to tag you XD
sudip chhetri
@SudipChhetri
Apr 19 2017 06:40
@forwebtech yap
Ming Zhu
@chocobrownie
Apr 19 2017 06:41
what is your "val"? @UnovaXan
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:41
@SudipChhetri you have define this onclick = "sessionInterval();" in your start button, but where did you make this function ??
Sandesh Shrestha
@UnovaXan
Apr 19 2017 06:41
val is the arguments other than the arr
Heathercoraje
@Heathercoraje
Apr 19 2017 06:41

@Masd925 here goes my code
```
function wave(str){
var len = str.length;
var result = new Array(len).fill(str);

for (var i = 0; i < result.length; i++) {
return result[i[i]].toUpperCase();
}
}

```
function wave(str){
 var len = str.length;
 var result = new Array(len).fill(str);

 for (var i = 0; i < result.length; i++) {
 return result[i[i]].toUpperCase();
 }
  // Code here
}
Shashank Shekhar
@ashwamegh
Apr 19 2017 06:41
@UnovaXan Why are u using arguments ..
Ming Zhu
@chocobrownie
Apr 19 2017 06:42
You need to give it a value in order to call back a true of false result
Shashank Shekhar
@ashwamegh
Apr 19 2017 06:42
it will create an array like this.. arguments = [[arr]]; @UnovaXan
Heathercoraje
@Heathercoraje
Apr 19 2017 06:43
@Masd925 Are you with me?
Sandesh Shrestha
@UnovaXan
Apr 19 2017 06:43
@shashank7200 because there is no other way to access the arguments passed in this one
Markus Kiili
@Masd925
Apr 19 2017 06:43
@Heathercoraje Yeah. I will check it.
Heathercoraje
@Heathercoraje
Apr 19 2017 06:43
@Masd925 Thx
CamperBot
@camperbot
Apr 19 2017 06:43
heathercoraje sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3872 | @masd925 |http://www.freecodecamp.com/masd925
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:43
@SudipChhetri your scripting is really complicated due to the repetitions, first make it clear and try to make it again and refactor your code please
Shashank Shekhar
@ashwamegh
Apr 19 2017 06:43
you can use ES6 syntax function(...arr, a, b ) @UnovaXan
Markus Kiili
@Masd925
Apr 19 2017 06:43
@Heathercoraje Don't return inside the loop. It will only loop once then.
sudip chhetri
@SudipChhetri
Apr 19 2017 06:44
@forwebtech ok and thanks after sometime I will return back
CamperBot
@camperbot
Apr 19 2017 06:44
sudipchhetri sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 181 | @forwebtech |http://www.freecodecamp.com/forwebtech
Heathercoraje
@Heathercoraje
Apr 19 2017 06:44
true.
let me take that out.
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:44
No Problem !
Markus Kiili
@Masd925
Apr 19 2017 06:45
@Heathercoraje Strings are immutable, so you cannot change one character to uppercase. Make a new string from the original that has the character changed and assign it back to the array.
Manish Giri
@Manish-Giri
Apr 19 2017 06:46
try another approach - use indexOf to push values into an array and return that array
Sandesh
Heathercoraje
@Heathercoraje
Apr 19 2017 06:47
@Masd925 @Manish-Giri let me try for a sec.
Markus Kiili
@Masd925
Apr 19 2017 06:47
@Heathercoraje So result[i] = ... <- construct the changed string here.
Jake
@JakeDVirus
Apr 19 2017 06:50
shall i have to pass event as argument explicitly in event listener like function(event) to access the event object's properties or the argument eventis automatically passed implicitly under the hood, because when i tried to access the event object property without passing event as argument like this function(){alert(event.type)} it did worked.
so is it necessary to pass the eventas argument?
Dan Couper
@DanCouper
Apr 19 2017 06:50
Yes, you need the argument otherwise that parameter is undefined
Markus Kiili
@Masd925
Apr 19 2017 06:51
@NeelDVirus event is a parameter of that function expression. Event object is automatically passed as an argument to that function.
Dan Couper
@DanCouper
Apr 19 2017 06:52
^ yeah, i realised that as soon as i typed the above, ignore mine
Jake
@JakeDVirus
Apr 19 2017 06:53
@Masd925 yeah i know event is just a parameter. so event.type and ev.type is same. But if event object is passed automatically then what's the logical need to pass the event explicity like function(e)
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:54
is event in writing, is equivalent to e ??
Markus Kiili
@Masd925
Apr 19 2017 06:54
@NeelDVirus I think you need to write the parameter in order to use the event object.
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:54
sometimes e is used in the parameter of a function, that stores the event object !
sudip chhetri
@SudipChhetri
Apr 19 2017 06:56
@forwebtech are you there
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:56
@SudipChhetri yes ?
sudip chhetri
@SudipChhetri
Apr 19 2017 06:57
@forwebtech now my bminus is not working
Markus Kiili
@Masd925
Apr 19 2017 06:57
@NeelDVirus That event you use with event.typewithout using the parameter will be window.event. It might work with some browsers, but is not reliable.
Dan Couper
@DanCouper
Apr 19 2017 06:58
@NeelDVirus prevention of default behaviour and event bubbling. To access the event object. To give it a name (e l, myEvent, someClickEvent, whatever). Also because implied/implicit parameters are not great.
Aizaz Shahid
@aizazshahid
Apr 19 2017 06:58
@SudipChhetri still start button isn't working ??
sudip chhetri
@SudipChhetri
Apr 19 2017 06:58
I have commented all other code
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:00
where you apply that function ??
on which tag ??
sudip chhetri
@SudipChhetri
Apr 19 2017 07:00
in break minus
minus of break length
Jake
@JakeDVirus
Apr 19 2017 07:01
@Masd925 can yo ugive a specific instance where the need of passing argument is logically needed, i mean any context where event object wont be accessed; Anything like that which can differentiate it logically and stringly
sudip chhetri
@SudipChhetri
Apr 19 2017 07:01
@forwebtech assigining in the variable doesn't works
Jake
@JakeDVirus
Apr 19 2017 07:01
@DanCouper do you mean preventDefault() wont work without passing the argument/parameter?
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:02
ok am checking !
Markus Kiili
@Masd925
Apr 19 2017 07:02
@NeelDVirus When you need to use the event object that has information about the event and the element event was happened upon.
Ivo Tsolov
@ivoTsolov
Apr 19 2017 07:02
hello people
nice to see you around
sudip chhetri
@SudipChhetri
Apr 19 2017 07:03
@forwebtech sorry now it is working
Markus Kiili
@Masd925
Apr 19 2017 07:03
@NeelDVirus Reliable way to use that event object is to write a parameter on the event handler, and use that parameter inside the callback function.
Ivo Tsolov
@ivoTsolov
Apr 19 2017 07:03
is anyone going to learn node.js ?
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:03
@SudipChhetri you have forgot to terminate the comment */
at the end, i have checked your function it is printing in console
sudip chhetri
@SudipChhetri
Apr 19 2017 07:04
@forwebtech yes i found it
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:05
@SudipChhetri it is working here:
bminus.onclick = function(){
  console.log("231");
}
i think your code in it something wrong
sudip chhetri
@SudipChhetri
Apr 19 2017 07:06
@forwebtech plz suggest me
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:06
now its working fine !
bminus.onclick = function(){

  if(btext.value>1){
    btext.value = btext.value - 1;
  }

}
try to check it
@SudipChhetri also when you are dealing with JS, open you console by ctrl+shift+k (key in firefox), for errors
Dan Couper
@DanCouper
Apr 19 2017 07:07
@NeelDVirus yup, that is normally the canonical example. And another easy way to see the behaviour if you put an event handler on a an element - like a div with a few buttons in - then try to change the behaviour depending on which button is clicked, you need the event object to access that properly
sudip chhetri
@SudipChhetri
Apr 19 2017 07:08
@forwebtech ok
@forwebtech thanks
CamperBot
@camperbot
Apr 19 2017 07:10
sudipchhetri sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:warning: sudipchhetri already gave forwebtech points
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 07:10
@Masd925 what you think of this for @Heathercoraje challenge thing https://repl.it/HPW3
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:10
@SudipChhetri You're welcome !
Ashton
@Electrixz05
Apr 19 2017 07:10
Can someone help me out with "Accessing Objects Properties with the Dot Operator"?

// Setup
var testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats"
};

// Only change code below this line

var hatValue = testObj; // Change this line
var shirtValue = testObj; // Change this line

Aizaz Shahid
@aizazshahid
Apr 19 2017 07:10
@Electrixz05 yes !
Ashton
@Electrixz05
Apr 19 2017 07:10
Read in the property values of testObj using dot notation. Set the variable hatValue equal to the object property hat and set the variable shirtValue equal to the object property shirt.
want link?
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:11
@Electrixz05 use like that testObj.hat and testObj.shirt respectively
Markus Kiili
@Masd925
Apr 19 2017 07:11
@HeebieGeeBee Yes, that is better than using fill.
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 07:11
was trying to think how to refactor it, but its too early
Ashton
@Electrixz05
Apr 19 2017 07:12
@forwebtech what about the Value?
ROBUSTO8
@ROBUSTO8
Apr 19 2017 07:12

have a question just poking around the "Seek and Destroy" challenge and I don't understand something:

function destroyer(arr) {
function x(value){
return value !== arguments[1];
}
return arr.filter(x);
}

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

why does this return [1,2,3,1,2,3] instead of [1,3,1,3]? arguments[1] should = 2 no? if i replace arguments[1] with "2" the return is [1,3,1,3] what's going on here?

Aizaz Shahid
@aizazshahid
Apr 19 2017 07:12
@Electrixz05 you got me there :) also use .value or either it will put the object there
Ashton
@Electrixz05
Apr 19 2017 07:12
@forwebtech Oh Never Mind
@forwebtech Thanks
CamperBot
@camperbot
Apr 19 2017 07:12
electrixz05 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 191 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:12
@Electrixz05 You're welcome !
Ashton
@Electrixz05
Apr 19 2017 07:13
;D
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 07:13
still a nice little challenge to wake up the mind i guess
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:13
@ROBUSTO8 you cant make functions in nesting but you can call them there !
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 07:13
not that it really has, still need more coffee
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:14

@ROBUSTO8

function first() {

}

function second() {
  first();
}

that is the nesting

Jake
@JakeDVirus
Apr 19 2017 07:14

@DanCouper @Masd925

i just found some strange behaviour. strange because i could not reconcile it.

1: This code work

function(){event.preventDefault()}

2: This code dont work

function(){eve.preventDefault()}

3: again This code work

function(eve){eve.preventDefault()}

Whats going under the hood?

Aizaz Shahid
@aizazshahid
Apr 19 2017 07:14
@NeelDVirus event is the correct keyword in JS
like global variable !
and the third one is argument !
you can name it whatever you have to !
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 07:15
you can use just e aswell i believe
ROBUSTO8
@ROBUSTO8
Apr 19 2017 07:15
thanks @forwebtech
CamperBot
@camperbot
Apr 19 2017 07:15
robusto8 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 192 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:15
@ROBUSTO8 yes ! Welcome !
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 07:16
i think in the 3rd one youre just giving the event argument a custom name
Jake
@JakeDVirus
Apr 19 2017 07:16
@forwebtech then why did it worked in no.3
if number3 worked because i passed the argument then again i dint passed the argument in number 1 but still that work. now why's that?
Markus Kiili
@Masd925
Apr 19 2017 07:16
@NeelDVirus The parameter name can be about anything. It will contain the event object when the callback is executed. Without a parameter, event points to window.event and the code works on some browsers.
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:17
@NeelDVirus event is an object that is called when something happens :)
like document
Jake
@JakeDVirus
Apr 19 2017 07:17
@HeebieGeeBee i know i could pass even e as well. but it depends on arguments i am passing then in number1 i dint passed any argument but still it worked
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:17
but you can also pass document as an argument !
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 07:18
@NeelDVirus what @Masd925 said it basically inherits it
if thats the right word
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:18
here
function myFunc(doc) {
doc.write("abcd");
}

myFunc(document);
Markus Kiili
@Masd925
Apr 19 2017 07:19
@NeelDVirus You are not passing anything. You are defining a function expression with possibly some parameters. Passing of arguments happens under the hood when the event fires and the function is executed. Event object is passed into the function as first argument, and stored on the first parameter you defined what ever its name is.
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:19
i don't know it will practically work, but conceptually it should to be worked
Jake
@JakeDVirus
Apr 19 2017 07:20
@forwebtech yeah i also found that event is passed automatically but then why is the need of passing the argument if without passing can do fine alone.
@HeebieGeeBee in this i am counting on you also man
Julio Roman
@jroman123
Apr 19 2017 07:20
function destroyer(arr) {
  var args = Array.prototype.slice.call(arguments);
  args.splice(0,1);

return arr.filter(function (task) {
   return args.indexOf(task)===-1;
});

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
On the args. splice(0,1) is returning 2 & 3.
Isn't (0,1) supposed to be splicing index 0 and 1?
And if yes shouldn't needed to be args.splice(1,2); ???
Please explain.
Markus Kiili
@Masd925
Apr 19 2017 07:21
@jroman123 Splice mutates the args array by removing the first element.
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 07:21
@NeelDVirus listen to @Masd925 he knows far more than i do, but i think just its what event listeners callbacks have as their default arguments
Jake
@JakeDVirus
Apr 19 2017 07:23
@Masd925 can you forward me some links where this context is well explained where i can help myself to understand..
Markus Kiili
@Masd925
Apr 19 2017 07:24
@NeelDVirus If you use event without event parameter, you are using window.event global variable, and that is not reliable way to use the event object.
Jake
@JakeDVirus
Apr 19 2017 07:24
@HeebieGeeBee oh thank man. i am gona have a look to it
CamperBot
@camperbot
Apr 19 2017 07:24
neeldvirus sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1386 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Julio Roman
@jroman123
Apr 19 2017 07:25
@Masd925 so by creating the Array.prototype.slice.call(arguments); and later the splice it basically mutates to reverse the normal operation of the splice method?
Jake
@JakeDVirus
Apr 19 2017 07:26
@Masd925 oh that means if i pass eas event parameter then then event object is reference by e , or else it is referenced by windows.event... am i close to it??
Markus Kiili
@Masd925
Apr 19 2017 07:26
@jroman123 Splice mutates the array in place and returns an array of removed elements.
Julio Roman
@jroman123
Apr 19 2017 07:27
@Masd925 Ok no wonder it also worked with 0,0...
@Masd925 Thanks bro
CamperBot
@camperbot
Apr 19 2017 07:27
jroman123 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3873 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Apr 19 2017 07:27
@NeelDVirus If you wan't to use the event object, define a parameter on the event handler and use it. Using event without an event parameter is not reliable.
Jake
@JakeDVirus
Apr 19 2017 07:29
@Masd925 ok thank man.. i am getting on it!! if you have any other links which you think ll be helpfull then please forward it. i ll really appreciate that. well i am going to checkout the link you already sent
CamperBot
@camperbot
Apr 19 2017 07:29
neeldvirus sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3874 | @masd925 |http://www.freecodecamp.com/masd925
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:30
@Masd925 Why is it windows.event not reliable ?
Markus Kiili
@Masd925
Apr 19 2017 07:31
@forwebtech I believe it only works on some browsers, but not all.
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 07:31
i think firefox has an issue with it not being defined in the parameter
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:31
some compatibility issue ?
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 07:32
well thats the oneive had problems with before
or maybe firefox is ok with e but not with event
if its not declared
some wierd shit
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:33
why all the browsers can't use one rendering engine ! any technical reason ?
Markus Kiili
@Masd925
Apr 19 2017 07:34
@forwebtech window.event is a non-standard feature, so should not be used.
Jake
@JakeDVirus
Apr 19 2017 07:35
@HeebieGeeBee oh yeah i also discovered that now. in firefox the argument needs to be defined exlicity to work with event object. Thanks ..
CamperBot
@camperbot
Apr 19 2017 07:35
neeldvirus sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: neeldvirus already gave heebiegeebee points
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:35
thanks for that , @Masd925 @HeebieGeeBee
CamperBot
@camperbot
Apr 19 2017 07:35
forwebtech sends brownie points to @masd925 and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1387 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:star2: 3875 | @masd925 |http://www.freecodecamp.com/masd925
sudip chhetri
@SudipChhetri
Apr 19 2017 07:39
@forwebtech are you there
Markus Kiili
@Masd925
Apr 19 2017 07:41
@forwebtech Browser makers wan't everyone to use their browser. So money is the reason.
my button is not still woking @forwebtech
jmfrancia17
@jmfrancia17
Apr 19 2017 07:44
Need Help it should show as
FirstLine
\SecondLine\
ThirdLine

this is my code var myStr; // Change this line

myStr = "FirstLine \n \SecondLine\ \rThirdline";

can't seem to make it work

HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 07:45
@jmfrancia17 no spaces
is there anyways in which git bash is better than power shell? @Masd925
Markus Kiili
@Masd925
Apr 19 2017 07:49
@HeebieGeeBee Don't know too much about that.
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 07:49
fair enough
@jmfrancia17 also check your case sensitivity
ThirdLine*
Travis Bryant
@t-bryant
Apr 19 2017 07:51
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
kind of need help with this...not sure what is wrong with my code...I know I need something about the props in the if, just not sure what
HeebieGeeBee
@HeebieGeeBee
Apr 19 2017 07:53
@t-bryant well be good to look through the contacts array in some way
and the hasownproperty method just returns a boolean expression
@t-bryant and in he future its not really needed to paste all the contacts, just the code of the function youreworking on
jmfrancia17
@jmfrancia17
Apr 19 2017 07:55
@HeebieGeeBee tried that still not working
@HeebieGeeBee This are my errors. myStr should have two correctly escaped backslash characters \
and myStr should have encoded text with the proper escape sequences and no spacing.
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:57
@SudipChhetri back
still facing ?
Spyrantis Theodoros
@thodorisanta
Apr 19 2017 07:58
hey guys, so im doing the tic tac toe project with a table and im having trouble building the win() function which will return true when the table has a win combo with either X's or O's. now they win combos for an [1,2,3 || 4,5,6 || 7,8,9] table are : [1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 4, 7], [2, 5, 8], [3, 6, 9], [1, 5, 9], [7, 5, 3] but! i dont know how i will make my table cells to represent a number and how with that i can later check if those win combos have the same values(X or O) :/ any help?
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:59
@t-bryant ??
Travis Bryant
@t-bryant
Apr 19 2017 07:59
yes @forwebtech ?
Aizaz Shahid
@aizazshahid
Apr 19 2017 07:59
@t-bryant i can tell you the concept then try it to yourself
Travis Bryant
@t-bryant
Apr 19 2017 08:00
ok
Aizaz Shahid
@aizazshahid
Apr 19 2017 08:00
first you have to check the name
Carl Tamayo
@tanotamayo
Apr 19 2017 08:01
@t-bryant for loop and if statement thats the clue i can give you :)
Aizaz Shahid
@aizazshahid
Apr 19 2017 08:01
if you found that in the array then check the property is available or not
now you have to know something that, if the name will not find then checking the property is waste , so obviously then it should print ' Name not found '
first try to use these concepts then i will tell you!
just one hint don't check firstname with property
Damaris Muange
@ndush
Apr 19 2017 08:05
Add ["Paul",35] to the beginning of the myArray variable usi