These are chat archives for FreeCodeCamp/HelpJavaScript

24th
May 2017
Keon Samuel
@keonsam
May 24 2017 00:00
no
it don't work like that .push adds a new item to the existing array.
Manish Giri
@Manish-Giri
May 24 2017 00:01
@frentea you should review the docs on MDN
it mentions what every function returns
Jessie Wong
@frentea
May 24 2017 00:01
ok I'll do that
how about .shift() it returns a number or an array?
Manish Giri
@Manish-Giri
May 24 2017 00:02
it returns the deleted element
Jessie Wong
@frentea
May 24 2017 00:02
ok I see
john94
@lpy1994
May 24 2017 00:02
@Manish-Giri help me take a look at this challenge.
Ken Haduch
@khaduch
May 24 2017 00:03
@DavidMillerFL - yes, the scope of those function parameters is local to the function.
Manish Giri
@Manish-Giri
May 24 2017 00:04
maybe @khaduch can help you with that, @lpy1994
john94
@lpy1994
May 24 2017 00:04
@khaduch take a look at that challenge when you have a chance ?
Fady safwat
@fadySWHS
May 24 2017 00:08
@lpy1994

function palindrome(str) {
// Good luck!
str=str.toLowerCase();
var cleanstr = str.replace(/\W/g,"").replace(/\s+/g,"");
var cleanstr2 = str.replace(/\W/g,"").replace(/\s+/g,"");
cleanstr2=cleanstr2.split("");
cleanstr=cleanstr.split("");
cleanstr2.reverse();
if(cleanstr === cleanstr2){
return true;}
else {return false;}
}

palindrome("eye");

Hiro
@vineethkamisetty
May 24 2017 00:12
can anyone help me with Record Collection challenge?
Diego Mayer
@Chrono79
May 24 2017 00:36
@fadySWHS \s is already included in \W
You can't compare arrays directly like that
@vineethkamisetty show your function
Hiro
@vineethkamisetty
May 24 2017 00:46
@Chrono79
function updateRecords(id, prop, value) {
return collection[id][prop];
}
but in output console, its showing complete collection
Diego Mayer
@Chrono79
May 24 2017 00:52
@vineethkamisetty don't mind the output (it's custom tailored for that challenge)
try your code in repl.it or someplace like that
Also, in the instructions: Your function must always return the entire collection object.
Humberto Villarino
@HumbertoVillarino
May 24 2017 01:01
I'm working in the "Comparison with the Strict Equality Operator"
I'm using === that operator
Hiro
@vineethkamisetty
May 24 2017 01:01
@Chrono79 yes, but i was just testing to what it returns for that, but was surprised to see complete collection instead of just one object
Diego Mayer
@Chrono79
May 24 2017 01:01
@HumbertoVillarino one of the easy ones, what's the problem?
dyon3334
@dyon3334
May 24 2017 01:01
can someone tell me what imdoing wrong var myStr ="I am a \"double quoted \"string inside \"double quotes\".\";
Humberto Villarino
@HumbertoVillarino
May 24 2017 01:02
When I click Run Tests, there are 4 conditions that ahve to be fullfilled
Diego Mayer
@Chrono79
May 24 2017 01:02
@dyon3334 the last double quote shouldn't be escaped and check the spaces position
Humberto Villarino
@HumbertoVillarino
May 24 2017 01:02
The last one says "You should use the === operator
Diego Mayer
@Chrono79
May 24 2017 01:02
@HumbertoVillarino show your code
Humberto Villarino
@HumbertoVillarino
May 24 2017 01:02

function testStrict(val) {
if ((val) === 7) { // Change this line
return "Equal";
}
return "Not Equal";
}

// Change this value to test
testStrict(7);

dyon3334
@dyon3334
May 24 2017 01:03
@Chrono79 thanks
CamperBot
@camperbot
May 24 2017 01:03
dyon3334 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4089 | @chrono79 |http://www.freecodecamp.com/chrono79
Humberto Villarino
@HumbertoVillarino
May 24 2017 01:03
But I don't understand why I don't get a right answer on that if I'm using that operator
Trakra
@trgme
May 24 2017 01:03
anyone have minute to help me with parseInt() function - almost finished, I’ve been stumped for over an hour...
Humberto Villarino
@HumbertoVillarino
May 24 2017 01:04
I know it sounds really very easy, but I don't get my error. Sorry...
Diego Mayer
@Chrono79
May 24 2017 01:04
@HumbertoVillarino remove the parentheses around val
Alex
@alextran1502
May 24 2017 01:04
Hello. Can anyone look at this Profile Lookup challenge and let me know what I did wrong? The output keep going straight to the "else-if" statement even thought the variables are in the scope of contact
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUpProfile("Sherlock", "number");
Humberto Villarino
@HumbertoVillarino
May 24 2017 01:05
@Chrono79 could you explain me why the parenthesis make that comparison to fail?
Diego Mayer
@Chrono79
May 24 2017 01:06
@HumbertoVillarino they shouldn't maybe it's a quirk in the test
Humberto Villarino
@HumbertoVillarino
May 24 2017 01:06
Anyway, thanks @Chrono79 because now it works!!
CamperBot
@camperbot
May 24 2017 01:06
:star2: 4090 | @chrono79 |http://www.freecodecamp.com/chrono79
humbertovillarino sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Diego Mayer
@Chrono79
May 24 2017 01:06
@alextran1502 you shouldn't return no such contact at the first mismatch
Alex
@alextran1502
May 24 2017 01:07
@Chrono79 Why is that?
Diego Mayer
@Chrono79
May 24 2017 01:07
You should keep looking, don't you?
The contact you look for could be the any of the other contacts in the list
Alex
@alextran1502
May 24 2017 01:09
@Chrono79 thanks for the hint, I will keep thinking!
CamperBot
@camperbot
May 24 2017 01:09
alextran1502 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4091 | @chrono79 |http://www.freecodecamp.com/chrono79
Ken Haduch
@khaduch
May 24 2017 01:10
@lpy1994 - I have a basic version that works for small numbers, but not for larger numbers. I have to reorganize my function and have it generate prime numbers up to the limit needed.
Trakra
@trgme
May 24 2017 01:20
@alextran1502 fwiw, my IDE will let me know if error in JS code. or, you can validate syntax at [title]http://www.jslint.com - helps me troubleshoot..
dyon3334
@dyon3334
May 24 2017 01:20
please tell me what im doing wrong
var myStr="FirstLine\SecondLine\\r\ThirdLine"
myStr should have encoded text with the proper escape sequences and no spacing.
myStr should have one newline character \n
myStr should have one carriage return character \r
myStr should have two correctly escaped backslash characters \
Hiro
@vineethkamisetty
May 24 2017 01:22
@Chrono79 thanks!! repl.it is showing proper output compared to fcc. trying in it now!!
CamperBot
@camperbot
May 24 2017 01:22
vineethkamisetty sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4092 | @chrono79 |http://www.freecodecamp.com/chrono79
dyon3334
@dyon3334
May 24 2017 01:24
@Chrono79 can you help me ?
Diego Mayer
@Chrono79
May 24 2017 01:24
@dyon3334 where is your \n?
Use the last line as a template
dyon3334
@dyon3334
May 24 2017 01:25
@Chrono79 this line var myStr="FirstLine\SecondLine\r\ThirdLine"
Diego Mayer
@Chrono79
May 24 2017 01:26
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
Masaki
@masaki1223
May 24 2017 01:26

var currentWeather, lat,lon;


function getWeather(){
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
     lat=position.coords.latitude;
     lon=position.coords.longitude;
  })
}}
  $.ajax({
      type:'GET',
      dataType:'json/application',
url:'http://api.openweathermap.org/data/2.5/weather?'+lat+'&'+lon+'&appid=033902a8c189a32e8fb8bebab90',
      success:function(response){
        console.log('success');
      }
    })



getWeather();
Any help in how to get ajax? Why this doesn't work?
Diego Mayer
@Chrono79
May 24 2017 01:27
@masaki1223 lon and lat aren't defined when you call the ajax, put the ajax call inside the getCurrentPosition function
Unless you use Firefox you'll have troubles getting the location and accessing openweather api (in Chrome you should use https in codepen and openweather works with http)
dyon3334
@dyon3334
May 24 2017 01:27
@Chrono79 thanks a lot !!
CamperBot
@camperbot
May 24 2017 01:27
dyon3334 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: dyon3334 already gave chrono79 points
Crizkrozz
@Crizkrozz
May 24 2017 01:30

Could someone take a look at my Golf Code, Im stuck at the double bogey, where I put golfScore(4,6) and the console says Double bogey but its not checked off :
function golfScore(par, strokes) {
// Only change code below this line
if (strokes<2) { return "Hole-in-one!"; } else if (strokes <=par-2){ return "Eagle"; } else if (strokes==par-1){ return "Birdie"; } else if (strokes==par){ return "Par"; } else if (strokes==par + 1){ return "Bogey"; } else if (strokes==par + 2){ return " Double Bogey"; } else if (strokes >= par + 3){
return "Go Home!";
}

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

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

dyon3334
@dyon3334
May 24 2017 01:31
@Chrono79 still i dont get it working var myStr= "FirstLine\n\SecondLine\\rThirdLine"
Nazar Maksymchuk
@MANTENN
May 24 2017 01:31
@dyon3334 you need to have two backslashes, one is a escape the other is the slash
so \\ would be one backslash \
Ken Haduch
@khaduch
May 24 2017 01:32
@dyon3334 - if you post your code and surround it with backquotes, `your code here` - it will make it better for reading, because the browser will interpret double backslashes, etc.
Diego Mayer
@Chrono79
May 24 2017 01:32
@MANTENN try quoting him, you'll see it's ok
Nazar Maksymchuk
@MANTENN
May 24 2017 01:33
@Chrono79 ok
Diego Mayer
@Chrono79
May 24 2017 01:33
@dyon3334 try refreshing the browser, and add the semicolon at the end
Luke Sallmen
@LukeSallmen
May 24 2017 01:33
@Crizkrozz Your return statement for Double Bogey has an extra space at the beginning
Ashcon313
@Ashcon313
May 24 2017 01:33
Having trouble with Nesting For Loops

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

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



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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Luke Sallmen
@LukeSallmen
May 24 2017 01:33
{ return " Double Bogey"; }
dyon3334
@dyon3334
May 24 2017 01:33
@MANTENN @khaduch @Chrono79 okay thanks i will try
CamperBot
@camperbot
May 24 2017 01:33
dyon3334 sends brownie points to @mantenn and @khaduch and @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: dyon3334 already gave chrono79 points
:cookie: 206 | @mantenn |http://www.freecodecamp.com/mantenn
:star2: 2907 | @khaduch |http://www.freecodecamp.com/khaduch
Ashcon313
@Ashcon313
May 24 2017 01:34
why does my loop keep returning 1
Diego Mayer
@Chrono79
May 24 2017 01:34
@Ashcon313 your array is arr, not product
Ken Haduch
@khaduch
May 24 2017 01:34
@Crizkrozz - you appear to have an extra space in your " Double Bogey" at the start of the string?
Ashcon313
@Ashcon313
May 24 2017 01:34
I tried that @Chrono79 but it didn't work again
aRtoo
@artoodeeto
May 24 2017 01:34
hi guys, i have some problem. i think ive solved the problem and its returning the correct values of array but i still get wrong but no errors. the challenge is return largest number in arrays.
heres my code:
```
Diego Mayer
@Chrono79
May 24 2017 01:35
@Ashcon313 you should actually modify product value inside the loops
Crizkrozz
@Crizkrozz
May 24 2017 01:35
@khaduch thanks!
CamperBot
@camperbot
May 24 2017 01:35
crizkrozz sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2908 | @khaduch |http://www.freecodecamp.com/khaduch
aRtoo
@artoodeeto
May 24 2017 01:35
hi guys, i have some problem. i think ive solved the problem and its returning the correct values of array but i still get wrong but no errors. the challenge is return largest number in arrays.
heres my code:

var newArr= [];
function largestOfFour(arr) {

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

        var highNum = (Math.max.apply(null,arr[c]));
         newArr.push(highNum);


     // }
    }



  return newArr;
}

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
//should return [27,5,39,1001].
Luke Sallmen
@LukeSallmen
May 24 2017 01:35
@Ashcon313 You need to return product[i][j], not console.log it
I think.
Diego Mayer
@Chrono79
May 24 2017 01:35
@LukeSallmen no, he should return product outside the loops, but change its value before
Luke Sallmen
@LukeSallmen
May 24 2017 01:35
oh @Chrono79 is right
Ashcon313
@Ashcon313
May 24 2017 01:35
Okay thank you @Chrono79 @LukeSallmen
CamperBot
@camperbot
May 24 2017 01:35
ashcon313 sends brownie points to @chrono79 and @lukesallmen :sparkles: :thumbsup: :sparkles:
:cookie: 261 | @lukesallmen |http://www.freecodecamp.com/lukesallmen
:star2: 4093 | @chrono79 |http://www.freecodecamp.com/chrono79
Ashcon313
@Ashcon313
May 24 2017 01:35
yeah thats what Im trying
Luke Sallmen
@LukeSallmen
May 24 2017 01:35
but he needs to change it
inside the loop also
correct?
Diego Mayer
@Chrono79
May 24 2017 01:36
@Ashcon313 you've seen *= haven't you?
@artoodeeto don't use globals, they keep their values between tests
aRtoo
@artoodeeto
May 24 2017 01:37
@Chrono79 wait what??
@Chrono79 my newArr = [];??
Nazar Maksymchuk
@MANTENN
May 24 2017 01:37
@artoodeeto newArr is defined outside the function
Diego Mayer
@Chrono79
May 24 2017 01:37
@artoodeeto yes, move it inside the function
Ashcon313
@Ashcon313
May 24 2017 01:37
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++);
    } 



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

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

function multiplyAll(arr) {
var product = 1;
// Only change code below this line

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

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

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

```

so keep that though correct?
aRtoo
@artoodeeto
May 24 2017 01:37
@Chrono79 like why bro??
Masaki
@masaki1223
May 24 2017 01:37
@Chrono79


function getWeather(){
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
     var lat=position.coords.latitude;
     var lon=position.coords.longitude;

  $.ajax({
      type:'GET',
      dataType:'json/application',
url:'https://api.openweathermap.org/data/2.5/weather?'+lat+'&'+lon+'&appid=033902a8c189a32e8fb8bebab90',
      success:function(response){
        console.log('success');
      }
    })

    })
}}



getWeather();
Is there any problem still? It doesn't work yet. I'm using Chrome.
Diego Mayer
@Chrono79
May 24 2017 01:38
@artoodeeto I just told you why, when the next test is run, your array already has values inside
aRtoo
@artoodeeto
May 24 2017 01:39
@Chrono79 yea but the value is incomplete because it didnt finish the loop yet
Diego Mayer
@Chrono79
May 24 2017 01:39
@masaki1223 it won't work, openweather doesn't have https support
aRtoo
@artoodeeto
May 24 2017 01:39
@Chrono79 it the same as you put in inside the loop
Diego Mayer
@Chrono79
May 24 2017 01:40
@artoodeeto https://repl.it/HxQn/1 it isn't the same, each time you run a test, 4 new values are added, if you don't reset the array (or make it an empty one declaring it local), your array grows with each test
@masaki1223 you have to use a proxy for instance for that, check https://crossorigin.me
Ashcon313
@Ashcon313
May 24 2017 01:42
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 += [i][j];  
  } 



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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Still need help with this
How do I make the numbers multiply
Diego Mayer
@Chrono79
May 24 2017 01:43
@Ashcon313 *=, not += and what is [i][j]?
Ashcon313
@Ashcon313
May 24 2017 01:43
The product I want?
I had no idea
Diego Mayer
@Chrono79
May 24 2017 01:43
no
aRtoo
@artoodeeto
May 24 2017 01:43
@Chrono79 hey bro why is it not duplicating my array. but we the same code.
Diego Mayer
@Chrono79
May 24 2017 01:43
you have to use arr
Ashcon313
@Ashcon313
May 24 2017 01:43
@Chrono79 Then I get 1 my friend!
Diego Mayer
@Chrono79
May 24 2017 01:44
no, you need to use arr and [i][j]
aRtoo
@artoodeeto
May 24 2017 01:44
@Chrono79 idid bro. we have the same code.

var newArr= [];
function largestOfFour(arr) {

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

        var highNum = (Math.max.apply(null,arr[c]));
         newArr.push(highNum)

     // }
    }



  return newArr;
}

//largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]) 
//return [27,5,39,1001].
Ashcon313
@Ashcon313
May 24 2017 01:44
arr *= [i][j]
Diego Mayer
@Chrono79
May 24 2017 01:44
no
aRtoo
@artoodeeto
May 24 2017 01:44
@Chrono79 nevermind bro i saw whats the problem
Ashcon313
@Ashcon313
May 24 2017 01:44
@Chrono79 How do I assign arr[I][j] to give me a product
Diego Mayer
@Chrono79
May 24 2017 01:45
product *= arr[i][j];
Gulsvi
@gulsvi
May 24 2017 01:45
@artoodeeto Put var newArr = []; inside your function.
(I don't know why the challenge requires that)
aRtoo
@artoodeeto
May 24 2017 01:45
@SkyyCoder i did bro. but i dont know whats the reason
Ashcon313
@Ashcon313
May 24 2017 01:45
Oh hence the *
Diego Mayer
@Chrono79
May 24 2017 01:45
@SkyyCoder @artoodeeto one more time...
The global vars keep their value between test, your array keeps growing, didn't you see it here? https://repl.it/HxQn/1
aRtoo
@artoodeeto
May 24 2017 01:45
@SkyyCoder but im correct??
Ashcon313
@Ashcon313
May 24 2017 01:45
@Chrono79 Still null...
Cynwenn
@Cynwenn
May 24 2017 01:46
I'm trying to do the following with the function but it's not working.
Does someone have ideas to fix this please?
//add a method to the storeItem object called 'calculateDiscountPrice'
//this method should multiply the storeItem's 'price' and 'discountPercentage' to get the discount
//the method then subtracts the discount from the price and returns the discounted price
function addCalculateDiscountPriceMethod(storeItem) {

    storeItem.calculateDiscountPrice= function (price, discountPercentage) {
        var discount = storeItem.price*storeItem.discountPercentage;
        discount -= storeItem.price;
        return discount;
    };
  //add a method to the storeItem object called 'calculateDiscountPrice'
  //this method should multiply the storeItem's 'price' and 'discountPercentage' to get the discount
  //the method then subtracts the discount from the price and returns the discounted price
  //example:
  //price -> 20
  //discountPercentage -> .2
  //discountPrice = 20 - (20 * .2)
}
Gulsvi
@gulsvi
May 24 2017 01:46
@artoodeeto Yeah, that's correct. Guess it has something to do with the logic of how the tests are run according to @Chrono79
Ashcon313
@Ashcon313
May 24 2017 01:46
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

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

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



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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Having trouble getting this to multiply stuff for me
Diego Mayer
@Chrono79
May 24 2017 01:47
@Ashcon313 your inner loop is wrong at the end, you ended it with ; you should use curly braces to make it a nested loop, see the example code
aRtoo
@artoodeeto
May 24 2017 01:47
@Chrono79 bro its not growing. what do you mean by growing??
Diego Mayer
@Chrono79
May 24 2017 01:48
@artoodeeto it returns: [ 27, 5, 39, 1001, 27, 5, 39, 1001 ]
8 values instead of just 4 (that's growing at least to me)
The next test will return 12 values and so on
Ashcon313
@Ashcon313
May 24 2017 01:48
Jesus Christ
thank you chrono
aRtoo
@artoodeeto
May 24 2017 01:48
@Chrono79 bro because you have 2 parameters. i commented on the other one. try it bro
Diego Mayer
@Chrono79
May 24 2017 01:49
@artoodeeto that's what FCC does, it calls your function several times in a row, not only once, it doesn't reset your global vars for you either
When you make it local, your array starts always empty in each function call, that's why it works then, and not now
moshe18
@moshe18
May 24 2017 01:51
I'm having trouble understanding why I should pick
srry meant - why I should name a function as opposed to doing something like var func = function () { ... }
or if I should do it one way or another
Nazar Maksymchuk
@MANTENN
May 24 2017 01:53
@moshe18 you mean function expression vs function declaration
moshe18
@moshe18
May 24 2017 01:54
yep
Luke Sallmen
@LukeSallmen
May 24 2017 01:55
Does every function have an arguments object? Or is there only one arguments object because arguments are what are passed in rather than params?
Diego Mayer
@Chrono79
May 24 2017 01:56
@LukeSallmen all functions have their own arguments object, check MDN docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
moshe18
@moshe18
May 24 2017 01:57
@MANTENN Thanks!
CamperBot
@camperbot
May 24 2017 01:57
moshe18 sends brownie points to @mantenn :sparkles: :thumbsup: :sparkles:
:cookie: 209 | @mantenn |http://www.freecodecamp.com/mantenn
Luke Sallmen
@LukeSallmen
May 24 2017 02:01
@Chrono79 I guess I asked the wrong question. I read it earlier and it says that every function has an arguments object as a local variable - how can I access another function's arguments object outside of that function?
Debra Gitterman
@DGitterman
May 24 2017 02:01

Can someone share a solution for the Word Blanks exercise? I'm not sure what solution the exercise is looking for. This is not passing: function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) { var result = ""; // Your code below this line myNoun = "dog"; myAdjective = "cool"; myVerb = "swatted"; myAdverb = "disparagingly"; result = "I went to the " + myAdjective + " " + myNoun + " and " + myVerb + " " + myAdverb + "."; // Your code above this line return result; }

// Change the words here to test your function wordBlanks("hat", "obese", "fell", "snakily");

Luke Sallmen
@LukeSallmen
May 24 2017 02:01
Say I have nested functions and want to access the outer function's arguments inside of the inner function
Diego Mayer
@Chrono79
May 24 2017 02:01
@LukeSallmen create an array in the outer function and store the arguments there
aRtoo
@artoodeeto
May 24 2017 02:02
@Chrono79 ohh. ok bro. but if im not gonna use fcc still works fine right??
Luke Sallmen
@LukeSallmen
May 24 2017 02:02
@Chrono79 Tried that and it worked, but I couldn't figure out how to loop through them
@Chrono79 I'm doing the Seek and Destroy Challenge
Diego Mayer
@Chrono79
May 24 2017 02:02
@artoodeeto You'll still have that problem, avoid using globals when they aren't needed, unless your function is only called once
@DGitterman don't overwrite myNoun, etc. They are your function params, if you overwrite them the result will always be the same, no matter what arguments you call your function with
aRtoo
@artoodeeto
May 24 2017 02:04
@Chrono79 aight man. thanks man
CamperBot
@camperbot
May 24 2017 02:04
artoodeeto sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4094 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 24 2017 02:05
:+1:
Debra Gitterman
@DGitterman
May 24 2017 02:05
@Chrono79 , Thank you sooo much!
CamperBot
@camperbot
May 24 2017 02:05
dgitterman sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4095 | @chrono79 |http://www.freecodecamp.com/chrono79
Luke Sallmen
@LukeSallmen
May 24 2017 02:05

function destroyer(arr) {
  // Remove all the values
 var destroyerValues = [];
 for (var i = 1; i < arguments.length; i++) { 
    destroyerValues.push(arguments[i]);
 } 
  var newArr = arr.filter(function(value) { 
    return value != destroyerValues;
  });
  return newArr;

}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
@Chrono79 So I know my problem is the return statement in the arr.filter function
Diego Mayer
@Chrono79
May 24 2017 02:06
@LukeSallmen use indexOf
dyon3334
@dyon3334
May 24 2017 02:06
@Chrono79 can i get your help agian i dont get it right // Example
var myStr;
myStr = "This is the first sentence. ";
myStr += "This is the second sentence.";
'// Example
var myStr;
myStr = "This is the first sentence. ";
myStr += "This is the second sentence.";
'
Diego Mayer
@Chrono79
May 24 2017 02:06
@dyon3334 challenge name?
dyon3334
@dyon3334
May 24 2017 02:07
Concatenating Strings with the Plus Equals Operator
Diego Mayer
@Chrono79
May 24 2017 02:08
@dyon3334 that should work, are you sure you didn't change anything else?
Try refreshing the browser or copy that, reset, paste it and try again
dyon3334
@dyon3334
May 24 2017 02:09
@diego im so stupid i writed it in the example area thanks a lot !!
CamperBot
@camperbot
May 24 2017 02:09
dyon3334 sends brownie points to @diego :sparkles: :thumbsup: :sparkles:
:cookie: 35 | @diego |http://www.freecodecamp.com/diego
dyon3334
@dyon3334
May 24 2017 02:09
and sorry
Diego Mayer
@Chrono79
May 24 2017 02:09
no problem, always pay attention to the comments
dyon3334
@dyon3334
May 24 2017 02:10
@Chrono79 thanks again !!
CamperBot
@camperbot
May 24 2017 02:10
dyon3334 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4096 | @chrono79 |http://www.freecodecamp.com/chrono79
Trakra
@trgme
May 24 2017 02:12
help with 'Basic JavaScript: Use the parseInt Function' challenge in Basic JavaScript? [title]http://beta.freecodecamp.com/en/challenges/basic-javascript/use-the-parseint-function ? I’m pulling hair out..
karthiksagr
@karthiksagr
May 24 2017 02:13
Hi everyone, I'm having trouble with this problem... Any idea?

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.

We have provided a framework for testing your results with different words. The tests will run your function with several different inputs to make sure all of the provided words appear in the output, as well as your extra strings.

Manish Giri
@Manish-Giri
May 24 2017 02:14
@karthiksagr is that word blanks?
Diego Mayer
@Chrono79
May 24 2017 02:14
@karthiksagr Review constructing strings with variables and read mad libs link
Manish Giri
@Manish-Giri
May 24 2017 02:15
@trgme its fairly simple, what's the issue?
karthiksagr
@karthiksagr
May 24 2017 02:15
Yes
Screen Shot 2017-05-22 at 10.39.07 PM.png
Diego Mayer
@Chrono79
May 24 2017 02:15
@karthiksagr use the function parameters: myNoun, etc
Trakra
@trgme
May 24 2017 02:16
I’ve read docs - moz and on Microsoft.. just totally stumped on how to get started… I’ve read wiki… not sure what it is.. brain dead..?
Diego Mayer
@Chrono79
May 24 2017 02:17
@trgme show your code
Manish Giri
@Manish-Giri
May 24 2017 02:17
@trgme it's just a one line answer really
var a = parseInt("007");
Trakra
@trgme
May 24 2017 02:18
oh, thanks @Manish-Giri :-)
CamperBot
@camperbot
May 24 2017 02:18
trgme sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5624 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
May 24 2017 02:18
and the example shows most of it
Trakra
@trgme
May 24 2017 02:19
here’s code:
function convertToInteger(str) {
  var a = parseInt("007");
  var b = parseInt("56");
}
convertToInteger("56");
Manish Giri
@Manish-Giri
May 24 2017 02:21
you need to parse str
the input to your function
Greg Duncan
@GregatGit
May 24 2017 02:23
@trgme you are making a lot of basic errors which we all make at the start - your function needs to return the str it takes in
Trakra
@trgme
May 24 2017 02:23
ok, I’ve read that - but how come 007 passes and not 56?
Greg Duncan
@GregatGit
May 24 2017 02:23
you are not doing anything to the str - that is what you have to change then return
Manish Giri
@Manish-Giri
May 24 2017 02:23
ok, I’ve read that - but how come 007 passes and not 56?
that's just a bad way of their writing the test
you still need to use str
Greg Duncan
@GregatGit
May 24 2017 02:24
@trgme all you have done is created two variables which is not needed
Trakra
@trgme
May 24 2017 02:25
ok.. a nudge? i know not to write several different functions..
Manish Giri
@Manish-Giri
May 24 2017 02:26
@trgme have you not done the JS challenges on the regular site?
Trakra
@trgme
May 24 2017 02:26
@GregatGit @Manish-Giri so, docs show that.. any reference would help (not solution).. just not getting it.
Greg Duncan
@GregatGit
May 24 2017 02:26
@trgme
function convertToInteger(str) {
  var a =  // do something here with str
  return a;
}
Trakra
@trgme
May 24 2017 02:26
yes, I’m almost done with Basic JS…
ok, @GregatGit let me try that - thx.. i think i understand.. i’ll be back :-)
CamperBot
@camperbot
May 24 2017 02:27
trgme sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 850 | @gregatgit |http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
May 24 2017 02:28
@trgme at the start w3schools is a good resource for understanding basic functions, mozilla can be a bit overwhelming
@trgme the function needs to do something with str
Trakra
@trgme
May 24 2017 02:35
@Manish-Giri brownie points to you also :-)
@Manish-Giri thanks
CamperBot
@camperbot
May 24 2017 02:35
trgme sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: trgme already gave manish-giri points
jdaquino
@jdaquino
May 24 2017 02:37
hi!
Im experiecing some issue on my Title Case a Sentence lesson.
I think Ive solved it, but the goals are yet not met.

function titleCase(str) {//"Im a little tea pot"
var array= str.toLowerCase().split(" ");//Im, a, little, tea, pot
var str_final="";

for (var i = 0, array_letras=[];i<array.length;i++){
array_letras= array[i].split(""); //I'm

array_letras[0]=array_letras[0].toUpperCase();
str_final+=array_letras.join("")+ " ";

}
console.log(str_final);
return str_final;
}

titleCase("sHoRt AnD sToUt");

It should return "Short And Stout", and it does on the console.log(), but it doesnt clear the checklist items...
Keon Samuel
@keonsam
May 24 2017 02:40
@media only screen and (max-width: 480px){
  #brand {
    font-size: 16px;
  }
}
can't get that to work with SCSS.
jdaquino
@jdaquino
May 24 2017 02:42
How do I write in code format here?
Caleb Brenner
@cwborion
May 24 2017 02:42

Not sure what I’m missing, but according to the instructins I’ve written this exactly how it said to.

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

function randomWholeNum() {

  // Only change code below this line.

    Math.floor(Math.random() * 10);

  return Math.random();
}

https://www.freecodecamp.com/challenges/generate-random-whole-numbers-with-javascript#?solution=%0Avar%20randomNumberBetween0and19%20%3D%20Math.floor(Math.random()%20*%2020)%3B%0A%0Afunction%20randomWholeNum()%20%7B%0A%0A%20%20%2F%2F%20Only%20change%20code%20below%20this%20line.%0A%0A%20%20%20%20Math.floor(Math.random()%20*%2010)%3B%0A%20%20%0A%20%20return%20Math.random()%3B%0A%7D%0A

Christopher McCormack
@cmccormack
May 24 2017 02:42
@keonsam So you want the element with id #brand to be font-size 16 only when the screen viewport is below 480px?
@jdaquino
```
code
```
Keon Samuel
@keonsam
May 24 2017 02:43
@cmccormack yes
Christopher McCormack
@cmccormack
May 24 2017 02:43
@keonsam did you add <meta name="viewport" content="width=device-width, initial-scale=1"> to your head?
@keonsam and try @media screen and (max-width: 480px) {
Keon Samuel
@keonsam
May 24 2017 02:44
on codepen?
Christopher McCormack
@cmccormack
May 24 2017 02:45
@cwborion you're not returning your Math.floor call above your return. that line is basically doing nothing unless you return it or assign it to a variable then return that variable
@keonsam sure
codepen has a button to do the meta tag for you in the settings
Muhammad Hussain
@ReactorboY
May 24 2017 02:46

function palindrome(str) {
  // Good luck!
  var newStr = str.toLowerCase();

  var againNew = newStr.replace(/[^A-Za-z0-9]/g, '');
  var array = [];
  array = againNew.split("");
  var reArray = array.reverse();
  if(array == reArray){
    return true;
}
  else{
    return false;
  } 
    }


palindrome("eyE 45");
whats wrong I am doing here ?
jdaquino
@jdaquino
May 24 2017 02:47
Hi, Im having problems with the "Title Case A Sentence". According to the console.log(str_final); it already does what is asked, "sHort and StoUt" returns "Short And Stout", capitalized. But the editor doesnt recognizes it.
function titleCase(str) {//"Im a little tea pot"
  var array= str.toLowerCase().split(" ");//Im, a, little, tea, pot
  var str_final="";

  for (var i = 0,  array_letras=[];i<array.length;i++){
    array_letras= array[i].split(""); //I'm

    array_letras[0]=array_letras[0].toUpperCase();
    str_final+=array_letras.join("")+ " ";

  } 
    console.log(str_final);
    return str_final;
}

titleCase("sHoRt AnD sToUt");
Masaki
@masaki1223
May 24 2017 02:47



function getWeather(){
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
     var lat=Math.floor(position.coords.latitude*10000)/10000;
     var lon=Math.floor(position.coords.longitude*10000)/10000;

  $.ajax({
      type:'GET',
      dataType:'json/application',
url:'https://api.darksky.net/forecast/bab04d******99d52a/'+lat+','+lon,
      success:function(response){
        console.log('success');
      }
    })

    })
}}



getWeather();
WHy this is not working?
Caleb Brenner
@cwborion
May 24 2017 02:47
@cmccormack ah I made the mistake of assuming the return was to be left alone how it was written to start. Thanks!
CamperBot
@camperbot
May 24 2017 02:47
cwborion sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 651 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
May 24 2017 02:48
@cwborion np
Manish Giri
@Manish-Giri
May 24 2017 02:48
@trgme :+1:
Christopher McCormack
@cmccormack
May 24 2017 02:49
@masaki1223 check your browser console, you may be running into a CORS issue
@jdaquino you're probably appending one too many spaces to your string
jdaquino
@jdaquino
May 24 2017 02:51
@cmccormack checking...
Christopher McCormack
@cmccormack
May 24 2017 02:51
@jdaquino maybe use .join(" ") instead of appending, outside of your loop
jdaquino
@jdaquino
May 24 2017 02:53
Thnx! I see the problem. Still gonna work on it
@cmccormack Thanks
CamperBot
@camperbot
May 24 2017 02:53
jdaquino sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 652 | @cmccormack |http://www.freecodecamp.com/cmccormack
Abdul Hakim Satria Nusantara
@satrianusantara
May 24 2017 02:55
hi all, i need help
Christopher McCormack
@cmccormack
May 24 2017 02:56
@satrianusantara ask away
Abdul Hakim Satria Nusantara
@satrianusantara
May 24 2017 02:56
i just arrived inhere https://www.freecodecamp.com/challenges/counting-cards, but i dont understand at all. i solved the problem using if else statement, and i think it should be passed this section, but it didn't
Caleb Brenner
@cwborion
May 24 2017 02:57
On this exercise I typed it the way it suggested to and got it right, but I do not understand how it works. Any chance anyone can explain what is happening? I got 16 as far as what it would calculate to, but it came out to 10.

// Example
function ourRandomRange(ourMin, ourMax) {

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

ourRandomRange(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {

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

}

// Change these values to test your function
var myRandom = randomRange(5, 15);
Abdul Hakim Satria Nusantara
@satrianusantara
May 24 2017 02:57
is there any function that i have to use in this section?
Christopher McCormack
@cmccormack
May 24 2017 02:58
@satrianusantara just the function you've already been provided. if/else or switch statements are perfectly fine ways to solve it
@cwborion Math.random() returns a value between 0 and 1. When you multiply it by myMax-myMin + 1, you're setting a value range. For example: Math.random() * 10 would give you a value between 0 and 10. Math.floor rounds the decimal places off so it's just an integer value, 7 instead of 7.9852334909 or whatever. Adding myMin at the end bumps the number up into the range you set between myMax and myMin
@cwborion so for your example, the random number calculated would be somewhere between 5 and 15, but shouldn't be predictable. 16 shouldn't even be an option if your code passed
Abdul Hakim Satria Nusantara
@satrianusantara
May 24 2017 03:02
Capture.PNG
please check my code, thanks
Caleb Brenner
@cwborion
May 24 2017 03:03
@cmccormack ah okay that makes sense. FCC hasn’t went into any explanation as to how that code actually works rather than just asking you to understand it witouth explanation so I was getting confused about the myMin at the end and thought I was supposed to add 5. Thanks.
CamperBot
@camperbot
May 24 2017 03:03
cwborion sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: cwborion already gave cmccormack points
jdaquino
@jdaquino
May 24 2017 03:04
@satrianusantara sorry to ask, but, isnt that example supposed to use Swith Case ?
Alex
@alextran1502
May 24 2017 03:05

hello, can anyone look at this piece of code and let me know what I did wrong with the statement

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

And this is the whole code


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


function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++){
    if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop) === true){
      return contacts[i][prop];
    } else if (contacts[i].hasOwnProperty(prop) === false){ //The contact you look for could be the any of the other contacts in the list
      return "No such property";
    } else if (contacts[i].firstName !== firstName){ 
      return "No such property " + i;
    }

  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Sherlock", "number");

No matter what I use, the function keep going straight to that last statement. I have played with this challenge for 4 hours and still haven't figured out the problem in my logic

Christopher McCormack
@cmccormack
May 24 2017 03:05
@cwborion let me walk through an example using your range values provided to the function, simplifying as I go:
Math.floor(Math.random() * (myMax - myMin + 1)) + myMin;
Math.floor(0.7 * (myMax - myMin + 1)) + myMin;
Math.floor(0.7 * (15 - 5 + 1)) + 5;
Math.floor(0.7 * (11)) + 5;
Math.floor(7.7) + 5;
7 + 5;
12   // 5 <= 12 <= 15
Abdul Hakim Satria Nusantara
@satrianusantara
May 24 2017 03:05
@jdaquino ah ya? i just login for a long time, hehe, so i need to use switch case?
jdaquino
@jdaquino
May 24 2017 03:06
I remember so.
Abdul Hakim Satria Nusantara
@satrianusantara
May 24 2017 03:07
oke @jdaquino , i'll try thanks
CamperBot
@camperbot
May 24 2017 03:07
satrianusantara sends brownie points to @jdaquino :sparkles: :thumbsup: :sparkles:
:cookie: 245 | @jdaquino |http://www.freecodecamp.com/jdaquino
jdaquino
@jdaquino
May 24 2017 03:07
I mean, check the 5 or so
previous lessons
no probl
hanserri002
@hanserri002
May 24 2017 03:07
hey guys I'm on the word blanks challenge, not sure what I'm supposed to do here
Caleb Brenner
@cwborion
May 24 2017 03:08
@cmccormack thank you! very helpful.
CamperBot
@camperbot
May 24 2017 03:08
:warning: cwborion already gave cmccormack points
cwborion sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
Christopher McCormack
@cmccormack
May 24 2017 03:08
@alextran1502 logic is a bit off there. maybe try not combining the two conditionals in your first if statement - you want to first check the first name, then if there is a firstname match check the property. If the property then matches, return the value at that property, otherwise return a string. If the first check name fails though, you should move on to the next name in your loop. Only after looping all the way through do you return No such contacts
@cwborion np
Alex
@alextran1502
May 24 2017 03:09
@cmccormack thanks! I will try that way
CamperBot
@camperbot
May 24 2017 03:09
alextran1502 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 653 | @cmccormack |http://www.freecodecamp.com/cmccormack
hanserri002
@hanserri002
May 24 2017 03:10

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

// Your code above this line
return result;
}

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

wha do I do here
jdaquino
@jdaquino
May 24 2017 03:10
@hanserri002 what does the challenge says you to do?
hanserri002
@hanserri002
May 24 2017 03:11

wordBlanks("","","","") should return a string.

wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).

wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).

Trakra
@trgme
May 24 2017 03:13
I’m back :-) here’s where i stand now. w3 didn’t help (or I missed completely in parseInt() section.. stackoverflow is a little helpful, but not confining to just using parseInt()
function convertToInteger(str) {
  var number = parseInt("56"); // Pass
  var numb = parseInt("56"); // Pass
  var nu = parseInt("77"); //  Fails test
  var n = parseInt("JamesBond");  // NaN Fails test
  return number;
        // if use return number, numb nu, n individually they pass
}

convertToInteger("56");
jdaquino
@jdaquino
May 24 2017 03:14
Madlib is a family game.
Some writes a 4 different things in order (ex. "Dog", "House", "Plane", "Pepperoni"), and someone other writes the Sentence that will use the words, Without knowing them beforehand, so it must be FUNNY
hanserri002
@hanserri002
May 24 2017 03:15
@jdaquino still not understanding what I need to write for code
jdaquino
@jdaquino
May 24 2017 03:15
A ran into my __ and I went into my _ and my __ Saved me
hanserri002
@hanserri002
May 24 2017 03:16
@jdaquino but can you give me an example of how the code would look
jdaquino
@jdaquino
May 24 2017 03:16
@hanserri002 seems like the function will catch the 4 strings
Lenarey S. Torririt
@Lengzki
May 24 2017 03:17

How will I do this?
a should be assigned to b with =

I'm in the topic javascript

hanserri002
@hanserri002
May 24 2017 03:17
I didn't understand the previous lesson with the function either so where does the function fill in? what does the function replace with those works
words
@Lengzki var b = a
Trakra
@trgme
May 24 2017 03:19
@GregatGit @Manish-Giri - feel I’m closer… w3 didn’t reference str fwiw.
Greg Duncan
@GregatGit
May 24 2017 03:20
@trgme parse the input parameter which is str - nothing else
jdaquino
@jdaquino
May 24 2017 03:20
@Lengzki what lesson are you on?
Joseph
@revisualize
May 24 2017 03:21
Hello. How can I help?
Greg Duncan
@GregatGit
May 24 2017 03:21
you need one variable - use the str - and get rid of all the other variables @trgme
Joseph
@revisualize
May 24 2017 03:22
@Lengzki How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.

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

Here's an example of this:

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

You can use the fName and uName parameters just like a variable inside of your function.
Now this example only uses two parameters fName and uName. Whereas, wordBlanks has four parameters.

@hanserri002 If you'd like, I can talk about function declarations and parameters more. I can also touch on how parameters get their values from the function call and the argument passed via the function call.
@alextran1502 Did you solve Profile Lookup? (Just scrolling upward.)
Alex
@alextran1502
May 24 2017 03:26
@revisualize yes I did!
Joseph
@revisualize
May 24 2017 03:26
@alextran1502 Congrats.
Alex
@alextran1502
May 24 2017 03:27
thanks man
Trakra
@trgme
May 24 2017 03:28
@GregatGit ok, i think this is it.. but not passing 2 tests. maybe i just need to come back to it..

function convertToInteger(str) {
  str = parseInt("56"); // Passes Test
  str = parseInt("56"); // Fails Test
  str = parseInt("77"); //  Fails Test
  str = parseInt("JamesBond");  // NaN Passes Test
  return str;
}

convertToInteger("56");
Greg Duncan
@GregatGit
May 24 2017 03:30
@trgme
function convertToInteger(str) {
  str = parseInt("56"); //  Why is this parsing the 56 and not str?

  return str;
}
Trakra
@trgme
May 24 2017 03:31
@GregatGit because of the last line of code - converToInteger("56");
Greg Duncan
@GregatGit
May 24 2017 03:32
@trgme forget the test and use str - not the tests
try parsing str
Moisés Man
@moigithub
May 24 2017 03:32

if u have this code

myVar = 1
myVar = 2
myVar = 3

what would be the value of myVar 1 , 2 or 3 ?? @trgme

Trakra
@trgme
May 24 2017 03:32
3
Moisés Man
@moigithub
May 24 2017 03:33
yep.. last one will prevail.. all others assigment will be lost
Trakra
@trgme
May 24 2017 03:33
since you are reassigning myVar with new value, yes
Moisés Man
@moigithub
May 24 2017 03:33
  str = parseInt("56"); // Passes Test
  str = parseInt("56"); // Fails Test
  str = parseInt("77"); //  Fails Test
  str = parseInt("JamesBond");  // NaN Passes Test
soo what value will have str ?
Trakra
@trgme
May 24 2017 03:34
should be last one - JamesBond
Csaba Balogh
@JasonCorp84
May 24 2017 03:35
Good evening
Trakra
@trgme
May 24 2017 03:35
yea? follows same logic
Csaba Balogh
@JasonCorp84
May 24 2017 03:35
I am working on the seek and destroy challange
function destroyer(arr) {
  // Remove all the values
  var arg = [];
  var toFilter = arguments[0];
  var size = arguments.length;

  for (var i = 1; i < size; i++){
  arg.push(arguments[i]);
  }


 var destroyed = toFilter.filter(function(az){
     return (az !== arg);
 });
 return destroyed;
}
Greg Duncan
@GregatGit
May 24 2017 03:35
@trgme stop parsing what ever you think the tests will be and parse str - that is how you solve it
Csaba Balogh
@JasonCorp84
May 24 2017 03:36
Am I supposed to use some other technique inside the second function ?
Moisés Man
@moigithub
May 24 2017 03:36
yep.. soo since previous line will be lost.. no point on keep em
soo u only will need 1 line for str assigment/parse..
but instead of hardcoding values u need to make it more generic. using the variable/parameter provided
@trgme
Greg Duncan
@GregatGit
May 24 2017 03:38
@trgme they should be able to give you any string and if its a number you turn it into a number - stop parsing everything else but str
Trakra
@trgme
May 24 2017 03:38
@GregatGit @moigithub - ok.. thanks for all help.. will follow advice. i am too tired now.. I’m going to take a break and come back to it. Very much appreciated!
CamperBot
@camperbot
May 24 2017 03:38
trgme sends brownie points to @gregatgit and @moigithub :sparkles: :thumbsup: :sparkles:
:cookie: 851 | @gregatgit |http://www.freecodecamp.com/gregatgit
:star2: 3255 | @moigithub |http://www.freecodecamp.com/moigithub
Trakra
@trgme
May 24 2017 03:39
will do - thanks again.
Moisés Man
@moigithub
May 24 2017 03:39
@JasonCorp84 arg is an array.. like [2,3]
az is a single value like 1
ur code doing return (1 !== [2,3])
Csaba Balogh
@JasonCorp84
May 24 2017 03:40
yes, so arg[0] can be compared I got that
but how do you iterate each element ?
Moisés Man
@moigithub
May 24 2017 03:41
u could use a loop and a flag to compare,,
or indexOf array method
or use includes array method
or array.some method too i think...
Csaba Balogh
@JasonCorp84
May 24 2017 03:42
@moigithub thank you. I never heard of the loop and flag method :P
CamperBot
@camperbot
May 24 2017 03:42
jasoncorp84 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3256 | @moigithub |http://www.freecodecamp.com/moigithub
ArchivalBoat50
@ArchivalBoat50
May 24 2017 03:45
Hey guys, I am working on the random quote generator project. Do you guys know how I can integrate an API for my random quote generator?
\
or is that stuff too advanced and I should just put in the quotes to a variable?
Gulsvi
@gulsvi
May 24 2017 03:47
@ArchivalBoat50 A lot of people use this one - it has some code examples: https://quotesondesign.com/api-v4-0/
Definitely not too advanced if you've gone through the algorithm challenges already, just some annoying things to debug and issues that aren't really well documented
ArchivalBoat50
@ArchivalBoat50
May 24 2017 03:48
@SkyyCoder Hmm I'll try
Dave Reichert
@davidreichert
May 24 2017 03:51
I'm in JS stuck on "Stand in Line"
nextInLine([], 1) should return 1
Chan
@algoORgoal
May 24 2017 03:51
Can you give me a hint how to solve "Check for Palindromes"? I've been thinking about it for a long time but I have no idea what should I do.
Dave Reichert
@davidreichert
May 24 2017 03:51
how is that possible?
Chan
@algoORgoal
May 24 2017 03:52
01058778585
Gulsvi
@gulsvi
May 24 2017 03:53
@davidreichert You add 1 to the array and then remove the last item from the array, returning the item you removed. So, with an empty array to start with, you add 1 and then remove 1
  1. [] empty array
  2. add the number to the end of the array: [1]
  3. Remove the first element of the array: []
  4. Return the item removed: 1
Joseph
@revisualize
May 24 2017 03:57

@davidreichert Stand In Line is a CheckPoint where you're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

With that function declaration you have a function name of nextInLine. You have two parameters arr which represents an array passed into the function and item that represents a number passed to the function.
A few example function calls:

nextInLine([4,3,2] , 1) the values passed to arr is [4,3,2] and the value passed to item is 1

nextInLine([2,4,6,8] , 10) ... arr is [2,4,6,8] & item is 10

nextInLine([2,3,5,7,11] , 13) ... arr is [2,3,5,7,11] & item is 13 (first 5 and 6th prime numbers)

nextInLine([] , 0) ... arr is [] & item is 0

var myArr = [1,3,5,7]; nextInLine(myArr , 9) ... arr is [1,3,5,7] a copy of the value of the global variable myArr & item is 9

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Again the two parameters for the nextInLine function are arr & item.

Per the instructions: Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

You need to add the number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).

Then you need to have your function return the removed element from the array arr.

Dave Reichert
@davidreichert
May 24 2017 03:59
@SkyyCoder Thanks!
CamperBot
@camperbot
May 24 2017 03:59
davidreichert sends brownie points to @skyycoder :sparkles: :thumbsup: :sparkles:
:star2: 1462 | @skyycoder |http://www.freecodecamp.com/skyycoder
Dave Reichert
@davidreichert
May 24 2017 04:00
I think I did it right the first time...
It fulfilled the instructions, but then I just flip flopped the order of my 2 actions
Austin
@werewolfred
May 24 2017 04:02
hi I'm stuck on word blanks in java how do you structure the strings for the appropriate out put?
Gulsvi
@gulsvi
May 24 2017 04:02
@davidreichert congrats :)
@werewolfred One easy way to remember is that text goes between quotes and variables get surrounded by plus signs
(don't forget the spaces)
Joseph
@revisualize
May 24 2017 04:05

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

Here's an example of this:

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

You can use the fName and uName parameters just like a variable inside of your function.
Now this example only uses two parameters fName and uName. Whereas, wordBlanks has four parameters.

Austin
@werewolfred
May 24 2017 04:06
ok thanks you guys!
Adam Kim
@resv
May 24 2017 04:08
@revisualize Thank you for the "Stand In Line" lesson. I will try to review what you said now.
CamperBot
@camperbot
May 24 2017 04:08
:star2: 3999 | @revisualize |http://www.freecodecamp.com/revisualize
resv sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
May 24 2017 04:08
@resv No problem. Let me know if you need further assistance.
Caleb Brenner
@cwborion
May 24 2017 04:14

https://www.freecodecamp.com/challenges/make-object-properties-private#?solution=%0Avar%20Car%20%3D%20function()%20%7B%0A%20%20%2F%2F%20this%20is%20a%20private%20variable%0A%20%20var%20speed%20%3D%2010%3B%0A%0A%20%20%2F%2F%20these%20are%20public%20methods%0A%20%20this.accelerate%20%3D%20function(change)%20%7B%0A%20%20%20%20speed%20%2B%3D%20change%3B%0A%20%20%7D%3B%0A%0A%20%20this.decelerate%20%3D%20function()%20%7B%0A%20%20%20%20speed%20-%3D%205%3B%0A%20%20%7D%3B%0A%0A%20%20this.getSpeed%20%3D%20function()%20%7B%0A%20%20%20%20return%20speed%3B%0A%20%20%7D%3B%0A%7D%3B%0A%0Avar%20Bike%20%3D%20function()%20%7B%0A%0A%20%20%2F%2F%20Only%20change%20code%20below%20this%20line.%0A%20%20var%20gear%20%3D%202%3B%0A%20%20%0A%20%20this.setGear%20%3D%20function%20(change)%20%7B%0A%20%20%20%20gear%20%2B%3D%201%3B%0A%20%20%7D%0A%20%20this.setGear%20%3D%20function%20(change)%20%7B%0A%20%20%20%20gear%20-%3D%201%3B%0A%20%20%7D%3B%0A%20%20this.getGear%20%3D%20function%20()%20%7B%0A%20%20%20%20return%20gear%3B%0A%20%20%7D%3B%0A%7D%3B%0A%0Avar%20myCar%20%3D%20new%20Car()%3B%0A%0Avar%20myBike%20%3D%20new%20Bike()%3B%0A


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

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

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

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

var Bike = function() {

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

  this.setGear = function (change) {
    gear += 1;
  }
  this.setGear = function (change) {
    gear -= 1;
  };
  this.getGear = function () {
    return gear;
  };
};

var myCar = new Car();

var myBike = new Bike();

It says to use only two public methods in this challenge and I tried to use or ‘||’ to keep it to one but that didn’t work either. This is what I have so far. Anyone have any hints as to where I’m messing up?

Joseph
@revisualize
May 24 2017 04:17
@cwborion So you have a bit of an issue.
@cwborion Remove one of these:
  this.setGear = function (change) {
    gear += 1;
  }
Lenarey S. Torririt
@Lengzki
May 24 2017 04:18
@hanserri002 thanks
CamperBot
@camperbot
May 24 2017 04:18
lengzki sends brownie points to @hanserri002 :sparkles: :thumbsup: :sparkles:
:warning: @hanserri002's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Joseph
@revisualize
May 24 2017 04:19

@cwborion Also, in this:

  this.accelerate = function(change) {
    speed += change;
  };

Notice how the parameter change is used inside of the function as well?

@cwborion In your constructor method ... You should also use the parameter.
Caleb Brenner
@cwborion
May 24 2017 04:21
@revisualize okay so I deleted one have this now
var Bike = function() {

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

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

var myCar = new Car();

var myBike = new Bike();
Abhishek Tiwari
@fillopfy
May 24 2017 04:21
considering I have an array of integers and i have this code
 while(k<str.length)
    {
      p[k]=String.fromCharCode(val[k]);
      i++;
    }

  return p;
}
Joseph
@revisualize
May 24 2017 04:22
@cwborion Do you want to += gear or do you just want to set the gear to a new gear?
Abhishek Tiwari
@fillopfy
May 24 2017 04:22
what is wrong with it , why it is not converting that array of numbers to alphabets
Caleb Brenner
@cwborion
May 24 2017 04:22
@revisualize set to a new gear
Joseph
@revisualize
May 24 2017 04:22
@fillopfy Are you changing the value of k at any point?
@cwborion So, you don't want to += ... You want to assign the value of the new gear to the gear variable.
Caleb Brenner
@cwborion
May 24 2017 04:23
@revisualize figured it out. Thank you
CamperBot
@camperbot
May 24 2017 04:23
cwborion sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4000 | @revisualize |http://www.freecodecamp.com/revisualize
Abhishek Tiwari
@fillopfy
May 24 2017 04:23
@revisualize i am using while, so k is getting changed
Joseph
@revisualize
May 24 2017 04:23
@fillopfy I don't see k getting modified anywhere in your while loop.
Abhishek Tiwari
@fillopfy
May 24 2017 04:24
@revisualize sorry, that i is k actually
Joseph
@revisualize
May 24 2017 04:24
@fillopfy It looks like an i to me.
@fillopfy Why are you even using a while loop instead of a for loop?
Abhishek Tiwari
@fillopfy
May 24 2017 04:24
@revisualize misprinted, typing error
@revisualize it looks short, that's why
Long Nguyen
@longnt80
May 24 2017 04:35
what's up guys. I have a question with my javascript calculator: I want to set the limit of digits that can be input is 15, after that user cannot add more digit or math signs. I use append method to add values, but I don't know how to cancel the append method when the character's limit is reached.
Here's my pen
Jason Collier
@jcollier78
May 24 2017 04:35
Hi. I've completed my code for Check for Palindromes and it passes all tests except "1 eye for of 1 eye.). It's says it should return false, but after stripping spaces and punctuation you get "eyeforofeye" which should be true right?
Long Nguyen
@longnt80
May 24 2017 04:36
@jcollier78 you have to keep the number, I think. So it make it false.
Jason Collier
@jcollier78
May 24 2017 04:37
@longnt80 You're right. I should have read the question properly - "remove all non-alphanumeric characters". Thanks!
CamperBot
@camperbot
May 24 2017 04:37
jcollier78 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 297 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
May 24 2017 04:37
:+1:
Olu
@oluwoleilesanmi
May 24 2017 04:37
hi i need help on this

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

result = myNoun +"/r"+ myAdjective +"/r"+ myVerb +"/r"+ myAdverb +"/r";
// Your code above this line
return result;
}

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

i dont understand what the challenge is asking
Long Nguyen
@longnt80
May 24 2017 04:39
@oluwoleilesanmi you need to create a sentence from those words. Example: The big dog ran quickly
Olu
@oluwoleilesanmi
May 24 2017 04:40
ok thanks if you look at what i sent you will also see i concatinated the funtions arguments into a string
Long Nguyen
@longnt80
May 24 2017 04:42
@oluwoleilesanmi
result = myNoun +"/r"+ myAdjective +"/r"+ myVerb +"/r"+ myAdverb +"/r";
first, you don't need "/r"
second, it should be "\r"
it should be on a same line as a sentence
so you only need to add spaces
Olu
@oluwoleilesanmi
May 24 2017 04:43
ok let me try again thanks
Zachary David Saunders
@ZacharyDavidSaunders
May 24 2017 04:55
Hi guys.. I am building a node.js side project I've run into a design question and I could use some advice. I am trying to build a client application and a seperate server application both in node js. I have chosen to keep both the cleint code and the server code in the same github repo, however, I am not sure if I should run node init twice, once for the client and once for the server. I guess another way to think of this is: should both the client and server code belong in the same node module?
Olu
@oluwoleilesanmi
May 24 2017 04:56
@longnt80 thanks i changed it to result = myAdjective +" "+ myNoun +" "+ myVerb +" __ "+ myAdverb; and it worked
CamperBot
@camperbot
May 24 2017 04:56
:cookie: 298 | @longnt80 |http://www.freecodecamp.com/longnt80
oluwoleilesanmi sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
Long Nguyen
@longnt80
May 24 2017 04:57
@oluwoleilesanmi :+1:
Claudio Restifo
@Marmiz
May 24 2017 04:59

@ZacharyDavidSaunders you should write two different node command according to how you've set the client.
for example a npm start that node server.js to launch the server and a npm build to webpack the client and bundle it.

But it all comes down to how your server serve the content

Also not sure what you mean a "client application in Node". you mean SSR some static content?
tawares07
@tawares07
May 24 2017 05:01
Hi guys! I am little bit lost in Word Blanck (Java Script). I wrote the code (below) but I don´t know what to do.

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

result = myAdverb + myVerb + myHi + myAdjective + myNoun;
// Your code above this line
return result;
}

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

Zachary David Saunders
@ZacharyDavidSaunders
May 24 2017 05:01
@Marmiz okay, thanks. Basically it is a CLI app.
CamperBot
@camperbot
May 24 2017 05:01
zacharydavidsaunders sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 885 | @marmiz |http://www.freecodecamp.com/marmiz
Markus Kiili
@Masd925
May 24 2017 05:01
@tawares07 Did you change the function parameter names?
Zachary David Saunders
@ZacharyDavidSaunders
May 24 2017 05:02
I have mapped several scripts via the package.json file and I am using those to control the CLI client @Marmiz
Claudio Restifo
@Marmiz
May 24 2017 05:03

@ZacharyDavidSaunders

to control the CLI client

So you're expecting your app to be used on the command line?

tawares07
@tawares07
May 24 2017 05:03
@Masd925 yes. I changed for "cat", "little", "HIII", "hit", "slowly"
Ogundele Olumide
@Lumexralph
May 24 2017 05:03
@tawares07 you need to add spaces " " between your strings
Zachary David Saunders
@ZacharyDavidSaunders
May 24 2017 05:03
@Marmiz Yes, exactly!
Claudio Restifo
@Marmiz
May 24 2017 05:03
@ZacharyDavidSaunders then all you need are scripts :)
Ogundele Olumide
@Lumexralph
May 24 2017 05:03
@tawares07 and I think you added another parameter myHi
@Masd925 Good Morning
Markus Kiili
@Masd925
May 24 2017 05:03
@tawares07 What does the function return with that test case?
@Lumexralph @Marmiz Morning.
Zachary David Saunders
@ZacharyDavidSaunders
May 24 2017 05:04
@Marmiz Great! 😎...So should the server app be a completely seperate node module (seperate package.json file)?
Claudio Restifo
@Marmiz
May 24 2017 05:04
@Masd925 :wave: almost lunch time here :palm_tree:
tawares07
@tawares07
May 24 2017 05:05
@Lumexralph @Lumexralph Thanks!!!!!! O forgot the ""
CamperBot
@camperbot
May 24 2017 05:05
tawares07 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1803 | @lumexralph |http://www.freecodecamp.com/lumexralph
tawares07
@tawares07
May 24 2017 05:06
@Masd925 @Masd925 Thanks!!!
Claudio Restifo
@Marmiz
May 24 2017 05:07
@ZacharyDavidSaunders it all comes down to how your app is supposed to work.
The need of separation of package.json is if the client and the server are totally separated. Like I can run one and no use the other and the other way around
eg: I can run your client on my own server instead of using the one "provided" by your app
Zachary David Saunders
@ZacharyDavidSaunders
May 24 2017 05:11
@marmiz Well, I don’t intend for the user to create their own server. I will be providing a server/database system via AWS.
However, I would also like the server code to be open source.
Mykel Pyles
@Crim5onx
May 24 2017 05:11
On the convert Celsius to Fahrenheit challenge, Why is this not work: celsius * 9/5 +32;
Ogundele Olumide
@Lumexralph
May 24 2017 05:12
@tawares07 :+1:
@Crim5onx depends on your code.. the formula seems okay
Mykel Pyles
@Crim5onx
May 24 2017 05:13
function convertToF(celsius) {
var fahrenheit;
celsius * 9/5 +32;
return fahrenheit;
}
john94
@lpy1994
May 24 2017 05:13
@khaduch still up ken?
Claudio Restifo
@Marmiz
May 24 2017 05:13
@ZacharyDavidSaunders it doesn't really matter than. If you want to do a top notch job remember to keep modularity and how "easy would be to customize it" mentality since you're planning to OS it :)
but at the end of the day doesn't really matters
Ogundele Olumide
@Lumexralph
May 24 2017 05:13
@Crim5onx assign the result of the operation celsius * 9/5 +32; to fahrenheit
Thomas Magnus
@tmag298
May 24 2017 05:14
Can anyone help me with the Stand in Line challenge?
Abhishek Tiwari
@fillopfy
May 24 2017 05:14

function destroyer(arr) {
  // Remove all the values
  var m=1;var p=[];
  while(m<arguments.length)
    {
      p.push(arguments[m]);
      m++;
    }


 return arr.filter(function(){

   for(var i=0;i<arr.length;i++)
     {
       if(p[i]===arr[i])
         return false;
     }
   return true;

 });

}
Mykel Pyles
@Crim5onx
May 24 2017 05:14
@Lumexralph Thank you
CamperBot
@camperbot
May 24 2017 05:14
crim5onx sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1804 | @lumexralph |http://www.freecodecamp.com/lumexralph
Zachary David Saunders
@ZacharyDavidSaunders
May 24 2017 05:14
@Marmiz Great! Thanks again! 😁😁👍
Abhishek Tiwari
@fillopfy
May 24 2017 05:14
what is wrong in this code
Ogundele Olumide
@Lumexralph
May 24 2017 05:14
@tmag298 tried anything?
Claudio Restifo
@Marmiz
May 24 2017 05:14
@ZacharyDavidSaunders :sparkles: gl
Zachary David Saunders
@ZacharyDavidSaunders
May 24 2017 05:14
thanks!
Thomas Magnus
@tmag298
May 24 2017 05:14
@Lumexralph I really don't even know where to start and am somewhat confused by the challenge itself.
btw link to challenge: https://tinyurl.com/lv6vfxn
Ogundele Olumide
@Lumexralph
May 24 2017 05:15
@fillopfy I'll suggest using indexOf than a loop in your filter callback
Markus Kiili
@Masd925
May 24 2017 05:15
@fillopfy Filter iterates arr. You need to loop p (or use indexOf) inside the filter callback and put a parameter on the callback function that will hold the arr element being iterated by filter.
Thomas Magnus
@tmag298
May 24 2017 05:16
Am I supposed to use .pop and .shift on arr to make it so that the first value is dropped and another one added at its end? Can I even do that to a variable that doesn't have an explicitly declared array?
Markus Kiili
@Masd925
May 24 2017 05:16
@fillopfy Look at MDN filter page for simple examples of filter usage.
Xarri Jorge
@xarrijorge
May 24 2017 05:16
@tmag298 read up on array method push and shift
Ogundele Olumide
@Lumexralph
May 24 2017 05:16
@tmag298 you need to add values held by item parameter of the function to the end of array held by arr parameter....you need an array method for that
Abhishek Tiwari
@fillopfy
May 24 2017 05:17
@Lumexralph @Masd925 okay, let me try again then
Ogundele Olumide
@Lumexralph
May 24 2017 05:17
@tmag298 you also need to remove the first element in the arr and return that removed element and you're good
Thomas Magnus
@tmag298
May 24 2017 05:20
@Lumexralph wouldn't that just be .pop though?
Xarri Jorge
@xarrijorge
May 24 2017 05:21
@tmag298 it say add item to end so push and return first item unshift
Ogundele Olumide
@Lumexralph
May 24 2017 05:23
@tmag298 pop removes the last element in an array, what removes the first element?
Xarri Jorge
@xarrijorge
May 24 2017 05:23
@tmag298 pop and push work on the last element eg:[1,2,3,4]. 4. shift and unshift work on the begining element 1.
@Lumexralph shift and unshift. shift to add unshift to remove
Abhishek Tiwari
@fillopfy
May 24 2017 05:33
@Lumexralph @Masd925 thanks! indexOf worked
CamperBot
@camperbot
May 24 2017 05:33
fillopfy sends brownie points to @lumexralph and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4123 | @masd925 |http://www.freecodecamp.com/masd925
:star2: 1805 | @lumexralph |http://www.freecodecamp.com/lumexralph
Markus Kiili
@Masd925
May 24 2017 05:34
@fillopfy :+1:
Abhishek Tiwari
@fillopfy
May 24 2017 05:35
@kodinglife shift removes first elemt
@kodinglife unshift adds
Xarri Jorge
@xarrijorge
May 24 2017 05:36
@fillopfy YEAH, sorry got those mixed up
Thomas Magnus
@tmag298
May 24 2017 05:50
In an array, is the "first" element the most left or right element?
Markus Kiili
@Masd925
May 24 2017 05:50
@tmag298 Left.
Ogundele Olumide
@Lumexralph
May 24 2017 05:50
@tmag298 left
HAI NGUYEN
@gunv01
May 24 2017 05:53
hello, I have a trouble with the "Concatenating Strings with the Plus Equals Operator", can anyone help me :(
Ogundele Olumide
@Lumexralph
May 24 2017 05:55
@gunv01
var a  = "Ball";
a += " field";
a;//  "Ball field"
Rick Riggs
@wikiwiggs
May 24 2017 05:55
@naanT glad to see you got it
HAI NGUYEN
@gunv01
May 24 2017 05:59
@wikiwiggs Thanks !!
buddermancer
@buddermancer
May 24 2017 06:09
Hello
Anyone here right now?
Luke Sallmen
@LukeSallmen
May 24 2017 06:10
undoubtedly
buddermancer
@buddermancer
May 24 2017 06:10
Yo
Luke Sallmen
@LukeSallmen
May 24 2017 06:10
What's up?
buddermancer
@buddermancer
May 24 2017 06:10
I need help with something unrelated to coding
Luke Sallmen
@LukeSallmen
May 24 2017 06:10
how unrelated?
eh whatever, what do you need?
buddermancer
@buddermancer
May 24 2017 06:11
So
I couldn't find anywhere else to ask someone
so thats why I'm here
Mithun reddy
@mithunreddyt
May 24 2017 06:11
Hi can any one let me know why indexOf(), lastIndexOf(), search() methods exactly used for
Luke Sallmen
@LukeSallmen
May 24 2017 06:11
lol no problem
buddermancer
@buddermancer
May 24 2017 06:11
I just posted this on a website, waiting for a response
I just had a dream where I was fully aware of the fact that I was dreaming, suddenly I started hearing a loud voice whispering "57-58" or "58-59" I can't remember which numbers. I fell back asleep, but then around 1:00 AM I woke up and my head started shaking rapidly and I couldn't move, I tried to yell but nothing was happening. It's 2:07 and I'm scared to fall back asleep
Luke Sallmen
@LukeSallmen
May 24 2017 06:11
@mithunreddyt check out their pages on MDN
Mithun reddy
@mithunreddyt
May 24 2017 06:12
With an example please I am not getting the exact use
buddermancer
@buddermancer
May 24 2017 06:12
Alright thanks
Luke Sallmen
@LukeSallmen
May 24 2017 06:12
@mithunreddyt MDN has several examples of each
Ogundele Olumide
@Lumexralph
May 24 2017 06:13
Luke Sallmen
@LukeSallmen
May 24 2017 06:13
So y'all I'm still stuck on the Seeker Destroyer Challenge
I don't understand how to complete my filter function's return statement
keloman
@keloman
May 24 2017 06:13
Can anyone help me with the "Counting Cards" challenge? I can't seem to understand the idea behind it.
buddermancer
@buddermancer
May 24 2017 06:14
I still dont understand the "57-58" thing what the hell was happening there
Luke Sallmen
@LukeSallmen
May 24 2017 06:14
Dreams are just weird sometimes, @buddermancer
Ogundele Olumide
@Lumexralph
May 24 2017 06:14
@LukeSallmen you can use indexOf
buddermancer
@buddermancer
May 24 2017 06:14
But it felt like there was another presence in the room with me
Luke Sallmen
@LukeSallmen
May 24 2017 06:14
@Lumexralph Don't I still have to iterate through all arguments
buddermancer
@buddermancer
May 24 2017 06:14
Like I wasn't dreaming anymore
Luke Sallmen
@LukeSallmen
May 24 2017 06:14
@buddermancer From what I've heard from other people, that's common in sleep paralysis
erdogan
@eoeroglu
May 24 2017 06:15

hello. Im trying to make every words first letter capital in any given string and whit the code below Im having an error with the text "Cannot read property 'length' of undefined"

function titleCase(str) {
strLower = str.toLowerCase;
strSplit = strLower.split;
for (var i = 0; i <= strSplit.length - 1; i++) {
strSplit[i][0] = strSplit[i][0].toUpperCase;
}

return strSplit;

}

titleCase("I'm a little tea pot");

buddermancer
@buddermancer
May 24 2017 06:16
Yea you're right
"Humming, hissing, static, zapping and buzzing noises are reported during sleep paralysis.[11] Imagined sounds (voices, whispers and roars) are also experienced"
from the wiki
Ogundele Olumide
@Lumexralph
May 24 2017 06:16
@keloman you're to use your function to check the value in card which will determine if you'll increment or decrement count, and when done checking card you check if count is positive (greater than 0) or not, then you return count + the string (Bet or Hold)
@LukeSallmen you can use the arguments oject to separate the array and the remaining arguments passed
erdogan
@eoeroglu
May 24 2017 06:17
Can anyone help me with this error??
Luke Sallmen
@LukeSallmen
May 24 2017 06:17
@Lumexralph Already did
Markus Kiili
@Masd925
May 24 2017 06:17
@buddermancer I have a friend that goes to all the rock festivals in the summer, and after long periods of drinking, he almost always gets sleep paralysis.
Luke Sallmen
@LukeSallmen
May 24 2017 06:18
@Lumexralph I just don't understand how to filter with .indexOf()
An if statement where if .indexOf() returns > -1 ?
Ogundele Olumide
@Lumexralph
May 24 2017 06:18
@eoeroglu toUpperCase ==> toUpperCase();
buddermancer
@buddermancer
May 24 2017 06:18
I'm 13 though @Masd925
erdogan
@eoeroglu
May 24 2017 06:19
@Lumexralph same error unfortunately
Ogundele Olumide
@Lumexralph
May 24 2017 06:19
@eoeroglu and you need to concatenate the substring of the word in lowercase too
Markus Kiili
@Masd925
May 24 2017 06:19
@buddermancer Yeah. That doesn't sound like anything special. If it repeats, you might see someone about it.
Ogundele Olumide
@Lumexralph
May 24 2017 06:20
@eoeroglu your split and toLowerCase method too
buddermancer
@buddermancer
May 24 2017 06:20
ok
Dan Couper
@DanCouper
May 24 2017 06:20
@eoeroglu split is a function, and takes the thing you're splitting on as an argument - so like split(' ') to split on spaces
Ogundele Olumide
@Lumexralph
May 24 2017 06:20
@eoeroglu
strLower = str.toLowerCase;
strSplit = strLower.split;
erdogan
@eoeroglu
May 24 2017 06:23
@Lumexralph @DanCouper I'm changing everything you say and it always says somthing like "Cannot read/assign property '0' of string 'i'".... I think my code is a bit off...
Ather Ali
@atherali99
May 24 2017 06:25
hi
Ogundele Olumide
@Lumexralph
May 24 2017 06:25
@eoeroglu show your code
Ather Ali
@atherali99
May 24 2017 06:25

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

You are given a variable celsius representing a temperature in Celsius. Use the variable fahrenheit already defined and apply the algorithm to assign it the corresponding temperature in Fahrenheit. HELP ME

erdogan
@eoeroglu
May 24 2017 06:26

function titleCase(str) {
strLower = str.toLowerCase();
strSplit = strLower.split(' ');
for (var i = 0; i <= strSplit.length - 1; i++) {
strSplit[i][0] = strSplit[i][0].toUpperCase();
}

return strSplit;

}

titleCase("I'm a little tea pot");

Ogundele Olumide
@Lumexralph
May 24 2017 06:26
@atherali99 use the celsius parameter with the formula 9 / 5 + 32, assign it to fahrenheit
Sakshee Jain
@sakshee-19
May 24 2017 06:28

function uniteUnique(arr) {
var n=arguments.length;
var ar = Array.prototype.slice.call(arguments);
var res=[];
ar= ar.reduce(function(prev,curr){
return res.push(prev.filter(function(val){
return curr.indexOf(val)==-1;
}));

});
return ar;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);

Ogundele Olumide
@Lumexralph
May 24 2017 06:28
@eoeroglu by doing this you're trying to mutate a string which is not possible in JS strSplit[i][0] = strSplit[i][0].toUpperCase();
Ather Ali
@atherali99
May 24 2017 06:28
@Lumexralph plz tell me with syntax
Sakshee Jain
@sakshee-19
May 24 2017 06:28
it is showing filter is nota function
Ather Ali
@atherali99
May 24 2017 06:28
bcaus i am new
Sakshee Jain
@sakshee-19
May 24 2017 06:28
not a*
Ogundele Olumide
@Lumexralph
May 24 2017 06:28
@eoeroglu strSplit = strLower.split(' ');
@atherali99 celsius * 9 / 5 + 32; assign the result of that operation to fahrenheit
buddermancer
@buddermancer
May 24 2017 06:29
So do you think I'd be fine if I fall back asleep? @Masd925
Ogundele Olumide
@Lumexralph
May 24 2017 06:29
@sakshee-19 what datatype is prev ?
Markus Kiili
@Masd925
May 24 2017 06:30
@buddermancer Doesn't matter really because one needs to sleep. Talk to your parents about it.
buddermancer
@buddermancer
May 24 2017 06:30
ok
Ogundele Olumide
@Lumexralph
May 24 2017 06:31
@sakshee-19 reduce is used to shrink an array, if you want side-effects, you can use forEach instead of reduce
erdogan
@eoeroglu
May 24 2017 06:32
@Lumexralph well if I'm not mistaken in objects I could use that but I think in strings, that doesn't work, I guess?
Ogundele Olumide
@Lumexralph
May 24 2017 06:32
@eoeroglu yes, you can change an array or object but you can't change a string, you just store it's processed form
erdogan
@eoeroglu
May 24 2017 06:33
@Lumexralph thank you :) now i will try having two for loops, maybe this will work...
CamperBot
@camperbot
May 24 2017 06:33
:star2: 1806 | @lumexralph |http://www.freecodecamp.com/lumexralph
eoeroglu sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
Markus Kiili
@Masd925
May 24 2017 06:34
@eoeroglu Strings are primitive values and when you access its properties, it is wrapped into an array-like String object. That object is immutable. Those elements you access are read-only.
erdogan
@eoeroglu
May 24 2017 06:35
@Masd925 what I understand from your claim is that i cannot change them to uppercase like this?
Markus Kiili
@Masd925
May 24 2017 06:36
@eoeroglu Yes, you need to make a new string from the old, or make an array of characters and change that array content. I would prefer using string operations.
erdogan
@eoeroglu
May 24 2017 06:38
@Masd925 well I thought I did made two new strings with split and lowercase operations?
Ayush Bahuguna
@relentless-coder
May 24 2017 06:38
const arr = ['L', 'L', 'O']
arr.forEach(function(el){
    el = el.toLowerCase()
})
why wouldn't this work.
if I use a for loop it works
Nazar Maksymchuk
@MANTENN
May 24 2017 06:39
@relentless-coder you need to jQuery
I believe .forEach is a jquery function
Markus Kiili
@Masd925
May 24 2017 06:39
@eoeroglu You need to change the array content: strSplit[i] = ... <- construct the titlecased word here using the original word strSplit[i] and some string operations.
Nazar Maksymchuk
@MANTENN
May 24 2017 06:40
@relentless-coder I am wrong. It's a validate prototype method.
@relentless-coder it takes 3 arguements
Ayush Bahuguna
@relentless-coder
May 24 2017 06:43
@MANTENN that doesn't matter. the first argument represents the element. I am not new to this, it suddenly isn't working, I use forEach all the time
Nazar Maksymchuk
@MANTENN
May 24 2017 06:43
@relentless-coder it's a local variable
try setting arr[i] = el.toLowerCase()
Ayush Bahuguna
@relentless-coder
May 24 2017 06:43
okay, I'll try that.
Nazar Maksymchuk
@MANTENN
May 24 2017 06:43
but youll need to add a i into the function's arguements
erdogan
@eoeroglu
May 24 2017 06:44
@Masd925 I'm sorry I couldn't understand...
Dan Couper
@DanCouper
May 24 2017 06:44
@relentless-coder need to see more of the code, what you have is right, if the rest is right
Markus Kiili
@Masd925
May 24 2017 06:44
@eoeroglu You have an array of words. You need to get that looped word and make a titlecased word from it and assign it back to the array of words.
Ayush Bahuguna
@relentless-coder
May 24 2017 06:45
@DanCouper
 const str = createTeam.Name.replace(/\s/, '').slice(-3).split('').forEach(el =>  el.toUpperCase())
Dan Couper
@DanCouper
May 24 2017 06:46
Use map
Not for each
Marcus Zierke
@marcuszierke
May 24 2017 06:46
hey guys, I think I have trouble understanding some of the exercises
have a look

var Car = function(wheels, seats, engines) {
//Change this constructor
this.wheels = 4;
this.seats = 5;
this.engines = 1;
};

//Try it out here
var myCar = new Car(3,1,2);

erdogan
@eoeroglu
May 24 2017 06:47
@Masd925 I see now, and am trying. thank you :)
CamperBot
@camperbot
May 24 2017 06:47
eoeroglu sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4124 | @masd925 |http://www.freecodecamp.com/masd925
Ayush Bahuguna
@relentless-coder
May 24 2017 06:47
@DanCouper thank you. this works
Nazar Maksymchuk
@MANTENN
May 24 2017 06:47
@DanCouper can you help me with el.error.code === 4 not validated?
Marcus Zierke
@marcuszierke
May 24 2017 06:48
why is it not creating a new car instance?
Nazar Maksymchuk
@MANTENN
May 24 2017 06:48
Jessie Wong
@frentea
May 24 2017 06:49
Can anybody tell what is wrong here:
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if ( myObj.hasOwnProperty("checkProp")) {
return myObj.checkProp;
} else {
return "Not Found";
}
}
// Test your code by modifying these values
checkObj("gift");
Markus Kiili
@Masd925
May 24 2017 06:49
@marcuszierke It is, but the passed values are not set on the properties, because you don't use the constructor parameters on the code.
@frentea .checkProp looks for property key "checkProp", not the key stored in parameter checkProp.
Also think whether you need to use "checkProp" or checkProp.
Jessie Wong
@frentea
May 24 2017 06:50
what about myObj["checkProp"]? the same result?
Marcus Zierke
@marcuszierke
May 24 2017 06:51
just figured it out myself, thanks @Masd925
CamperBot
@camperbot
May 24 2017 06:51
marcuszierke sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4125 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
May 24 2017 06:51
@frentea "checkProp" is just a string. You should be using the parameter checkProp.
Nazar Maksymchuk
@MANTENN
May 24 2017 06:51
@Masd925 except when using bracket notation you need strings to access the properties value
Sanket Chaudhari
@sanket143
May 24 2017 06:52
what is the use of github
Markus Kiili
@Masd925
May 24 2017 06:53
@MANTENN Bracket notation evaluates the expression inside the brackets and coerces it to a string if needed. That is why it works with variables and expressions in addition to strings. Dot notation just reads the string literal written after the dot.
ozimanik
@ozimanik
May 24 2017 06:53
good morning my brothers :sparkles:
i love y'all ⁿᵒᵗ
Ayush Bahuguna
@relentless-coder
May 24 2017 06:54
@sanket143 it's like a bank account for your code.
you store your code there, and it remains safe there. You can pull code out from it anytime you want, make changes to it, and then push it back to your account
Nazar Maksymchuk
@MANTENN
May 24 2017 06:55
@relentless-coder or a distribution center/like warehouses
Anshul Adlakha
@anshuladlakha
May 24 2017 06:57

var latt;
var long;

$.getJSON("http://ip-api.com/json/?callback=?", function(response){
  latt = response.lat;
  long = response.lon;
});
How can i test if this is working or not?
Dan Couper
@DanCouper
May 24 2017 06:57
@relentless-coder issue is that forEach is for side effects, and it breaks the chain of methods the way you were trying to do it (each step in the chain should return a new, complete version of what you want): to make it work, you'd want to assign everything before forEach as a variable, so you have an array of characters. Then use forEach on that, then return the modified array of characters.
Sanket Chaudhari
@sanket143
May 24 2017 06:57
OH! and what is repositories there @relentless-coder
Dan Couper
@DanCouper
May 24 2017 06:58
@sanket143 somewhere to store all versions of all the code in a project
Jessie Wong
@frentea
May 24 2017 06:58
@Masd925

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

}

Markus Kiili
@Masd925
May 24 2017 06:58
@AnshulAdlakha Use the response data inside the callback function. Console.log for example.
Jessie Wong
@frentea
May 24 2017 06:58
didn't work either
Markus Kiili
@Masd925
May 24 2017 06:59
@frentea You need to use the bracket notation when the property key is stored on a variable like checkProp.
Sanket Chaudhari
@sanket143
May 24 2017 07:00
Oh cool I got it @DanCouper
Anshul Adlakha
@anshuladlakha
May 24 2017 07:00
@Masd925 i have never used the console.log function
Can you tell me how will it go down?
Sanket Chaudhari
@sanket143
May 24 2017 07:00
thanks @DanCouper
CamperBot
@camperbot
May 24 2017 07:00
sanket143 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 731 | @dancouper |http://www.freecodecamp.com/dancouper
Winston K
@princeofsin
May 24 2017 07:00
?
Can someone please help me
Sanket Chaudhari
@sanket143
May 24 2017 07:00
who create this camper Bot
who creates you @camperbot
Markus Kiili
@Masd925
May 24 2017 07:01
@AnshulAdlakha console.log("cat"); would print "cat" on the browser developer tools console. Put the thing you wan't to print inside the parenthesis.
Sanket Chaudhari
@sanket143
May 24 2017 07:01
@princeofsin go on
Jessie Wong
@frentea
May 24 2017 07:02
Yeah, it worked. Thanks! @Masd925
CamperBot
@camperbot
May 24 2017 07:02
frentea sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4126 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
May 24 2017 07:02
@frentea :+1:
Rick Willcox
@willcoxDev
May 24 2017 07:03
can someone point me in the right direction for a number > roman numeral conertor?
spliting the number up
into an array
then check to see which column (100s, 10s, 1 etc)
Markus Kiili
@Masd925
May 24 2017 07:04
@willcoxDev A popular way is to write the basis of Roman numerals in two array in numbers and letters. Then solve it by iterating the array of numbers and generating the result on the fly.
Rick Willcox
@willcoxDev
May 24 2017 07:04
what do you mean by the basis
Markus Kiili
@Masd925
May 24 2017 07:05
@willcoxDev 1,4,5,9,10,...
Winston K
@princeofsin
May 24 2017 07:05

I am having a issue with this problem:

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

You are given a variable celsius representing a temperature in Celsius. Use the variable fahrenheit already defined and apply the algorithm to assign it the corresponding temperature in Fahrenheit.

Markus Kiili
@Masd925
May 24 2017 07:05
You only need to consider those.
Winston K
@princeofsin
May 24 2017 07:06

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

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

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

Am i writing it wrong?
Rick Willcox
@willcoxDev
May 24 2017 07:06
celsius x 9/5 + 32 ;
(celsius *( 9/5)) + 32 ;
look up math operators
Winston K
@princeofsin
May 24 2017 07:06
pemtas
Rick Willcox
@willcoxDev
May 24 2017 07:06
u used x
Winston K
@princeofsin
May 24 2017 07:07
we can use that here?
Rick Willcox
@willcoxDev
May 24 2017 07:07
?
Winston K
@princeofsin
May 24 2017 07:07
pemdas*
Rick Willcox
@willcoxDev
May 24 2017 07:07
ur issue
is that you used
Winston K
@princeofsin
May 24 2017 07:07
sorry
Rick Willcox
@willcoxDev
May 24 2017 07:07
x
Winston K
@princeofsin
May 24 2017 07:07
my bad
Rick Willcox
@willcoxDev
May 24 2017 07:07
instead of *
Winston K
@princeofsin
May 24 2017 07:07
and thank you
Rick Willcox
@willcoxDev
May 24 2017 07:07
but i normally add bracket for clarity
and yes use normal math conventions
Winston K
@princeofsin
May 24 2017 07:07
no no you are right
i don't know what i was thinking
i am sorry lol
Rick Willcox
@willcoxDev
May 24 2017 07:08
:D
Dan Couper
@DanCouper
May 24 2017 07:08
@sanket143 the technology github uses (Git) is kind of a superpowered save, as well as saving the current thing you've done, it saves every single previous version. So you can go back and start working on an earlier version, or split a version off and work on that, then merge the changes back in. It lets lots of people work on a single codebase at the same time, with safeguards against overwriting what other people have already done or are doing
Rick Willcox
@willcoxDev
May 24 2017 07:09
@Masd925 so you woudl store the number in an array and the roman numberals in and array?
and iterate over each number and corraspond that number to an index of the roman numberal array?
Markus Kiili
@Masd925
May 24 2017 07:10
@willcoxDev It is easiest if you keep the number as a number and just store the Roman numerals in arrays.
Rick Willcox
@willcoxDev
May 24 2017 07:10
ok
Markus Kiili
@Masd925
May 24 2017 07:11
@willcoxDev Just start with the largest basis number and check how many times it fits into num and then the second etc.
ms-dosx86
@ms-dosx86
May 24 2017 07:11

instruction: Remove all falsy values from an array.
it nearly works, but it also delete strings, and i think problem in

arr[i] !== "";

know, i can use array.filter, but it easiest way for me

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var array = [];
  for (var i = 0; i < arr.length; i++) {
    if (arr[i] !== null && arr[i] !== false && arr[i] !== 0 && arr[i] !== "" && arr[i] !==        undefined && !(isNaN(arr[i]))) {
      array.push(arr[i]);
    }
  }
  return array;
}

bouncer([7, "ate", "", false, 9]);
Rick Willcox
@willcoxDev
May 24 2017 07:11
there is a cool trick for this
Markus Kiili
@Masd925
May 24 2017 07:12
@ms-dosx86 isNaN is not a test for value NaN: isNaN("cat"); // true
ms-dosx86
@ms-dosx86
May 24 2017 07:12
@Masd925 why it works with NaN ?
Rick Willcox
@willcoxDev
May 24 2017 07:12
a hint is that it is asking to get rid of all falsy values so if you can make it just test for true values
Markus Kiili
@Masd925
May 24 2017 07:12
@ms-dosx86 You can use && arr[i]===arr[i] && ... instead of that !(isNaN(arr[i])))
Rick Willcox
@willcoxDev
May 24 2017 07:12
its pretty simple
@ms-dosx86 trusty me you need to learn .filter(); I struggled with this qustion but alot of the next questins need to you filter and this is the easiest one
Kevin Gong
@kevingong1995
May 24 2017 07:13

hi i am having trouble with the mutations, I cant seem to figure out how to return true for mutations that are just mixed around such as mutation(["floor", "for"])

function mutation(arr) {
if(arr[0].toLowerCase().indexOf(arr[1].toLowerCase()) !== -1)
return true;
return false;
}

Rick Willcox
@willcoxDev
May 24 2017 07:13
so better to get it down now instead of avoided it
@kevingong1995 are u getting type error?
Kevin Gong
@kevingong1995
May 24 2017 07:14
no errors, just getting returns of -1 for those test cases
Rick Willcox
@willcoxDev
May 24 2017 07:14
that code is also mising curly brackets
Markus Kiili
@Masd925
May 24 2017 07:14
@ms-dosx86 FCC console shows NaN as null.
Rick Willcox
@willcoxDev
May 24 2017 07:15
== -1){return true;}
Jim
@JLOSS1
May 24 2017 07:15
anyone got a second? have an ajax call issue i think.
ms-dosx86
@ms-dosx86
May 24 2017 07:15
@willcoxDev i dont know how to use array.filter, i have tried
Jim
@JLOSS1
May 24 2017 07:15
image.png
Rick Willcox
@willcoxDev
May 24 2017 07:16
@ms-dosx86 yeh thats what I am saying. you really do need to learn it. The next question is a .filter() question and is much much harder
Kevin Gong
@kevingong1995
May 24 2017 07:16
even after adding the bracket, i am not getting it to work :o
ms-dosx86
@ms-dosx86
May 24 2017 07:16
@Masd925 wait wait, what it arr[i]===arr[i] means?? and why my code works after that
René
@RenevandenHeuvel
May 24 2017 07:16

I almost past challenge 162 named Local Scope and Functions. The feedback is that i shouldn't have a global myVar variable. I don't understand that, because I don't see a global myVar variable in my code:

function myLocalScope() {
'use strict';
var myVar;

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

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

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

Kevin Gong
@kevingong1995
May 24 2017 07:17
does indexOf() search for the whole word and not single letters?
Markus Kiili
@Masd925
May 24 2017 07:18
@ms-dosx86 NaN is the only value not equal to itself, so arr[i]===arr[i] is true always except when arr[i] is NaN.
So arr[i]===arr[i] tests if arr[i] is not NaN
Ather Ali
@atherali99
May 24 2017 07:18

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

Here is the text with the escape sequences written out.

"FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine"

ms-dosx86
@ms-dosx86
May 24 2017 07:20
@Masd925 how is this related to the deleting my string from array?
Markus Kiili
@Masd925
May 24 2017 07:20
@ms-dosx86 That only involves deleting NaN.
@ms-dosx86 Evil isNaN messed it up.
Blauelf
@Blauelf
May 24 2017 07:21
That's why ES2015 introduced Number.isNaN (does IE11 support that? Or do we need a polyfill?)
Rick Willcox
@willcoxDev
May 24 2017 07:22
@Masd925 should i be splitting the number or not. I have to split it to be able to iterate over it dont i?
ms-dosx86
@ms-dosx86
May 24 2017 07:22

@Masd925 but my code almost works and delete strings from array, after this

arr[i]===arr[i]

strings not removed and challenge accepted

Rick Willcox
@willcoxDev
May 24 2017 07:23
arr[i]===arr[i] always returns true though?
Markus Kiili
@Masd925
May 24 2017 07:23
@willcoxDev Better to iterate the array of numbers (the basis of Roman numerals).
@willcoxDev Not if arr[i] is NaN.
Rick Willcox
@willcoxDev
May 24 2017 07:23
ok so the num 36 should go into an array like [3,6]
Markus Kiili
@Masd925
May 24 2017 07:23
@willcoxDev No.
@willcoxDev Use arrays like this and solve it by iterating the NUM array. Keep num as a number:
  var NUM = [1000,900,500,400,100,90,50,40,10,9,5,4,1];
  var ROM = ['M','CM','D','CD','C','XC','L','XL','X','IX','V','IV','I'];
Rick Willcox
@willcoxDev
May 24 2017 07:24
ok
ozimanik
@ozimanik
May 24 2017 07:24
Ghettotourist ohne Rap bist du nix, Egal wir viel Tattoos du hast, wie viel Testo du spritzt du bleibst was du bist, Ghettotourist
Rick Willcox
@willcoxDev
May 24 2017 07:24
thanks ill try that now
Blauelf
@Blauelf
May 24 2017 07:25
No Number.isNaN on IE11. Why do people still consider this to be a web browser? A web browser for viewing websites not changed since 1997?
@ozimanik Isn't "Tatoos" spelled as "Tattoos"?
Markus Kiili
@Masd925
May 24 2017 07:26
@Blauelf Web developing would be too easy without IE. I have a lot of fun fun fun at work making things work on old IE's.
ozimanik
@ozimanik
May 24 2017 07:26
@Blauelf what do you mean? ~Justin B.
Kevin Gong
@kevingong1995
May 24 2017 07:26

could someone tell me how to use the indexOf() method to return true for mutation(["floor", "for"])?
Did i do something wrong in my code?

function mutation(arr) {
if(arr[0].toLowerCase().indexOf(arr[1].toLowerCase()) !== -1){
return true;
}
return false;
}

ms-dosx86
@ms-dosx86
May 24 2017 07:26
@Masd925 i still dont understand why the strings are not deleted now, but thank you
CamperBot
@camperbot
May 24 2017 07:26
ms-dosx86 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4127 | @masd925 |http://www.freecodecamp.com/masd925
Blauelf
@Blauelf
May 24 2017 07:27
@kevingong1995 You have to check whether each individual character in arr[1] can be found in arr[0], not the whole string.
Ather Ali
@atherali99
May 24 2017 07:27

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

Kevin Gong
@kevingong1995
May 24 2017 07:27
would that mean implementing a forloop?
René
@RenevandenHeuvel
May 24 2017 07:27
Hi everyone, can somebody help me with challenge 162?
Markus Kiili
@Masd925
May 24 2017 07:27
@ms-dosx86 Look at your condition. Only thing that relates strings is arr[i]!=="".
So it only removes empty strings.
Blauelf
@Blauelf
May 24 2017 07:28
@kevingong1995 I used a for loop, and also tried array method every. But for loop is great.
Claudio Restifo
@Marmiz
May 24 2017 07:28
@atherali99 are you asking a question?
René
@RenevandenHeuvel
May 24 2017 07:28
I have partially solved it
Ather Ali
@atherali99
May 24 2017 07:28
@Marmiz yes
Blauelf
@Blauelf
May 24 2017 07:28
@RenevandenHeuvel Challenges have names, not numbers.
Ather Ali
@atherali99
May 24 2017 07:28
@Marmiz can u help me
Claudio Restifo
@Marmiz
May 24 2017 07:28
@atherali99 I'd be happy to help. Which one is your question?
Vedant Kashyap
@vedant15188
May 24 2017 07:29

Hey guys... I'm trying to do the Wikipedia Viewer Project and I'm stuck in retrieving the JSON Response from Wikipedia API... Here is my Javascript code

function getRandomArticle() {
    query=document.getElementById("searchBar").value;
    $.getJSON("Access-Control-Allow-Origin: https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles="+query, function (response) {
        console.log(JSON.stringify(response));
    });
}

Whenever I hit the search button the console log shows

"XMLHttpRequest cannot load access-control-allow-origin: https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles=Hardwell. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https."

Anshul Adlakha
@anshuladlakha
May 24 2017 07:29

var latt;
var long;

$.getJSON("http://ip-api.com/json/?callback=?", function(response){
  latt = response.lat;
  long = response.lon;
  console.log(latt+long);
});
@Masd925 i tried doing it in jsfiddle but it shows nothing
ms-dosx86
@ms-dosx86
May 24 2017 07:29
@Masd925 it seems, i understand. Strings didnt pass compare with isNaN
Ather Ali
@atherali99
May 24 2017 07:29

@Marmiz Here is the text with the escape sequences written out.

"FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine"

Blauelf
@Blauelf
May 24 2017 07:29
@vedant15188 Remove that Access-Control-Allow-Origin: in front of the URL, and add origin=* to the parameter list.
René
@RenevandenHeuvel
May 24 2017 07:30
@Blauelf ah ok. It's challenge Local Scope and Functions. It says that I must remove my global myVar variable, but i don't understand it, because I don't see this variable in my code.
Markus Kiili
@Masd925
May 24 2017 07:30
@ms-dosx86 isNaN tests whether the value is NaN after coercion to type Number, so it returns true for many values besides just NaN. isNaN is not used much because it has confusing cases.
Blauelf
@Blauelf
May 24 2017 07:30
@RenevandenHeuvel Can you show the code?
Claudio Restifo
@Marmiz
May 24 2017 07:30
@atherali99 that's how your string is suppose to look. You have to "translate" some word with the code equivalent (newline - backslash ...)
Vedant Kashyap
@vedant15188
May 24 2017 07:31
@Blauelf Thanks... got it
CamperBot
@camperbot
May 24 2017 07:31
vedant15188 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4219 | @blauelf |http://www.freecodecamp.com/blauelf
Ather Ali
@atherali99
May 24 2017 07:31
@Marmiz FirstLine
\SecondLine\
ThirdLine
Anshul Adlakha
@anshuladlakha
May 24 2017 07:31
@Masd925 ?
Ather Ali
@atherali99
May 24 2017 07:31
@Marmiz i wana to print like this
Claudio Restifo
@Marmiz
May 24 2017 07:32
@atherali99 I know.
the question is - how do you print a new line?
a backslah?
a carriage return?
Ather Ali
@atherali99
May 24 2017 07:32
@Marmiz yes
@Marmiz right
Claudio Restifo
@Marmiz
May 24 2017 07:33

@atherali99 this

"FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine"

Is how you string should look like in pseudo-code

René
@RenevandenHeuvel
May 24 2017 07:33

@Blauelf
function myLocalScope() {
'use strict';
var myVar;

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

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

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

Blauelf
@Blauelf
May 24 2017 07:34
@RenevandenHeuvel Looks pretty valid. Have you tried reloading the page? Or maybe initialising your local variable myVar to some value?
Ather Ali
@atherali99
May 24 2017 07:34
@Marmiz r u got answer
René
@RenevandenHeuvel
May 24 2017 07:37
@Blauelf I reloaded the page and passed it. Will do that next time. Thanks
CamperBot
@camperbot
May 24 2017 07:37
renevandenheuvel sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4220 | @blauelf |http://www.freecodecamp.com/blauelf
Miljan Grcic
@Nightimer
May 24 2017 07:38
Is there bug with Caesars Cipher?
Blauelf
@Blauelf
May 24 2017 07:38
@RenevandenHeuvel Happens sometimes, especially when global variables are involved. If you are convinced your code is correct, at least try reloading. Or, to quote IT Crowd, "Have you tried turning it off and on again?"
Claudio Restifo
@Marmiz
May 24 2017 07:39
@Nightimer not as far as I'm aware. What's the issue you're experiencing?
Miljan Grcic
@Nightimer
May 24 2017 07:39
function rot13(str) { // LBH QVQ VG!

  var splited = str.split("").map(function (x) {
    return x.charCodeAt();
  });

  var deciphered = splited.map(function (y) {

    if ((y - 13) < 65) {
    return String.fromCharCode(y + 13);

    } else if ((y - 13) >= 65) {
      return String.fromCharCode(y - 13);
    }
  }).join("");

  return deciphered;


}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
this kinda looks like too much pain in t.. ...
Blauelf
@Blauelf
May 24 2017 07:40
@Nightimer What about non-letters?
Miljan Grcic
@Nightimer
May 24 2017 07:41
Thats the part i need to figure out now
Anshul Adlakha
@anshuladlakha
May 24 2017 07:43
navigator.geolocation.getCurrentPosition(function(position) {
  console.log(position.coords.latitude, position.coords.longitude);
});
will this work?
Blauelf
@Blauelf
May 24 2017 07:43
@Nightimer Only letters should be shifted, non-letters should pass unaltered.
Miljan Grcic
@Nightimer
May 24 2017 07:43
hmm i think i kinda get it
Kevin Gong
@kevingong1995
May 24 2017 07:53

Could i get some help on seek and destroy?
Why am i not allowed to filter this way?

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

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

i seem to get a type error saying 2 is not a function

Xarri Jorge
@xarrijorge
May 24 2017 07:54
@kevingong1995 filter is basically a loop so should be outside the for loop
Nazar Maksymchuk
@MANTENN
May 24 2017 07:55
@kodinglife how would I get the current iteration?
@kodinglife
var missingTracks = duration.filter(function(item,i) {
        if(item <= 0) {
                return i;
        }
    });
Kevin Gong
@kevingong1995
May 24 2017 07:56
@kodinglife so would i even need a loop to begin with ?
Nazar Maksymchuk
@MANTENN
May 24 2017 07:57
No one wants to help. Fine i'll figure it out on my own.
Markus Kiili
@Masd925
May 24 2017 07:57
@kevingong1995 Filter iterates arr, so you only need to loop or iterate the arguments object.
Xarri Jorge
@xarrijorge
May 24 2017 07:57
@kevingong1995 if you use a loop don't filter us conditions, else use filter
Markus Kiili
@Masd925
May 24 2017 07:57
@kevingong1995 You need to pass a function into filter that determines which elements to keep.
Kevin Gong
@kevingong1995
May 24 2017 07:58
im a little confused on how to create a function like that, could you explain how i would do that?
Xarri Jorge
@xarrijorge
May 24 2017 07:59
@kevingong1995
arr.filter(function(x){
return code;
});
Kevin Gong
@kevingong1995
May 24 2017 08:00

so would my case be

arr.filter(function (x){
return arguments[i];
});

given that its in a for loop iterating with variable i
Xarri Jorge
@xarrijorge
May 24 2017 08:11
@kevingong1995 the return function should return a logic calculation
@kevingong1995 eg: to return the largest of [5, 7] i would: array.filter(function(a,b){ return a>b});
Miljan Grcic
@Nightimer
May 24 2017 08:13
function rot13(str) { // LBH QVQ VG!

  var splited = str.split("").map(function (x) {
    return x.charCodeAt();
  });

  var deciphered = splited.map(function (y) {

    if ((y - 13) < 65 && (y - 13) > 50) {
    return String.fromCharCode(y + 13);

    } else if ((y - 13) >= 65) {
      return String.fromCharCode(y - 13);
    } else {
      return String.fromCharCode(y);
    }
  }).join("");
  return deciphered;



}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Sucess
amelink
@amelink
May 24 2017 08:14
hi can anyone help me with Title Case a Sentence
Palak Trivedi
@Palaklive
May 24 2017 08:19
@forkerino thanks my friend. I'm disconnect from a long time
CamperBot
@camperbot
May 24 2017 08:19
palaklive sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2361 | @forkerino |http://www.freecodecamp.com/forkerino
Luke Sallmen
@LukeSallmen
May 24 2017 08:25

function destroyer(arr) {
  // Remove all the values
 var destroyerValues = [];
 for (var i = 1; i < arguments.length; i++) { 
    destroyerValues.push(arguments[i]);
 } 
  var newArr = arr.filter(function(value) { 
    return value != arr.indexOf(destroyerValues);
  });
  return newArr;

}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
so I know my problem is my return statement for my filter function
but I can't understand how to use .indexOf
or how to pass my destroyerValues to indexOf
Xarri Jorge
@xarrijorge
May 24 2017 08:27
@LukeSallmen shouldn't it be indexOf(destroyerValues[i])? destroyerValues is an array so doesn't have an index
Robert Arifin
@renkachan
May 24 2017 08:28
guys wanna ask
var merged = [].concat.apply([],arr);
what is [] stands for in there?
i am not quite sure
i think the first [] indicate array, the second one i am not sure
Luke Sallmen
@LukeSallmen
May 24 2017 08:28
@kodinglife the function isn't inside the for loop, so that wouldn't work
@kodinglife but you're probably not too far off, I need to do something like that
Xarri Jorge
@xarrijorge
May 24 2017 08:30
@LukeSallmen Yeah, you're right.
ozimanik
@ozimanik
May 24 2017 08:30
can some1 help
Xarri Jorge
@xarrijorge
May 24 2017 08:31
@ozimanik what with?
Xarri Jorge
@xarrijorge
May 24 2017 08:32
@ozimanik just return Math.random();
ozimanik
@ozimanik
May 24 2017 08:32
@kodinglife thats what i dit it dont works so confusing

function randomFraction() {

  // Only change code below this line.


  return Math.random();

  // Only change code above this line.
}
this cant be wrong ufo361
Xarri Jorge
@xarrijorge
May 24 2017 08:33
@ozimanik refresh your browser
ozimanik
@ozimanik
May 24 2017 08:33
been there done that
in firefox, chrome, opera, ie, [tor]
ufo 361 digga weil ich nie scheiter
Xarri Jorge
@xarrijorge
May 24 2017 08:34
@ozimanik reset the challenge and try again
@ozimanik it worked for me fine
aceroAD
@aceroAD
May 24 2017 08:37
hi, i have a problem with the falsy bouncer challenge, i dont know how to include in the for [i ] === NaN so it takes it out of the array!
function bouncer(arr) {
  var cont = [];
  for (var i = 0; i < arr.length;i++){
    if (arr[i] === false || arr[i] === null || arr[i === 0] || arr[i] === "" || arr[i] === undefined){
      arr.splice(i,i);
    }
  }
  return arr;
}
ozimanik
@ozimanik
May 24 2017 08:38
@kodinglife ok i will try to do that i really appreciate your help, i mean how can a guy be so nice to me everyone is always ignoring me and you just helped me out and didnt even want anything back thank you so much man i owe you something forever <3
CamperBot
@camperbot
May 24 2017 08:38
ozimanik sends brownie points to @kodinglife :sparkles: :thumbsup: :sparkles:
:cookie: 421 | @kodinglife |http://www.freecodecamp.com/kodinglife
Xarri Jorge
@xarrijorge
May 24 2017 08:39
@ozimanik no problem bro. all part of the learning curve :thumbsup:
Blauelf
@Blauelf
May 24 2017 08:48
@aceroAD
  1. While arr.splice(i, 1); --i; would work (first argument to splice is the index, second the number of elements to remove), I recommend using alternatives like filter.
  2. You are not testing for NaN. NaN is a bit tricky, as it equals nothing, not even itself. You can use that by using || arr[i] !== arr[i].
  3. You misplaced ] in your test for 0.
Chris Juchtmans
@kjuchtmans
May 24 2017 08:49
morning everyone :wave:
aceroAD
@aceroAD
May 24 2017 08:50
@Blauelf why filter, i read the definition of filter and didnt understand it very well.
Blauelf
@Blauelf
May 24 2017 08:51
@aceroAD If you don't want that long chain of conditions, you could make it a lot shorter. For example, if and also the ! operator (and many more) treat all truthy and all falsy values the same.
@aceroAD filter processes an array, and creates and returns a new one from the elements a callback returns truthy for. You could do that yourself with a for loop, if you want, pushing the elements that are truthy.
Chris Juchtmans
@kjuchtmans
May 24 2017 08:53

Question on addEventListener method using a JS listener function: should I first code the method, and then the function, or goes the function first?

My code :
button.addEventListener('click', generateQuote); [etc etc] function generateQuote ( ) { [ etc etc }

thanks!

Tiago Correia
@tiagocorreiaalmeida
May 24 2017 08:54

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

fahrenheit *= 1.8;
fahrenheit += 32;

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

// Change the inputs below to test your code
convertToF(-30);
whyat's missing to give fahrenheit the value contained inc elsius

Robert Arifin
@renkachan
May 24 2017 08:55
@LukeSallmen why dont just use splice ? put the first argument into array, then use 2 for to check if it match with the next argument or not . if yes, just splice it
Markus Kiili
@Masd925
May 24 2017 08:56
@kjuchtmans You can use a declared function, or an anonymous function. Anonymous can be easier to write but declared one could be easier to debug and test.
aceroAD
@aceroAD
May 24 2017 08:56
@Blauelf thank you, im trying to understand how filter works
Yahia
@y-zaky
May 24 2017 08:56
hey guys how r u all?
CamperBot
@camperbot
May 24 2017 08:56
aceroad sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4221 | @blauelf |http://www.freecodecamp.com/blauelf
Yahia
@y-zaky
May 24 2017 08:56
I am getting a JSONP call back in my weather app with all the information i need to finish it
but i have a question.
ozimanik
@ozimanik
May 24 2017 08:56
@bowssy88 im good my brother
Imrul91
@Imrul91
May 24 2017 08:56
var code = "formatted";
Yahia
@y-zaky
May 24 2017 08:56
@ozimanik my bro :)
Imrul91
@Imrul91
May 24 2017 08:56
sorry testing
Tiago Correia
@tiagocorreiaalmeida
May 24 2017 08:57

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

fahrenheit *= 1.8;
fahrenheit += 32;

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

// Change the inputs below to test your code
convertToF(-30);
whyat's missing to give fahrenheit the value contained inc elsius if someone canhelp

Markus Kiili
@Masd925
May 24 2017 08:57
@Imrul91 You can edit or delete messages later.
Imrul91
@Imrul91
May 24 2017 08:57
@Masd925 trying to figure out how to format the code before i post
Yahia
@y-zaky
May 24 2017 08:57
my question is how can i access the info form myJSON P call back ? so that I can update my HTML?
What is the variable that is currently holding all the information i need ?
Markus Kiili
@Masd925
May 24 2017 08:58
@kjuchtmans Declared function you can place before or after the eventlistener line. Declarations are processed first before line to line execution.
Chris Juchtmans
@kjuchtmans
May 24 2017 08:58
@Masd925 okay, what about order? is the function written first, or is the addEventListener written first?
Ziratsu
@Ziratsu
May 24 2017 08:59

``
function palindrome(str) {
var newStr ="";
str.replace(/\W/g, '');
return str;
}

palindrome("_eye");
``

Hi guys, why it's not removing the "_"? :(
Chris Juchtmans
@kjuchtmans
May 24 2017 08:59
@Masd925 alright. but it wouldn't break code to write eventlistener line first, referring to a function which is only declared below?
Imrul91
@Imrul91
May 24 2017 09:00
var code = "formatted";
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a < 0);
  answer = "undefined";

  // 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);
Chris Juchtmans
@kjuchtmans
May 24 2017 09:00
@Masd925 thanks, I understand that now. back to the drawing table
CamperBot
@camperbot
May 24 2017 09:00
kjuchtmans sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4128 | @masd925 |http://www.freecodecamp.com/masd925
Imrul91
@Imrul91
May 24 2017 09:00
I know it's wrong but I'm not sure how to define where a and b are less than 0, to be defined as undefined
Maksim
@SirGoldman
May 24 2017 09:01
Hi, what is the function to capitalize first letter of the string?
Markus Kiili
@Masd925
May 24 2017 09:02
@SirGoldman Strings are immutable, so you always make new strings from the old. You can use .toUpperCase() and some string operations.
Tiago Correia
@tiagocorreiaalmeida
May 24 2017 09:03
var myStr = " I am a \" double quoted \" string inside \"double quotes \".";
Variable myStr should contain the string: I am a "double quoted" string inside "double quotes". can't understand what's wrong probably its just a space between letters,if you acan help
Maksim
@SirGoldman
May 24 2017 09:03
@Masd925 .toUppperCase()catipatizes all the letters.
Markus Kiili
@Masd925
May 24 2017 09:03
@SirGoldman Yes, you need to get the first letter first.
Ziratsu
@Ziratsu
May 24 2017 09:05
How to put a code snippet in a nice shape? (with the black background)
Maksim
@SirGoldman
May 24 2017 09:06

@Ziratsu

(shift+enter for line break) var code = "formatted";

ups :D
Markus Kiili
@Masd925
May 24 2017 09:06
@SirGoldman There is no way to change a string character. You need to make a new titlecased string by getting the first character, uppercasing it, and appending the rest of the string lowercased to it.
Blauelf
@Blauelf
May 24 2017 09:07

@renkachan [] is the empty array.

In case of [].concat.apply, the empty array's concat method is found in Array.prototype, that whole thing is Array.prototype.concat.apply. In that place, any array would have that effect, the empty array itself is not used.

Then there's the first argument to apply, which is the object to use as this when calling Array.prototype.concat.

These are about equivalent:

myArr.concat(arr1, arr2, arr3)
Array.prototype.concat.call(myArr, arr1, arr2, arr3)
Array.prototype.concat.apply(myArr, [arr1, arr2, arr3])

(unless of course you had given your array its own concat method, which is very unlikely)
So

var merged = [].concat.apply([], arr);

or

var merged = Array.prototype.concat.apply([], arr);

is equivalent to

var merged = [].concat(arr[0], arr[1], ..., arr[arr.length-1]); // not actual code

without requiring you to know the number of elements in arr.

Maksim
@SirGoldman
May 24 2017 09:07
@Masd925 Thanks
CamperBot
@camperbot
May 24 2017 09:07
sirgoldman sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4129 | @masd925 |http://www.freecodecamp.com/masd925
Maksim
@SirGoldman
May 24 2017 09:08

@Ziratsu

`.
//your code

shit, didint work :/
Yahia
@y-zaky
May 24 2017 09:08
guys, i am receiving the correct information in my call back BUT, how do i access this information?
Ziratsu
@Ziratsu
May 24 2017 09:08
`` The following
Yahia
@y-zaky
May 24 2017 09:08
Screen Shot 2017-05-24 at 10.05.29.png
Ziratsu
@Ziratsu
May 24 2017 09:08
Well i'm struggling ^^
Blauelf
@Blauelf
May 24 2017 09:09
```js Shift+Return for line break in chat mode
var answer = 42;
``` also requires its own line
var answer = 42;
Yahia
@y-zaky
May 24 2017 09:09
my API call back is working, but where can i find this info to add it to my html??
Ziratsu
@Ziratsu
May 24 2017 09:09
``` Hello world
Thorbjørn Bruarøy
@The2rB
May 24 2017 09:09

Anyone able to help me understand this?

I have been able to pass this challenge using "addition assignment" (+=) and breaking the code on multiple lines. But I would like to understand why this does not work.

https://www.freecodecamp.com/challenges/word-blanks

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

result = "We were walking the " + myNoun + "when the " + myAdjective + "buglar " myVerb + " " + myAdverb "down the street.";

// Your code above this line
return result;
}

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

Ziratsu
@Ziratsu
May 24 2017 09:09
h
function palindrome(str) {
  var newStr ="";
   str.replace(/\W/g, '');
return str;
}


palindrome("_eye");
Blauelf
@Blauelf
May 24 2017 09:10
@The2rB You are missing two +, and there should be more space in your string literals.
Ziratsu
@Ziratsu
May 24 2017 09:10
Nice ! Thank's @Blauelf
CamperBot
@camperbot
May 24 2017 09:10
ziratsu sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4222 | @blauelf |http://www.freecodecamp.com/blauelf
Ziratsu
@Ziratsu
May 24 2017 09:10
So here my question, why the "_" did not disappear?
Markus Kiili
@Masd925
May 24 2017 09:12
@Ziratsu Underscore is a word character.
Thorbjørn Bruarøy
@The2rB
May 24 2017 09:12

@Blauelf Thanks, I'll try. Tried to roll back the code to the one that did not work - so might have copied the wrong one. I'll be back :)

BTW: Why can't I make the code display with ´´´ in this chat?

CamperBot
@camperbot
May 24 2017 09:12
the2rb sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4223 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
May 24 2017 09:13
@The2rB ```, not ´´´
@The2rB Also a line with triple backticks before and one after your code. Use Shift+Return to insert line breaks when in chat mode.
@Ziratsu Don't forget that strings are immutable, so you need to use replace's return value, it would not change str in any way, only return a new string. Of course same for toLowerCase or toUpperCase if you want to use one of those.
Thorbjørn Bruarøy
@The2rB
May 24 2017 09:16
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

  result = "We were walking the " + myNoun + " when the " + myAdjective + "buglar " myVerb + " " + myAdverb "down the street."; 


  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
That is my code wrongly copyed before - and it gives the error "SyntaxError: missing ; before statement
Blauelf
@Blauelf
May 24 2017 09:16
@The2rB + before myVerb and after myAdverb
Thorbjørn Bruarøy
@The2rB
May 24 2017 09:17
and a space ...
Blauelf
@Blauelf
May 24 2017 09:17
Also, need space in front of "buglar" and "down"
Thorbjørn Bruarøy
@The2rB
May 24 2017 09:18
I have no idea on how long I have been looking at that code - and not seen the problem. Probably looked at is to long that I went blind ...
Chris Juchtmans
@kjuchtmans
May 24 2017 09:19

Question on appending to HTML :

Which is more advisable / secure to use
(assume existing array 'randomQuote'):

  1. html += randomQuote.quote [followed by] $(".quote").html(html);
    or
  2. quote.innerHTML = randomQuote[random].quote; ?
Thorbjørn Bruarøy
@The2rB
May 24 2017 09:20

Thanks again @Blauelf . Worked now. Funny about that - when it is written correctly.
Started earlier to remove strings from behind to see when it validated. Should have seen the error then ...

Thanks a lot for helping. As I said - I were able to pass it using +=, but were keen to understand why it did not work when having the code on one line. Feels a bit better now, knowing I understood how to solve it, just didn't write it correctly :)

CamperBot
@camperbot
May 24 2017 09:20
:warning: the2rb already gave blauelf points
the2rb sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
Ziratsu
@Ziratsu
May 24 2017 09:21
ok @Blauelf , and you know the formula to remove "_" ? since it's counted as a character I don't know if it's possible
Victor Popescu
@VicPopescu
May 24 2017 09:21
@kjuchtmans both are ok but I think first one is easier to read
Blauelf
@Blauelf
May 24 2017 09:22
@Ziratsu Two options come to my mind: Character sets [], or alternative match |.
Chris Juchtmans
@kjuchtmans
May 24 2017 09:23
@VicPopescu thanks for that
Ziratsu
@Ziratsu
May 24 2017 09:24
@Blauelf Well I find a way with this one (I'm not understanding it very well it's from StackOv)
``
function palindrome(str) {
  var newStr ="";
  newStr = str.replace(/[^0-9a-z]/gi, '');
return newStr;
}


palindrome("_eye");
Markus Kiili
@Masd925
May 24 2017 09:26
@kjuchtmans About equally unsecure. JS textContent, innerText or jQuery text() are safer.
Blauelf
@Blauelf
May 24 2017 09:26
@Ziratsu /[^0-9a-z]/gi uses a negated character set (matching anything but the listed ones, so anything but digits and lowercase letters), with a case-insensitive and global flag.
@Ziratsu If you want to know more about regular expressions, there's a Regular Expressions Ressources page on the forum (migrated from the GitHub wiki)
Abhishek Tiwari
@fillopfy
May 24 2017 09:28
is anyone doing JSON and Ajax challeneges? I am not understanding what I need to do, all the code is provided by them then what is the need for the challeneg
Thomas
@sjurs1
May 24 2017 09:29
Hello guys, maybe you can help me out here. Trying to get back and forth between fahrenheit and celsius on my local weather app, but after successfully switching to fahrenheit, I can't seem to get it back to celsius. I thought about putting the on click event in the document ready function but seeing as the temperature gathered from my ajax request is only defined within my getweather function, I figured I had to put it there.
 $("#temperature").html(
            "Temperature: " + userTemp + "<a href='#' id='tempchange'> °C</a>"
          );
          var count = 0;
          $("#tempchange").on("click", function() {
            count += 1;
            if (count % 2 != 0) {
              userTemp = (userTemp*1.8)+32;
              $("#temperature").html("Temperature: " + userTemp + "<a href='#' id='tempchange'> °F</a>")
              count +=1;
            }
            else {
              userTemp = (userTemp-32)/1.8;
              $("#temperature").html("Temperature: " + userTemp + "<a href='#' id='tempchange'> °C</a>")
            };
          });
There's something wrong with the logic here I'm guessing. I'll link to the pen if you guys want.
Blauelf
@Blauelf
May 24 2017 09:30
@sjurs1 Why the second count += 1?
Amir Saleem
@amirsaleem96
May 24 2017 09:30
Hi, I have a question
What is the difference between WebGL and D3?
Bharathiraja
@bharathi04
May 24 2017 09:30

function nextInLine(arr, item) {
// Your code here

return item; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

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

What is the code is doing?
Blauelf
@Blauelf
May 24 2017 09:30
@sjurs1 Also, I would not want to convert back and forth, you have rounding errors each time.
Chris Juchtmans
@kjuchtmans
May 24 2017 09:30

@fillopfy just finished them; yeah there is a bit more provided and less coding required by you, at this stage.

But in my experience: the assignments that follow make you do ALL the coding, and wanting MUCH more background info.
Good thing there is always MDN docs :smile: - especially on using JS to change your HTML
Good luck!

Bharathiraja
@bharathi04
May 24 2017 09:31
any suggestion please
Abhishek Tiwari
@fillopfy
May 24 2017 09:32
@kjuchtmans background of what? json?
Blauelf
@Blauelf
May 24 2017 09:32
@bharathi04 Review array methods like push, pop, unshift, and shift. And pick one for each of the two parts of this task.
Aleksander Gębicki
@Takumar
May 24 2017 09:32
@bharathi04 you have to add item element to your arr array.
You've learnt about methods for adding and removing elements of array before
Chris Juchtmans
@kjuchtmans
May 24 2017 09:33
@fillopfy again, for me as a beginner:
correct JSON syntax
correct AJAX calls
appending values to HTML elements, and more
leomartin
@abhirupleo
May 24 2017 09:33
function lookUpProfile(firstName, prop){
// Only change code below this line
var answer;
for(var i=0; i<contacts.length;i++){
if(contacts[i].hasOwnProperty(firstName)&&contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}else if(!contacts[i].hasOwnProperty(firstName)){
answer="No such contact";
}else if(contacts[i].hasOwnProperty(firstName)&& !contacts[i].hasOwnProperty(prop)){
answer="No such property";
}
}
return answer;
// Only change code above this line
}
what is
wrong with this code
?
Abhishek Tiwari
@fillopfy
May 24 2017 09:33
@kjuchtmans it's tricky to remember json code, do I have to remember them?
Blauelf
@Blauelf
May 24 2017 09:33
@abhirupleo Initialise answer to "No such contact", and don't do anything on name mismatch in the loop.
leomartin
@abhirupleo
May 24 2017 09:34
okay thanks @Blauelf
CamperBot
@camperbot
May 24 2017 09:34
abhirupleo sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
Bharathiraja
@bharathi04
May 24 2017 09:34
Actually i want this output: nextInLine([2], 1) should return 2
CamperBot
@camperbot
May 24 2017 09:34
:star2: 4224 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
May 24 2017 09:34
@abhirupleo Also, don't test for contacts[i].hasOwnProperty(firstName), variable firstName contains a string you need to compare to contacts[i].firstName
leomartin
@abhirupleo
May 24 2017 09:35
okay
Blauelf
@Blauelf
May 24 2017 09:35
@abhirupleo And you have an odd combination of return-early and single-return pattern. Better pick one.
leomartin
@abhirupleo
May 24 2017 09:37
okay
Thomas
@sjurs1
May 24 2017 09:37

@Blauelf Oops, forgot to remove that, I was just trying a couple of different things. Oh that's a smart point. I changed it to this which I figure is a better way to do it.

$("#temperature").html(
            "Temperature: " +
              userTempCelsius +
              "<a href='#' id='tempchange'> °C</a>"
          );
          var count = 0;
          $("#tempchange").on("click", function() {
            count += 1;
            if (count % 2 != 0) {
              var userTempFahrenheit = userTempCelsius * 1.8 + 32;
              $("#temperature").html(
                "Temperature: " +
                  userTempFahrenheit +
                  "<a href='#' id='tempchange'> °F</a>"
              );
            } else {
              $("#temperature").html(
                "Temperature: " +
                  userTempCelsius +
                  "<a href='#' id='tempchange'> °C</a>"
              );
            }
          });

I tried console logging the count variable, and it only comes up as 0, IE it doesn't increment at all. Should I put it somewhere else?

Blauelf
@Blauelf
May 24 2017 09:39
@sjurs1 Where did you log it? Inside the click handler?
Chris Juchtmans
@kjuchtmans
May 24 2017 09:40
@fillopfy not really, but for one of the first assignments called "Random Quote Generator" you need a list of quotes to randomly select.
I formatted those quotes in JSON because it seems to be the agreed notation for lists of stuff / data, you perhaps later want to make changes to.
Just giving you my 5 cts
Thomas
@sjurs1
May 24 2017 09:41
@Blauelf My bad, had it on the outside. It logs 1 now, but nothing happens on the next click.
Blauelf
@Blauelf
May 24 2017 09:42
@sjurs1 You remove the element the handler is attached to. Not much of a surprise then.
Stephen James
@sjames1958gm
May 24 2017 09:42
@sjurs1 You are replacing the element with id tempchange, you are going to lose the click handler
tahashin
@tahashinegp
May 24 2017 09:43

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes":