These are chat archives for FreeCodeCamp/HelpJavaScript

15th
May 2017
Eric Hasegawa
@EricHasegawa
May 15 2017 00:00
@revisualize Yeah I know
Random
@SaiKhal
May 15 2017 00:00
@cmccormack ok thanks, I'm assuming the html request are async and are messing me up?
CamperBot
@camperbot
May 15 2017 00:00
saikhal sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 577 | @cmccormack |http://www.freecodecamp.com/cmccormack
Dovydas Stirpeika
@Giveback007
May 15 2017 00:01
hey @cmccormack i just figured out how to do it without a promise.
Christopher McCormack
@cmccormack
May 15 2017 00:01
@SaiKhal html requests? Do you mean XMLHttpRequest? If so, yeah that's your problem most likely
Joseph
@revisualize
May 15 2017 00:01
@EricHasegawa Okay. So, what do you think you should have your for loop iterate across if it is not the function name and it isn't the lenght of product (Which is just a number).
Christopher McCormack
@cmccormack
May 15 2017 00:01
@Giveback007 awesome that was quick
Dovydas Stirpeika
@Giveback007
May 15 2017 00:01
https://codepen.io/giveback007/pen/qmxdjw?editors=0010
check console, I just have the ajax call itself
Eric Hasegawa
@EricHasegawa
May 15 2017 00:02
@revisualize I have to multiply the product variable by all the numbers in the subarrays of arr, I really don't know where to begin here
Random
@SaiKhal
May 15 2017 00:02
@cmccormack yea sorry XMLHttpRequest, so in this case do I have to treat it like a local variable and do everything inside the function?
Dovydas Stirpeika
@Giveback007
May 15 2017 00:03
turns out that sucess is kind of like a promise in that it wont run until it get's the data back
Christopher McCormack
@cmccormack
May 15 2017 00:03
@Giveback007 I don't think that's technically using a Promise - you're making the call within the success callback, which is another perfectly fine way to do it :)
Joseph
@revisualize
May 15 2017 00:03
@EricHasegawa But, you've already started. You're doing fine.
Eric Hasegawa
@EricHasegawa
May 15 2017 00:03
@revisualize I'm not sure where to go from here though
Dovydas Stirpeika
@Giveback007
May 15 2017 00:03
@cmccormack yeah that's what I'm saying :D I beat the system!! muahaha
Christopher McCormack
@cmccormack
May 15 2017 00:03
@SaiKhal or use Deferred https://mdn.io/deferred
Joseph
@revisualize
May 15 2017 00:03
@EricHasegawa What do you have to iterate across? You already said it.
Eric Hasegawa
@EricHasegawa
May 15 2017 00:04
@revisualize The values in the subarrays? I'm not really sure
Christopher McCormack
@cmccormack
May 15 2017 00:04
@Giveback007 haha just wait until you have to do many of those and you're nesting 40 columns deep :D
Joseph
@revisualize
May 15 2017 00:04

@EricHasegawa You said this:

@EricHasegawa
@revisualize I have to multiply the product variable by all the numbers in the subarrays of arr

@EricHasegawa subarray of arr
Dovydas Stirpeika
@Giveback007
May 15 2017 00:05
@cmccormack :( that's scary
Joseph
@revisualize
May 15 2017 00:05
@EricHasegawa So you have to iterate across arr
@EricHasegawa Right?
Dovydas Stirpeika
@Giveback007
May 15 2017 00:05
@cmccormack anyways thnx again for helping me brain storm
CamperBot
@camperbot
May 15 2017 00:05
giveback007 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: giveback007 already gave cmccormack points
Dovydas Stirpeika
@Giveback007
May 15 2017 00:06
it should have the project done in the next hour hopeful I can show it off to you guys
Christopher McCormack
@cmccormack
May 15 2017 00:06
@Giveback007 yeah nesting never looks as good and it makes it hard to troubleshoot, that's why I like using the Promise response of the jquery ajax calls so much. You're already using jQuery, might as well take advantage of it :)
Eric Hasegawa
@EricHasegawa
May 15 2017 00:06
@revisualize Yeah, what would the code for that look like?
Joseph
@revisualize
May 15 2017 00:06
@EricHasegawa You already have the code for that.
Christopher McCormack
@cmccormack
May 15 2017 00:06
@Giveback007 $.when is also a really nice one if you need to wait for a bunch of stuff to resolve before moving on
Eric Hasegawa
@EricHasegawa
May 15 2017 00:07
@revisualize Whereabouts?
Joseph
@revisualize
May 15 2017 00:07
@EricHasegawa Right here! You just have to fix it.
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0; i < multiplyAll.length; i++ ) {
    for var ()
  }
  // Only change code above this line
  return product;
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Eric Hasegawa
@EricHasegawa
May 15 2017 00:07
@revisualize I really don't know what I'm doing here
I'm very confused
Joseph
@revisualize
May 15 2017 00:08
@EricHasegawa Slow down. Focus on one thing at a time.
Eric Hasegawa
@EricHasegawa
May 15 2017 00:08
@revisualize Okay, what should I do first?
Joseph
@revisualize
May 15 2017 00:09
@EricHasegawa If you had an array var arr = [ "A" , "H" , "S" , "K" ]; How would you iterate across that array with a for loop?
Eric Hasegawa
@EricHasegawa
May 15 2017 00:09
@revisualize Would you not do what I did in my code?
Joseph
@revisualize
May 15 2017 00:10
@EricHasegawa I would make one change to your code to get the first for loop working. Then I'd start making changes to the second for loop to get it working.
Eric Hasegawa
@EricHasegawa
May 15 2017 00:10
@revisualize What change would that be?
Joseph
@revisualize
May 15 2017 00:11
@EricHasegawa If you had an array var arr = [ "A" , "H" , "S" , "K" ]; How would you iterate across that array with a for loop?
Eric Hasegawa
@EricHasegawa
May 15 2017 00:12
for (var i=0; i < arr.length; i++)
@revisualize
Joseph
@revisualize
May 15 2017 00:12
@EricHasegawa Great!
@EricHasegawa There's the start of your first for loop.
Eric Hasegawa
@EricHasegawa
May 15 2017 00:13
@revisualize Oh thanks, why is it arr.length and not product.length?
CamperBot
@camperbot
May 15 2017 00:13
erichasegawa sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3965 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 15 2017 00:13
@EricHasegawa var product = 1; ... Product holds the value of a NUMBER. ... Numbers don't have .lengths
Eric Hasegawa
@EricHasegawa
May 15 2017 00:14
@revisualize Right okay thanks, any tips on how I could set up the second for loop?
CamperBot
@camperbot
May 15 2017 00:14
erichasegawa sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: erichasegawa already gave revisualize points
Joseph
@revisualize
May 15 2017 00:15
@EricHasegawa Each time your function runs.. The value of product will always be 1.
@EricHasegawa How do you iterate across an array?
@EricHasegawa Arrays have values stored in elements that are accessed via indexes.
Eric Hasegawa
@EricHasegawa
May 15 2017 00:17
for (var j=0; j < arr[i].length; j++)
@revisualize would it be like that? That's what they did in the sample code
Joseph
@revisualize
May 15 2017 00:17
@EricHasegawa The element of an Array can be anything. A number, a sting, or even another array
@EricHasegawa It would be just like that.
Eric Hasegawa
@EricHasegawa
May 15 2017 00:17
@revisualize Okay, and what next?
Joseph
@revisualize
May 15 2017 00:18
@EricHasegawa That's a good question.. What do you need to do next?
@EricHasegawa You said this:
@EricHasegawa
@revisualize I have to multiply the product variable by all the numbers in the subarrays of arr
Eric Hasegawa
@EricHasegawa
May 15 2017 00:18
@revisualize Well I'm not sure what my existing code has already done, so I don't know what comes next
Joseph
@revisualize
May 15 2017 00:19
@EricHasegawa But, you've already said what you have to do.
Eric Hasegawa
@EricHasegawa
May 15 2017 00:19
@revisualize Yeah, but could you tell me what I've done already?
Joseph
@revisualize
May 15 2017 00:19
@EricHasegawa Show me what you've written.
Eric Hasegawa
@EricHasegawa
May 15 2017 00:20

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

}
}

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

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

@revisualize

Joseph
@revisualize
May 15 2017 00:21
@EricHasegawa What do you think that code does so far?
Eric Hasegawa
@EricHasegawa
May 15 2017 00:22
@revisualize It likely iterates through all of the subarrays, but I'm not sure
Joseph
@revisualize
May 15 2017 00:23
@EricHasegawa How about we don't give a broad description and give something more defined.
Eric Hasegawa
@EricHasegawa
May 15 2017 00:24
@revisualize I figured out the code and it's working now, but I'm really not sure why, could you possibly explain the second for loops purpose to me?

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < arr.length; i++ ) {
for (var j=0; j < arr[i].length; j++) {
console.log(arr[i][j]);
product = 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]]);

electricpen
@electricpen
May 15 2017 00:24
I have created an infinite loop bug that only happens in one of 5 test cases and passes the other 4
Eric Hasegawa
@EricHasegawa
May 15 2017 00:24
There's my code
electricpen
@electricpen
May 15 2017 00:24
Its a bit hard to debug because of the infinite loop
function smallestCommons(arr) {
  var lcm = 1; //least common multiplier
  var waldo = 0; //where am I?
  function multiple(x, y) {
    var z = x;
    while (z%x !== 0 || z%y !== 0) {
      z += 1;
    }
    return z;
  }
  arr.sort();
  var endpoint = arr[1];
  for (var i = arr[1]-1; i > arr[0]; i--) {
    arr = [arr[0], i, ...arr.slice(1)];
  }
  lcm = multiple(arr[waldo], endpoint);
  waldo += 1; // waldo on the move!
  for (var j = waldo; j < endpoint; j++) {
    lcm = multiple(arr[j], lcm);
  }
  return lcm;
}


smallestCommons([1,13]);
Joseph
@revisualize
May 15 2017 00:25
@EricHasegawa Okay let's break something down.
Alexx Martínez
@AlexxMart
May 15 2017 00:25

I'm having problems with the exercise "Split Strings with split". My code:

```

var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split('');
` ``

the last objective "You should split the string by its spaces." is not met
Stephen James
@sjames1958gm
May 15 2017 00:26
@AlexxMart The value in the () is what to split on. You split on empty string not spaces
Christopher McCormack
@cmccormack
May 15 2017 00:26
@electricpen try to avoid changing an array that you're currently iterating over
Eric Hasegawa
@EricHasegawa
May 15 2017 00:26
@revisualize Okay, what is it? I think I have to go soon
Joseph
@revisualize
May 15 2017 00:27
@EricHasegawa If you have an array like this:
var myArray = [ [1,2,3] , [4,5,6] , [7,8,9] ];
myArray[0] is [1,2,3]
myArray[0][0] is 1
myArray[0][1] is 2
myArray[0][2] is 3
myArray[1] is [4,5,6]
myArray[1][0] is 4
myArray[1][1] is 5
myArray[1][2] is 6
myArray[2] is [7,8,9]
myArray[2][0] is 7
myArray[2][1] is 8
myArray[2][2] is 9
Alexx Martínez
@AlexxMart
May 15 2017 00:27
@sjames1958gm but it says I have to split the string by its spaces
Stephen James
@sjames1958gm
May 15 2017 00:27
@AlexxMart And this '' is not space this is ' '
Eric Hasegawa
@EricHasegawa
May 15 2017 00:28
@revisualize Got it, I'm more confused as to what exactly the second 'for' loop is doing
Alexx Martínez
@AlexxMart
May 15 2017 00:28
got it! Thanks @sjames1958gm
CamperBot
@camperbot
May 15 2017 00:28
alexxmart sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7307 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 15 2017 00:28
@AlexxMart :+1:
dinosaurjude
@dinosaurjude
May 15 2017 00:28
so im on factorialize a number. so to list out the numbers i would need to make a for loop that stops when it reaches the number put into the argument then multiply all those numbers. right?
Dovydas Stirpeika
@Giveback007
May 15 2017 00:28
hey what is the best way to use a comparison operator on null?
Joseph
@revisualize
May 15 2017 00:29
@EricHasegawa The second loop is iterating across the sub array.
Netrunner21
@Netrunner21
May 15 2017 00:29
@dinosaurjude sort of
@dinosaurjude you can do both at the same time
Eric Hasegawa
@EricHasegawa
May 15 2017 00:30
@revisualize I'm heading out now, but thanks a lot for the help you cleared a few things up!
CamperBot
@camperbot
May 15 2017 00:30
erichasegawa sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: erichasegawa already gave revisualize points
Netrunner21
@Netrunner21
May 15 2017 00:31
@dinosaurjude remember your operators. You technically don't have to list anything out.
MissLisaMN
@MissLisaMN
May 15 2017 00:31

on Word Blanks... not understanding what I am doing wrong... here is my code :
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "Here the " + myNoun + " is " + myAdjective + " and " + myVerb + " very " + myAdverb + " around";
return result;
}
// 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");

dinosaurjude
@dinosaurjude
May 15 2017 00:31
i ll look over the operators link . thank you @Netrunner21
CamperBot
@camperbot
May 15 2017 00:31
dinosaurjude sends brownie points to @netrunner21 :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @netrunner21 |http://www.freecodecamp.com/netrunner21
Stephen James
@sjames1958gm
May 15 2017 00:31
@electricpen Does this work on smaller ranges?
Netrunner21
@Netrunner21
May 15 2017 00:32
@dinosaurjude no problem.
Stephen James
@sjames1958gm
May 15 2017 00:32
@MissLisaMN Don't redefine the function inside the existing function

@MissLisaMN

result = "Here the " + myNoun + " is " + myAdjective + " and " + myVerb + " very " + myAdverb + " around";

this line is all you need to add

MissLisaMN
@MissLisaMN
May 15 2017 00:33
@sjames1958gm thanks!
CamperBot
@camperbot
May 15 2017 00:33
misslisamn sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7308 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 15 2017 00:33
@MissLisaMN In these earlier challenges, they will generally provide the function framework
Joseph
@revisualize
May 15 2017 00:35

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) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

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

electricpen
@electricpen
May 15 2017 00:35
@sjames1958gm this code works on every test case except the last one on the challenge
the 1-13 range in the code I pasted works
the one that breaks it is 23, 18 I think
Dovydas Stirpeika
@Giveback007
May 15 2017 00:40
The twitch API project, it's finally finished . I would like some input if anyone wouldn't mind:
https://codepen.io/giveback007/full/qmxdjw/
Mohamed Derhalli
@derhallim
May 15 2017 00:40
@sjames1958gm :v:
@HeebieGeeBee @JLuboff :clap:
Long Nguyen
@longnt80
May 15 2017 00:42

hello,

var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};


function insert(id, prop ,value) {
  collection[id] = {prop: value}
  console.log(collection);
  return collection;
}

insert(9999, "tracks", "Take a Chance on Me");

In this example, the returned collection with the id 9999 has the key prop instead of tracks. How to I fix it so that it write as tracks?

electricpen
@electricpen
May 15 2017 00:42
@Giveback007 aren't you supposed to show some non-existent accounts to show you have that error processing in your code?
Christopher McCormack
@cmccormack
May 15 2017 00:42
@Giveback007 your nav collapse could use a little work as it overlays the users when active.
Joseph
@revisualize
May 15 2017 00:42
Did they change that challenge again?
Dovydas Stirpeika
@Giveback007
May 15 2017 00:43
@electricpen I did, click on the mister404
@cmccormack what do you mean?
electricpen
@electricpen
May 15 2017 00:43
@Giveback007 I mean instead of displaying as offline
Joseph
@revisualize
May 15 2017 00:43
@longnt80 That isn't how I see that challenge: https://www.freecodecamp.com/challenges/record-collection
electricpen
@electricpen
May 15 2017 00:43
@Giveback007 it should say it is a 404 without having to click on it I thought
Dovydas Stirpeika
@Giveback007
May 15 2017 00:44
@electricpen good point, thank you for you input
CamperBot
@camperbot
May 15 2017 00:44
giveback007 sends brownie points to @electricpen :sparkles: :thumbsup: :sparkles:
:cookie: 284 | @electricpen |http://www.freecodecamp.com/electricpen
electricpen
@electricpen
May 15 2017 00:44
np
Long Nguyen
@longnt80
May 15 2017 00:44
@revisualize no, it's just something I'm experimenting
@revisualize I want to make a case when user insert a new id, the function will create a new id with value as a new object
the problem is it read prop as the key
should be tracks
Christopher McCormack
@cmccormack
May 15 2017 00:48
@longnt80 try collection[id][prop] = value maybe?
Dovydas Stirpeika
@Giveback007
May 15 2017 00:49
how to you change properties of a css class using JS?
Long Nguyen
@longnt80
May 15 2017 00:50
@cmccormack it said Cannot set property 'tracks' of undefined
I think because it is not an object yet
Christopher McCormack
@cmccormack
May 15 2017 00:51
ah yeah maybe add it first , collection[id] = {}; collection[id][prop] = value;
Netrunner21
@Netrunner21
May 15 2017 00:51
Has anyone figured out Convert HTML Entities without chaining replace()? Can it be done with one replace?
Moisés Man
@moigithub
May 15 2017 00:51
collection[id].tracks = {}
collection[id]["tracks"] = {}
collection[id][prop] = {}
Christopher McCormack
@cmccormack
May 15 2017 00:52
@longnt80 looks like you can wrap it in brackets in the object too -
> var a = 'test';
> var coll = {[a]: 3}
{ test: 3 }
Long Nguyen
@longnt80
May 15 2017 00:52
@cmccormack thank you
CamperBot
@camperbot
May 15 2017 00:52
longnt80 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 578 | @cmccormack |http://www.freecodecamp.com/cmccormack
Netrunner21
@Netrunner21
May 15 2017 00:53
function convertHTML(str) {
  // &colon;&rpar;
  return str.replace(/&/gi,"&amp;").replace(/</gi,"&lt;").replace(/>/gi,"&gt;").replace(/'/gi,"&apos;").replace(/"/gi,"&quot;");
}

convertHTML("Dolce & Gabbana");
Long Nguyen
@longnt80
May 15 2017 00:53
@moigithub can only use [prop] because user might use key other than tracks
Christopher McCormack
@cmccormack
May 15 2017 00:53
@longnt80 thank you - I didn't know you could use bracket notation like that until you asked the question :D
CamperBot
@camperbot
May 15 2017 00:53
cmccormack sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 251 | @longnt80 |http://www.freecodecamp.com/longnt80
Netrunner21
@Netrunner21
May 15 2017 00:53
is there an easier way to do this?
Long Nguyen
@longnt80
May 15 2017 00:54
@cmccormack hah, glad we both learned something
Christopher McCormack
@cmccormack
May 15 2017 00:55
@Giveback007 document.getElementById(id).style.property = new style
Moisés Man
@moigithub
May 15 2017 00:56
@Netrunner21 i did exactly same code as u did
Long Nguyen
@longnt80
May 15 2017 00:56
@Netrunner21 I don't think so
Rick Brown
@RickBr0wn
May 15 2017 00:57

hi all.. Caesars Cipher.. not quite working the way thought :/

function rot13(str) { // LBH QVQ VG!

var deCodedNumber = 0;
var deCodedArray = [];

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

var codedNumber = str.charCodeAt(i);

if(codedNumber < 77){
  deCodedNumber = codedNumber + 13;
}
else{
  deCodedNumber = codedNumber - 13;
}
deCodedArray.push(deCodedNumber);

}

deCodedArray.pop();
var answer = deCodedArray.join();
var returnValue = String.fromCharCode(answer);

return returnValue;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

Christopher McCormack
@cmccormack
May 15 2017 00:57
@Giveback007 jQuery also has .css("color", "red") for example.
Rick Brown
@RickBr0wn
May 15 2017 00:57
any suggestions?
_Code1001_
@Coce510
May 15 2017 00:57

// Initialize these three variables
var a=5;
var b=10;
var c= string;

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

Rick Brown
@RickBr0wn
May 15 2017 00:57

function rot13(str) { // LBH QVQ VG!

var deCodedNumber = 0;
var deCodedArray = [];

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

var codedNumber = str.charCodeAt(i);

if(codedNumber < 77){
  deCodedNumber = codedNumber + 13;
}
else{
  deCodedNumber = codedNumber - 13;
}
deCodedArray.push(deCodedNumber);

}

deCodedArray.pop();
var answer = deCodedArray.join();
var returnValue = String.fromCharCode(answer);

return returnValue;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

_Code1001_
@Coce510
May 15 2017 00:58
How do I make c say "I am a String"
help
Long Nguyen
@longnt80
May 15 2017 00:58
@Coce510 change var c= string;
_Code1001_
@Coce510
May 15 2017 00:59
change it to what?
nvm
Long Nguyen
@longnt80
May 15 2017 00:59
@Coce510
var c= string;
"I am a String"
c = c + " String!";
Netrunner21
@Netrunner21
May 15 2017 01:00
@moigithub @longnt80 alright. thanks for the input guys.
CamperBot
@camperbot
May 15 2017 01:00
netrunner21 sends brownie points to @moigithub and @longnt80 :sparkles: :thumbsup: :sparkles:
:star2: 3226 | @moigithub |http://www.freecodecamp.com/moigithub
:cookie: 252 | @longnt80 |http://www.freecodecamp.com/longnt80
Rick Brown
@RickBr0wn
May 15 2017 01:04
anyone free to help me plz :)
Christopher McCormack
@cmccormack
May 15 2017 01:12
@RickBr0wn why are you popping the first value in your array?
@RickBr0wn also you're pushing the character value to the array but then joining them and trying to return the String.fromCharCode - that isn't going to work how you expect. Joining them without an argument will return a comma separated string, and the fromCharCode is going to give you gibberish for that string
FlashHero
@FlashHero
May 15 2017 01:16
@RickBr0wn I think you need to say if number is greater than 65 and less than 77 and add else if for if the number is greater than 77 and less than 90
Christopher McCormack
@cmccormack
May 15 2017 01:16
@RickBr0wn try instead converting each value before pushing to the array, then return the joined array
_Code1001_
@Coce510
May 15 2017 01:18
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
How do I do that?
Christopher McCormack
@cmccormack
May 15 2017 01:19
@Coce510 11%3 is the same as finding the remainder of 11/3
_Code1001_
@Coce510
May 15 2017 01:19
ik
but I need to use the % symbol
Christopher McCormack
@cmccormack
May 15 2017 01:19
yes
_Code1001_
@Coce510
May 15 2017 01:20
var remainder; 11%3=2
Do I do that?
Christopher McCormack
@cmccormack
May 15 2017 01:20
@Coce510 nope, the first part you declared remainder, which is fine, but the second part you did nothing. You need to assign the results of your math to the variable
FlashHero
@FlashHero
May 15 2017 01:21
use equal sign to assign the value of expression
_Code1001_
@Coce510
May 15 2017 01:21
var remainder=2;
Christopher McCormack
@cmccormack
May 15 2017 01:22
@Coce510 nope - you need to let the math provide the answer
_Code1001_
@Coce510
May 15 2017 01:22
I understand
Christopher McCormack
@cmccormack
May 15 2017 01:22
so if 11%3 will provide the result of 2, then just assign 11%3 to your variable
_Code1001_
@Coce510
May 15 2017 01:22
Thanks @cmccormack and @cmccormack
CamperBot
@camperbot
May 15 2017 01:22
coce510 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 579 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
May 15 2017 01:22
np
MissLisaMN
@MissLisaMN
May 15 2017 01:27
Local Scope and Functions? No idea...
like where do I put the myVar?
Christopher McCormack
@cmccormack
May 15 2017 01:28
where does it say?
MissLisaMN
@MissLisaMN
May 15 2017 01:29
and what do I define it with? It says inside myLocalScope, did that I thought, didn't work
Christopher McCormack
@cmccormack
May 15 2017 01:29
show what you did
Netrunner21
@Netrunner21
May 15 2017 01:30
@MissLisaMN I didn't define it with anything when I did mine
MissLisaMN
@MissLisaMN
May 15 2017 01:30

function myLocalScope() {
'use strict';
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
*myVar, i used proper case

Netrunner21
@Netrunner21
May 15 2017 01:31
@MissLisaMN remove the ()
Christopher McCormack
@cmccormack
May 15 2017 01:31
@MissLisaMN to declare a variable within the scope of the function, you need to add var prior
Netrunner21
@Netrunner21
May 15 2017 01:31
@MissLisaMN ()'s are reserved for methods
Randy
@rsmorin2
May 15 2017 01:32
Does anyone have a suggestion for a arguments object tutorial? I tried reading the suggested MDN page but I left feeling more confused than anything else
Netrunner21
@Netrunner21
May 15 2017 01:32
@cmccormack @MissLisaMN that's right, you'll need var myVar;
MissLisaMN
@MissLisaMN
May 15 2017 01:32
now it says myVar is not defined
Christopher McCormack
@cmccormack
May 15 2017 01:32
@MissLisaMN yes
that's what it says in your comments
MissLisaMN
@MissLisaMN
May 15 2017 01:33
@cmccormack @Netrunner21 thank you
CamperBot
@camperbot
May 15 2017 01:33
misslisamn sends brownie points to @cmccormack and @netrunner21 :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @netrunner21 |http://www.freecodecamp.com/netrunner21
:cookie: 580 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
May 15 2017 01:33
np
Netrunner21
@Netrunner21
May 15 2017 01:33
@MissLisaMN works on mine, but you could add a string like "boo" or something
@MissLisaMN did you get the green check mark?
@rsmorin2 what's the name of the challenge?
Randy
@rsmorin2
May 15 2017 01:34
@Netrunner21 Seek and Destroy
Christopher McCormack
@cmccormack
May 15 2017 01:35
@Netrunner21 she was supposed to get that error then remove the console log
Xi
@yuman959
May 15 2017 01:35
Hi friends, I got stuck on Twitch API project. On the website it says we need to use the new API url (https://wind-bow.gomix.me/twitch-api) to avoid Twitch’s new registration requirement. However, it doesn’t print anything in my console log when I used this alternative request URL. Anybody can help me understand? https://codepen.io/yuman959/pen/wdXMgj
Netrunner21
@Netrunner21
May 15 2017 01:35
@cmccormack interesting, I never had to remove it, unless I'm not remembering that far back.
function myLocalScope() {
  'use strict';
  var myVar;

  console.log(myVar);
}
myLocalScope();
Christopher McCormack
@cmccormack
May 15 2017 01:36
@yuman959 <a href="#">
Netrunner21
@Netrunner21
May 15 2017 01:36
@rsmorin2 I remember this one now. I remember having to use some trickeration to get it to work
Christopher McCormack
@cmccormack
May 15 2017 01:37
@yuman959 you'll need to add the # of it's going to reload the page each time. After that you're going to get a CORS error - look into jsonp to resolve that one
Netrunner21
@Netrunner21
May 15 2017 01:37
@rsmorin2 what's the part that has you confused?
Randy
@rsmorin2
May 15 2017 01:40
@Netrunner21 - I could just slice up the argument object into new vars and pass it thought a for loop or map it and return the answer that way, but what I'm looking for is a better tutorial or something to get a better understanding of arguement objects and how to use them in a js method without having to split up the object first
Dovydas Stirpeika
@Giveback007
May 15 2017 01:41
i'm stumped. When I use the filter for online or offline the div elements are still technically there. Idk how to make them be noneffective to flex box.
Capture.PNG
Christopher McCormack
@cmccormack
May 15 2017 01:42
@Giveback007 display: none;
Dovydas Stirpeika
@Giveback007
May 15 2017 01:42
@cmccormack that's what I did
Christopher McCormack
@cmccormack
May 15 2017 01:42
maybe you need it in the surrounding container as well
Netrunner21
@Netrunner21
May 15 2017 01:43
@rsmorin2 I like your thinking. Basically you can use a filter function. arr is the first argument, but you'll have to use arguments[1] and arguments[2] to access the rest of the object. Technically you could use arguments[0] instead of arr
Dovydas Stirpeika
@Giveback007
May 15 2017 01:43
I did
DF
@freecodecamper23
May 15 2017 01:43
Hey guys, could anyone help me with the queue lesson?
Manish Giri
@Manish-Giri
May 15 2017 01:43
@freecodecamper23 what's the problem?
Netrunner21
@Netrunner21
May 15 2017 01:44
@rsmorin2 when I did mine I filtered (returned) values that weren't equal to the values of arguments[1], arguments[2], and so on. There were a limited number in the ests so I did not use a loop
FlashHero
@FlashHero
May 15 2017 01:44
@Manish-Giri can you tell me what is this mean
Array.prototype.concat.apply([],arguments);
DF
@freecodecamper23
May 15 2017 01:45
@Manish-Giri well I'm trying to make function nextInLine ([2], 1) return 2
Randy
@rsmorin2
May 15 2017 01:45
@Netrunner21 - I appreciate the imput, but what I was asking is if anyone else had a better place I could read up on arguments objects. I considered doing it the way you suggested already, I just don't how
I just don't get "how"
Dovydas Stirpeika
@Giveback007
May 15 2017 01:47
@cmccormack I just found my error, when creating the <a> element I did a.class = classOnOff instead of a.className = classOnOff, so you were technically correct. Thank you
CamperBot
@camperbot
May 15 2017 01:47
giveback007 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 581 | @cmccormack |http://www.freecodecamp.com/cmccormack
Netrunner21
@Netrunner21
May 15 2017 01:47
@rsmorin2 I know it well enough to pass the tests here, but I don't know it well enough be super specific about what they do, unfortunately. I do need to read up on that. I have to go. If I had more time, I'd try to help you more. Sorry man.
Manish Giri
@Manish-Giri
May 15 2017 01:47
@FlashHero I think it's just creating a new array with the arguments, which is an array-like object.
Randy
@rsmorin2
May 15 2017 01:48
@Netrunner21 no worries!
Christopher McCormack
@cmccormack
May 15 2017 01:48
@Giveback007 that's great glad you got it
Manish Giri
@Manish-Giri
May 15 2017 01:49
@freecodecamper23 okay, and?
FlashHero
@FlashHero
May 15 2017 01:49
@Manish-Giri what is the first argument in apply which is the empty array
Manish Giri
@Manish-Giri
May 15 2017 01:52
@FlashHero it's an empty array, you're basically concatenating the arguments object with an empty array to transform the array-like arguments object into an actual array.
FlashHero
@FlashHero
May 15 2017 01:55
@Manish-Giri so that empty array is like a placeholder for variable name arr so basically its pushing the value of the concatenation to that empty array which is then stored in variable right?
Manish Giri
@Manish-Giri
May 15 2017 01:56
not quite
the empty array is optional
you can also have var arr = Array.prototype.concat.apply([1],arguments);
whatever is the first argument will be concatenated with the arguments and the resulting array will be returned
function foo() {
  var arr = Array.prototype.concat.apply([1],arguments);
  return arr;
}

console.log(foo(2,3)); //[1, 2, 3]
FlashHero
@FlashHero
May 15 2017 02:02
@Manish-Giri so even without the first argument its still concatenating but it's array like object so you need to concat it with array to make it actual array right?
Cynwenn
@Cynwenn
May 15 2017 02:03
Hello could someone tell me why my object lookup isn't working??
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line

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

// Change this value to test
lookup("charlie");

Manish Giri
@Manish-Giri
May 15 2017 02:05
@Cynwenn return result;
this still returns an empty string
@FlashHero yup
FlashHero
@FlashHero
May 15 2017 02:05
@Manish-Giri ok thanks
CamperBot
@camperbot
May 15 2017 02:05
flashhero sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5503 | @manish-giri |http://www.freecodecamp.com/manish-giri
Gavo Bon
@GavoGavo
May 15 2017 02:06
Hello all! I have solved the problem but I don't really understand the logic behind it. I'm doing Iterate Through an Array with a For Loop and just don't understand what it means when it says Remember that Arrays have zero-based numbering, which means the last index of the array is length - 1. Our condition for this loop is i < arr.length, which stops when i is at length - 1.
I think arr.length is giving me the number of entries(?) in the array arr.
but if we following the example given, we are adding 1 to count each iteration(?) of the loop, so starting at 0, how is it that the loop stops at.. -1?
Long Nguyen
@longnt80
May 15 2017 02:08
@GavoGavo index is the position of each entry
Manish Giri
@Manish-Giri
May 15 2017 02:08
I think arr.length is giving me the number of entries(?) in the array arr.
yes
Long Nguyen
@longnt80
May 15 2017 02:09

@GavoGavo

but if we following the example given, we are adding 1 to count each iteration(?) of the loop, so starting at 0, how is it that the loop stops at.. -1?

can you give the example?

Manish Giri
@Manish-Giri
May 15 2017 02:09
and the last entry will always be at arr.length - 1
like a = [1,2,3]
a.length is 3
and the last index is 2
a.length - 1
Gavo Bon
@GavoGavo
May 15 2017 02:10
OOOOH
OH oh yes! THank you! I was thinking of -1 as an actual number value, not the definition that the last position is whatever that position is MINUS one
thank you thank you thank you
Manish Giri
@Manish-Giri
May 15 2017 02:10
:+1:
Gavo Bon
@GavoGavo
May 15 2017 02:10
thank you @Manish-Giri and @longnt80
CamperBot
@camperbot
May 15 2017 02:10
gavogavo sends brownie points to @manish-giri and @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 254 | @longnt80 |http://www.freecodecamp.com/longnt80
:star2: 5504 | @manish-giri |http://www.freecodecamp.com/manish-giri
Gavo Bon
@GavoGavo
May 15 2017 02:10
wooohoo excited by that
and also feel like a bit of a fool
Manish Giri
@Manish-Giri
May 15 2017 02:10
lol
Gavo Bon
@GavoGavo
May 15 2017 02:11
My biggest problems in FreeCodeCamp so far are understanding the explanations haha
Long Nguyen
@longnt80
May 15 2017 02:11
@GavoGavo you're gonna use it a lot in the future so you'll get it somehow
Gavo Bon
@GavoGavo
May 15 2017 02:11
@longnt80 awesomely terrifying :D
Anurag Lahon
@anuraglahon16
May 15 2017 02:13

function truncateString(str, num) {
// Clear out that junk in your trunk
if(str.length>num)
{
return str.splice(num);
}else{
return str;}
}

truncateString("A-tisket a-tasket A green and yellow basket", 8); what's wrong here?

Stephen James
@sjames1958gm
May 15 2017 02:14
@anuraglahon16 You are not adding the ... to the end (also the string length + ... should === num)
unless num <= 3
Anurag Lahon
@anuraglahon16
May 15 2017 02:15
@sjames1958gm what i am not adding
Stephen James
@sjames1958gm
May 15 2017 02:15
@anuraglahon16 '...'
Anurag Lahon
@anuraglahon16
May 15 2017 02:16
if i only want to have a function which truncates if it greater than num
Stephen James
@sjames1958gm
May 15 2017 02:16
Return the truncated string with a ... ending
Anurag Lahon
@anuraglahon16
May 15 2017 02:17

function truncateString(str, num) {
// Clear out that junk in your trunk
if(str.length>num)
{
return str.splice(num) + "...";
}else{
return str;}
}

truncateString("A-tisket a-tasket A green and yellow basket", 8); @sjames1958gm

Stephen James
@sjames1958gm
May 15 2017 02:18
Note that inserting the three dots to the end will add to the string length.
truncateString("A-tisket a-tasket A green and yellow basket", 11); should be "A-tisket..."
So the length after adding '...' should be 11
Anurag Lahon
@anuraglahon16
May 15 2017 02:19
@sjames1958gm oh
my present code is giving an error
Mark Evans
@MarkFBS
May 15 2017 02:24

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

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

// Change the inputs below to test your code
convertToF(0);
convertToF(-30);
convertToF(-10);
convertToF(20);
convertToF(30);

cant seem to pass this section :( Any help?

Manish Giri
@Manish-Giri
May 15 2017 02:26
@MarkFBS 0 * 9/5 +
won't this always return 0?
Anurag Lahon
@anuraglahon16
May 15 2017 02:32
@MarkFBS fahrenheit=celsius* 9/5 +32;
Somia ♡
@somiajagadish
May 15 2017 02:36

In the casino game Blackjack, a player can gain an advantage over the house by keeping track of the relative number of high and low cards remaining in the deck. This is called Card Counting.

Having more high cards remaining in the deck favors the player. Each card is assigned a value according to the table below. When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.
Count Change Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K', 'A'

You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.

Example Output
"-3 Hold"
"5 Bet"

Hint
Do NOT reset count to 0 when value is 7, 8, or 9.

I need help
Manish Giri
@Manish-Giri
May 15 2017 02:37
@somiajagadish post your code
Somia ♡
@somiajagadish
May 15 2017 02:37

@Manish-Giri var count = 0;

function cc(card) {
// Only change code below this line

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

i have no clue what to do
Manish Giri
@Manish-Giri
May 15 2017 02:37
oh
Somia ♡
@somiajagadish
May 15 2017 02:38
yeahhh
Manish Giri
@Manish-Giri
May 15 2017 02:38
do you know switch-case or if/else?
Somia ♡
@somiajagadish
May 15 2017 02:38
yes
Manish Giri
@Manish-Giri
May 15 2017 02:38
okay
you can use either for this challenge
for the first step
Somia ♡
@somiajagadish
May 15 2017 02:39
ok
Manish Giri
@Manish-Giri
May 15 2017 02:39
make a switch/if-else where you have 3 conditions
Somia ♡
@somiajagadish
May 15 2017 02:39
ok
Manish Giri
@Manish-Giri
May 15 2017 02:40
  1. card values are 1 2, 3, 4, 5, 6
  2. card values are 7, 8, 9
  3. card values are 10, 'J', 'Q', 'K', 'A'
Somia ♡
@somiajagadish
May 15 2017 02:40
okay so i make a if/else statement and then what do i do?
Manish Giri
@Manish-Giri
May 15 2017 02:40
for the first case, you increment count by 1, for the third case, you decrement count by 1, and the second case doesn't modify count
in effect, you can avoid making the second case completely
do upto here first, then post your code
Somia ♡
@somiajagadish
May 15 2017 02:41
okay
@Manish-Giri thanks i get it now
CamperBot
@camperbot
May 15 2017 02:42
somiajagadish sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5505 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
May 15 2017 02:42
:+1:
Mark Evans
@MarkFBS
May 15 2017 02:47
@Manish-Giri You are correct! No idea what I was thinking. Thank you! and thanks @anuraglahon16
CamperBot
@camperbot
May 15 2017 02:47
markfbs sends brownie points to @manish-giri and @anuraglahon16 :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @anuraglahon16 |http://www.freecodecamp.com/anuraglahon16
:star2: 5506 | @manish-giri |http://www.freecodecamp.com/manish-giri
MissLisaMN
@MissLisaMN
May 15 2017 02:49

Help with Stand in line challenge: here are the instructions-Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed. mY questions are: Do I use shift, or pop? Or am I totally misunderstanding how to do this? here is what the code they gaveme looks like : 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));

Manish Giri
@Manish-Giri
May 15 2017 02:50
@MissLisaMN okay, your function gets two arguments - arr and item, yes?
MissLisaMN
@MissLisaMN
May 15 2017 02:50
@Manish-Giri yes
Manish Giri
@Manish-Giri
May 15 2017 02:50
the first step is to add the number itemto the end of the array arr, use .push() for this.
MissLisaMN
@MissLisaMN
May 15 2017 02:51
@Manish-Giri where do I place the .push()?
Manish Giri
@Manish-Giri
May 15 2017 02:51
// Your code here
after this comment
@MissLisaMN
beingbing
@beingbing
May 15 2017 02:52
in Profile Lookup challenge i could not understand why my function is not passing.
can anybody suggest me, what the challenge want us to do.
MissLisaMN
@MissLisaMN
May 15 2017 02:53
@Manish-Giri arr.push(); under //Your code here?
Manish Giri
@Manish-Giri
May 15 2017 02:53
@MissLisaMN yes
but that's not complete
what are you pushing on?
review how .push() works
MissLisaMN
@MissLisaMN
May 15 2017 02:53
nextInLine function?
Manish Giri
@Manish-Giri
May 15 2017 02:54
the first step is to add the number itemto the end of the array arr, use .push() for this.
@MissLisaMN
cameron
@whoopswoop
May 15 2017 02:54

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

// Your code above this line
return result;
}

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

MissLisaMN
@MissLisaMN
May 15 2017 02:55
@Manish-Giri thank you for the resource!
CamperBot
@camperbot
May 15 2017 02:55
misslisamn sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5507 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
May 15 2017 02:55
@whoopswoop there's no need to do this
myNoun = "dog";
myAdjective = "big";
myVerb = "ran";
myAdverb = "quickly";
that happens automatically when the function is called
but you need to add spaces here
result = myNoun + myAdjective + myVerb + myAdverb;
@MissLisaMN like for example [1,2,3].push(4)
grfraser
@grfraser
May 15 2017 02:56
why does this work in code pen but not on my computer or js fiddle?
http://codepen.io/grfraser/pen/PmerZZ
https://jsfiddle.net/grfraser/9t24bxqp/2/
Claudio Restifo
@Marmiz
May 15 2017 03:01
@grfraser are you importing the libraries correctly on our machine?
grfraser
@grfraser
May 15 2017 03:01
i know it looks crappy but the javascript must be off
@Marmiz i believe so yes
check out the fidddle its the exact same
Joseph
@revisualize
May 15 2017 03:02

@whoopswoop 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.

Claudio Restifo
@Marmiz
May 15 2017 03:04
@grfraser so where's the issue if they are the same?
Adam
@Kloppers
May 15 2017 03:04
Hi all, having trouble with the Javascript profile lookup exercise
Joseph
@revisualize
May 15 2017 03:04
@Kloppers What is the state of your function? (Just the function not the large ass array)
Adam
@Kloppers
May 15 2017 03:05
for (var i=0; i<contacts.length; i++){
if (contacts[i].firstName == firstName){
if (contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}
else {
return "No such prop";
}
}
else {
return "No such contact";
}
}
Joseph
@revisualize
May 15 2017 03:05
@Kloppers Okay. So, your for loop isn't actually looping
Adam
@Kloppers
May 15 2017 03:05
Oops, how do you format chat messages like the console display?
cameron
@whoopswoop
May 15 2017 03:05
thank you @revisualize
CamperBot
@camperbot
May 15 2017 03:05
whoopswoop sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3966 | @revisualize |http://www.freecodecamp.com/revisualize
kerafyrm02
@kerafyrm02
May 15 2017 03:06
@adam use ```
Joseph
@revisualize
May 15 2017 03:06
@Kloppers Let me show you a trimmed down version of the concept that you have.
Adam
@Kloppers
May 15 2017 03:06
cheers
Joseph
@revisualize
May 15 2017 03:06

@Kloppers

for ( ..... ) {
    if (evaluation) {
        return "truth";
    } else {
        return "lies";
    }
 }

This exact loop.. Does not loop.
Why?

Adam
@Kloppers
May 15 2017 03:07
Would it exit at the first return_
?
Joseph
@revisualize
May 15 2017 03:07
The return statement ends function execution and specifies a value to be returned to the function caller.
Syntax
return [[expression]];
expression
The expression to return. If omitted, undefined is returned instead.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
@Kloppers Kind of correct. When the return statement is triggered your function will halt. If the evaluation is true. The function halts. If the evaluation is false.. The function halts.
Adam
@Kloppers
May 15 2017 03:08
Ahhh, so I expected
Joseph
@revisualize
May 15 2017 03:08
@Kloppers Now your code doesn't need to be changed a lot.
@Kloppers You just have to change a key thought process with your logic.
@Kloppers Let's say you were at a big business event and you're quite popular (with all those skills you have) throughout the event you got handed 200 business cards (Which will remain unordered). Now, I walk up to you at the end and ask you.. Do you have a Business Card for "Jane Smith"? Now you loop look through your stack of 200 business cards. When would you tell me that you didn't have a business card for Jane?
Adam
@Kloppers
May 15 2017 03:09
@revisualize at the end of the stack
Joseph
@revisualize
May 15 2017 03:09
@Kloppers Technically no.
Jonathan Marx Domah
@marxcom
May 15 2017 03:09
help guys "use strict"; let favorite = redNosedReindeer + " is Santa's favorite reindeer."; let redNosedReindeer = "Rudolph"; let redNosedReindeer = "Comet";
Joseph
@revisualize
May 15 2017 03:09
@Kloppers After.
Ricardo Lara
@AlejandrLara12
May 15 2017 03:09
hello guys!
Joseph
@revisualize
May 15 2017 03:10
@Kloppers after you loop look through all of the contacts cards in your array of object stack. That's when you'd tell me you don't have one for the individual.
Ricardo Lara
@AlejandrLara12
May 15 2017 03:10
Could you javaScript coders help me out?
Adam
@Kloppers
May 15 2017 03:10
@revisualize Gotcha, so outside of the loop!
Ricardo Lara
@AlejandrLara12
May 15 2017 03:10

function uniteUnique(arr) {
  console.log("#### Init ", arr);

  var unic = [];

  arr.forEach(function(current,index){
    if(unic.indexOf(current) < 0){
      unic.push(current);
      console.log('unic: ',unic);
    }  
  });

  return unic;
}

uniteUnique([[1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]]);
Joseph
@revisualize
May 15 2017 03:10
@Kloppers :D
Adam
@Kloppers
May 15 2017 03:10
@revisualize You are a gentleman and a scholar
Ricardo Lara
@AlejandrLara12
May 15 2017 03:10
uniteUnique([[1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]]);
Joseph
@revisualize
May 15 2017 03:10
@Kloppers Also, your text strings aren't correct.
Adam
@Kloppers
May 15 2017 03:11
@revisualize On the return statements?
Ricardo Lara
@AlejandrLara12
May 15 2017 03:11
// this is how I "when over it"
uniteUnique([[1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]]);

// this is how the input should looks like
uniteUnique( [1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8] );
Joseph
@revisualize
May 15 2017 03:11
@Kloppers You have "No such prop" ... that's not correct.
Adam
@Kloppers
May 15 2017 03:11
oh, derp
Lol... maybe I shouldn't be coding right now
LaTanya Powers
@latanyapowers
May 15 2017 03:12
Hello I am trying to get the i---; for my Var. I have myVar--; and i = myVar--; and it is coming up to be 9 but the answer needs to be 10. Can anyone please help?
Joseph
@revisualize
May 15 2017 03:12
@Kloppers Solve it?

@latanyapowers

var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8

See how the one for getting num from 7 to 8 doesn't use the assignment operator (=)?
The lesson is requesting that you recreate that process so that you know how to increment and decrement a number with short notation.

@latanyapowers Which challenge are you working on?
LaTanya Powers
@latanyapowers
May 15 2017 03:13
I am on 86
Adam
@Kloppers
May 15 2017 03:13
@revisualize Almost thank you, I'm one "objective" away now
CamperBot
@camperbot
May 15 2017 03:13
kloppers sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3967 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 15 2017 03:14
@latanyapowers Challenges don't have numbers. Names.
LaTanya Powers
@latanyapowers
May 15 2017 03:14
Decrement a number with JavaScript
Joseph
@revisualize
May 15 2017 03:15
@latanyapowers Yeah. So. the same concept as with ++ for --
Brian
@BrianCodes33
May 15 2017 03:15
do y’all think algorithms help in writing apps?
LaTanya Powers
@latanyapowers
May 15 2017 03:16
Right, I was able to get the previous ++ but when I do the same for -- its not letting me. I keep getting a 9 and they want an answer 10
Joseph
@revisualize
May 15 2017 03:16

@latanyapowers

var num = 10;
num = num - 1; // 9
num -= 1; // 8
num--; // 7

See how the one for getting num from 8 to 7 doesn't use the assignment operator (=)?
The lesson is requesting that you recreate that process so that you know how to increment and decrement a number with short notation.

Vijay SIngh
@Darth-koder007
May 15 2017 03:16
If one would summarize closures in least words, how would they do it?
Joseph
@revisualize
May 15 2017 03:16
@latanyapowers You just have to change this line: myVar = myVar - 1; to myVar--;
grfraser
@grfraser
May 15 2017 03:17

why does my codepen work for Random Quote Generator but it doesnt work on my local comp or on Js Fiddle. Please feel free to check them both out and provide feed back. There must be something wrong with the jQuery that codepen is not catching. They are exactly the same.

https://jsfiddle.net/grfraser/9t24bxqp/3/
http://codepen.io/grfraser/pen/PmerZZ

Joseph
@revisualize
May 15 2017 03:17
@Darth-koder007 Closures
Claudio Restifo
@Marmiz
May 15 2017 03:17

@BrianCodes33

do y’all think algorithms help in writing apps?

In mathematics and computer science, an algorithm is a self-contained sequence of actions to be performed.

So definitely yes since you'll likely write a sequence of actions :)

Adam
@Kloppers
May 15 2017 03:17
@revisualize Yup, got it. Was getting confused because couldn't see the final }... was outside the "edit between these lines" haha
LaTanya Powers
@latanyapowers
May 15 2017 03:17
thanks. Let me see
Vijay SIngh
@Darth-koder007
May 15 2017 03:17
@revisualize yeah!?
Joseph
@revisualize
May 15 2017 03:18
@latanyapowers You need to learn how to do short notation for incrementing and decrementing numeric variable values.
@Darth-koder007 That was my answer to your question.

If one would summarize closures in least words, how would they do it?

Closures

Moiz Masud
@MoizMasud
May 15 2017 03:18
hi
i have a quick question
anyone willing to help?
Vijay SIngh
@Darth-koder007
May 15 2017 03:18
@joseph please elaborate
@MoizMasud hey buddy, what's the question
Moiz Masud
@MoizMasud
May 15 2017 03:19

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

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

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

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

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

idk where im going wrong
Claudio Restifo
@Marmiz
May 15 2017 03:19
@grfraser it's not working since JSFiddle is blocking the api due to being served over HTTP instead of HTTPS
Is a standard security check
zxyango
@zxyango
May 15 2017 03:20
Pig Latin how to solve
grfraser
@grfraser
May 15 2017 03:20
@Marmiz why does it work on codepen?
zxyango
@zxyango
May 15 2017 03:20
LaTanya Powers
@latanyapowers
May 15 2017 03:20
Thank you. I was able to get it.
grfraser
@grfraser
May 15 2017 03:21
@Marmiz and which is the http one? they both show https
Claudio Restifo
@Marmiz
May 15 2017 03:21

@revisualize

If one would summarize closures in least words, how would they do it?
Closures

:laughing: great explanation :+1:

Vijay SIngh
@Darth-koder007
May 15 2017 03:21
@revisualize thanks
CamperBot
@camperbot
May 15 2017 03:21
darth-koder007 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3968 | @revisualize |http://www.freecodecamp.com/revisualize
Moiz Masud
@MoizMasud
May 15 2017 03:21
@Darth-koder007 any luck?
Claudio Restifo
@Marmiz
May 15 2017 03:21
@grfraser the api is calling an http endpoint
Anyone else want me to google stuff for them?
Claudio Restifo
@Marmiz
May 15 2017 03:22
@revisualize this is a better service for googling stuff for people:
https://lmgtfy.com/
Joseph
@revisualize
May 15 2017 03:22
@Marmiz I know.
Claudio Restifo
@Marmiz
May 15 2017 03:22
:+1:
grfraser
@grfraser
May 15 2017 03:23
@Marmiz omg i see it now thanks so much!
CamperBot
@camperbot
May 15 2017 03:23
grfraser sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 862 | @marmiz |http://www.freecodecamp.com/marmiz
Claudio Restifo
@Marmiz
May 15 2017 03:24
@grfraser working with API in codepen/fiddle is generally a pain for either CROS or Mixed-Content.
Which is good since you learn a bit of security.. but definitely confusing; especially when starting :)
grfraser
@grfraser
May 15 2017 03:25
for sure. i was hung up all day on that. one letter off. haha wow thanks so much.
Anurag Lahon
@anuraglahon16
May 15 2017 03:27

Remove all falsy values from an array.

Falsy values in JavaScript are false, null, 0, "", undefined, and NaN.

grfraser
@grfraser
May 15 2017 03:28
@Marmiz i guess codepen doesnt care about http https sometimes
Claudio Restifo
@Marmiz
May 15 2017 03:32
@grfraser it does, but since you are using it over http it won't affect. Try switching to https://codepen and you'll see it being blocked as well :)
@anuraglahon16 have you checked the Boolean documentation?
grfraser
@grfraser
May 15 2017 03:37
oh i was on http://codepen? i know i typed that it but i thought it defaulted back to https
@Marmiz after the answer to that i have one more related issue if you dont mind.
Claudio Restifo
@Marmiz
May 15 2017 03:37
@grfraser happy to help if I can :)
grfraser
@grfraser
May 15 2017 03:38
thanks man :smile: okay so it really did default to http://codepen
?
whereas i thought it defaulted back to https since it only showed codepen.io
how do you check that?
i use chrome btw
Corey
@kuehlc
May 15 2017 03:40

...function palindrome(str) {
// Good luck!

var newStr = str.replace(/([^\d])(\d)([^\w]*)/, "");
var newStr2 = newStr.replace(" ", "");
var revStr = newStr2.split('').reverse().join('');

if (newStr2 == revStr) {
return true;
} else {
return false;
}
}

anyone see something wrong with this?
Claudio Restifo
@Marmiz
May 15 2017 03:42

@grfraser that depends on how they've set their ends.
In general you can set to redirect every request from http:mywebsiteto be redirected to https:mywebsite. Maybe codepen decided to keep the http alive as well. Don't know their intention/design choices... but there's luckily a blog post about it if you look for it.

As for inspecting, new version of chrome has an i info button next to the url that gives you this kind of info

Brittany Heller
@b-marie
May 15 2017 03:44
Hey guys, I’m really struggling with the Selecting from many options with Switch Statements challenge. Here is my code… Does anyone know what I’m doing wrong?

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch(val) {
case val === 1:
answer = "alpha";
break;
case val === 2:
answer = "beta";
break;
case val === 3:
answer = "gamma";
break;
case val === 4:
answer = "delta";
break;
}
// Only change code above this line
return answer;
}

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

instructions are: Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"
grfraser
@grfraser
May 15 2017 03:46
@Marmiz ah duh. thank you. and two more questions actually what does this mean bc now codepen https is telling me this. loading some quotes and sometimes loading nothing and displaying in console:
XMLHttpRequest cannot load https://quotesondesign.com/wp-json/posts?%20%20%20filter[orderby]=rand&filter[posts_per_page]=32&callback=. The 'Access-Control-Allow-Origin' header has a value 'http://s.codepen.io' that is not equal to the supplied origin. Origin 'https://s.codepen.io' is therefore not allowed access.
CamperBot
@camperbot
May 15 2017 03:46
grfraser sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:warning: grfraser already gave marmiz points
Brittany Heller
@b-marie
May 15 2017 03:47
Ahh it looks like I needed to set case to just the numbers… nevermind :)
grfraser
@grfraser
May 15 2017 03:47
now if you click multiple times you will eventually get a quote. whereas the JS Fiddle one works perfectly.
@Marmiz
Matt Gagne
@justcbdev
May 15 2017 03:49
What's the command for posting a screenshot from the FCC challenge editor?
grfraser
@grfraser
May 15 2017 03:51
thats a good question @justcbdev
Claudio Restifo
@Marmiz
May 15 2017 03:51

@grfraser if you read the error:

The 'Access-Control-Allow-Origin' header has a value 'http://s.codepen.io' that is not equal to the supplied origin. Origin 'https://s.codepen.io' is therefore not allowed access

meaning that somehow the header for the request still come from http codepen. I don't know how you've switched to the https version. Have a look on how you can do it properly

@justcbdev here's an article on code formatting in gitter
grfraser
@grfraser
May 15 2017 03:53
@Marmiz i feel like that is a site issue
@Marmiz it worked perfect on codepen with just http in the api
while on the http version of the site
Claudio Restifo
@Marmiz
May 15 2017 03:54
@grfraser it is a site issue. I'm telling it from the beginning ^^
grfraser
@grfraser
May 15 2017 03:55
very odd. so it is the codepen site issue, not the https quotes on design api site issue correct?
Claudio Restifo
@Marmiz
May 15 2017 03:55
an https usually don't talk with a http for security reason. No problem between two https
@grfraser according to that api the content is over http only
but check their docs
grfraser
@grfraser
May 15 2017 03:56
but on js fiddle it works thru https
only
Matt Gagne
@justcbdev
May 15 2017 03:56
@Marmiz Thanks :)
CamperBot
@camperbot
May 15 2017 03:56
justcbdev sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 863 | @marmiz |http://www.freecodecamp.com/marmiz
grfraser
@grfraser
May 15 2017 03:57
anyways i can look into that more later i suppose. the main issue i have is that it still doesnt work on my computer. i have it uploaded to the internet if you wanna give a quick check to the link and source?
Claudio Restifo
@Marmiz
May 15 2017 03:58

@grfraser I think you're not following...
two https talks with each other so is normal that it works.

somehow you had an error lately with codepen that the request will still come from http codepen even tho you're browsing https codepen. This means that probably only switching url is not enough to "port" the code over a more secure protocol. Check with codepen what's the suggested method

Chris Cullen
@123xylem
May 15 2017 03:59
<style>
.dropdown {
    float: left;
    box-sizing:border-box;
    width: 24%;
font-size:1rem;
    display: inline-block;
border:1px solid silver;
  background: rgba(0, 0, 0, 0.08);
padding:0.4rem;
border-radius:5%;
text-align: center;
text-decoration: underline;
font-weight:500;
color:black;
}

.dropdown a{
    display:block;
    margin: 2px;
text-align: center;
font-weight: 300;
text-decoration: none;
color:black;

}

.dropdown a:hover{
border:0.001rem black solid;

}

.dropdown-title{
    position: relative;
    margin-bottom: 1rem;
text-align:center;
margin-left: auto;
margin-right: auto;
}

.dd-img{
height:5rem width:10rem;
padding:0.2rem;
position:relative;
    background-position: 50% 50%;
    background-repeat:   no-repeat;
    background-size:     cover;


}

.dropdown-content {
    display: none;
    position: absolute;
    top:7rem;
    background-color: rgba(255, 255, 255, 0.8);
        min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    padding: 12px 16px;
    z-index: 1;
}

.dropdown:hover .dropdown-content {
    display: block;
    color:black;
}

.nav-bar{
display:inline
}

</style>

<div class="nav-bar">
<div class="dropdown">
<div class="thumbnail text-center">


<img class="dd-img" src="//cdn.shopify.com/s/files/1/1879/8825/collections/download_grande@2x.jpeg?v=1494750935" alt="Meditation"> 
 <p class="dropdown-title">Meditation</p>

</div>
  <div class="dropdown-content">
    <a href="/collections/meditation">Bolster!</a>
   <a href="/collections/meditation">Oils</a>   
<a href="/collections/meditation">Chairs</a>
  </div>
</div>
<div class="dropdown">
<div class="text-center thumbnail">

<img class="dd-img" src="//cdn.shopify.com/s/files/1/1879/8825/collections/yogabali_0a21bf93-b45a-4746-ab49-ee74d22cb76d_grande@2x.jpg?v=1494750572" alt="Yoga">  <p class="dropdown-title">Yoga</p>

</div>
  <div class="dropdown-content">
    <a href="/collections/yoga">Bolster!</a>
   <a href="/collections/yoga">Oils</a>   
<a href="/collections/yoga">Chairs</a>
</div>
  </div>


<div class="dropdown">
<div class="text-center thumbnail"> 
   <img class="dd-img" src="//cdn.shopify.com/s/files/1/1879/8825/collections/mandala_grande@2x.jpg?v=1494750193" alt="Zen Home">
<p class="dropdown-title">Zen-Home</p>

  </div>
  <div class="dropdown-content">
    <a href="/collections/homeware">Bolster!</a>
   <a href="/collections/homeware">Oils</a>   
<a href="/collections/homeware">Chairs</a>
  </div>
  </div>

<div class="dropdown">
<div class="text-center thumbnail">
<img class="dd-img" src="//cdn.shopify.com/s/files/1/1879/8825/collections/slide_1_1024x1024_75e658c0-67d7-4dd0-ad94-c12ffe7ba701_grande@2x.jpg?v=1492844266" alt="Health">   <p class="dropdown-title">Health</p>

  </div>
  <div class="dropdown-content">
    <a href="/collections/health">Bolster!</a>
   <a href="/collections/health">Oils</a>   
<a href="/collections/health">Chairs</a>
  </div>
</div>

</div>
Matt Gagne
@justcbdev
May 15 2017 03:59
var myStr = "\"FirstLine\n\\SecondLine\\ \rThirdLine\""; // Change this line

//I've tried everything...googling...several online escape testing tools, the linux printf from the CLI...and for the life of me I can't get this to work. And I suggestions?
Chris Cullen
@123xylem
May 15 2017 03:59
Any idea why my dropdown hover wont select anymore?
Gulsvi
@gulsvi
May 15 2017 03:59
@grfraser It works great for me, if I use this link in the getJSON:
https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]="+pgNum+"&callback="
@123xylem Do you have a codepen link for that code?
Chris Cullen
@123xylem
May 15 2017 04:00
@SkyCoder01 its at the bottom of the page here
Ken Haduch
@khaduch
May 15 2017 04:00
@justcbdev - you should not have any whitespaces in the string at the end. You do not have to have the quoted quotes - that is \" - just regular quotes to delimit the string.. That might do it.
Claudio Restifo
@Marmiz
May 15 2017 04:00
@grfraser the "issue" could be as simple al that the browser still had in cache the request from the http.
Matt Gagne
@justcbdev
May 15 2017 04:00
@khaduch Thanks, I'll give it a try.
CamperBot
@camperbot
May 15 2017 04:00
justcbdev sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2872 | @khaduch |http://www.freecodecamp.com/khaduch
grfraser
@grfraser
May 15 2017 04:01
@SkyCoder01 it seems to work on codepen when i have http codepen and http api. when i switch both to https it doesnt seem to work. @Marmiz good point. ill clear my cache.
Gulsvi
@gulsvi
May 15 2017 04:01
@grfraser It works great over HTTPS if you use the link I gave you
Matt Gagne
@justcbdev
May 15 2017 04:02
@khaduch Lol, I took our the space after the "\r" and then the two \" and that got it. Thanks again. :)
CamperBot
@camperbot
May 15 2017 04:02
justcbdev sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: justcbdev already gave khaduch points
Gulsvi
@gulsvi
May 15 2017 04:03
@grfraser http://s.codepen.io/skycoder/pen/mmKOpv and https://s.codepen.io/skycoder/pen/mmKOpv
^^ Both copies of your codepen and they work over HTTP and HTTPS
You do need to use encodeURIComponent() for your tweet text, however, or it will get truncated when there is punctuation in your quote text. (apostrophes, semi-colons)
Ken Haduch
@khaduch
May 15 2017 04:03
@justcbdev - great! You should re-read the instructions and see what you missed. THey definitely mention the whitespaces. The quoted quotes was a little different from other things I've seen people do with that- but good luck going forward! :+1:
dinosaurjude
@dinosaurjude
May 15 2017 04:10
doing Check for Palindromes. wondering what i would need to use .replace for? so far i got single words to reverse and return true if its the same but it wont return true if the argument has spaces.
Netrunner21
@Netrunner21
May 15 2017 04:11
@dinosaurjude you could replace the spaces with nothing.
dinosaurjude
@dinosaurjude
May 15 2017 04:12
@Netrunner21 dont know why i didnt think of that lol. thanks
CamperBot
@camperbot
May 15 2017 04:12
dinosaurjude sends brownie points to @netrunner21 :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @netrunner21 |http://www.freecodecamp.com/netrunner21
grfraser
@grfraser
May 15 2017 04:12
@SkyCoder01 yes i noticed that as well! thanks man give me a min
CamperBot
@camperbot
May 15 2017 04:12
grfraser sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:star2: 1384 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Netrunner21
@Netrunner21
May 15 2017 04:12
@dinosaurjude no problem dino
grfraser
@grfraser
May 15 2017 04:15
@SkyCoder01 i have to click like 10 times or more to get a new quote on each
how do i use encodeURIComponent()though?
where would i put it?
c0d0er
@c0d0er
May 15 2017 04:18
does anybody know what does the following mean? i am on the fcc beta challenges which require using glitch, but not yet find the way, https://beta.freecodecamp.com/en/challenges/basic-node-and-express/introduction-to-the-basic-node-and-express-challenges

Working on these challenges will involve you writing your code on Glitch on our starter project. After completing each challenge you can copy your public Glitch url (to the homepage of your app) into the challenge screen to test it! Optionally you may choose to write your project on another platform but it must be publicly visible for our testing.
Start this project on Glitch using this link or clone this repository on GitHub! If you use Glitch, remember to save the link to your project somewhere safe!
Markus Ivancsics
@ivancsicsmarkus
May 15 2017 04:21
@c0d0er You are able to develop on your own machine and when you finish, you should test it on Glitch OR you are able to develop on Glitch from the start.
grfraser
@grfraser
May 15 2017 04:33
@Marmiz did you disappear? :worried:
Claudio Restifo
@Marmiz
May 15 2017 04:34
@grfraser can I help?
grfraser
@grfraser
May 15 2017 04:35
check out grantrfraser.com/portfolio -yes i know its crap but the quotes appear with two weird ae symbols rather than a dash?
or it doesnt work … now. let me knwo if it woorks for you
its working in one browser but not another
cleared cache works, still weird symbols though
grfraser
@grfraser
May 15 2017 04:41
@SkyCoder01 mentioned encodeURIComponent() but i dont understand how to use it
@Marmiz
Claudio Restifo
@Marmiz
May 15 2017 04:41

@grfraser with all due respect... have you google it, or at least try to solve it yourself?
I just did a dumb search and I had exactly the answer I was about to give to you.

Mi point is: try to learn how to learn

grfraser
@grfraser
May 15 2017 04:41
yes i looked at the mdn
Claudio Restifo
@Marmiz
May 15 2017 04:42
@grfraser anyway the "weird" symbol is just a different encoding (probably iso) instead of UTF-8
grfraser
@grfraser
May 15 2017 04:42
UTF-8 yes i saw that. but how do i change that in my html?
is UTF8 the standard?
sorry i am a nooob
if it is the standard i will use it but i dont want to use it if it isnt
jw if you knew
Claudio Restifo
@Marmiz
May 15 2017 04:49
Just by inspecting your source:
//script.js
$("#quote").html(a[0].content + "<p>— " + a[0].title + "</p>")
I guess the issue lies here
Anupama
@anupamaupadhyay
May 15 2017 04:51
I am getting error "Do not change code above the line
" while using var a;
a=7;
var b;
b=a;
what is wrong here please help ?
grfraser
@grfraser
May 15 2017 04:52
@Marmiz yes but that is not actually what my file has
its really this
$(document).ready (function () {
  $('#submit').click(function () {
    var pgNum = Math.floor(Math.random()*40);
    $.getJSON("https://quotesondesign.com/wp-json/posts?   filter[orderby]=rand&filter[posts_per_page]="+pgNum+"&callback=", function(a) {
    $("#quote").html(a[0].content + "<p>— " + a[0].title + "</p>")
    $(".twitter-share-button").attr("href",   "https://twitter.com/intent/tweet?text="+ (a[0].content.replace(/(<([^>]+)>)|(\\n)/gi,"") + " -" + a[0].title.replace(/(<([^>]+)>)|(\\n)/gi,"")));
});  
});
  });
but shows up as that when inspecting and displayed
Claudio Restifo
@Marmiz
May 15 2017 04:55
check your editor encoding settings then
@anupamaupadhyay where is var a declared?
make sure that the setup is unchanged
__SharifTarver__
@Sharifdesigns22
May 15 2017 05:01

this isn’t freecodecamp related but I wanted to know why my script keeps showing up on the left side of the screen. Can someone give me a hand?

<script src="https://cdn.jotfor.ms/static/prototype.forms.js" type="text/javascript"></script>

<script src="https://cdn.jotfor.ms/static/jotform.forms.js?3.3.376" type="text/javascript"></script>

<script type="text/javascript"> JotForm.init(function(){ JotForm.alterTexts({"alphabetic":"This field can only contain letters","alphanumeric":"This field can only contain letters and numbers.","characterLimitError":"Too many Characters. The limit is","confirmClearForm":"Are you sure you want to clear the form","confirmEmail":"E-mail does not match","currency":"This field can only contain currency values.","email":"Invalid E-mail.","fillMask":"Field value must fill mask.","generalError":"There are errors on the form. Please fix them before continuing.","generalPageError":"There are errors on this page. Please fix them before continuing.","gradingScoreError":"Score total should only be less than or equal to","incompleteFields":"There are incomplete required fields. Please complete them.","inputCarretErrorA":"Input should not be less than the minimum value:","inputCarretErrorB":"Input should not be greater than the maximum value:","lessThan":"Your score should be less than","maxDigitsError":"The maximum digits allowed is","maxSelectionsError":"The maximum number of selections allowed is","minSelectionsError":"The minimum required number of selections is","multipleFileUploads_emptyError":"{file} is empty, please select files again without it.","multipleFileUploads_fileLimitError":"Only {fileLimit} file uploads allowed.","multipleFileUploads_minSizeError":"{file} is too small, minimum file size is {minSizeLimit}.","multipleFileUploads_onLeave":"The files are being uploaded, if you leave now the upload will be cancelled.","multipleFileUploads_sizeError":"{file} is too large, maximum file size is {sizeLimit}.","multipleFileUploads_typeError":"{file} has invalid extension. Only {extensions} are allowed.","numeric":"This field can only contain numeric values","pastDatesDisallowed":"Date must not be in the past.","pleaseWait":"Please wait...","required":"This field is required.","requireEveryCell":"Every cell is required.","requireEveryRow":"Every row is required.","requireOne":"At least one field required.","submissionLimit":"Sorry! Only one entry is allowed. Multiple submissions are disabled for this form.","uploadExtensions":"You can only upload following files:","uploadFilesize":"File size cannot be bigger than:","wordLimitError":"Too many words. The limit is"}); }); JotForm.prepareCalculationsOnTheFly([null,null,null,null,null,{"name":"email5","qid":"5","text":"E-mail","type":"control_email"},{"name":"uploadYour","qid":"6","text":"Upload your files here ","type":"control_fileupload"},null,{"name":"yourMessage8","qid":"8","text":"Your message","type":"control_textarea"},{"name":"fullName","qid":"9","text":"Full Name","type":"control_textbox"},{"name":"submitA","qid":"10","text":"Submit a design!","type":"control_head"},{"name":"submit","qid":"11","text":"Submit","type":"control_button"}]);</script>

<link href="https://cdn.jotfor.ms/static/formCss.css?3.3.376" rel="stylesheet" type="text/css" />

<link type="text/css" rel="stylesheet" href="https://cdn.jotfor.ms/css/styles/nova.css?3.3.376" />

<link type="text/css" media="print" rel="stylesheet" href="https://cdn.jotfor.ms/css/printForm.css?3.3.376" />

<link type="text/css" rel="stylesheet" href="https://cdn.jotfor.ms/themes/CSS/58ed63ff7dc758cf9006aa82.css?"/>

<style type="text/css">
@import url('https://shots.jotform.com/elton/genericTheme.css'); .form-label-left{ width:150px !important; } .form-line{ padding-top:12px; padding-bottom:12px; } .form-label-right{ width:150px !important; } .form-all{ width:454px; color:#000000 !important; font-family:'Rambla'; font-size:16px; } .form-radio-item label, .form-checkbox-item label, .form-grading-label, .form-header{ color: #555; } </style> <style type="text/css" id="form-designer-style"> /*

grfraser
@grfraser
May 15 2017 05:02
@Marmiz i use brackets. from stack overflow brackets core contributor "Brackets currently only supports UTF-8 encoded files."
so pretty odd
c0d0er
@c0d0er
May 15 2017 05:09
@ivancsicsmarkus thanks
bilaal-s
@bilaal-s
May 15 2017 05:18
@grfraser remove that — symbol, its causing your problem
Amir Saleem
@amirsaleem96
May 15 2017 05:24
How many lines of code do you write daily ?
Manish Giri
@Manish-Giri
May 15 2017 05:27
@Marmiz writes about 700
DrReaper33
@GrantVenter01
May 15 2017 05:32
Good day all, a work colleague of mine built a questionnaire in Adobe Captivate using HTML5. he needs to save the answers to an excel readable file like csv. how can we do that using javascript?
Markus Kiili
@Masd925
May 15 2017 05:39
@GrantVenter01 With just front-end JS, I don't think accessing the file system is possible.
DrReaper33
@GrantVenter01
May 15 2017 05:52
@Masd925 Then how will I be able to do it?
Markus Kiili
@Masd925
May 15 2017 05:54
@GrantVenter01 I am not an expert on this subject, but standalone programs can access the file system, or you could send the questionnaire to a server and the user could download the file from the server.
So I think you need a backend for that.
DrReaper33
@GrantVenter01
May 15 2017 05:57
@Masd925 Thank you so muck for your quick response
CamperBot
@camperbot
May 15 2017 05:57
grantventer01 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4071 | @masd925 |http://www.freecodecamp.com/masd925
youUnion619
@youUnion619
May 15 2017 06:18
can anyone help me with my code i m doing the counting cards;

var count = 0;

function cc(card) {
// Only change code below this line
if ((card >= 2 && card <=9) || card =='J' || card =='Q' || card =='k' || card =='A')
{
switch (card){
case 2:
count +=1;
break;
case 3:
count +=1;
break;
case 4:
count +=1;
break;
case 5:
count +=1;
break;
case 6:
count +=1;
break;
case 7:
count += 0;
break;
case 8:
count += 0;
break;
case 9:
count += 0;
break;
case 10:
count -=1;
break;
case 'J':
count -=1;
break;
case 'Q':
count -=1;
break;
case 'K':
count -=1;
break;
case 'A':
count -=1;
break;
}
}

return "count";

Markus Kiili
@Masd925
May 15 2017 06:21
@youUnion619 Is it k or K on the if there?
Manish Giri
@Manish-Giri
May 15 2017 06:21
@youUnion619 you're supposed to return bet or hold along with count
and you can group certain cases together, without break
Markus Kiili
@Masd925
May 15 2017 06:21
@youUnion619 At the end you need to test value of count and make a return based on it.
youUnion619
@youUnion619
May 15 2017 06:22
should i test it to see if its positive?
Markus Kiili
@Masd925
May 15 2017 06:22
@youUnion619 Yes.
youUnion619
@youUnion619
May 15 2017 06:23
i cant group the cases because i need to break for each case i think
Markus Kiili
@Masd925
May 15 2017 06:24
@youUnion619 You can group cases for same increment together.
youUnion619
@youUnion619
May 15 2017 06:24
i have tried it at first but didn't work
Markus Kiili
@Masd925
May 15 2017 06:24
MDN switch page shows how to group cases.
youUnion619
@youUnion619
May 15 2017 06:24
ik but didn't work
i have fixed the K and and tested the value of count but still isn't working
if ((card >= 2 && card <=9) || card =='J' || card =='Q' || card =='K' || card =='A')
{
switch (card){
case 2:
count +=1;
break;
case 3:
count +=1;
break;
case 4:
count +=1;
break;
case 5:
count +=1;
break;
case 6:
count +=1;
break;
case 7:
count += 0;
break;
case 8:
count += 0;
break;
case 9:
count += 0;
break;
case 10:
count -=1;
break;
case 'J':
count -=1;
break;
case 'Q':
count -=1;
break;
case 'K':
count -=1;
break;
case 'A':
count -=1;
break;
}
}
if (count > 0){
return count+" bet";
}
return count+" hold";
// Only change code above this line
}
youUnion619
@youUnion619
May 15 2017 06:32
ok its working now thanks for the help
Anupama
@anupamaupadhyay
May 15 2017 06:35
Hi My code

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

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

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

its not giving correct results for nehative number
negative*
Manish Giri
@Manish-Giri
May 15 2017 06:37
@anupamaupadhyay formula is wrong
Anupama
@anupamaupadhyay
May 15 2017 06:38
Sorry I tried this

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

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

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

physicalgorithm
@physicalgorithm
May 15 2017 06:42
Guys, do you know a good brute force for instagram in js? I wondering how its algorithm works and how to code it
Quentin Butler
@quentin1431
May 15 2017 06:42
@anupamaupadhyay fahrenheit = (celsius * 1.8) + 32;
@physicalgorithm Why would you need a brute force for instagram?
Anupama
@anupamaupadhyay
May 15 2017 06:45
thanks @quentin1431
CamperBot
@camperbot
May 15 2017 06:45
anupamaupadhyay sends brownie points to @quentin1431 :sparkles: :thumbsup: :sparkles:
:cookie: 312 | @quentin1431 |http://www.freecodecamp.com/quentin1431
Quentin Butler
@quentin1431
May 15 2017 06:45
@anupamaupadhyay No Problem.
Gavo Bon
@GavoGavo
May 15 2017 06:50
Hey all. I'm having trouble with Nesting For Loops. So far I've entered
for (var i=0; i < arr.length; i++) { for (var j=0; j < arr[i].length; j++); }
which is basically copying from the example (because I can't wrap my head around the nesting component properly). but I don't know what the question is asking of me (again). What do I need to multiply?
I've tried a few combinations that I can't get to wrok
*work
Markus Kiili
@Masd925
May 15 2017 06:51
@GavoGavo Then you need to somehow use the subarray element arr[i][j]
Gavo Bon
@GavoGavo
May 15 2017 06:52
hey @Masd925 . So what I did try was product = product * arr[i][j];
tobi10
@tobi10
May 15 2017 06:52
hey guys, is anyone having issues doing the tasks and creating a bug on the beta version of FCC?. I can't proceed because it just shows running test but doesn't run the test, so I tried filing a bug and i can't do that also.
Anupama
@anupamaupadhyay
May 15 2017 06:55
How to write

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

getting erroor var myStr= "newline"+\t"backslash"+\n"backslash"+\t"carriage-"+\n"return";
physicalgorithm
@physicalgorithm
May 15 2017 06:56
@quentin1431 Yesterday I find a source code of a bruteforce for instagram. But it was Python and I didn't understand the logic. So that, I'm wondering how it works and to understand this, I need to convert it Javascript lang. That's why I need 😅
gerome0123
@gerome0123
May 15 2017 06:57
how to remove part of a url example i have data = "/accounts/page=1" how to remove page=1?
Gavo Bon
@GavoGavo
May 15 2017 06:59
@Masd925 then I tried doing console.log(arr[i][j]);
Markus Kiili
@Masd925
May 15 2017 07:00
@GavoGavo Logging doesn't really do too much. Just shows it on the console. You have a variable there you need to multiply?
Gavo Bon
@GavoGavo
May 15 2017 07:01
yep. Product needs to multiplied by whatever value is a result of the loop I guess
Markus Kiili
@Masd925
May 15 2017 07:02
@GavoGavo Try to implement that.
Gavo Bon
@GavoGavo
May 15 2017 07:04
@Masd925 I have been. I've tried : product = product*arr[i][j];
I feel like I'm missing something majorly
..and also that maybe I'm not meant to be a programmer :P
Markus Kiili
@Masd925
May 15 2017 07:04
@GavoGavo That seems good. Post the code please.
Gavo Bon
@GavoGavo
May 15 2017 07:05

```function multiplyAll(arr) {
var product = 1;
var outProd = "";
// Only change code below this line
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++);
product = product*arr[i][j];
}

// Only change code above this line

}

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

hrmm. not sure why that's not formatted
kreuel
@kreuel
May 15 2017 07:06

hi Guys,
For Seek And Destroy: could you assist me on how can I make the "return value !== 2 && value !== 3" be a dynamic to look on the value of the arguments which I temporary stored in array. ```
function destroyer(arr) {
// Remove all the values
var temp, test, getVal;
var argumentsVal = [];

//convert the arguments to array
var args = Array.prototype.slice.call(arguments, 1);
//then push the value to a array variable
argumentsVal.push(args);

//get the array value to check if the a value exist.
getVal = arr.filter(compareValue);

//function to filter values
function compareValue(value) {
//return arr.indexOf(value) !== 1;
return value !== 2 && value !== 3;
}
return getVal;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
```

blob
Gavo Bon
@GavoGavo
May 15 2017 07:07
done above @Masd925
Blara02
@Blara02
May 15 2017 07:08

hey can someone help me out with the "Profile Lookup" challenge?

var j = 0;
var i = 0;
count = 0;
countt = 0;

while (i === 0) {
if (contacts[count].firstName == firstName) {
i++;
if (contacts[count].lastName == prop) {
return contacts[count].lastName;
} else if (contacts[count].number == prop) {
return contacts[count].number;
} else if (contacts[count].likes == prop) {
return contacts[count].likes;
} else {
return "No such property";
}
} else if (count > 5) {
i++;
return "No such contact";
} else {
count++;
}
}

this is the code I have added, im not sure why its not returning the when it is == to prop

Faisal Rusheidat
@lostandfound24
May 15 2017 07:09
var j = 0;
var i = 0;
count = 0;
countt = 0;
while (i === 0) {
if (contacts[count].firstName == firstName) {
i++;
if (contacts[count].lastName == prop) {
return contacts[count].lastName;
} else if (contacts[count].number == prop) {
return contacts[count].number;
} else if (contacts[count].likes == prop) {
return contacts[count].likes;
} else {
return "No such property";
}
} else if (count > 5) {
i++;
return "No such contact";
} else {
count++;
}
}
gerome0123
@gerome0123
May 15 2017 07:09
how to remove part of a url example i have data = "/accounts/page=1" how to remove page=1?
Markus Kiili
@Masd925
May 15 2017 07:10
@kreuel Don't use the argumentsVal array. Just use arr and args.
@kreuel Filter iterates arr, so use indexOf on args.
Blara02
@Blara02
May 15 2017 07:11
thank u for black boxing it @lostandfound24, i can never get it to work on my tablet
CamperBot
@camperbot
May 15 2017 07:11
blara02 sends brownie points to @lostandfound24 :sparkles: :thumbsup: :sparkles:
:cookie: 244 | @lostandfound24 |http://www.freecodecamp.com/lostandfound24
gerome0123
@gerome0123
May 15 2017 07:11
how to remove part of a url example i have data = "/accounts/page=1" how to remove page=1?
how to remove part of a url example i have data = "/accounts/page=1" how to remove page=1?
Quentin Butler
@quentin1431
May 15 2017 07:13
@gerome0123 You could use something like this is page=1 will always be the same:
data = "/accounts/page=1";
data = data.replace('/page=1','');
Markus Kiili
@Masd925
May 15 2017 07:13
@lostandfound24 You only need a for loop through contacts array and two nested if's for firstname and property existence tests. You are hardcoding property keys, which is wrong.
Faisal Rusheidat
@lostandfound24
May 15 2017 07:14
@Masd925 You are right - @Blara02
kreuel
@kreuel
May 15 2017 07:14
@Masd925 hi thanks for the response, yes I'm not using the argumentsVal. for "Filter iterates arr, so use indexOf on args" what do you mean is that after I filter the arr then in my function Compare, use the args(e.g args.indexOf(value))?
CamperBot
@camperbot
May 15 2017 07:14
kreuel sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4072 | @masd925 |http://www.freecodecamp.com/masd925
Gavo Bon
@GavoGavo
May 15 2017 07:15
hey @Masd925 my code was:
function multiplyAll(arr) {
  var product = 1;
  var outProd = "";
  // Only change code below this line
for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++);
 product = product*arr[i][j];
}

  // Only change code above this line

}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
ignoring my outprod variable..I put it in there to try something earlier and forgot to remove
Quentin Butler
@quentin1431
May 15 2017 07:16
@gerome0123 If page=1 could change to something else like: page=11 or whatever, then a better solution would be:
data = "/accounts/page=1";
data = data.substring(0, (data.indexOf('page=') - 1));
gerome0123
@gerome0123
May 15 2017 07:16
it help me this too .replace(/page=\w+/g, '')
let me check that too
Markus Kiili
@Masd925
May 15 2017 07:17
@kreuel Filter automatically iterates the array arr,and passes each arr element into the callback function compareValue as value. Inside the callback, you need to test if value (the array element being iterated by filter) is found on args. If it is you need to tell filter to discard the element (return false). If not, return true. You can use indexOf for that test.
@GavoGavo You have modified the code above and below where you should have. Reset the code and try again.
// Only change code below this line
// Only change code above this line
Obey those.
kreuel
@kreuel
May 15 2017 07:19
@Masd925 thanks will try your advise.
CamperBot
@camperbot
May 15 2017 07:19
kreuel sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: kreuel already gave masd925 points
Gavo Bon
@GavoGavo
May 15 2017 07:20
@Masd925 you were right. Thanks for that
CamperBot
@camperbot
May 15 2017 07:20
gavogavo sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4073 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
May 15 2017 07:21
@GavoGavo :+1:
Ogundele Olumide
@Lumexralph
May 15 2017 07:25
@Masd925 How did it go?
Good Morning
ozimanik
@ozimanik
May 15 2017 07:28
NEIN ich will nicht sterben :(
Markus Kiili
@Masd925
May 15 2017 07:28
@Lumexralph I dived a bit too long and didn't manage to do the surface protocol in 15 seconds (I did it in 16.5 seconds). So I didn't get a result. Time was good 6min25sec, which would have gotten the bronze medal and the best results were 6:33 and 6:29, so very close.
Santhosh Kumar Rajagiri
@santhu342
May 15 2017 07:29
Profile Lookup
how cad find the first name in multiple array
Ogundele Olumide
@Lumexralph
May 15 2017 07:29
@santhu342 use a loop
Santhosh Kumar Rajagiri
@santhu342
May 15 2017 07:29
yes i already use for loop
Thomas Faller
@thomasfaller
May 15 2017 07:30

Hey guys, is there anything I’m doing wrong here in my wheather script?

// VARIABLES

var $tempWrapper = $("#temp-wrapper");
var $locationWrapper = $("#location");
var $weatherIconWrapper = $("#weather-icon-wrapper");
var $weatherStatusWrapper = $("#weather-status");

navigator.geolocation.getCurrentPosition(function(position) {   // HTML Geolocation API  
var $lat = position.coords.latitude; 
var $long = position.coords.longitude;
$.ajax({
url:"http://api.openweathermap.org/data/2.5/weather?lat=" + $lat + "&lon=" + $long + "&APPID=bae4b37551ad15c5be94bb6d7178601d",
 dataType: "json",
success: function(result){
var $city = result.name;                                // City
var $country = result.sys.country;                      // Country
var $weatherDesc = result.weather[0].description;       // Description of Weather
var $weatherIcon = result.weather[0].icon;              // Icon code from openweathermap
var $tempC = result.main.temp - 273.15;                 // Temp in Celsius
var $tempF = result.main.temp * (9/5) - 459.67;         // Temp in Farenheit

          // DISPLAYING THE INFO IN THE WEB APP

$locationWrapper.html("<h1>" + $city + ", " + $country + "</h1>");
$weatherIconWrapper.html("<img style=\"width: 120px;\" src=\"http://openweathermap.org/img/w/" + $weatherIcon + ".png\" alt=\"weather icon\">");
$weatherStatusWrapper.html("<h1>" + $weatherDesc + "</h1>");
$tempWrapper.html("<h1>" + $tempC.toFixed(0) + " °C</h1>");     // toFixed(0) to make sure the temp is a whole number
}});
});

I tried console.logging in a couple of places in the script and the coordinates are being taken, but everything stops after success: function(result){ … Any guesses?

Santhosh Kumar Rajagiri
@santhu342
May 15 2017 07:30

my code is

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

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

}

else if(contacts[i].hasOwnProperty(firstName))
{

}
else
return "No such property";

}
Ogundele Olumide
@Lumexralph
May 15 2017 07:30
@Masd925 :clap:
ozimanik
@ozimanik
May 15 2017 07:31

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

   var fahrenheit = celsius * 9 / 5 + 32;

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

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


//convertToF(-30) should return a value of -22
//convertToF(-10) should return a value of 14
Ogundele Olumide
@Lumexralph
May 15 2017 07:31
@santhu342
Here's an outline, if you follow it step-wise it'll help a great deal in telling you what to do or step you missed
1. you need a loop to pick each objects in the contacts array
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                  return the value of prop in the object
                 1.1.1.2  return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
ozimanik
@ozimanik
May 15 2017 07:31

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

   var fahrenheit = celsius * 9 / 5 + 32;

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

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


//convertToF(-30) should return a value of -22
//convertToF(-10) should return a value of 14
Quentin Butler
@quentin1431
May 15 2017 07:31
@thomasfaller Hi, one thing I can quickly see, you cannot use http URL, you will have to use https URL. If you can find one :)
ozimanik
@ozimanik
May 15 2017 07:31
whats wrong
Ogundele Olumide
@Lumexralph
May 15 2017 07:32
@ozimanik declare fahrenheit once
ozimanik
@ozimanik
May 15 2017 07:32
but shouldnt it work like this becuase it isnt defined on top
Quentin Butler
@quentin1431
May 15 2017 07:32
@ozimanik fahrenheit = (celsius * 1.8) + 32;
Ogundele Olumide
@Lumexralph
May 15 2017 07:33
@ozimanik there's already a variable declared with that name, it's not initialized that's all
Pieter Stokkink
@forkerino
May 15 2017 07:33
@ozimanik just drop the second var, because that line will be ignored.
ozimanik
@ozimanik
May 15 2017 07:33
@forkerino @Lumexralph @quentin1431 kk ty got the solution
CamperBot
@camperbot
May 15 2017 07:33
ozimanik sends brownie points to @forkerino and @lumexralph and @quentin1431 :sparkles: :thumbsup: :sparkles:
:star2: 2241 | @forkerino |http://www.freecodecamp.com/forkerino
:star2: 1749 | @lumexralph |http://www.freecodecamp.com/lumexralph
Pieter Stokkink
@forkerino
May 15 2017 07:33
@Lumexralph :wave:
CamperBot
@camperbot
May 15 2017 07:33
:cookie: 313 | @quentin1431 |http://www.freecodecamp.com/quentin1431
Markus Kiili
@Masd925
May 15 2017 07:33
@forkerino Morning.
Pieter Stokkink
@forkerino
May 15 2017 07:33
@Masd925 Hello!
Ogundele Olumide
@Lumexralph
May 15 2017 07:33
@forkerino :wave: how're you?
Pieter Stokkink
@forkerino
May 15 2017 07:34
good good
@Lumexralph I won a ticket to CodeMotion conference
So Im going there tomorrow and wednesday
Ogundele Olumide
@Lumexralph
May 15 2017 07:35
@forkerino hmmm...... coool! where's that and what's it about?
Pieter Stokkink
@forkerino
May 15 2017 07:35
@Lumexralph in Amsterdam: http://amsterdam2017.codemotionworld.com/
Thomas Faller
@thomasfaller
May 15 2017 07:35
@quentin1431 Oh nice one, thanks.
CamperBot
@camperbot
May 15 2017 07:35
thomasfaller sends brownie points to @quentin1431 :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @quentin1431 |http://www.freecodecamp.com/quentin1431
Thomas Faller
@thomasfaller
May 15 2017 07:36
I think I’ll stick to DarkSky, I’m able to making it work more consistently for some reasons
Ogundele Olumide
@Lumexralph
May 15 2017 07:36
@forkerino in Holland now?
Pieter Stokkink
@forkerino
May 15 2017 07:36
@Lumexralph yeah, still
best time of year to be here
Quentin Butler
@quentin1431
May 15 2017 07:37
@thomasfaller Nice, I also used another API to get it to work. Glad you got it working.
Ogundele Olumide
@Lumexralph
May 15 2017 07:38
@forkerino cool.... i'm waiting for the knowledge you'll share from the conference cos i'll disturb you....be prepared for me
Markus Kiili
@Masd925
May 15 2017 07:39
@forkerino Yes, tell us everything afterwards ;)
Pieter Stokkink
@forkerino
May 15 2017 07:39
@Lumexralph :smile: I actually won the ticket by being the first person over at the nodeschool.io meeting to be able to explain the .reduce function.
I'll just record everything on my phone. :joy:
Thomas Faller
@thomasfaller
May 15 2017 07:40
@quentin1431 Yeah, thanks! I’m kinda relieved I’m starting to be know my way around JSONs and APIs. For some reason though, the app is still taking a very long time to retrive and display the info.
Is there something wrong with the way I nest my script or something?
I mean since the geolocation requires a function, you need everything to be nest in there otherwise the coordinates (being local) are useless but maybe I’m getting that wrong.
CamperBot
@camperbot
May 15 2017 07:40
:warning: thomasfaller already gave quentin1431 points
thomasfaller sends brownie points to @quentin1431 :sparkles: :thumbsup: :sparkles:
Pieter Stokkink
@forkerino
May 15 2017 07:40
@Masd925 @Lumexralph If the wifi is good I can do some live reporting.
Markus Kiili
@Masd925
May 15 2017 07:40
@forkerino You told them that reduce is the fauset and the goose of array iteration?
Faisal Rusheidat
@lostandfound24
May 15 2017 07:40
Hi guys, I'm stuck on this one.
function titleCase(str) {
  var lowerCase =  str.toLowerCase();
  var arrayOfStr = lowerCase.split(' ');
  for (i = 0; i < arrayOfStr.length; i++) {

  }

}

titleCase("I'm a little tea pot");
Thomas Faller
@thomasfaller
May 15 2017 07:41
this one works pretty well though:
Pieter Stokkink
@forkerino
May 15 2017 07:41
@Masd925 I didn't use those particular terms, but did tell them that you could implement .map and .filter and many other methods with just .reduce.
Ogundele Olumide
@Lumexralph
May 15 2017 07:41
@forkerino anyone you choose...... :+1:
@forkerino :joy:
Markus Kiili
@Masd925
May 15 2017 07:42
@forkerino Yeah, it is the general iterator.
Quentin Butler
@quentin1431
May 15 2017 07:42
@thomasfaller It should depend on the response from the API call. Some will be faster. And in general https calls will be slower. I think if one paid for a good API it should work pretty well.
Pieter Stokkink
@forkerino
May 15 2017 07:45
@lostandfound24 One hint is to overwrite the elements currently in the array
lazzlo
@lazzlo
May 15 2017 07:46
Hey guys. What API did you use for the Random Quote Machine project?
kreuel
@kreuel
May 15 2017 07:46
@Masd925 managed to resolved the task, Thanks for the explanation. I add the below code. if (args.indexOf(value) > -1) {
return false;
} else {
return true;
}
CamperBot
@camperbot
May 15 2017 07:46
kreuel sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: kreuel already gave masd925 points
kreuel
@kreuel
May 15 2017 07:46
if (args.indexOf(value) > -1) { return false; } else { return true; }
Markus Kiili
@Masd925
May 15 2017 07:46
@kreuel Just return args.indexOf(value) === -1; would do.
So that if is redundant.
Quentin Butler
@quentin1431
May 15 2017 07:47
@Lazzlo You can use any one you want. Is your not working?
Pieter Stokkink
@forkerino
May 15 2017 07:47
@Lazzlo I used the forismatic api, but https can be an issue. Another one is quotes on design, which many use.
kreuel
@kreuel
May 15 2017 07:47
@Masd925 wow that's another solution, okay i will take note of it.
HeebieGeeBee
@HeebieGeeBee
May 15 2017 07:48
mornin
Pieter Stokkink
@forkerino
May 15 2017 07:48
@HeebieGeeBee :wave:
lazzlo
@lazzlo
May 15 2017 07:48
@quentin1431 @forkerino I tried the Forismatic one but the CORS thing is really not passing through my thick skull
Markus Kiili
@Masd925
May 15 2017 07:48
@Lumexralph We should perform Maundy on @forkerino . He will then share.
Pieter Stokkink
@forkerino
May 15 2017 07:50
@Lazzlo yeah, that trips a lot of people up. One way is to use a proxy to tunnel the request: https://cors-anywhere.herokuapp.com/ or https://crossorigin.me
Ogundele Olumide
@Lumexralph
May 15 2017 07:50
@Masd925 :smile: after you
Manpreet29
@Manpreet29
May 15 2017 07:51
heelo can nyone help me with stand in line challenge?
lazzlo
@lazzlo
May 15 2017 07:52
@forkerino Yeah, I experimented with crossorigin.me but it still wouldn't work. Anyways, I think I found another API. Thanks for the help mate
CamperBot
@camperbot
May 15 2017 07:52
lazzlo sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2242 | @forkerino |http://www.freecodecamp.com/forkerino
Ogundele Olumide
@Lumexralph
May 15 2017 07:52
@Masd925 @forkerino seems reactJS is now like another way of programming in JS and not a framework in my opinion
@Manpreet29 tried anything?
@HeebieGeeBee Bro!
Faisal Rusheidat
@lostandfound24
May 15 2017 07:53
@forkerino I'm guiessing charAt()is app in this cas
Manpreet29
@Manpreet29
May 15 2017 07:53
@Lumexralph ya i did but not getting exactly wht to do
lazzlo
@lazzlo
May 15 2017 07:53
@forkerino One more quick question. The API I found is one that requires authentication. Do you know how I would add a header in an ajax request?
Ogundele Olumide
@Lumexralph
May 15 2017 07:54
@Manpreet29 you are to add item to the end of arr which is an array, how'll you do that?
HeebieGeeBee
@HeebieGeeBee
May 15 2017 07:54
seems when theres react native aswell
you can make all apps for all platforms in javascript
Manpreet29
@Manpreet29
May 15 2017 07:54
[ [ 1,2,3,4,5], 1] @Lumexralph ?
Pieter Stokkink
@forkerino
May 15 2017 07:55
@lostandfound24 you can use .charAt() or just use indexes. str[0] will be the first letter. Note that you cannot overwrite single letters, you have to overwrite the whole string.
@Lazzlo are you using jQuery or not?
Ogundele Olumide
@Lumexralph
May 15 2017 07:55
@Manpreet29 push
lazzlo
@lazzlo
May 15 2017 07:55
@forkerino Yeah I am
Ogundele Olumide
@Lumexralph
May 15 2017 07:55
@HeebieGeeBee but they're all built on JS
Manpreet29
@Manpreet29
May 15 2017 07:55
ya @Lumexralph i will try dat
Ogundele Olumide
@Lumexralph
May 15 2017 07:56
@Manpreet29 then you need to remove the first element in arr array, what array method will you use for that?
Manpreet29
@Manpreet29
May 15 2017 07:56
pop @Lumexralph
Pieter Stokkink
@forkerino
May 15 2017 07:56
@Lazzlo you can add a settings object to the .ajax request. You'll have to check the docs at your api and at https://api.jquery.com/jQuery.ajax/ for the specific syntax that is needed.
Ogundele Olumide
@Lumexralph
May 15 2017 07:57
@Manpreet29 pop removes the last element in an array not the first
lazzlo
@lazzlo
May 15 2017 07:57
@forkerino Thank you so much :)
CamperBot
@camperbot
May 15 2017 07:57
lazzlo sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: lazzlo already gave forkerino points
Manpreet29
@Manpreet29
May 15 2017 07:57
.shift() @Lumexralph
Ogundele Olumide
@Lumexralph
May 15 2017 07:57
@Manpreet29 yes
Manpreet29
@Manpreet29
May 15 2017 07:57
thanks i wil try that
@Lumexralph thanks
CamperBot
@camperbot
May 15 2017 07:58
manpreet29 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1750 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
May 15 2017 07:58
@Manpreet29 you remove that element and return it and you're done
Markus Kiili
@Masd925
May 15 2017 07:58
@HeebieGeeBee So React is something similar to Angular, but React native is something totally different?
HeebieGeeBee
@HeebieGeeBee
May 15 2017 07:58
isthat a question?
Ogundele Olumide
@Lumexralph
May 15 2017 07:58
@Masd925 i think so much stuff has been built on React, so they say react native i think
Pieter Stokkink
@forkerino
May 15 2017 07:59
React Native is for mobile, no?
HeebieGeeBee
@HeebieGeeBee
May 15 2017 07:59
react native is just a platform to create native apps
in react
Ogundele Olumide
@Lumexralph
May 15 2017 07:59
@HeebieGeeBee what's native app?
Pieter Stokkink
@forkerino
May 15 2017 08:00
React Native lets you build mobile apps using only JavaScript. It uses the same design as React, letting you compose a rich mobile UI from declarative components.
HeebieGeeBee
@HeebieGeeBee
May 15 2017 08:00
like an app you download from google play and apple app store
you have react windows too
for building windows applications
Pieter Stokkink
@forkerino
May 15 2017 08:00
I was playing with Electron the other day. Very cool stuff.
Ogundele Olumide
@Lumexralph
May 15 2017 08:00
@forkerino hmm..... React is becoming very powerful
HeebieGeeBee
@HeebieGeeBee
May 15 2017 08:01
expo is pretty cool too
Pieter Stokkink
@forkerino
May 15 2017 08:01
@Lumexralph We should stop it!
No one machine can rule mankind!
HeebieGeeBee
@HeebieGeeBee
May 15 2017 08:01
with like the live update and preview on yourphone
Ogundele Olumide
@Lumexralph
May 15 2017 08:01
@forkerino after we've dealt with Google
Pieter Stokkink
@forkerino
May 15 2017 08:01
:joy:
Ogundele Olumide
@Lumexralph
May 15 2017 08:01
@forkerino and FB
HeebieGeeBee
@HeebieGeeBee
May 15 2017 08:02
i was kinda trying to find out more though
Ogundele Olumide
@Lumexralph
May 15 2017 08:02
@forkerino if we dealt with FB we deal with React
HeebieGeeBee
@HeebieGeeBee
May 15 2017 08:02
about the licence with react
Pieter Stokkink
@forkerino
May 15 2017 08:02
@Lumexralph can you imagine the power GitHub has? It is more behind the scenes, but my god, the source code that dwells in its internals must be borderline conscious by now.
HeebieGeeBee
@HeebieGeeBee
May 15 2017 08:03
i dont think github is even run by any humans anymore
Pieter Stokkink
@forkerino
May 15 2017 08:05
@Manpreet29 put your code inside the function, and use the function parameters instead of testArr and 6.
@Masd925 here's a nice puzzle: https://www.codewars.com/kata/one-line-task-palindrome-string/train/javascript It took me quite some time to solve.
Ogundele Olumide
@Lumexralph
May 15 2017 08:07
@forkerino i can imagine....but JS is powerful
HeebieGeeBee
@HeebieGeeBee
May 15 2017 08:07
Basilix
@SyncMaster93
May 15 2017 08:07
a should be assigned to b with = ?
too ez.. but im stupid.. :D

help!!

HeebieGeeBee
@HeebieGeeBee
May 15 2017 08:07
i bet @Masd925 has, but i mean, normal ppl
Ogundele Olumide
@Lumexralph
May 15 2017 08:07
@HeebieGeeBee :worried: i only seldomly consult it....
Pieter Stokkink
@forkerino
May 15 2017 08:08
@HeebieGeeBee on occassion
HeebieGeeBee
@HeebieGeeBee
May 15 2017 08:08
i think its put me to sleep like every time
Pieter Stokkink
@forkerino
May 15 2017 08:09
yes it is a bit dry here and there.
Ogundele Olumide
@Lumexralph
May 15 2017 08:09
@HeebieGeeBee very dry but informative and the way they explained their algorithms.... and boring
Claudio Restifo
@Marmiz
May 15 2017 08:09

@SyncMaster93 the = gives (ie Assign) a value to a variable:

var x = 1

then I can reuse variable's value around:

var y = x + 1
//x = 1
//y =  2
HeebieGeeBee
@HeebieGeeBee
May 15 2017 08:10
im amazed anyone is able to
ozimanik
@ozimanik
May 15 2017 08:10
Quatschen von Bargeld aber haben kein Cent, wo steht dein Wagen, wo steht dein Benz?
HeebieGeeBee
@HeebieGeeBee
May 15 2017 08:11
is that something about a car?
Rick Riggs
@wikiwiggs
May 15 2017 08:18
I think I 've found a bug, anyone willing to confirm?
XiaoJunling
@XiaoJunling
May 15 2017 08:19

创建一个变量 fahrenheit,然后计算出摄氏度对应的华氏度。

convert(0) 应该返回一个数字
convert(-30) 应该返回 -22
convert(-10) 应该返回 14
convert(0) 应该返回 32
convert(20) 应该返回 68
convert(30) 应该返回 86

function convert(celsius) {
// Only change code below this line
var fahrenheit;
var Celsius;
fahrenheit=Celsius*9/5+32
// Only change code above this line
return fahrenheit;
}

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

how could I improve?
Claudio Restifo
@Marmiz
May 15 2017 08:19
@wikiwiggs which one?
Rick Riggs
@wikiwiggs
May 15 2017 08:20
@Marmiz
Falsy Bouncer
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  return arr;
}

bouncer([7, "ate", "", false, 9].filter(function(x){
  var falsy = [false, null, 0, "", undefined, NaN];
  var flag = 0;
  for (var i=0;i<falsy.length;i++) {
    if (x == falsy[i]) { flag++; }
  }
  if (flag === 0) {
    return x;
  }
}));
Ogundele Olumide
@Lumexralph
May 15 2017 08:20
@XiaoJunling use celsius parameter not Celsius
Pieter Stokkink
@forkerino
May 15 2017 08:21
@wikiwiggs NaN !== NaN is true in JS.
Claudio Restifo
@Marmiz
May 15 2017 08:21
@wikiwiggs steps to reproduce? Bug description? Just a code is a bit vague as Bug report ^^
Pieter Stokkink
@forkerino
May 15 2017 08:22
@wikiwiggs also, your code should be inside the function.
and a .filter function keeps something for true and filters something out for false.
Rick Riggs
@wikiwiggs
May 15 2017 08:23
I was just testing, and got the proper return value, but it just didn't pass.
XiaoJunling
@XiaoJunling
May 15 2017 08:23
@Lumexralph thank you!
CamperBot
@camperbot
May 15 2017 08:23
xiaojunling sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1751 | @lumexralph |http://www.freecodecamp.com/lumexralph
Pieter Stokkink
@forkerino
May 15 2017 08:23
@wikiwiggs that is because you added the code in the wrong place.
@wikiwiggs it should be in here:
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  return arr;
}
Claudio Restifo
@Marmiz
May 15 2017 08:23
@wikiwiggs it won't pass because your "function" is applied in the wrong place.
Challenge tests run your function each time. Global variables will change with each call of your function.
Rick Riggs
@wikiwiggs
May 15 2017 08:24
What is the whole comment about???, I thought we had to filter it out before it was even passed to the function because of what the comment says.
Pieter Stokkink
@forkerino
May 15 2017 08:25
@wikiwiggs well, the bouncer bounces falsy values out, that is what the function is for. If you show false ID, out you go.
don't do the bouncer's work for him in another place :)
Rick Riggs
@wikiwiggs
May 15 2017 08:25
OK, that makes sense, I just read it as: don't you dare allow a falsy value to be seen inside this function body.
LOL
Pieter Stokkink
@forkerino
May 15 2017 08:26
lol