These are chat archives for FreeCodeCamp/HelpJavaScript

12th
Jun 2017
Brooks
@Brodavis
Jun 12 2017 00:01
when accessing nested objects, when is it indicated to use "" and not to use "" ?
for example why is the "top drawer" in quotes? is it because its in bracket notation?
var ourStorage = {
  "desk": {
    "drawer": "stapler"
  },
  "cabinet": {
    "top drawer": { 
      "folder1": "a file",
      "folder2": "secrets"
    },
    "bottom drawer": "soda"
  }
};
ourStorage.cabinet["top drawer"].folder2;  // "secrets"
ourStorage.desk.drawer; // "stapler"
Stephen James
@sjames1958gm
Jun 12 2017 00:04
@Brodavis You use "" when the value is the name of property - without quotes it will process as a variable.
Brooks
@Brodavis
Jun 12 2017 00:07
but isnt folder a property too? @sjames1958gm
mvroehling
@mvroehling
Jun 12 2017 00:07
@Brodavis Its because of the spaces.
Brooks
@Brodavis
Jun 12 2017 00:07
@mvroehling Thanks. so if it has spaces it needs quotes AND bracket notation?
CamperBot
@camperbot
Jun 12 2017 00:07
brodavis sends brownie points to @mvroehling :sparkles: :thumbsup: :sparkles:
:warning: @mvroehling's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Stephen James
@sjames1958gm
Jun 12 2017 00:07
@Brodavis You can use .folder2 because folder2 has no spaces.
mvroehling
@mvroehling
Jun 12 2017 00:10
@Brodavis Correct. When you use the . notation, the syntax finds the next word behind the "."
Now if you try call myObject.top drawer The computer tries to look up the property top. So yes, if you have spaces in your property you have to use myObject["top drawer"]
monkeyfingerz
@monkeyfingerz
Jun 12 2017 00:11

''''var num=[2,5,8,9];
var target=0;

function hello(num,target){
for(var i=0;i<=num.length;i++){
console.log(num[0]+num[i]);
};
hello();

CamperBot
@camperbot
Jun 12 2017 00:11
:bulb: to format code use backticks! ``` more info
monkeyfingerz
@monkeyfingerz
Jun 12 2017 00:11
why am i getting the error' unexpected end of input'?
Zach Hall
@el4z
Jun 12 2017 00:12

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

Hey guys I'm on the profile-lookup challenge - I've almost got it, just instead of returning "no such contact" when an incorrect firstname is put in it says "contacts[i] is undefined" - any ideas?

Stephen James
@sjames1958gm
Jun 12 2017 00:13
@el4z Because i is === contacts.length which is past end of the array
monkeyfingerz
@monkeyfingerz
Jun 12 2017 00:13
if(undefined){return "no such property";}
meslance
@meslance
Jun 12 2017 00:13
Having trouble understanding what Word Blanks is about.
Stephen James
@sjames1958gm
Jun 12 2017 00:13
@monkeyfingerz You have two { but only 1 }
monkeyfingerz
@monkeyfingerz
Jun 12 2017 00:14
thanks @sjames1958gm
CamperBot
@camperbot
Jun 12 2017 00:14
monkeyfingerz sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7722 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Sarah
@aggibabi
Jun 12 2017 00:14
image.png
any suggestions?
Zach Hall
@el4z
Jun 12 2017 00:14
@sjames1958gm thanks man
CamperBot
@camperbot
Jun 12 2017 00:14
el4z sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7723 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 12 2017 00:14
@el4z :+1:
@aggibabi You need to check each letter of arr[1] separately
Sloomey
@Sloomey
Jun 12 2017 00:17
Can someone help me with the Word Blanks one

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
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");

that's my code
Stephen James
@sjames1958gm
Jun 12 2017 00:18
@Sloomey You need to use string concatenation to join the words/string is myNoun, etc and assign to result.
You literal strings to put spaces between the words
Zach Hall
@el4z
Jun 12 2017 00:18
@stephen are you saying that the loop keeps going until i = an array that isn't defined? How then do I make the while loop end after it's finished testing all the existing arrays?
mvroehling
@mvroehling
Jun 12 2017 00:19
@el4z you are trying to access conacts[i], but i is above limit of contacts.length!
Stephen James
@sjames1958gm
Jun 12 2017 00:19
@el4z You can check if i == contacts.length and return no such contacts in that case
Zach Hall
@el4z
Jun 12 2017 00:19
right thank you
so if (i==contacts.length)
return answer = "No such contact";
cheers
Stephen James
@sjames1958gm
Jun 12 2017 00:20
@el4z yes
meslance
@meslance
Jun 12 2017 00:20
@Sloomey I'm on the same one.
Sarah
@aggibabi
Jun 12 2017 00:21
@Sloomey Ok that makes sense. I am at a loss of how to do that. haha
@sjames1958gm ^
Stephen James
@sjames1958gm
Jun 12 2017 00:22
@aggibabi loop over each letter in arr[1] and check arr[0] has the letter, if not return false. If all the letters are there - return true
Adam Faraj
@adamfaraj
Jun 12 2017 00:23
Can I get some feedback on my fake create account from?
https://codepen.io/adamfaraj/pen/XgdpVx?editors=1010
my next step is to validate the email
mvroehling
@mvroehling
Jun 12 2017 00:32
@adamfaraj So you want to create a function that checks for a valid email adress?
Adam Faraj
@adamfaraj
Jun 12 2017 00:33
yeah, thats what I'm searching for now @mvroehling
it seems that there's already a template floating around on stackoverflow and other places
mvroehling
@mvroehling
Jun 12 2017 00:34
@adamfaraj Do you know how to do it without looking up for a solution ?
farheen
@farh33n
Jun 12 2017 00:34

I am working on Random Quote Machine and struggling with populating text attribute of twitter share button .Here is the code

<a class="twitter-share-button" target = "_blank"  href="https://twitter.com/intent/tweet?text=" + quoteArea.innerText>
Tweet</a>

quoteArea is the class of div where I displays the quote. How do I correctly refer to it to form a valid url?

Adam Faraj
@adamfaraj
Jun 12 2017 00:34
@farh33n close your </a> tag
fdemaa
@fdemaa
Jun 12 2017 00:34
switch works like else if ?
farheen
@farh33n
Jun 12 2017 00:35
@adamfaraj it is closed in actual code. this is just copy paste mistake.
mvroehling
@mvroehling
Jun 12 2017 00:35
@fdemaa Yes. Switch is just syntatic sugar
Joseph
@revisualize
Jun 12 2017 00:35
Hello
fdemaa
@fdemaa
Jun 12 2017 00:35
@mvroehling thanks man!
CamperBot
@camperbot
Jun 12 2017 00:35
fdemaa sends brownie points to @mvroehling :sparkles: :thumbsup: :sparkles:
:cookie: 229 | @mvroehling |http://www.freecodecamp.com/mvroehling
Joseph
@revisualize
Jun 12 2017 00:36
@adamfaraj Your validateEmail function sucks.
Adam Faraj
@adamfaraj
Jun 12 2017 00:36
hahaha
still working on it
meslance
@meslance
Jun 12 2017 00:36
@Sloomey Did you figure it out?
Joseph
@revisualize
Jun 12 2017 00:37
@adamfaraj You asked for feedback. That's all I could think of.
Adam Faraj
@adamfaraj
Jun 12 2017 00:37
lol. it's still an empty function
but you got me
Joseph
@revisualize
Jun 12 2017 00:39
@adamfaraj Here's another bit of feedback. Moar Images.
Adam Faraj
@adamfaraj
Jun 12 2017 00:39
yeah, i'm trying to get functionality down before making it pretty
Joseph
@revisualize
Jun 12 2017 00:40
@adamfaraj Is it good or bad practice to store passwords in variables?
Adam Faraj
@adamfaraj
Jun 12 2017 00:41
@revisualize dang....didn't think about that
nsonhouse
@nsonhouse
Jun 12 2017 00:41
Hello all.
Adam Faraj
@adamfaraj
Jun 12 2017 00:41
@revisualize what do you suggest
nsonhouse
@nsonhouse
Jun 12 2017 00:41
Need some help with mySQL
Joseph
@revisualize
Jun 12 2017 00:42
@adamfaraj I'd suggest not storing the password value but a hash of the password value.
nsonhouse
@nsonhouse
Jun 12 2017 00:42
Is there a schema data type for an array in mySQL?
ex: [0, 1, 2, 3, 4]
Joseph
@revisualize
Jun 12 2017 00:42
@adamfaraj When the password field is updated. Update the hash to compare against.
@adamfaraj Then when the verify password field is updated check if the hashes match.
@adamfaraj Then you're not storing the password as a plain text password.
Adam Faraj
@adamfaraj
Jun 12 2017 00:44
@revisualize how do I do that? never really dealt with security on my projects
Joseph
@revisualize
Jun 12 2017 00:44
@adamfaraj And make sure that the hash you use on the frontend is NOT the same as on the backend
Stephen James
@sjames1958gm
Jun 12 2017 00:44
@farh33n You cannot without using js.
Adam Faraj
@adamfaraj
Jun 12 2017 00:45
@revisualize ohhh. this isn't being used for any real login or create account. i'm just creating one for practice. but how would i go about doing that
@adamfaraj I don't completely understand the variable / function memory management in JavaScript.
I think it would just be a bad idea to store someone's password in plain text in a JS variable.
Adam Faraj
@adamfaraj
Jun 12 2017 00:53
@revisualize yeah, you're right. i think. haha.
Joseph
@revisualize
Jun 12 2017 00:54
@adamfaraj Also, It's a good time to learn a little bit about crypto and one way hashes
Adam Faraj
@adamfaraj
Jun 12 2017 00:55
ok. thanks @revisualize
CamperBot
@camperbot
Jun 12 2017 00:55
adamfaraj sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4145 | @revisualize |http://www.freecodecamp.com/revisualize
Adam Faraj
@adamfaraj
Jun 12 2017 00:55
will figure out this email validation function, then fix the password var
130mk
@130mk
Jun 12 2017 00:55
is there any parameter i can set to eliminate the delimiter and the sub delimiter?
Joseph
@revisualize
Jun 12 2017 00:56
@adamfaraj There's also PasswordJS
farheen
@farh33n
Jun 12 2017 00:57
@sjames1958gm do you know how to do this?
I have tried lots of ways including removing the button and recreating it using java script but I could not set the value of text there as well.
Adam Faraj
@adamfaraj
Jun 12 2017 00:57
yeah, i'm trying to use vanilla JS on codepen.io to do it
intervolver
@intervolver
Jun 12 2017 01:00

mozilla's reference material says to declare a boolean like this:

new Boolean([value])

but code camp's challenge parser throws the warning "Do not use Boolean as a constructor". What's the right way to assign a boolean?

mvroehling
@mvroehling
Jun 12 2017 01:03
@intervolver what code did you exactly write?
Lance Ward
@Lanceward410
Jun 12 2017 01:03
@intervolver create a different name for the variable
@intervolver And just assign it as true or false
intervolver
@intervolver
Jun 12 2017 01:04
I got it, you're just not supposed to use "new"
so it should be
```
Lance Ward
@Lanceward410
Jun 12 2017 01:04
@intervolver Use Shift + enter to go to next line :D
intervolver
@intervolver
Jun 12 2017 01:04
Boolean([value])
just without new
farheen
@farh33n
Jun 12 2017 01:05
@intervolver var boo = new Boolean(value);
Lance Ward
@Lanceward410
Jun 12 2017 01:05
@intervolver I'm not sure exactly what you're trying to do, but to create a boolean, you can just write ```var variableName = true;
intervolver
@intervolver
Jun 12 2017 01:06
I solved the challenge, it was just a formatting problem. I missed this on mozilla's reference:
var x = Boolean(expression);     // preferred
var x = new Boolean(expression); // don't use
farheen
@farh33n
Jun 12 2017 01:06
@intervolver and to keep it simple
var boo = true/false;
takeo33
@takeo33
Jun 12 2017 01:07

hi i don't know what to do with this code.. // Only change code below this line

var remainder
remainder =11
11 % 3 = 2

farheen
@farh33n
Jun 12 2017 01:07
@takeo33 what do u want to do with this code?
takeo33
@takeo33
Jun 12 2017 01:07
@farh33n Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
mvroehling
@mvroehling
Jun 12 2017 01:07
@intervolver If you just want to use true and false use : true or false
If you want to make an object out of that X u'll have to use new Boolean(true or false)
intervolver
@intervolver
Jun 12 2017 01:08
I needed to reduce a variable to its boolean for Falsy Bouncer, which I passed with this:
function bouncer(arr) {
  var newArr = arr.filter(function(a){
    return Boolean(a) !== false;
  });
  return newArr;
}
I solved the problem by removing "new" from before Boolean
farheen
@farh33n
Jun 12 2017 01:08
@takeo33 is this you want?
var remainder = 11% 3;
takeo33
@takeo33
Jun 12 2017 01:09
@farh33n yes!!!!! thank you!! $$
CamperBot
@camperbot
Jun 12 2017 01:09
takeo33 sends brownie points to @farh33n :sparkles: :thumbsup: :sparkles:
:cookie: 323 | @farh33n |http://www.freecodecamp.com/farh33n
Adam Faraj
@adamfaraj
Jun 12 2017 01:10
Boolean is a function inherently
return arr.filter(Boolean);
farheen
@farh33n
Jun 12 2017 01:10
@takeo33 pleased to help you
Adam Faraj
@adamfaraj
Jun 12 2017 01:11
@intervolver
intervolver
@intervolver
Jun 12 2017 01:16
I don't seem to be able to use it to replace my code
@adamfaraj how would I use that to filter all indexes with an initial value of false? I'm not sure of the syntax
Adam Faraj
@adamfaraj
Jun 12 2017 01:18
you're trying to get rid of all the falsy values from your array, right?
{1,2,false] becomes [1,2]
Harry Fahringer III
@harryrf
Jun 12 2017 01:20
I'm working on the weather app and I like the weather api I'm using, but I don't like their icons so much. I'm trying to figure out a way to use a climacons webfont based on the condition code, but I must be missing something.
I'm working locally atm, codepen and I aren't getting along tonight.
intervolver
@intervolver
Jun 12 2017 01:21

yeah, but what is the use syntax? As a function, Boolean doesn't seem to work like this

return arr.filter(Boolean(){ return !== true;});

it doesn't accept curly braces, and I've never used it as a function before

@adamfaraj
OH
just on its own, it doesn't need arguments at all
function bouncer(arr) {
  return arr.filter(Boolean);
}
Worked fine
@adamfaraj thanks :)
CamperBot
@camperbot
Jun 12 2017 01:24
intervolver sends brownie points to @adamfaraj :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @adamfaraj |http://www.freecodecamp.com/adamfaraj
intervolver
@intervolver
Jun 12 2017 01:24
Could I use Boolean in a similar way to remove all true indexes?
meslance
@meslance
Jun 12 2017 01:25
I need help with Passing Values to Functions with Arguments.
intervolver
@intervolver
Jun 12 2017 01:26
@meslance What are you stuck on?
Quang-Thuy Hoang
@averageAZNguy
Jun 12 2017 01:26
hello everyone. I'm at the seek and destroy challenge and i'm trying to figure out how to even access the 2nd and third input when only one argument is passed through the function
meslance
@meslance
Jun 12 2017 01:27
@intervolver Calling out the function after defining it
Quang-Thuy Hoang
@averageAZNguy
Jun 12 2017 01:28

function destroyer(arr,arr2) {
// Remove all the values
return arr;
}

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

only returns the first 6 elements in the first array but i'm trying to access the 2,3 outside that array
meslance
@meslance
Jun 12 2017 01:28

@intervolver I have this code

function functionWithArgs(arg1, arg2){
console.log(arg1+arg2);
}

But not sure how that comes out to 5

Quang-Thuy Hoang
@averageAZNguy
Jun 12 2017 01:29
sorry its actually:

function destroyer(arr) {
// Remove all the values
return arr;
}

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

Manish Giri
@Manish-Giri
Jun 12 2017 01:29
@averageAZNguy you can use the arguments object.
intervolver
@intervolver
Jun 12 2017 01:29

@meslance you just enter the name of the function on a new line, and pass the arguments into brackets afterwards, something like this:

myFunction(arg1 , arg2, arg3, etc)

separating your arguments with commas

Manish Giri
@Manish-Giri
Jun 12 2017 01:29
MDN has a good link on it.
intervolver
@intervolver
Jun 12 2017 01:29
and a ; on the end
meslance
@meslance
Jun 12 2017 01:31
@intervolver Says the function is not defined
functionWithArgs(arg1, arg2, arg3);
intervolver
@intervolver
Jun 12 2017 01:32
@meslance have you defined a new function like the in the example above?

@meslance the example function is defined like this:

function ourFunctionWithArgs(a, b) {
  console.log(a - b);
}

and called like this:

ourFunctionWithArgs(10, 5);
Quang-Thuy Hoang
@averageAZNguy
Jun 12 2017 01:34
@Manish-Giri Thanks. I reread the hint. It clicked. I didn't understand what it meant the first read through
CamperBot
@camperbot
Jun 12 2017 01:34
averageaznguy sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5960 | @manish-giri |http://www.freecodecamp.com/manish-giri
intervolver
@intervolver
Jun 12 2017 01:34
so you want to define your own function, functionWithArgs(a, b) in a similar way @meslance
Manish Giri
@Manish-Giri
Jun 12 2017 01:34
@averageAZNguy good job!
meslance
@meslance
Jun 12 2017 01:35
@intervolver I'm still kinda confused on the whole exercise but I just copied that and it worked
Joseph
@revisualize
Jun 12 2017 01:36
@meslance Didn't I explain functions to you yesterday? Function declarations and function calls and I spoke about parameters?
DistinctWolf
@DistinctWolf
Jun 12 2017 01:36
what is wrong with this code help please

function dropElements(arr, func) {
  var thefunction=arguments[1];
  for(var i=0;i<arr.length;i++){
    if(thefunction(arr[i])===false){
      arr.shift();      
    }else{
      return arr.slice(i);
    }
  }
}

dropElements([0, 1, 0, 1], function(n) {return n === 1;});
intervolver
@intervolver
Jun 12 2017 01:37
@meslance You can learn to do it over time through repetition, but it might be worth spending some time studying the core idea of what a function is
DistinctWolf
@DistinctWolf
Jun 12 2017 01:38
@revisualize I already analyzed the code from that website but I don't get how 1 doesn't equal to 1
meslance
@meslance
Jun 12 2017 01:40
@revisualize I'm still foggy on these ideas. I understand what some are asking for but others I don't.
intervolver
@intervolver
Jun 12 2017 01:42
@meslance do you understand the principle behind what a function is? Not what a specific function is or does, but just the general concept?
meslance
@meslance
Jun 12 2017 01:43
@intervolver No.
urbanikon
@urbanikon
Jun 12 2017 01:43
can anyone help me with some Java
Joseph
@revisualize
Jun 12 2017 01:44
@FlashHero First off.. Everywhere you have thefunction just replace with func
@FlashHero And remove this line: var thefunction=arguments[1];
Manish Giri
@Manish-Giri
Jun 12 2017 01:45
@urbanikon Java? or JavaScript?
urbanikon
@urbanikon
Jun 12 2017 01:45
JS
@Manish-Giri
Manish Giri
@Manish-Giri
Jun 12 2017 01:45
ask away
urbanikon
@urbanikon
Jun 12 2017 01:45
can i just tell you what section of the map im on. would that make it easier ?
Joseph
@revisualize
Jun 12 2017 01:45
@urbanikon Challenge Name.
Manish Giri
@Manish-Giri
Jun 12 2017 01:45
the challenge name would be easier
@urbanikon
urbanikon
@urbanikon
Jun 12 2017 01:46
convert Celsius to Fahrenheit
intervolver
@intervolver
Jun 12 2017 01:46
@meslance A function is a way to save time when we want to perform a basic task over and over again. When you define a function, you're describing the task you want to do.
An example of a task would be solving an algebraic problem like "a + b". In javascript you could just type "4+5" and get "9", but sometimes you want to do that a lot, and with changing variables. So you write a function like this:
DistinctWolf
@DistinctWolf
Jun 12 2017 01:46

function dropElements(arr, func) {
  for(var i=0;i<arr.length;i++){
    if(func(arr[i])===false){
      arr.shift();      
    }else{
      return arr.slice(i);
    }
  }
}

dropElements([0, 1, 0, 1], function(n) {return n === 1;});
still not working ?
Manish Giri
@Manish-Giri
Jun 12 2017 01:47
@urbanikon okay, what's your question?
also, pls tag while responding, helps notify.
urbanikon
@urbanikon
Jun 12 2017 01:48
I can't figure out the algorithm @Manish-Giri
my bad
Joseph
@revisualize
Jun 12 2017 01:48
@FlashHero Okay here's your problem.
@FlashHero First i is 0
intervolver
@intervolver
Jun 12 2017 01:48
@meslance
function addTwoNumbers(a , b) { return a + b; } @meslance
Joseph
@revisualize
Jun 12 2017 01:48
@FlashHero Right.
@FlashHero Then because that is true you're changing the arr.
@FlashHero [1,0,1]
Manish Giri
@Manish-Giri
Jun 12 2017 01:49
@urbanikon do you see a formula on the left?
Joseph
@revisualize
Jun 12 2017 01:49
@FlashHero Then i becomes 1
Manish Giri
@Manish-Giri
Jun 12 2017 01:49
there's an expression, involving 9/5 and 32
@urbanikon
Joseph
@revisualize
Jun 12 2017 01:49
@FlashHero arr[1] is 0
urbanikon
@urbanikon
Jun 12 2017 01:49
yeah @Manish-Giri
Manish Giri
@Manish-Giri
Jun 12 2017 01:49
what does it look like? can you write it here?
@urbanikon
intervolver
@intervolver
Jun 12 2017 01:50

@meslance that function takes two variables, a and b, adds them together, and returns the sum. When you want to use it, you call it, like this:

addTwoNumbers(4 , 5);

just typing the name of the function, and passing the variables you want to use into the brackets, will make it perform its function, in this case adding the two numbers and returning their sum

urbanikon
@urbanikon
Jun 12 2017 01:50
The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32. @Manish-Giri
soo.. Celsius =
Manish Giri
@Manish-Giri
Jun 12 2017 01:51
right, so here are the key bits
intervolver
@intervolver
Jun 12 2017 01:51
@meslance is this helping at all?
urbanikon
@urbanikon
Jun 12 2017 01:51
@Manish-Giri listening
Manish Giri
@Manish-Giri
Jun 12 2017 01:51
the temperature in Celsius times 9/5, plus 32
DistinctWolf
@DistinctWolf
Jun 12 2017 01:51
@revisualize doesn't it have to test every value with the function until it's true ? I'm confused
Joseph
@revisualize
Jun 12 2017 01:51
@FlashHero Look.
Manish Giri
@Manish-Giri
Jun 12 2017 01:51
you have been given a celsius parameter,
function convertToF(celsius) {
@urbanikon
Homculus
@HomunculusLotus
Jun 12 2017 01:51
function bouncer(arr) 
{
  var keepTheseOut = [0, false, null, "", undefined, NaN];
  var falseDummy = false;
  var nullDummy = null;

  for (var i = 0; i < arr.length; i++)
    {
      if (keepTheseOut.includes(arr[i]))
        {
          arr.splice(i,1); 
        }
      else if (arr[i] == falseDummy)
        {
          arr.splice(i,1);
        }
      else if (arr[i] == nullDummy)
        arr.splice(i,1);

    }


  return arr;
}

bouncer([1, null, NaN, 2, undefined]);
Could I get some help on this? When I run the code, false and null still pop out.
That's why I checked manually for false and null
but it still doesn't filter them out.
Manish Giri
@Manish-Giri
Jun 12 2017 01:53

@urbanikon if you multiply that celsius variable with 9/5 and add 32 to it, what you get is the corresponding temperature in Fahrenheit.

so your left side is the variable fahrenheit, your right side is the expression that you need to create with celsius.

Homculus
@HomunculusLotus
Jun 12 2017 01:53
Also, for some reason
bouncer([false, null, 0, NaN, undefined, ""]) returns 

[null, null, ""]
mvroehling
@mvroehling
Jun 12 2017 01:53
function palindrome(str) {
  str = str.replace(/(\W|[_])/gi, "");
  str = str.toLowerCase();

  for(var i = 0; i < str.length/2; i++) {
    if (str[i] != str[str.length-i-1])
      return false;
  }

  return true;
}
This function is working. But I was wondering if there is a more cleaner way to do it? I tried using str == str.reverse(), but since str is just an object that obviously is not working...
Manish Giri
@Manish-Giri
Jun 12 2017 01:54
@mvroehling .reverse() is an Array function.
If you need to use it, you gotta first split the string into an array of characters, then use reverse on it.
urbanikon
@urbanikon
Jun 12 2017 01:54
alright @Manish-Giri would you mind recreating what you are explaing to me in code. I am a visual learner and it's just hard for me to see what you are explaining
mvroehling
@mvroehling
Jun 12 2017 01:55
@Manish-Giri OH yeah I forgot I split them before.
Joseph
@revisualize
Jun 12 2017 01:55
@FlashHero
arr is [0,1,0,1]
i is 0
arr[0] is 0
so.. arr.shift()
Now arr is [1,0,1]
The for loops...
i is 1
arr[1] is 0
and 0 is not 1
so. arr.shift()
Now arr is [0,1]
the for loops.
i is 2
arr is [0,1] so ... arr.length() is 2
Therefore, the loop halts
intervolver
@intervolver
Jun 12 2017 01:55
@meslance I PM'd you, it'll be under All Conversations on the left if you want further help
Manish Giri
@Manish-Giri
Jun 12 2017 01:55
@urbanikon okay, if I've got a variable a and I want to assign the value 10 to it, how would you do it?
urbanikon
@urbanikon
Jun 12 2017 01:56
@Manish-Giri var a = 10;
right?
Manish Giri
@Manish-Giri
Jun 12 2017 01:56
right
Joseph
@revisualize
Jun 12 2017 01:56
@FlashHero Does that make sense?
Manish Giri
@Manish-Giri
Jun 12 2017 01:56
so this is like an expression, you've got the variable on the left, and you're assigning a value to it.
now if I say, multiply 10 by 2, and assign it to a, how would you do it?
@urbanikon
urbanikon
@urbanikon
Jun 12 2017 01:57
a = 10 * 2; @Manish-Giri
Manish Giri
@Manish-Giri
Jun 12 2017 01:57
yup
now, let's change things a bit.
DistinctWolf
@DistinctWolf
Jun 12 2017 01:58
@revisualize no
Joseph
@revisualize
Jun 12 2017 01:58
@FlashHero walk through it.
Manish Giri
@Manish-Giri
Jun 12 2017 01:59

You've got two variables, x and y. Let's say x has some value, you don't know what it is.

How would you assign the value in x to the variable y

@urbanikon
Joseph
@revisualize
Jun 12 2017 01:59
@FlashHero How can I help?
@FlashHero You realize that .shift() is modifying the Array.
urbanikon
@urbanikon
Jun 12 2017 02:00
var x = y; .. ?i think @Manish-Giri
Manish Giri
@Manish-Giri
Jun 12 2017 02:01
you've got it reversed
the thing you're assigning to, always goes on the left
whatever value you're assigning(be it a value or another variable), that goes on the right
just like var a = 10;
@urbanikon
urbanikon
@urbanikon
Jun 12 2017 02:02
okay okay
@Manish-Giri
Manish Giri
@Manish-Giri
Jun 12 2017 02:02
so now you've got var y = x;, right?
urbanikon
@urbanikon
Jun 12 2017 02:03
yeah @Manish-Giri
Manish Giri
@Manish-Giri
Jun 12 2017 02:03
so, last step is - multiply x by 10, and assign it to y, how would you do that? @urbanikon
DistinctWolf
@DistinctWolf
Jun 12 2017 02:04
@revisualize oh i get it so when array is shifted, the for loop checks for the current index and since some values has already gotten shifted the current index is the next number not the first number in the array right ?
Joseph
@revisualize
Jun 12 2017 02:04
@FlashHero You have the size of the array going down as you're incrementing i upward.
urbanikon
@urbanikon
Jun 12 2017 02:06
var y = 10x;
@Manish-Giri
DistinctWolf
@DistinctWolf
Jun 12 2017 02:06
@revisualize yes, I think i got it now thanks
CamperBot
@camperbot
Jun 12 2017 02:06
flashhero sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4146 | @revisualize |http://www.freecodecamp.com/revisualize
urbanikon
@urbanikon
Jun 12 2017 02:06
celsius = 30;
celsius *= 9/5;
celsius += 32;
fahrenheit= celsius ;
this is what i was working on btw @Manish-Giri
Manish Giri
@Manish-Giri
Jun 12 2017 02:07
try to put it all in one line
fahrenheit on the left
the expression on the right
fahrenheit = .....
@urbanikon celsius = 30;, also this is where you're going wrong.
urbanikon
@urbanikon
Jun 12 2017 02:08
what should celsius be ?
Manish Giri
@Manish-Giri
Jun 12 2017 02:08
What if the celsius value is 100, if you do this, you're assigning 30 to celsius, so now the 100 is lost..
urbanikon
@urbanikon
Jun 12 2017 02:08
humm.. alright makes sense
Manish Giri
@Manish-Giri
Jun 12 2017 02:09
okay, backing up a bit -
function doSomething(stuff) {
  return stuff;
}
when you write a function, you can optionally pass in parameters to your function.
in this function, stuff is such a parameter.
mvroehling
@mvroehling
Jun 12 2017 02:10
function findLongestWord(str) {
  var words = str.split(" ");
  words = words.sort(function(a, b){
    return b.length - a.length;
  });

  return words[0].length;
}
Is there a more elegant way to find the longest word in a string?
Manish Giri
@Manish-Giri
Jun 12 2017 02:10
When you call this function, it would be like doSomething("Hello")
@urbanikon
here, you CALL the function with the argument Hello
urbanikon
@urbanikon
Jun 12 2017 02:11
oh boy.. maybe i should start with python because i am low key lost @Manish-Giri
Manish Giri
@Manish-Giri
Jun 12 2017 02:11
now this string "Hello" replaces the stuff parameter you had declared at the time you wrote the function.
um
Kyle Holm
@thekholm80
Jun 12 2017 02:11
@urbanikon you got this, don't give up
urbanikon
@urbanikon
Jun 12 2017 02:12
alright alright .. im going to keep trying. It's just hard stuff to wrap your head around
@thekholm80
Manish Giri
@Manish-Giri
Jun 12 2017 02:12
it's the same theory everywhere, no matter which language you choose. But perhaps you could do the JS lessons on Codeacademy first? They're much easier, and has more examples than FCC.
Kyle Holm
@thekholm80
Jun 12 2017 02:12
but once you get it, it feels awesome
urbanikon
@urbanikon
Jun 12 2017 02:12
alright ill try Code A.
Thanks guys. I shall be back soon !'
Manish Giri
@Manish-Giri
Jun 12 2017 02:13
if only d3.selectAll()felt as awesome
@thekholm80
:weary:
Kyle Holm
@thekholm80
Jun 12 2017 02:13
a little counter-intuitive, isn't it?
Manish Giri
@Manish-Giri
Jun 12 2017 02:13
yup
Homculus
@HomunculusLotus
Jun 12 2017 02:13
Is anyone available to help me?
Kyle Holm
@thekholm80
Jun 12 2017 02:13
selecting stuff that doesn't exist
Manish Giri
@Manish-Giri
Jun 12 2017 02:13
very
mvroehling
@mvroehling
Jun 12 2017 02:13
@HomunculusBrainEater depends on the question
Manish Giri
@Manish-Giri
Jun 12 2017 02:13
first you select stuff that doesn't exist
Kyle Holm
@thekholm80
Jun 12 2017 02:14
then you create it lol
Homculus
@HomunculusLotus
Jun 12 2017 02:14
function bouncer(arr) 
{
  var keepTheseOut = [0, false, null, " ", undefined, NaN];
  var falseDummy = false;
  var nullDummy = null;

  for (var i = 0; i < arr.length; i++)
    {
      if (keepTheseOut.includes(arr[i]))
        {
          arr.splice(i,1); 
        }
      else if (arr[i] == falseDummy)
        {
          arr.splice(i,1);
        }
      else if (arr[i] == nullDummy)
        arr.splice(i,1);

    }


  return arr;
}

bouncer([false, null, 0, NaN, undefined, " "]);
is my code for the falsy bouncer test.
Manish Giri
@Manish-Giri
Jun 12 2017 02:14
then you do .data().enter() and create placeholder elements
what a load of crap
@thekholm80
Homculus
@HomunculusLotus
Jun 12 2017 02:14
When I run it, I get [null, null, ""] as an output.
Kyle Holm
@thekholm80
Jun 12 2017 02:14
just think if it as magic
Homculus
@HomunculusLotus
Jun 12 2017 02:14
I..have no idea what's happening tbh.
I only did the manual false and null checks because they keep showing up as well.
For whatever it's worth, the empty string doesn't show up if I input [7, "ate", "", false, 9].
Only false does.
Harry Fahringer III
@harryrf
Jun 12 2017 02:15

To access my weather API's condition code I'm using geo.current.condition.code, under condition in the JSON file, you also have text and icon. I do not like their icon and would like to use my own.

    $.getJSON(api, function (geo) {

      var location = geo.location;
      var current = geo.current;
      var condition = geo.current.condition;
      var icon = "";
      var conditionCode = geo.current.condition.code;

      if (conditionCode === 1000) {
        icon = "climacon sun";
        $("currentConditionIcon").prepend($("<div class='" + icon + "'></div>"));
      }
  });

I'm attempting to replace it with a weather webfont. Looking at this snippit, what am I doing wrong?

urbanikon
@urbanikon
Jun 12 2017 02:15
thank you again @Manish-Giri
CamperBot
@camperbot
Jun 12 2017 02:15
urbanikon sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
Manish Giri
@Manish-Giri
Jun 12 2017 02:15
your user name is quite something
CamperBot
@camperbot
Jun 12 2017 02:15
:star2: 5961 | @manish-giri |http://www.freecodecamp.com/manish-giri
urbanikon
@urbanikon
Jun 12 2017 02:16
lol thanks
Manish Giri
@Manish-Giri
Jun 12 2017 02:16
@urbanikon welcome! all the best, and hit us up if you need help.
Harry Fahringer III
@harryrf
Jun 12 2017 02:17
everything else within that same $.getJSON works, just not the icon change.
Elliw Seehorn
@ellsee
Jun 12 2017 02:20

// Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 0;

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

// Only change code below this line
processed= processArg(2);

what is wrong with my code for challenge "Assignment with a Returned Value"?

Mine is setup down
Manish Giri
@Manish-Giri
Jun 12 2017 02:20
@ellsee what's the expected result?
they mention that on the left.
Elliw Seehorn
@ellsee
Jun 12 2017 02:21
nevermind. i fixed it myself. thank you for offering help!
Manish Giri
@Manish-Giri
Jun 12 2017 02:21
cool
Homculus
@HomunculusLotus
Jun 12 2017 02:22
So...does anyone know what my issue is?
Elliw Seehorn
@ellsee
Jun 12 2017 02:22
i was in the wrong keyboard, had a greek question mark instead of semicolon lol
Kyle Holm
@thekholm80
Jun 12 2017 02:23
ouch
Elliw Seehorn
@ellsee
Jun 12 2017 02:23
@HomunculusBrainEater what's the code? what's the challenge?
Kyle Holm
@thekholm80
Jun 12 2017 02:23
I don't know how you could even tell, they look the same to me
Homculus
@HomunculusLotus
Jun 12 2017 02:23
function bouncer(arr) 
{
  var keepTheseOut = [0, false, null, " ", undefined, NaN];
  var falseDummy = false;
  var nullDummy = null;

  for (var i = 0; i < arr.length; i++)
    {
      if (keepTheseOut.includes(arr[i]))
        {
          arr.splice(i,1); 
        }
      else if (arr[i] == falseDummy)
        {
          arr.splice(i,1);
        }
      else if (arr[i] == nullDummy)
        arr.splice(i,1);

    }


  return arr;
}

bouncer([false, null, 0, NaN, undefined, " "]);
It is the falsy bouncer test.
Elliw Seehorn
@ellsee
Jun 12 2017 02:23
i couldnt, but i was looking and i couldn't tell what wrong then i saw my keyboard was on greek @thekholm80
Homculus
@HomunculusLotus
Jun 12 2017 02:23
I keep outputting false and null, despite the manual checks.
This little bit even outputs [null, null, ""].
Though the empty string is usually killed.
Kyle Holm
@thekholm80
Jun 12 2017 02:24
@ellsee well spotted in any case
Manish Giri
@Manish-Giri
Jun 12 2017 02:24
@thekholm80 the white background here is literally killing me
WAINGOR
@WAINGOR
Jun 12 2017 02:24
Hi all, I am stuck @ basic algo challenges : Seek & Destroy. Can anybody help?

function destroyer(arr) {
// maak array van arguments
var args = Array.from(arguments);
// element mag niet blijven als deze aanwezig is in arguments
function filterSame(elem) {
  if (args.indexOf(elem)) {
    return false;
  }
  else {return true;}
}

var copyUnique = arr.filter(filterSame);
  return copyUnique;


}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Manish Giri
@Manish-Giri
Jun 12 2017 02:24
and I've been on it all day
Kyle Holm
@thekholm80
Jun 12 2017 02:25
@Manish-Giri turn your brightness down?
Manish Giri
@Manish-Giri
Jun 12 2017 02:25
it's at 0 already
Kyle Holm
@thekholm80
Jun 12 2017 02:25
sunglasses
bonus: you'll look cool
Harry Fahringer III
@harryrf
Jun 12 2017 02:28
No one is sure how to help me?
Manish Giri
@Manish-Giri
Jun 12 2017 02:28
33.png
me likey
Kyle Holm
@thekholm80
Jun 12 2017 02:28
did you just hack the css in chrome dev tools?
Manish Giri
@Manish-Giri
Jun 12 2017 02:28
:smiling_imp:
Adam Faraj
@adamfaraj
Jun 12 2017 02:29
@harryrf not there yet
Homculus
@HomunculusLotus
Jun 12 2017 02:29
Maybe try StackOverflow?
Long Nguyen
@longnt80
Jun 12 2017 02:29
@Manish-Giri use f.lux
Kyle Holm
@thekholm80
Jun 12 2017 02:30
@harryrf sorry I don't really know jQuery
Homculus
@HomunculusLotus
Jun 12 2017 02:30
Also there's a dark theme
Open up gitterr in the new-tab mode and press your avatar on the top right.
There's a 'toggle dark theme' button.
Adam Faraj
@adamfaraj
Jun 12 2017 02:30
can someone help me debug my email validator function please?
Manish Giri
@Manish-Giri
Jun 12 2017 02:31
@longnt80 doesn't Flux just dim the brightness, as opposed to making it dark?
Elliw Seehorn
@ellsee
Jun 12 2017 02:31

function nextInLine(arr, item) {
// Your code here
nextInLine.push("");
nextInLine.shift("");
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));

i'm getting the error nextInLine.push is not a function. i mean, it's not wrong, it isn't a function, but why is this an issue?

Alvin-Capello
@Alvin-Capello
Jun 12 2017 02:31
Could someone offer some help? I am doing the Spinal Tap Case Algorithm and I have code the works for all the options except "thisIsSpinalTap" My problem is I can't figure out why it won't work for that instance, since I prepared for it in my code.
Manish Giri
@Manish-Giri
Jun 12 2017 02:31
@HomunculusLotus I'm already on gitter dark theme, but that site is outside of gitter.
Alvin-Capello
@Alvin-Capello
Jun 12 2017 02:31
```
Long Nguyen
@longnt80
Jun 12 2017 02:32
@Manish-Giri it does both I guess, the color temperature really helps
Alvin-Capello
@Alvin-Capello
Jun 12 2017 02:32
function spinalCase(str) {
  var firstStr = str.split("");
 var lowStr = str.toLowerCase(); 
  var arrStr = lowStr.split("");
  for (var i = 0; i < arrStr.length; i++) {
    if (arrStr[i] === " " || arrStr[i] === "_") {
      arrStr[i] = "-";
    } else if (arrStr[i] === "l") {
      if (arrStr[i+1] === "t") {
        var slicey = arrStr.slice(0,i+1);
        var slicey2 = arrStr.slice(i+1);
       slicey.push("-");
        arrStr = slicey.concat(slicey2);
        } else if (arrStr[i] === "s"){
          if (arrStr[i+1] === "i" || arrStr[i+1] === "s") {
        var dicey = arrStr.slice(0,i+1);
        var dicey2 = arrStr.slice(i+1);
       dicey.push("-");
        arrStr = dicey.concat(dicey2);
          }
        }
    }
  }
  var joinStr = arrStr.join("");
  return joinStr;
}
Kyle Holm
@thekholm80
Jun 12 2017 02:32
@ellsee push is an array method, you're trying to use it on a function
Adam Faraj
@adamfaraj
Jun 12 2017 02:32
@ellsee arr.push() should work
Kyle Holm
@thekholm80
Jun 12 2017 02:32
@ellsee nextInLine is the name of your function
Elliw Seehorn
@ellsee
Jun 12 2017 02:34
ok so @adamfaraj the arr.push() worked but the challenge still doesn't and i don't know why?
@thekholm80 thank you for the tip as well
CamperBot
@camperbot
Jun 12 2017 02:34
ellsee sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1020 | @thekholm80 |http://www.freecodecamp.com/thekholm80
Kyle Holm
@thekholm80
Jun 12 2017 02:34
push("") pushes an empty string into the array
Elliw Seehorn
@ellsee
Jun 12 2017 02:35
the challenge is Stand in Line

function nextInLine(arr, item) {
// Your code here
arr.push();
arr.shift();
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));

my updated code
Adam Faraj
@adamfaraj
Jun 12 2017 02:35

function nextInLine(arr, item) {
  // Your code here
  arr.push();
  arr.shift();
  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));
so what is the goal
remove the first element and add item?
Elliw Seehorn
@ellsee
Jun 12 2017 02:36

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

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

nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
Kyle Holm
@thekholm80
Jun 12 2017 02:36
arr.push(); isn't pushing a value into the array Array.push()
Alvin-Capello
@Alvin-Capello
Jun 12 2017 02:37
I could really use some help here.
Adam Faraj
@adamfaraj
Jun 12 2017 02:37
@ellsee you need to push the item into the array
so with arr.push(); you're pushing nothing into the array
if arr.push(1), or whatever, you're pushing 1 into the array
Elliw Seehorn
@ellsee
Jun 12 2017 02:38
@Alvin-Capello i would if i knew how. you're a further along. ill check back as soon as i can
i'm a bit confused as to what i should even be pushing @adamfaraj
Kyle Holm
@thekholm80
Jun 12 2017 02:39
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array
Adam Faraj
@adamfaraj
Jun 12 2017 02:40
Add the number to the end of the array
number = item
Elliw Seehorn
@ellsee
Jun 12 2017 02:41
so it would look like arr.push(item);?
Adam Faraj
@adamfaraj
Jun 12 2017 02:41
yes!
Elliw Seehorn
@ellsee
Jun 12 2017 02:42
is the arr.shift([0]) valid or does it also need rewriting?
Adam Faraj
@adamfaraj
Jun 12 2017 02:42
shift will not take an argument
it's understood that it will remove the first item
Elliw Seehorn
@ellsee
Jun 12 2017 02:43
ok. good to know. i have now accomplished nextInLine([], 1) should return 1 and After nextInLine(testArr, 10), testArr[4] should be 10. i still am at a loss for nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
i feel like my code should be more complex but i don't know how or where
Kyle Holm
@thekholm80
Jun 12 2017 02:43
Array.shift() returns the shifted value, so you have to catch it
Elliw Seehorn
@ellsee
Jun 12 2017 02:45
i think it has something to do with the line return item;
do i put arr.shift(); in the place of item?
Kyle Holm
@thekholm80
Jun 12 2017 02:46
yes!
it asks you to return the removed item
Adam Faraj
@adamfaraj
Jun 12 2017 02:47
return arr.shift();
it should have the item pushed into it
if you have arr.push(item); before return arr.shift();
Joseph
@revisualize
Jun 12 2017 02:48
Hey hey.
@ellsee I have a write up on that lesson if you want to see
Elliw Seehorn
@ellsee
Jun 12 2017 02:49
@adamfaraj @thekholm80 y'all are the greatest! thanks so much for helping me through it, nice to know there's people like y'all on the community!
CamperBot
@camperbot
Jun 12 2017 02:49
ellsee sends brownie points to @adamfaraj and @thekholm80 :sparkles: :thumbsup: :sparkles:
:warning: ellsee already gave thekholm80 points
:cookie: 272 | @adamfaraj |http://www.freecodecamp.com/adamfaraj
Elliw Seehorn
@ellsee
Jun 12 2017 02:49
thanks dude @revisualize ill keep that for reference
CamperBot
@camperbot
Jun 12 2017 02:49
ellsee sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4147 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 12 2017 02:50
@ellsee Just read it over really quick. Some information in there will help you in further lessons.
Elliw Seehorn
@ellsee
Jun 12 2017 02:50
👍 @revisualize
BigWootWoot
@BigWootWoot
Jun 12 2017 02:59
Can someone show me how to post code I'm working on
Harry Fahringer III
@harryrf
Jun 12 2017 02:59
I'm back to correct myself on my issue. I keep making the same silly mistake of not adding a # to my selector
Kyle Holm
@thekholm80
Jun 12 2017 02:59
copy your code, then
```
paste your code here
```
Harry Fahringer III
@harryrf
Jun 12 2017 02:59
:fire:
BigWootWoot
@BigWootWoot
Jun 12 2017 02:59
thank you
having trouble getting this to go through
'''
CamperBot
@camperbot
Jun 12 2017 03:00
:bulb: to format code use backticks! ``` more info
BigWootWoot
@BigWootWoot
Jun 12 2017 03:00

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

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

}

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

CamperBot
@camperbot
Jun 12 2017 03:00
:bulb: to format code use backticks! ``` more info
BigWootWoot
@BigWootWoot
Jun 12 2017 03:01

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

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

}

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

CamperBot
@camperbot
Jun 12 2017 03:01
:bulb: to format code use backticks! ``` more info
Harry Fahringer III
@harryrf
Jun 12 2017 03:02
The was almost correct, but you're using single quotes ' instead of backticks `
Kyle Holm
@thekholm80
Jun 12 2017 03:02
myObj.hasOwnProperty(checkObj) === true is what we call an anti-pattern, you're basically saying "if this is true equals true"
it still works but just an fyi
BigWootWoot
@BigWootWoot
Jun 12 2017 03:02
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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


}

// Test your code by modifying these values
checkObj("gift");
Kyle Holm
@thekholm80
Jun 12 2017 03:03
but you do need to remove the semicolon from this line: if (myObj.hasOwnProperty(checkObj) === true);
BigWootWoot
@BigWootWoot
Jun 12 2017 03:03
@thekholm80 thank you
CamperBot
@camperbot
Jun 12 2017 03:03
bigwootwoot sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1021 | @thekholm80 |http://www.freecodecamp.com/thekholm80
Kyle Holm
@thekholm80
Jun 12 2017 03:03
looks like you've got the right idea
BigWootWoot
@BigWootWoot
Jun 12 2017 03:04
thanks I have been fighting this one 30 min and it was just overlooking a ;
thank you for the help
Kyle Holm
@thekholm80
Jun 12 2017 03:04
it's always a semicolon lol
or a greek questionmark
Long Nguyen
@longnt80
Jun 12 2017 03:09
Any critism is much welcomed for review my Pomodoro clock:
https://codepen.io/longnt80/full/xdNmKv/
BigWootWoot
@BigWootWoot
Jun 12 2017 03:11

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

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

}

// Test your code by modifying these values
checkObj("gift");
``` Now no matter what i put in it returns "Not Found"

Kyle Holm
@thekholm80
Jun 12 2017 03:11
@longnt80 it's very clean, good job
Adam Faraj
@adamfaraj
Jun 12 2017 03:11
@longnt80 i like it
BigWootWoot
@BigWootWoot
Jun 12 2017 03:11
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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



}

// Test your code by modifying these values
checkObj("gift");
Kyle Holm
@thekholm80
Jun 12 2017 03:11
@BigWootWoot what is checkObj?
Long Nguyen
@longnt80
Jun 12 2017 03:12
@thekholm80 @adamfaraj thanks guys, one thing is missing is the sound
CamperBot
@camperbot
Jun 12 2017 03:12
longnt80 sends brownie points to @thekholm80 and @adamfaraj :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @adamfaraj |http://www.freecodecamp.com/adamfaraj
:star2: 1022 | @thekholm80 |http://www.freecodecamp.com/thekholm80
Kyle Holm
@thekholm80
Jun 12 2017 03:12
did you mean checkProp?
myObj.hasOwnProperty(checkObj) here i mean
@longnt80 when the break is over the session timer doesn't restart?
BigWootWoot
@BigWootWoot
Jun 12 2017 03:13
yes i did. Thank you for all this
Kyle Holm
@thekholm80
Jun 12 2017 03:13
happy to help
Long Nguyen
@longnt80
Jun 12 2017 03:14

@thekholm80

@longnt80 when the break is over the session timer doesn't restart?

I was planning to have one interval (session and break) at a time, so user have to choose a new one or simply click the Start button again

Kyle Holm
@thekholm80
Jun 12 2017 03:14
cool
not complaining, just curious
Kevin NOUTSAWO
@kevnoutsawo
Jun 12 2017 03:18
Hello everyone!
Jorge Vargas
@jvsole17
Jun 12 2017 03:18
can someone help me
i keep getting illegal return statement

// Setup
function abTest(a, b) {
// Only change code below this line
if (a < 0 || b < 0);
return undefined;
}

// Only change code above this line
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

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

Adam Faraj
@adamfaraj
Jun 12 2017 03:19

// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a < 0 || b < 0);
   return undefined;
}


  // Only change code above this line
  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(-2,2);
Kevin NOUTSAWO
@kevnoutsawo
Jun 12 2017 03:19
I stuck on "Profile Lookup" exercise. Help please.
Jorge Vargas
@jvsole17
Jun 12 2017 03:19
nvm
i ficked it
Adam Faraj
@adamfaraj
Jun 12 2017 03:19
uhh
Jorge Vargas
@jvsole17
Jun 12 2017 03:19
i was suppose to put brakets before return
and take out semicolon
lol
Adam Faraj
@adamfaraj
Jun 12 2017 03:19
{}
Jorge Vargas
@jvsole17
Jun 12 2017 03:19
yea
Adam Faraj
@adamfaraj
Jun 12 2017 03:19
if() {
}
Jorge Vargas
@jvsole17
Jun 12 2017 03:19
@adamfaraj thanks tho
CamperBot
@camperbot
Jun 12 2017 03:19
jvsole17 sends brownie points to @adamfaraj :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @adamfaraj |http://www.freecodecamp.com/adamfaraj
Kevin NOUTSAWO
@kevnoutsawo
Jun 12 2017 03:20
Here is my code :
Joseph
@revisualize
Jun 12 2017 03:20
@jvsole17 The ; is a statement TERMINATOR
Kevin NOUTSAWO
@kevnoutsawo
Jun 12 2017 03:21

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

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

It stops at the first element, I have a hard time figuring out why.
```
Please help!
```
Adam Faraj
@adamfaraj
Jun 12 2017 03:25
function lookUpProfile(firstName, prop){
// Only change code below this line

for(var i = 0; i < contacts.length; i++){
  if(contacts[i].firstName === firstName){
    if(contacts[i].hasOwnProperty(prop)){
      return contacts[i][prop];
    }
    else{
      return "No such property";
    }
  }
  else{
    return "No such contact";
  }
}
// Only change code above this line
}
Makopa
@makopa
Jun 12 2017 03:25
Good day campers :fire: is it possible in javascript to convert numbers to in words? for example, input: 127 output: one-hundred twenty seven, without using any build in methods
Alvin-Capello
@Alvin-Capello
Jun 12 2017 03:25
If someone could help me here, I would really appreciate it. I am doing the Spinal Tap Case Algorithm and the code I have so far works for all of the options except "thisIsSpinalTap". Here is my code.
Moisés Man
@moigithub
Jun 12 2017 03:26
u returning "no contact" at first mismatch
u should check ALL contacts before that @kevnoutsawo
Alvin-Capello
@Alvin-Capello
Jun 12 2017 03:26
function spinalCase(str)  {
 var lowStr = str.toLowerCase(); 
  var arrStr = lowStr.split("");
  for (var i = 0; i < arrStr.length; i++) {
    if (arrStr[i] === " " || arrStr[i] === "_") {
      arrStr[i] = "-";
    } else if (arrStr[i] === "l") {
      if (arrStr[i+1] === "t") {
        var slicey = arrStr.slice(0,i+1);
        var slicey2 = arrStr.slice(i+1);
       slicey.push("-");
        arrStr = slicey.concat(slicey2);
        } else if (arrStr[i] === "s"){
          if (arrStr[i+1] === "i" || arrStr[i+1] === "s") {
        var dicey = arrStr.slice(0,i+1);
        var dicey2 = arrStr.slice(i+1);
       dicey.push("-");
        arrStr = dicey.concat(dicey2);
          }
        }
    }
  }
  var joinStr = arrStr.join("");
  return joinStr;
Kevin NOUTSAWO
@kevnoutsawo
Jun 12 2017 03:27
@makopa Yes, with an algorithm !
Adam Faraj
@adamfaraj
Jun 12 2017 03:28
@moigithub not my code. haha. just cant read it when it's not in that format
Makopa
@makopa
Jun 12 2017 03:28
@kevnoutsawo is there any chance that you know any existing code for that problems?
Kevin NOUTSAWO
@kevnoutsawo
Jun 12 2017 03:30
@makopa I made such a project 7 years ago, I don't think I still have the source code.
Alvin-Capello
@Alvin-Capello
Jun 12 2017 03:30
When I print my code out onto the console it outputs correctly, but not when I hit the run tests button.
Kevin NOUTSAWO
@kevnoutsawo
Jun 12 2017 03:31
@moigithub Thanks a lot.
CamperBot
@camperbot
Jun 12 2017 03:31
kevnoutsawo sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3355 | @moigithub |http://www.freecodecamp.com/moigithub
Makopa
@makopa
Jun 12 2017 03:31
@kevnoutsawo ok bro.! no problem thanks
CamperBot
@camperbot
Jun 12 2017 03:31
makopa sends brownie points to @kevnoutsawo :sparkles: :thumbsup: :sparkles:
:cookie: 218 | @kevnoutsawo |http://www.freecodecamp.com/kevnoutsawo
Elliw Seehorn
@ellsee
Jun 12 2017 03:32

I am on Chaining If Else Statements, and I have an issue. Only thing is, it is an unrecoverable syntax error so I don't know what it is. Here is my code

function testSize(num) {
// Only change code below this line
if (num <5) {
return "Tiny";
} else if (num <10) {
return "Small";
} else if (num<15) {
return "Medium";
} else if (num<20) {
return "Large";
} else {
return "Huge";
// Only change code above this line
}

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

any ideas?

Aditya
@adichouhan
Jun 12 2017 03:34
@ellsee can u post screenshot
Alvin-Capello
@Alvin-Capello
Jun 12 2017 03:36
@ellsee Your last "else" statement does not have a closing curly brace.
Mukul Agrawal
@mukul09
Jun 12 2017 03:36
@ellsee i think you are missing "}" of your function
David
@DavidNoN
Jun 12 2017 03:37

function nextInLine(arr, item) {
// Your code here
item = arr.shift();
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));

Don't know whats wrong
Adam Faraj
@adamfaraj
Jun 12 2017 03:37
function testSize(num) {
// Only change code below this line
if (num <5) {
return "Tiny";
} else if (num <10) {
return "Small";
} else if (num<15) {
return "Medium";
} else if (num<20) {
return "Large";
} else {
return "Huge";
// Only change code above this line
}
// Change this value to test
testSize(7);
Elliw Seehorn
@ellsee
Jun 12 2017 03:37
thanks! i added one and it did something weird but then i deleted it and the existing worked now. @Alvin-Capello @mukul09
CamperBot
@camperbot
Jun 12 2017 03:37
ellsee sends brownie points to @alvin-capello and @mukul09 :sparkles: :thumbsup: :sparkles:
:cookie: 276 | @alvin-capello |http://www.freecodecamp.com/alvin-capello
:cookie: 427 | @mukul09 |http://www.freecodecamp.com/mukul09
Mukul Agrawal
@mukul09
Jun 12 2017 03:38
@ellsee :+1:
Aditya
@adichouhan
Jun 12 2017 03:38
@DavidNoN yu forget to push item in array
Adam Faraj
@adamfaraj
Jun 12 2017 03:38
@ellsee bracket your code with ```
() your code ()
damn it
haha

welp
use the tick beside the number 1. top left
David
@DavidNoN
Jun 12 2017 03:39
Thanks @adichouhan
CamperBot
@camperbot
Jun 12 2017 03:39
davidnon sends brownie points to @adichouhan :sparkles: :thumbsup: :sparkles:
:cookie: 196 | @adichouhan |http://www.freecodecamp.com/adichouhan
dinosaurjude
@dinosaurjude
Jun 12 2017 03:52
would i need to make to for loops for the Sum All Numbers in a Range algorithm? i already have two variables with the max and min numbers in them. i just dont know what to do next.
mvroehling
@mvroehling
Jun 12 2017 03:55
@dinosaurjude can u send me link of that challenge please?
@mvroehling
mvroehling
@mvroehling
Jun 12 2017 03:57
@dinosaurjude So you have the min and max value. Have you already worked with for loops ? You can iterate over a range of numbers
fdemaa
@fdemaa
Jun 12 2017 03:57
guys can anyone told me if i write this code wrong way , is an exercise with switch

function chainToSwitch(val) {
  var answer = "";
  // Only change code below this line

 switch (val){
  case:
  val==="bob";
  answer="Marley";
  break;

  case: 
  val===42;
  answer="The Answer";
  break;

  case:
  val===1;
  answer="There is no #1";
  break;

  case:
  val===99;
  answer="Missed me by this much!";
  break;

  case:
  val===7;
  answer="Ate nine";


}



  // Only change code above this line  
  return answer;  
}
Aditya
@adichouhan
Jun 12 2017 03:58
@fdemaa show me what is task
mvroehling
@mvroehling
Jun 12 2017 03:59
@fdemaa u are using the wrong syntax here. Use case "bob":
dinosaurjude
@dinosaurjude
Jun 12 2017 03:59
@mvroehling this is pretty much all i have. it looks bad right now lol. i think i need to push the numbers from the loops into an array and then use .reduce(). is that right?
function sumAll(arr) {
  var answer;
  var smallNum = Math.min.apply(null, arr);
  var largestNum = Math.max.apply(null, arr);
  var smallAll;
  var largeAll;
  for(var i = 1; i<smallNum.length; i++){
    smallAll = smallNum[i];


  }
  for(var j= 1; j<largestNum.length; j++){
    largeAll = largestNum[j];

      }
  return answer;
}

sumAll([1, 4]);
i also just realized the function is called sumALL and will be changing my variables to something better
mvroehling
@mvroehling
Jun 12 2017 04:01
@dinosaurjude I think u're misinterpreting the task. Sum all numbers ranging from min to max
dinosaurjude
@dinosaurjude
Jun 12 2017 04:03
if its [1,4] then i need to return the sum of 1 +2 +3 +4?
mvroehling
@mvroehling
Jun 12 2017 04:03
@dinosaurjude yes
@dinosaurjude u can first write it in a for loop. If that's working you can figure out a smarter way using the .reduce method
dinosaurjude
@dinosaurjude
Jun 12 2017 04:05
so only one for loop will be needed?
mvroehling
@mvroehling
Jun 12 2017 04:06
@dinosaurjude Yes, only one for loop. But it can also be done with no for loop at all
dinosaurjude
@dinosaurjude
Jun 12 2017 04:06
i feel like im making this more complicated than it needs to be lol. thank you for helping me @mvroehling
CamperBot
@camperbot
Jun 12 2017 04:06
dinosaurjude sends brownie points to @mvroehling :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @mvroehling |http://www.freecodecamp.com/mvroehling
Haiti415
@Haiti415
Jun 12 2017 04:10
how to assign a to variable b with the =
mvroehling
@mvroehling
Jun 12 2017 04:11
@Haiti415 a equals b :)
fdemaa
@fdemaa
Jun 12 2017 04:11
@mvroehling thanks man, i wrote all the case wrong, !
CamperBot
@camperbot
Jun 12 2017 04:11
fdemaa sends brownie points to @mvroehling :sparkles: :thumbsup: :sparkles:
:cookie: 254 | @mvroehling |http://www.freecodecamp.com/mvroehling
fdemaa
@fdemaa
Jun 12 2017 04:11
i make it work ! thanks
mvroehling
@mvroehling
Jun 12 2017 04:11
@fdemaa u're welcome
Abhishek Tiwari
@fillopfy
Jun 12 2017 04:11
function pairElement(str) {

 var arr=[["A","T"],["T","A"],["C","G"],["G","C"]];var n=[];

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


      if(str[i].match(arr[i][0]))

      n.push(arr[i]);

    }

  return n;
}

pairElement("GCG");
what's wrong with my code
Haiti415
@Haiti415
Jun 12 2017 04:12
doesn't work I wrote a =b
Adam Faraj
@adamfaraj
Jun 12 2017 04:13
@fillopfy you're missing a { after your if statement
i think?
Abhishek Tiwari
@fillopfy
Jun 12 2017 04:13
@adamfaraj missing what?
mvroehling
@mvroehling
Jun 12 2017 04:13
@fillopfy you need to move n.push() a line up.
Abhishek Tiwari
@fillopfy
Jun 12 2017 04:13
@Haiti415 make b=a to assign a to b
@mvroehling a line up?
Adam Faraj
@adamfaraj
Jun 12 2017 04:14
don't if statements need the if(){}?
mvroehling
@mvroehling
Jun 12 2017 04:14
@fillopfy the Yeah. I can see an empty line ur code
@adamfaraj not if its a single liner
Abhishek Tiwari
@fillopfy
Jun 12 2017 04:14
@mvroehling it doesnt matter
mvroehling
@mvroehling
Jun 12 2017 04:15
@fillopfy So what is the problem?
Abhishek Tiwari
@fillopfy
Jun 12 2017 04:15
@mvroehling that i dont know
mvroehling
@mvroehling
Jun 12 2017 04:15
@fillopfy what is it supposed to and what does it do?
Abhishek Tiwari
@fillopfy
Jun 12 2017 04:15
but leaving one line or hundred lines doesnt matter
mvroehling
@mvroehling
Jun 12 2017 04:16
@fillopfy I didnt know that u could trail after the if statement, thanks
CamperBot
@camperbot
Jun 12 2017 04:16
mvroehling sends brownie points to @fillopfy :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @fillopfy |http://www.freecodecamp.com/fillopfy
Abhishek Tiwari
@fillopfy
Jun 12 2017 04:16
@mvroehling it is supposed to check each char in string and return one that matches from arr
@adamfaraj it is same
Makopa
@makopa
Jun 12 2017 04:18
how can i remove decimals? for example. 3.9 i want to convert it from 3 only
heroiczero
@heroiczero
Jun 12 2017 04:19
@makopa floor() method maybe
Aditya
@adichouhan
Jun 12 2017 04:19
@makopa use floor() in built function
Makopa
@makopa
Jun 12 2017 04:20
@heroiczero man it works
digit1 = Math.floor(inputNum / 10);
heroiczero
@heroiczero
Jun 12 2017 04:20
@makopa :+1: :)
Makopa
@makopa
Jun 12 2017 04:20
@adichouhan ya it works like magic <3
Aditya
@adichouhan
Jun 12 2017 04:35

function isLess(a, b) {
// Fix this code
if (a < b) {
return true;
} else {
return false;
}
}

// Change these values to test
isLess(10, 15);
pls help me

i don't understand what to do
John
@j0hnc
Jun 12 2017 04:40
what challenge is that
Mohak Chaturvedi
@lucky73
Jun 12 2017 04:40
i am stuck at the assignment Stand in Line i have writeen this code but not working

function nextInLine(arr, item) {
// Your code here
arr=arr.push(6);
var nextInLine= arr.shift();

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

Aditya
@adichouhan
Jun 12 2017 04:40
@j0hnc 202
John
@j0hnc
Jun 12 2017 04:40
link?
John
@j0hnc
Jun 12 2017 04:41
push item not 6
Claudio Restifo
@Marmiz
Jun 12 2017 04:41
@adichouhan your function return true if a is less than b.... which I believe it's what you were expecting. So where's the issue?
fdemaa
@fdemaa
Jun 12 2017 04:41
you have to use push and shift
John
@j0hnc
Jun 12 2017 04:41
and return arr.shift()
fdemaa
@fdemaa
Jun 12 2017 04:41
@lucky73
John
@j0hnc
Jun 12 2017 04:42
@adichouhan return a < b;
your function is correct
Claudio Restifo
@Marmiz
Jun 12 2017 04:42
@adichouhan read the description, is asking you to remove the if statement :)
Mohak Chaturvedi
@lucky73
Jun 12 2017 04:42
@j0hnc @fdemaa it says arr.shift is not a function
John
@j0hnc
Jun 12 2017 04:42
arr.shift()
fdemaa
@fdemaa
Jun 12 2017 04:42
.shift()
John
@j0hnc
Jun 12 2017 04:42
it is a function
Aditya
@adichouhan
Jun 12 2017 04:43
@j0hnc thnx it's simple
CamperBot
@camperbot
Jun 12 2017 04:43
adichouhan sends brownie points to @j0hnc :sparkles: :thumbsup: :sparkles:
:cookie: 351 | @j0hnc |http://www.freecodecamp.com/j0hnc
Claudio Restifo
@Marmiz
Jun 12 2017 04:43
@adichouhan try to understeand why you can place a condition into a function and expect a true/false return
that's what you should brig home with you
Mohak Chaturvedi
@lucky73
Jun 12 2017 04:45
@j0hnc still not working

function nextInLine(arr, item) {
// Your code here
arr=arr.push(item);

return arr.shift(); // 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));

fdemaa
@fdemaa
Jun 12 2017 04:45
@Marmiz claudio can you help me with a basic exercise , i have a code and in console its giving me empty strings
John
@j0hnc
Jun 12 2017 04:45
arr.push(item); you don't have to assign it to arr
@lucky73
fdemaa
@fdemaa
Jun 12 2017 04:45

function chainToSwitch(val) {
  var answer = "";
  // Only change code below this line

 switch (val) {
  case val === "bob":
  answer = "Marley";
  break;

   case val === 42:
  answer = "The Answer";
  break;

   case val === 1:
  answer = "There is no #1";
  break;

   case val === 99:
  answer = "Missed me by this much!";
  break;

   case val === 7:
  answer = "Ate nine";


}

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

// Change this value to test
console.log(chainToSwitch(42));
Claudio Restifo
@Marmiz
Jun 12 2017 04:45
@fdemaa sure! What's the issue?
Mohak Chaturvedi
@lucky73
Jun 12 2017 04:46
@j0hnc it shows error with arr.shift() return
fdemaa
@fdemaa
Jun 12 2017 04:46
in the fcc console , when i call the function
is empty
John
@j0hnc
Jun 12 2017 04:46
paste your code
Claudio Restifo
@Marmiz
Jun 12 2017 04:47

@fdemaa change from

console.log(chainToSwitch(42));

to

chainToSwitch(42)
Mohak Chaturvedi
@lucky73
Jun 12 2017 04:47
removing assignment had done the trick thank you @j0hnc
CamperBot
@camperbot
Jun 12 2017 04:47
lucky73 sends brownie points to @j0hnc :sparkles: :thumbsup: :sparkles:
:cookie: 352 | @j0hnc |http://www.freecodecamp.com/j0hnc
Claudio Restifo
@Marmiz
Jun 12 2017 04:47
@fdemaa fcc console is not a fully functional console. If you want, open the browser console. you'll see the printed function there
fdemaa
@fdemaa
Jun 12 2017 04:48
still dont , im using the console from codepen
John
@j0hnc
Jun 12 2017 04:49
@fdemaa case "bob"
not case val === "bob"
Claudio Restifo
@Marmiz
Jun 12 2017 04:50
@fdemaa it's an empty string because your switch function is wrong. Mind the syntax there
fdemaa
@fdemaa
Jun 12 2017 04:51
@Marmiz okey i will check
Makopa
@makopa
Jun 12 2017 04:51
i made a program to convert numbers to words, range is 1 to 99 only, if i want to extend it up to 999, what is the best approach? im kinda blocked at the moment here is the code
var inputNum = 50;
var digit1,digit2;
var str1 = ['','','twenty', 'thirty', 'fourty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];
var str2 = [
            '','one', 'two', 'three', 'four', 'five', 
            'six', 'seven','eight','nine','ten',
            'eleven','twelve','thirteen','fourteen','fifteen',
            'sixteen','seventeen','eighteen','nineteen'
           ];


if(inputNum < 1 || inputNum > 99){
  console.log('Out of range');
} else if(inputNum >=1 && inputNum <= 19) {
  console.log(str2[inputNum]);
} else if(inputNum > 19 && inputNum < 100){
  digit1 = Math.floor(inputNum / 10);
  digit2 = inputNum % 10;
  console.log(str1[digit1] + ' ' + str2[digit2]);
}
Claudio Restifo
@Marmiz
Jun 12 2017 04:51
@fdemaa just for reference:
switch (expression) {
  case value1:
    //Statements executed when the result of expression matches value1
    [break;]
  case value2:
    //Statements executed when the result of expression matches value2
    [break;]
as you see is case value1 and not case val == something
John
@j0hnc
Jun 12 2017 04:52
that's what I just said
Jonathan Carroll
@gkcodeman
Jun 12 2017 04:55

```var count = 0;
var response = "";

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

switch(card){

case 2:
case 3:
case 4:
case 5:
case 6:
  count += 1;
  response = count + " Bet";
  break;

case 7:
case 8:
case 9:

  response = count + " Hold";
  break;

case 10: 
case "J":
case "Q":
case "K":
case "A":
  count -= 1;
  response = count + " Hold";

}

return response;
// 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');```

fdemaa
@fdemaa
Jun 12 2017 04:55
@Marmiz thanks man!
CamperBot
@camperbot
Jun 12 2017 04:55
fdemaa sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 928 | @marmiz |http://www.freecodecamp.com/marmiz
Jonathan Carroll
@gkcodeman
Jun 12 2017 04:55
sorry about the code input there
but does anyone see the issue, I'm still not passing 2 checks

```var count = 0;
var response = "";

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

switch(card){

case 2:
case 3:
case 4:
case 5:
case 6:
  count += 1;
  response = count + " Bet";
  break;

case 7:
case 8:
case 9:

  response = count + " Hold";
  break;

case 10: 
case "J":
case "Q":
case "K":
case "A":
  count -= 1;
  response = count + " Hold";

}

return response;
// 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');
```

ugh
John
@j0hnc
Jun 12 2017 04:58
you could return the response after
like so
if(count > 0){
return count + " Bet";
} else {
return count + " Hold";
}
Ogundele Olumide
@Lumexralph
Jun 12 2017 04:59
@gkcodeman you need to check if count is greater than 0 or not before you return count + string
John
@j0hnc
Jun 12 2017 04:59
@gkcodeman also you can delete case 7, 8,9 since they don't do anything
Jonathan Carroll
@gkcodeman
Jun 12 2017 05:02
@Lumexralph how would I write that into the switch statement
John
@j0hnc
Jun 12 2017 05:02
just add the code I showed you after the switch statement @gkcodeman
Ogundele Olumide
@Lumexralph
Jun 12 2017 05:03
@gkcodeman it'll be after the switch statement, let your switch only increment or decrement count
Jonathan Carroll
@gkcodeman
Jun 12 2017 05:05

var count = 0;
var response = "";

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

  switch(card){

    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count += 1;

      break;



    case 10: 
    case "J":
    case "Q":
    case "K":
    case "A":
      count -= 1;


  }

  if(count > 0){
    return count + " Bet";
  } else {
    return count + " Hold";
  }

  return response;


  // 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');
John
@j0hnc
Jun 12 2017 05:05
yes good
Saikat-Sinha
@Saikat-Sinha
Jun 12 2017 05:05
can anyone please help me fixing the eyebrows with id (#reflect-head) of https://codepen.io/AskSaikatSinha/full/xRzzqg/ semi -circular eyebrows
Jonathan Carroll
@gkcodeman
Jun 12 2017 05:05
@j0hnc @Lumexralph thanks
CamperBot
@camperbot
Jun 12 2017 05:05
gkcodeman sends brownie points to @j0hnc and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1917 | @lumexralph |http://www.freecodecamp.com/lumexralph
:cookie: 353 | @j0hnc |http://www.freecodecamp.com/j0hnc
Jonathan Carroll
@gkcodeman
Jun 12 2017 05:06
i didn't think about chaining the if / else with the switch statment like that, I was under the impression you should choose one or the other to solve your problem
ShirazPirzada
@ShirazPirzada
Jun 12 2017 05:18
Example

5 % 2 = 1 because
Math.floor(5 / 2) = 2 (Quotient)
2 * 2 = 4
5 - 4 = 1 (Remainder)
Usage
In mathematics, a number can be checked even or odd by checking the remainder of the division of the number by 2.

17 % 2 = 1 (17 is Odd)
48 % 2 = 0 (48 is Even)
Note
The remainder operator is sometimes incorrectly referred to as the "modulus" operator. It is very similar to modulus, but does not work properly with negative numbers.

Instructions
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
can someone explain
its not a code
cant understand it
Mukul Agrawal
@mukul09
Jun 12 2017 05:19
i am on the challenge DROP IT and here's my code , why its not working
function dropElements(arr, func) {
  // Drop them elements.
  for(var i=0;i<arr.length;i++)
    {
      if(func(arr[i]))
     { 
       break;
     } 
      else
         {
         arr.shift();
         }

    }
return arr;
}

dropElements([1, 2, 3], function(n) {return n < 3; });
mvroehling
@mvroehling
Jun 12 2017 05:21
@ShirazPirzada The modulo operator is divsion with rest.
John
@j0hnc
Jun 12 2017 05:22
@mukul09 try subtracting 1 from i after you shift
Mukul Agrawal
@mukul09
Jun 12 2017 05:22
@j0hnc ya its now working but how?
John
@j0hnc
Jun 12 2017 05:23
because you're skipping one if you shift it
all the elements after the one deleted get shifted to the left
[1, 2, 3] if you shift this it will be like this [2, 3] but i is now 1 so it won't check 2
Mukul Agrawal
@mukul09
Jun 12 2017 05:25
@j0hnc yes, thanks
CamperBot
@camperbot
Jun 12 2017 05:25
mukul09 sends brownie points to @j0hnc :sparkles: :thumbsup: :sparkles:
:cookie: 354 | @j0hnc |http://www.freecodecamp.com/j0hnc
Markus Kiili
@Masd925
Jun 12 2017 05:33
@mukul09 A while loop that targets the first element would be clearer.
John
@j0hnc
Jun 12 2017 05:37
you could prevent the skipping thing
prakhar01
@prakhar01
Jun 12 2017 05:44

function reverseString(str) {

return str;
}

reverseString("hello");

reverse the following string
help?
Prajwal
@prajwalcm
Jun 12 2017 05:54
Guys..
What is about palindromes challenge??
Check for Palindromes
Return true if the given string is a palindrome. Otherwise, return false.
mvroehling
@mvroehling
Jun 12 2017 05:55
What palindrome is a sequence that is read the same forward and backwards
anna for example
Prajwal
@prajwalcm
Jun 12 2017 05:56
Yeah..But getting no idea how to start with my code...
mvroehling
@mvroehling
Jun 12 2017 05:56
have you removed all the whitespace already?
Prajwal
@prajwalcm
Jun 12 2017 05:56
Ok.
Will do it first.
Thanks @mvroehling
CamperBot
@camperbot
Jun 12 2017 05:56
prajwalcm sends brownie points to @mvroehling :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @mvroehling |http://www.freecodecamp.com/mvroehling
mvroehling
@mvroehling
Jun 12 2017 05:56
and turn it to lowercase, thats what you can do to prepare your string
Daniel Forero
@dforero4
Jun 12 2017 06:12
struggling a little to start the Roman Numeral Converter algorithm... any initial advice?
mvroehling
@mvroehling
Jun 12 2017 06:16
@dforero4 Think about how you can split a number into chunks. Thousands, hundreds, tenths, and single numbers
Ctrl-Altz
@Ctrl-Altz
Jun 12 2017 06:22
question on convert c to f
Daniel Forero
@dforero4
Jun 12 2017 06:22
ill start with that! thanks @mvroehling
CamperBot
@camperbot
Jun 12 2017 06:22
dforero4 sends brownie points to @mvroehling :sparkles: :thumbsup: :sparkles:
:cookie: 288 | @mvroehling |http://www.freecodecamp.com/mvroehling
but it only returns last line how do we return all the lines?
Daniel Forero
@dforero4
Jun 12 2017 06:24
what exactly are you asking @Ctrl-Altz ?
mvroehling
@mvroehling
Jun 12 2017 06:24
@Ctrl-Altz what do you mean ?
Ctrl-Altz
@Ctrl-Altz
Jun 12 2017 06:24
look at this please = return fahrenheit;
nvm
hold on
That is the info I put it but its not return all vars
only the last one ive done
Daniel Forero
@dforero4
Jun 12 2017 06:27
this challenge should really only be one line... use mathematical operators to convert the inputted parameter value
*the Celsius to Fahrenheit formula
foxthor
@foxthor
Jun 12 2017 06:28
Hi just need some help with nesting loops, What does (arr [i][j]); do?
does it add i and j, or multiply?
Ctrl-Altz
@Ctrl-Altz
Jun 12 2017 06:28
Okay so how do i make it on one line? can i get an example
Daniel Forero
@dforero4
Jun 12 2017 06:29
here's an example @Ctrl-Altz
var newValue = (C to F formula);
its pseudocode of course
@foxthor the notation arr[i][j] is used for a 2-D array. so it's a value.
Pieter Stokkink
@forkerino
Jun 12 2017 06:30
@foxthor it just accesses the j'th element of the i'th subarray
Daniel Forero
@dforero4
Jun 12 2017 06:31
exactly
think of a matrix when using 2-D arrays
Ctrl-Altz
@Ctrl-Altz
Jun 12 2017 06:32
oh my I'm completely stumped still smh
foxthor
@foxthor
Jun 12 2017 06:32
ok thanks @forkerino @marcdavey
CamperBot
@camperbot
Jun 12 2017 06:32
foxthor sends brownie points to @forkerino and @marcdavey :sparkles: :thumbsup: :sparkles:
:cookie: 176 | @marcdavey |http://www.freecodecamp.com/marcdavey
:star2: 2567 | @forkerino |http://www.freecodecamp.com/forkerino
Daniel Forero
@dforero4
Jun 12 2017 06:32
@Ctrl-Altz ok, what is the C to F formula?
Ctrl-Altz
@Ctrl-Altz
Jun 12 2017 06:34
Yeah i dont know man sad i knw
mvroehling
@mvroehling
Jun 12 2017 06:35
@Ctrl-Altz read the instructions of the challenge carefully. Its written there
Daniel Forero
@dforero4
Jun 12 2017 06:35
very true
Ctrl-Altz
@Ctrl-Altz
Jun 12 2017 06:35
ohh shit okay 9/5 32
John
@j0hnc
Jun 12 2017 06:36
read-search-ask
intervolver
@intervolver
Jun 12 2017 06:36
Hey, I could really use a hint on this challenge https://www.freecodecamp.com/challenges/seek-and-destroy. I can separate the array and following arguments into different arrays, but I can't run a .filter(function) inside of a loop. I've tried multiple approaches. I don't want the answer, just a little hint on what direction to take would mean a lot
John
@j0hnc
Jun 12 2017 06:36
@intervolver you can
@intervolver you can use a function
@intervolver write a function outside the for loop and then use it in there
intervolver
@intervolver
Jun 12 2017 06:37
is that the right direction to go in? I was trying that for a while and getting lost
John
@j0hnc
Jun 12 2017 06:37
hint: arr = filterOut(arr, arguments[i]);
that goes in the for loop
mvroehling
@mvroehling
Jun 12 2017 06:37
@intervolver you can run a filter function of the arr
intervolver
@intervolver
Jun 12 2017 06:37
here's where I was at last:
function destroyer(arr) {
  var arr2 = arr.slice.call(arguments);
  var arr3 = arr2.slice([0],1);
  var arr4 = [];

  //return arr3[0].indexOf(arr2[1]) !== -1;

  function killShot(array){
    arr4 = array.filter(function(val){
      val = arr2[i];
    });
  }
  for (i = 0, j = 1; i < arr3.length; i++){
    if(arr3[0].indexOf(arr2[j]) !== -1){
      killShot(arr3);
    }
    else{
      j++;
    }
  }
  return arr3;
}
it doesn't work and I'm starting to think I'm really overthinking the problem
John
@j0hnc
Jun 12 2017 06:38
the filter function should return return val !== arg;
yes you are
it's more simpler than that
intervolver
@intervolver
Jun 12 2017 06:39
so use the filter function to filter the array right in the argument?
John
@j0hnc
Jun 12 2017 06:39
you don't need any of those arrays
intervolver
@intervolver
Jun 12 2017 06:39
I was worried about that...
mvroehling
@mvroehling
Jun 12 2017 06:39
your if statement looks very promising! This should be inside your filter function, that you run on the arr
u need to tweak the arguments though
intervolver
@intervolver
Jun 12 2017 06:40
alright, I'll start by trying to as much as I can in the filter function
@mvroehling @j0hnc thanks
CamperBot
@camperbot
Jun 12 2017 06:40
intervolver sends brownie points to @mvroehling and @j0hnc :sparkles: :thumbsup: :sparkles:
:cookie: 289 | @mvroehling |http://www.freecodecamp.com/mvroehling
:cookie: 358 | @j0hnc |http://www.freecodecamp.com/j0hnc
John
@j0hnc
Jun 12 2017 06:40
good luck :)
Ctrl-Altz
@Ctrl-Altz
Jun 12 2017 06:46
I get the c to f is 9/5 plus 32 but how do add it would all in one line like i got the right info obv but still dont get how it all would go in one line.
John
@j0hnc
Jun 12 2017 06:47
c * 9/5 + 32
ramamrajdev
@ramamrajdev
Jun 12 2017 06:49
#243 challenge to capitalise first letter of each word in the string... but how to short remaining letters of the string..please help...
Ctrl-Altz
@Ctrl-Altz
Jun 12 2017 06:50
i think im going to call it a night it not getting thought to me ..
John
@j0hnc
Jun 12 2017 06:50
split array of words, split each word and uppercase the first letter, join everything back
Ctrl-Altz
@Ctrl-Altz
Jun 12 2017 06:50
Thanks for the hep @j0hnc @dforero4 @mvroehling
CamperBot
@camperbot
Jun 12 2017 06:50
ctrl-altz sends brownie points to @j0hnc and @dforero4 and @mvroehling :sparkles: :thumbsup: :sparkles:
:cookie: 266 | @dforero4 |http://www.freecodecamp.com/dforero4
:cookie: 359 | @j0hnc |http://www.freecodecamp.com/j0hnc
:cookie: 290 | @mvroehling |http://www.freecodecamp.com/mvroehling
ramamrajdev
@ramamrajdev
Jun 12 2017 06:51
@j0hnc i did this but the remaining letters are also in upper case
John
@j0hnc
Jun 12 2017 06:51
arr[i][0].toUpperCase();
something like that
I can't give you everything, hard work pays off so think :)
ramamrajdev
@ramamrajdev
Jun 12 2017 06:52
i did str[i][0].charAt[0].toUpperCase();
Daniel Forero
@dforero4
Jun 12 2017 06:54
ok still a little stuck on the Roman Numeral Converter... I know you have to divide up the number in 1000s, 100s, 10s, 1s and so on, but i guess im just trying to think of the most efficient way
John
@j0hnc
Jun 12 2017 06:56
@dforero4 go in terms of 1 4 5 9 10, etc
10, 40, 50, 90, etc
mvroehling
@mvroehling
Jun 12 2017 06:58
@dforero4 most efficient way is to create a lookup table and plug numbers into it
Tai Jones
@taiJones00
Jun 12 2017 06:59
TypeError: Cannot read property 'Akira' of undefined
What does this mean
mvroehling
@mvroehling
Jun 12 2017 07:00
this means that there is no such property "Akira"
John
@j0hnc
Jun 12 2017 07:00
hint: if you want 11, find the last largest value before 11, so in this case 10, so then subtract 11-10 = 1, then find the largest one before that
@dforero4
that would give you XI
mvroehling
@mvroehling
Jun 12 2017 07:02
@taiJones00 it looks to me that you flipped property with value
Tai Jones
@taiJones00
Jun 12 2017 07:02
? What do you mean
John
@j0hnc
Jun 12 2017 07:03
paste your code to see what you're doing wrong
Tai Jones
@taiJones00
Jun 12 2017 07:04
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop)
{
// Only change code below this line
if (contacts.firstName[firstName] === true && contacts.hasOwnProperty(prop) === true)
{
return contacts[prop];
}
else if (contacts.firstName[firstName] === false)
{
return "No such contact";
}
else if (contacts.hasOwnProperty(firstName) === true|| contacts.hasOwnProperty(prop) === true)
{
return "No such property";
}

}
// Only change code above this line

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

John
@j0hnc
Jun 12 2017 07:05
ah you need to split the conditions
because what if there is a contact but it doesn't have that property?
Tai Jones
@taiJones00
Jun 12 2017 07:06
split the conditions? Make more?
John
@j0hnc
Jun 12 2017 07:06
i'll give you a hint
antas sharma
@antas0
Jun 12 2017 07:07
How can i print FirstLine
\SecondLine\
ThirdLine
John
@j0hnc
Jun 12 2017 07:07
if (contacts.firstName[firstName])
{
    if(contacts.hasOwnProperty(prop)) {
        return contacts[prop];
    } else {
        return "No such property";
    }
}
antas sharma
@antas0
Jun 12 2017 07:07
How can i print
FirstLine
\SecondLine\
ThirdLine
this in javascript?
Thanks @j0hnc but thats not what i want
CamperBot
@camperbot
Jun 12 2017 07:08
antas0 sends brownie points to @j0hnc :sparkles: :thumbsup: :sparkles:
:cookie: 360 | @j0hnc |http://www.freecodecamp.com/j0hnc
John
@j0hnc
Jun 12 2017 07:08
I'm not talking to you?
antas sharma
@antas0
Jun 12 2017 07:09
ohh
Tai Jones
@taiJones00
Jun 12 2017 07:09
oh. I think I get it. Do the same thing with no such contact
damn john
John
@j0hnc
Jun 12 2017 07:09
yeah, you get the idea now
Tai Jones
@taiJones00
Jun 12 2017 07:09
get wrk done
John
@j0hnc
Jun 12 2017 07:10
that's what I'm talking about
Adam Faraj
@adamfaraj
Jun 12 2017 07:10
can anyone help me debug this?
Daniel Forero
@dforero4
Jun 12 2017 07:10
Thanks @mvroehling and @j0hnc for you advice! i got it!
CamperBot
@camperbot
Jun 12 2017 07:10
dforero4 sends brownie points to @mvroehling and @j0hnc :sparkles: :thumbsup: :sparkles:
:warning: dforero4 already gave mvroehling points
:cookie: 361 | @j0hnc |http://www.freecodecamp.com/j0hnc
Adam Faraj
@adamfaraj
Jun 12 2017 07:10
when both password fields are blank, i don't want any message to be displayed
Tai Jones
@taiJones00
Jun 12 2017 07:10
thanks @j0hnc
CamperBot
@camperbot
Jun 12 2017 07:10
taijones00 sends brownie points to @j0hnc :sparkles: :thumbsup: :sparkles:
:cookie: 362 | @j0hnc |http://www.freecodecamp.com/j0hnc
Adam Faraj
@adamfaraj
Jun 12 2017 07:11
and if you put something in the password field and then match it in the verify field, but delete the password field, it still says password matches
??
John
@j0hnc
Jun 12 2017 07:12
you need an event listener
for the keyboard
I think
@adamfaraj if both are empty then you need a condition statement and do something that says not to display that text
Adam Faraj
@adamfaraj
Jun 12 2017 07:16
@j0hnc this is what i have
else if (password == "" && verifyPassword == "") {
    document.getElementById("verified").innherHTML = "";
  }
Tai Jones
@taiJones00
Jun 12 2017 07:16
function lookUpProfile(firstName, prop)
{
// Only change code below this line
if (contacts.firstName[firstName])
{
if(contacts.hasOwnProperty(prop))
{
return contacts[prop];
}
else
{
return "No such property";
}
if (contacts.hasOwnProperty)
{
if(contacts.firstName[firstName])
{
return contacts[prop];
}
else
{
return "No such contact";
}
}
}
}
says can't read the property agian
mvroehling
@mvroehling
Jun 12 2017 07:17
contacts.hasOwnProperty what does this mean ?
John
@j0hnc
Jun 12 2017 07:18
@adamfaraj like this
if (password !== "" && verifyPassword !== "") {
    if(password === verifyPassword) {
      document.getElementById("verified").innerHTML = "<span style='color:red'> Password does not match!</span>";
    } else {
      document.getElementById("verified").innerHTML = "Password matches!";
    }


  } else if (password == "" && verifyPassword == "") {
    document.getElementById("verified").innherHTML = "";
  } 
}
Tai Jones
@taiJones00
Jun 12 2017 07:20
if (contacts.firstName[firstName])
{
if(contacts.hasOwnProperty(prop))
{
return contacts[prop];
}
else
{
return "No such property";
}
if (contacts.hasOwnProperty)
{
if(contacts.firstName[firstName])
{
return contacts[prop];
}
else
{
return "No such contact";
}
}
}
}
Dont mind this
Adam Faraj
@adamfaraj
Jun 12 2017 07:20
@j0hnc i'm getting the same bug with that
mvroehling
@mvroehling
Jun 12 2017 07:21
@taiJones00 Still, what does if (contacts.hasOwnProperty) mean ?
@taiJones00 This is like saying: Hi name is.
You gotta tell him what to look for
John
@j0hnc
Jun 12 2017 07:24
@adamfaraj you need a keyboard event listener
@adamfaraj to check if the user deleted everything
Tai Jones
@taiJones00
Jun 12 2017 07:24
if (contacts.firstName[firstName])
{
if(contacts.hasOwnProperty(prop))
{
return contacts[prop];
}
else
{
return "No such property";
}
if (contacts.hasOwnProperty)
{
if(contacts.firstName[firstName])
{
return contacts[prop];
}
else
{
return "No such contact";
}
}
}
Now it just says undefined object
mvroehling
@mvroehling
Jun 12 2017 07:25
@taiJones00 You still have that line of invalid syntax
Dan Couper
@DanCouper
Jun 12 2017 07:26
@adamfaraj For a single field, you want to listen for keyup if the response should come as you type. In that listener you check on the value of the fields. An event on blur will also be useful to check on whether one or the other field (or both) have a value when you unfocused.
John
@j0hnc
Jun 12 2017 07:26
@taiJones00 if (contacts.hasOwnProperty(prop))
Tai Jones
@taiJones00
Jun 12 2017 07:27
Don't know what you mean by the hi thing but the other thing means. hasOwnProperty checks if an object has a property. Contacts.hasOwnProperty("likes"); with a property of likes existing in the objects of contacts would return true
Adam Faraj
@adamfaraj
Jun 12 2017 07:27
@DanCouper so instead of oninput(), i should have onkeyup()?
mvroehling
@mvroehling
Jun 12 2017 07:29
@taiJones00 Yeah that is correct. But check your code. Read carefully. You write if (contacts.hasOwnProperty), which is invalid syntax. hasOwnProperty requires an argument
Tai Jones
@taiJones00
Jun 12 2017 07:29
prop is a variable to a function I assume. If the value entered for prop by the user is in the object of contacts then if (contacts.hasOwnProperty(prop)) equals true
John
@j0hnc
Jun 12 2017 07:29
@adamfaraj https://api.jquery.com/keypress/ check this out
Tai Jones
@taiJones00
Jun 12 2017 07:29
Oh
My bad
Adam Faraj
@adamfaraj
Jun 12 2017 07:30
@j0hnc trying to use vanilla JS, no jQuery, but i appreciate it
mvroehling
@mvroehling
Jun 12 2017 07:30
@taiJones00 errors like that can be nasty sometimes
Tarun Garhwal
@eoo
Jun 12 2017 07:30
this is my code for caesars cypher :

function rot13(str) { // LBH QVQ VG!
  answer = '';

  for(var i = 0; i < str.length; i++){
    answer += String.fromCharCode(str.charCodeAt(i) - 13);
  }

  return answer;
}
CamperBot
@camperbot
Jun 12 2017 07:30
:bulb: to format code use backticks! ``` more info
Tai Jones
@taiJones00
Jun 12 2017 07:30
There's still a problem. TypeError: undefined is not an object (evaluating 'contacts.firstName[firstName]')
John
@j0hnc
Jun 12 2017 07:30
@adamfaraj then use oninput
Adam Faraj
@adamfaraj
Jun 12 2017 07:31
@j0hnc it was
Dan Couper
@DanCouper
Jun 12 2017 07:31
If you want a response as a user types, yes, it's more accurate. Listening to input is fine though. You really have to listen for more than one event, you can't really just listen for input, because of the fact you have two fields: the range of states they can be in at any one time is quite large, it's easier if you listen for a few events.
Pieter Stokkink
@forkerino
Jun 12 2017 07:31
@taiJones00 contacts is an array, you need to access the individual contact by index first and then do .hasOwnProperty or .firstName
Tai Jones
@taiJones00
Jun 12 2017 07:32
Contacts is an object
Pieter Stokkink
@forkerino
Jun 12 2017 07:32
@eoo There are 2 things you need to incorporate in your code. If the character isn't a letter, you should just pass it on. If it is in the first half of the alphabet, you should add 13 instead of subtract 13.
Tarun Garhwal
@eoo
Jun 12 2017 07:32
the problem i cant figure out it how to loop back to Z if the ascii code after subtracting 13 goes out of range for A-Z
Pieter Stokkink
@forkerino
Jun 12 2017 07:32
@taiJones00 arrays are objects, so technically you are right.
@eoo Put an if else block inside your loop and check the character
Adam Faraj
@adamfaraj
Jun 12 2017 07:33
@DanCouper ahhh, you're right. adding the onkeyup function on my password as well helped with one of the bugs
Tarun Garhwal
@eoo
Jun 12 2017 07:33
whoa thats pretty straightforward
Adam Faraj
@adamfaraj
Jun 12 2017 07:33
@DanCouper so can you help me figure out how to make my message disappear if both fields are empty?
Pieter Stokkink
@forkerino
Jun 12 2017 07:33
@taiJones00 you need to loop through contacts before doing any of the checks you do.
Tarun Garhwal
@eoo
Jun 12 2017 07:33
brb lemme try
Tai Jones
@taiJones00
Jun 12 2017 07:34
So should I put the code I have inside a loop?
Is the code so far good
mvroehling
@mvroehling
Jun 12 2017 07:34
@taiJones00 yes, you want to be able to identify every object inside your array.
@taiJones00 for example how would you refer to the third entry of your contacts?
Ashan Mohammed
@AshanMohammed
Jun 12 2017 07:35
Hello,
Does anyone know how to use skycons? An icon pack provided by darksky
John
@j0hnc
Jun 12 2017 07:35
nvm I remember solving that, you're right
Tai Jones
@taiJones00
Jun 12 2017 07:35
Contacts[2]
John
@j0hnc
Jun 12 2017 07:36
I used 3 lines of code to solve it
rp98
@rp98
Jun 12 2017 07:38

function palindrome(str) {
str=str.toLowerCase();
var arr=[];
var re=/[^a-z0-9]/gi;
str=str.replace(re," ");
for(var i=0;i<str.length;i++){
arr[i]=str[i];
}

for(var j=0;j<Math.floor((arr.length)/2);j++){
if(arr[j]!=arr[arr.length-1-j]&&arr[j]!=" ")
break;
else
continue;

}
if(j==(Math.floor((arr.length)/2))-1)
return true;
else
return false;
}
Hey! I am not able to figure out what is wrong with this code. Could someone help please?

Pieter Stokkink
@forkerino
Jun 12 2017 07:39
@taiJones00 you will need some indexes inside your loop to access the current contact you are examining. The code will still need some work, but it is a lot easier to troubleshoot once you have your loop in place.
Prashanth Vaidya
@thecodearrow
Jun 12 2017 07:39

This is for TITLECASE PROBLEM. I solved it eventually, so not looking for a solution, but I want to know why this does not work.
Can anyone let me know?

'''

function titleCase(str) {
str=str.toLowerCase();
var strArr=str.split(' ');
for(var i=0;i<strArr.length;i++){

strArr[i][0]=strArr[i][0].toUpperCase();
}
str=strArr.join(' ');

return str;
}

'''

CamperBot
@camperbot
Jun 12 2017 07:39
:bulb: to format code use backticks! ``` more info
Pieter Stokkink
@forkerino
Jun 12 2017 07:39
@rp98 the first mistake I see is that you replace things with a space. Use an empty string instead.
Prashanth Vaidya
@thecodearrow
Jun 12 2017 07:40

Sorry,

```

function titleCase(str) {
str=str.toLowerCase();
var strArr=str.split(' ');
for(var i=0;i<strArr.length;i++){

strArr[i][0]=strArr[i][0].toUpperCase();
}
str=strArr.join(' ');

return str;
}

John
@j0hnc
Jun 12 2017 07:40
@thecodearrow think you might have to split each word too
Pieter Stokkink
@forkerino
Jun 12 2017 07:40
@thecodearrow strings are immutable, so you cannot overwrite a single letter
mvroehling
@mvroehling
Jun 12 2017 07:41
@thecodearrow strArr[i][0] is read only if I'm correct. Anyone else who knows better?
Pieter Stokkink
@forkerino
Jun 12 2017 07:41
@mvroehling correct
Tai Jones
@taiJones00
Jun 12 2017 07:43
for (i = 0; i < contacts.length; i++)
{
if (contacts[i].firstName[firstName])
{
if(contacts[i].hasOwnProperty(prop))
{
return contacts[i][prop];
}
else
{
return "No such property";
}
if (contacts[i].hasOwnProperty(prop))
{
if(contacts[i].firstName[firstName])
{
return contacts[i][prop];
}
else
{
return "No such contact";
}
}
}
}
Okay I have the loop
Prashanth Vaidya
@thecodearrow
Jun 12 2017 07:43
Okay! So since Javascript strings are immutable, only way to change them is by using appropriate methods. Am I correct?
Pieter Stokkink
@forkerino
Jun 12 2017 07:44
@thecodearrow You can also overwrite them completely (which is easiest in this case)
You can use the index to access the letters
@taiJones00 Ok, the first mistake I see is the condition of the first if. You need to compare contacts[i].firstName to the firstName variable to see if the names match.
Prashanth Vaidya
@thecodearrow
Jun 12 2017 07:45
Thanks a lot @forkerino
CamperBot
@camperbot
Jun 12 2017 07:45
thecodearrow sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2568 | @forkerino |http://www.freecodecamp.com/forkerino
Andrea Mammoliti
@AndreusSH
Jun 12 2017 07:46
Can anyone help me with this assignment please?

When you are defining a string you must start and end with a single or double quote. What happens when you need a literal quote: " or ' inside of your string?

In JavaScript, you can escape a quote from considering it as an end of string quote by placing a backslash () in front of the quote.

var sampleStr = "Alan said, \"Peter is learning JavaScript\".";

This signals to JavaScript that the following quote is not the end of the string, but should instead appear inside the string. So if you were to print this to the console, you would get:

Alan said, "Peter is learning JavaScript".
Instructions

Use backslashes to assign a string to the myStr variable so that if you were to print it to the console, you would see:

I am a "double quoted" string inside "double quotes".

I don't understand how to write that
Anshul Adlakha
@anshuladlakha
Jun 12 2017 07:47

function steamrollArray(arr) {
  var reg = /[,]/g;
  var regNum = /^\d+$/;
  var regAlph = /[a-z]|[A-Z]/;
  var finalArr=[];
  var stringArr =  arr.toString();
  stringArr = stringArr.replace(reg , "");   
  var splitStr = stringArr.split("");
  for(i=0;i<splitStr.length;i++){
    if(regNum.test(splitStr[i])){
      finalArr.push(Number(splitStr[i]));
    }
    else if(regAlph.test(splitStr[i])){
      finalArr.push(splitStr[i]);
    }


  }
 return finalArr;

}

steamrollArray([1, {}, [3, [[4]]]]);
Can anyone help me , i am really close to solving this challenge.
just need a way to convert the 'object' to {}.
Tai Jones
@taiJones00
Jun 12 2017 07:48
if (contacts[i].firstName[firstName] == contacts[i].firstName) @forkerino Right?
if the value = the property
Tarun Garhwal
@eoo
Jun 12 2017 07:48
@forkerino here
Pieter Stokkink
@forkerino
Jun 12 2017 07:48
@AndreusSH it is pretty much like the example:
var sampleStr = "Alan said, \"Peter is learning JavaScript\".";
In your case, you also need to escape the "s like so : \". Just copy paste the string they want to your code and add backslashes where needed.
Tarun Garhwal
@eoo
Jun 12 2017 07:48

function rot13(str) { // LBH QVQ VG!
  answer = '';

  var charCode, newCharCode;
  for(var i = 0; i < str.length; i++){
    charCode = str.charCodeAt(i);

    if(charCode < 'N'.charCodeAt(0)){

      answer += String.fromCharCode(charCode + 13);
    }
    else {
      answer += String.fromCharCode(newCharCode - 13);
    }
  }
  return answer;
}
Pieter Stokkink
@forkerino
Jun 12 2017 07:49
@taiJones00 no, it is much simpler. contacts[i].firstName === firstName
Tarun Garhwal
@eoo
Jun 12 2017 07:49
the else statement doesnt seem to work
Tai Jones
@taiJones00
Jun 12 2017 07:49
if (contacts[i].firstName[firstName] == firstName)
Aha got it!
Tarun Garhwal
@eoo
Jun 12 2017 07:49
the if block runs fine
ooh oj
ok
nvm
rp98
@rp98
Jun 12 2017 07:50
@forkerino But even then I guess, that shouldn't really cause any problems because later on, I fixed the comparisons taking into considerations the spaces. I am sorry, but is there something I'm missing? Could you please explain a bit there?
Pieter Stokkink
@forkerino
Jun 12 2017 07:50
@anshuladlakha that's an interesting approach. Haven't seen that one before.
@rp98 the spaces might not be symmetrical
so if you have a_bc_ba it would become a bc ba
which wouldn't pass the test, but is a palindrome according to the spec
Anshul Adlakha
@anshuladlakha
Jun 12 2017 07:51
@forkerino Yeah i'm kind of surprised i came up with it :smile:
But it is giving me problems when i try to satisfy the last condition.
Tai Jones
@taiJones00
Jun 12 2017 07:51
if (contacts[i].firstName[firstName] == firstName)
{
if (contacts[i].hasOwnProperty(prop) == prop)
{
return contacts[i][prop];
}
else
{
return "No such property";
}
okay I ran it
but it won't work
Pieter Stokkink
@forkerino
Jun 12 2017 07:52
@anshuladlakha yeah, I can imagine. It is not the easiest solution (the Array.isArray method is much more elegant). You could probably test of your string is 'object' somewhere...
Markus Kiili
@Masd925
Jun 12 2017 07:52
@taiJones00 ["firstName"] <- quotes
Pieter Stokkink
@forkerino
Jun 12 2017 07:52
@taiJones00 I don't understand .firstName[firstName].... why twice? The firstName property doesn't have a property itself, it is a string.
Markus Kiili
@Masd925
Jun 12 2017 07:53
Just if (contacts[i].hasOwnProperty(prop)){...}
Ogundele Olumide
@Lumexralph
Jun 12 2017 07:53
@forkerino @Masd925 Good Morning
Anshul Adlakha
@anshuladlakha
Jun 12 2017 07:53
@forkerino I tried using String.replace and it works but i cant replace it with the objects symbol. is there a way around that?
Markus Kiili
@Masd925
Jun 12 2017 07:53
and if (contacts[i].firstName === firstName)
@Lumexralph @forkerino Morning.
Tai Jones
@taiJones00
Jun 12 2017 07:54
I thought I was checking the value of the
nevermind im stupid
Pieter Stokkink
@forkerino
Jun 12 2017 07:54
@anshuladlakha yeah, don't use replace. Instead, do a test before pushing to the final array and push {} if needed.
@Lumexralph @Masd925 :wave:
Markus Kiili
@Masd925
Jun 12 2017 07:54
@taiJones00 Nobody is stupid here. You only have thick skull. :elephant:
Anshul Adlakha
@anshuladlakha
Jun 12 2017 07:54
@forkerino ok i will try
Tai Jones
@taiJones00
Jun 12 2017 07:55
just like elephant
if (contacts[i].hasOwnProperty(prop))
{
if(contacts[i].firstName == firstName)
{
return contacts[i][prop];
}
else
{
return "No such contact";
}
}
Okay why doesn't this return no such contact
John
@j0hnc
Jun 12 2017 07:57
it's backwards
Dan Couper
@DanCouper
Jun 12 2017 07:58

@adamfaraj you need to check the value of both fields in the callback function every time - if the value for both is "", then you can get rid of the message. keyup will pick up the backspace key being hit, so that should work. It will help if you have a common class for the password fields, so you can just check the value of both of them at the same time.

Also, don't use inline listeners, use addEventListener in the JS - same thing you're doing now, but all in the JS, not the HTML. Cache your selectors as well - at the top of the JS have like var password = document.getElementById('password');, rather than writing all that out in the functions every time.

Ken Haduch
@khaduch
Jun 12 2017 07:58
Good morning everyone- how are you all this Monday morning?
John
@j0hnc
Jun 12 2017 07:58
you first have to see if something exists before asking if it has something in it
night here
Chris Juchtmans
@kjuchtmans
Jun 12 2017 07:58
good morning coders! :wave:
Ken Haduch
@khaduch
Jun 12 2017 07:59
Actually 4am here, so it's technically night for me. Just up helping my mom...
John
@j0hnc
Jun 12 2017 07:59
oh wow
that's super early
Chris Juchtmans
@kjuchtmans
Jun 12 2017 08:00
@khaduch good lad.
Ken Haduch
@khaduch
Jun 12 2017 08:00
@kjuchtmans - good morning
Tai Jones
@taiJones00
Jun 12 2017 08:00
wait what
John
@j0hnc
Jun 12 2017 08:00
i can't function at these times
Michiel
@MichielHuijse
Jun 12 2017 08:00
Hi while wrking in codepen I acciddentally removed my javascript and saved it. Now it is all gone is there a way to go back? Also I pasted here in gitter does gitter make a backup of the message you send? Lastly to prevent this what is the best toolset to prevent this from happening in the future, I am thinking about doing everything local from now on.
John
@j0hnc
Jun 12 2017 08:00
@taiJones00 if you're trying to see if a box has a ball in it the box has to exist before checking if the ball is in there
Andrea Mammoliti
@AndreusSH
Jun 12 2017 08:01
@forkerino thanks a lot
CamperBot
@camperbot
Jun 12 2017 08:01
andreussh sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2569 | @forkerino |http://www.freecodecamp.com/forkerino
Chris Juchtmans
@kjuchtmans
Jun 12 2017 08:02
@MichielHuijse I used to have the same issue. so now i code locally (using Notepad++) and copy/paste regularly into codepen for testing + backup
Ken Haduch
@khaduch
Jun 12 2017 08:02
@MichielHuijse - if you pasted here it should be available. Look for the search option on the left and put your name in there. Doesn't show up chronologically or anything but you should see your posts
Chris Juchtmans
@kjuchtmans
Jun 12 2017 08:03

Who can tell me why my button click is not properly toggling between Fahrenheit & Celcius?

Code:

//CONVERTING FAHRENHEIT TO CELCIUS, VICE VERSA
    var temp = json.currently.temperature;
    var currentUnit = $("#temp-type-text").text();
    var conversion = 0;

    function fahrToCelc(temp) {
        conversion = (temp - 32) * 1.8;
        return conversion;
        }

    function celcToFahr(temp) {
        conversion = (temp * 1.8) + 32;
        return conversion;
        }

    if (currentUnit === Celcius) {    
        $("#convertButton").on(click, fahrToCelc);
        //using named function 'fahrToCelc' => function parameters are sent by default
        $("#temp").html(conversion);
        $("#temp-unit").html("&deg;F");
        $("#temp-type-text").text("Fahrenheit");
    } 

    else if (currentUnit === Fahrenheit) {
        $("#convertButton").on(click, celcToFahr);
        //using named function 'celcToFahr' => function parameters are sent by default
        $("#temp").html(conversion);
        $("#temp-unit").html("&deg;C");
        $("#temp-type-text").text("Celcius");
    }

Thanks!

John
@j0hnc
Jun 12 2017 08:03
should be "click" I think
Tai Jones
@taiJones00
Jun 12 2017 08:04
well there's no such contact and no such property
for (i = 0; i < contacts.length; i++)
{
if (contacts[i].firstName == firstName)
{
if (contacts[i].hasOwnProperty(prop))
{
return contacts[i][prop];
}
else
{
return "No such property";
}
if (contacts[i].hasOwnProperty(prop))
{
if(contacts[i].firstName == firstName)
{
return contacts[i][prop];
}
else
{
return "No such contact";
}
}
}
}
No such property works but nosuchcontact doesn't
Michiel
@MichielHuijse
Jun 12 2017 08:04
@kjuchtmans and @khaduch thanks, helpfull tips!
CamperBot
@camperbot
Jun 12 2017 08:04
michielhuijse sends brownie points to @kjuchtmans and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2974 | @khaduch |http://www.freecodecamp.com/khaduch
:cookie: 264 | @kjuchtmans |http://www.freecodecamp.com/kjuchtmans
Tai Jones
@taiJones00
Jun 12 2017 08:04
I figured flipping the no such property would get the contact version to work
Chris Juchtmans
@kjuchtmans
Jun 12 2017 08:04
@j0hnc Oops! good eyesight, sir
Dan Couper
@DanCouper
Jun 12 2017 08:04
@MichielHuijse 1. No on codepen, supposed to be throwaway. 2. Yes, you can use search, but it might take a day or so to be searchable. 3. Git is designed for this.
Michiel
@MichielHuijse
Jun 12 2017 08:05
@DanCouper Thanks
CamperBot
@camperbot
Jun 12 2017 08:05
michielhuijse sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 760 | @dancouper |http://www.freecodecamp.com/dancouper
John
@j0hnc
Jun 12 2017 08:05
@kjuchtmans the logic of the toggle should be in the function or in the event too
checking if (currentUnit === Celcius) in the click event
Ogundele Olumide
@Lumexralph
Jun 12 2017 08:06
@khaduch Good Morning
Chris Juchtmans
@kjuchtmans
Jun 12 2017 08:06
@j0hnc like, I can't declare functions first, and run the if statements below that?
makes sense, will give it a shot
John
@j0hnc
Jun 12 2017 08:07
you're gonna click the button more than once, won't you
Chris Juchtmans
@kjuchtmans
Jun 12 2017 08:07
@j0hnc that's correct
Ken Haduch
@khaduch
Jun 12 2017 08:08
@Lumexralph - hey there, good morning...
Ogundele Olumide
@Lumexralph
Jun 12 2017 08:10
@khaduch how're you doing?
Chris Juchtmans
@kjuchtmans
Jun 12 2017 08:10
So logically, I would rather:
  1. state the click event
  2. declare the functions inside 1.
  3. place the if statements + append to html inside 2.
    Does that seem reasonable ?
Tai Jones
@taiJones00
Jun 12 2017 08:11
The code looks fine to me. What's wrong @j0hnc
John
@j0hnc
Jun 12 2017 08:12
@kjuchtmans i would do it differently
Chris Juchtmans
@kjuchtmans
Jun 12 2017 08:12
@j0hnc go on
John
@j0hnc
Jun 12 2017 08:12
declare the function outside
you would call it like this
convert(valueFahrenheit, "celsius");
or simpler
$("#change-scale").click(function() {
        if(scale === "fahrenheit") {
            temperature = Math.round(((temperature - 32) * 5/9));
            $("#temperature").text(temperature).append(" " + c);
            scale = "celsius";
        } else {
            temperature = Math.round(temperature * 9/5 + 32);
            $("#temperature").text(temperature).append(" " + f);
            scale = "fahrenheit"; 
        }        
 });
something like that
Pieter Stokkink
@forkerino
Jun 12 2017 08:15
@taiJones00 the return for "No such contact" should not be inside the loop. If you are inside the loop, it means you haven't looked at all contacts yet
Chris Juchtmans
@kjuchtmans
Jun 12 2017 08:16
@j0hnc thank you, let me take a good look at that
CamperBot
@camperbot
Jun 12 2017 08:16
kjuchtmans sends brownie points to @j0hnc :sparkles: :thumbsup: :sparkles:
:cookie: 363 | @j0hnc |http://www.freecodecamp.com/j0hnc
Ken Haduch
@khaduch
Jun 12 2017 08:16
@MichielHuijse - I just put a search in for your name with @MichielHuijse and found the post that I made just a couple minutes ago. The search only searches the current room - and the ordering is definitely not chronological! There is also a way to get the archive of the entire room - I forget how to do that, though.
I second the comment about using a local editor such as Notepad++ - I keep a running file with information, links, questions and answers... Also, github is a place to save code, as was mentioned. In fact, in the lower right corner of the CodePen interface, there is a way to save a pen as a gist in github. Or you can go directly to github and create a"gist" and paste your code into it. Lots of ways to preserve your work. Also - sometimes people have used CodePen in a way that gets them confused, saving a project a few times under different names - see if you can find it in the list of Pens on your account and maybe it's there under another name...
Pieter Stokkink
@forkerino
Jun 12 2017 08:17
@khaduch @MichielHuijse You can access the archives through the settings in the top right.
Ken Haduch
@khaduch
Jun 12 2017 08:18
@Lumexralph - i'm doing okay... visiting / helping my elderly mom and just trying to stay patient... getting a little coding / helping time in because I know i'll not be able to relax for very long. :)
@forkerino - thanks, I forget where you get that. Yes, I see it in the little control panel icon in the top navbar.. thanks for the reminder!
CamperBot
@camperbot
Jun 12 2017 08:19
khaduch sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2570 | @forkerino |http://www.freecodecamp.com/forkerino
Ken Haduch
@khaduch
Jun 12 2017 08:22
the current archive for this room is only going up to june 5th, so that's a little bit behind the times...
Pieter Stokkink
@forkerino
Jun 12 2017 08:23
@MichielHuijse It might be a good idea to start using an editor that integrates with git automatically, like VS code, Atom (not sure?), Sublime has a plugin for it. So you just click a button and provide a message and it automatically commits it to a local repo.
Pieter Stokkink
@forkerino
Jun 12 2017 08:27
@codeyhere what did you try?
Aman
@codeyhere
Jun 12 2017 08:28
looking up player 16
bayin
@innermogo
Jun 12 2017 08:29
hello
I need help
Pieter Stokkink
@forkerino
Jun 12 2017 08:29
@codeyhere you have to put a number in the first variable and use that variable in the brackets for the second variable
bayin
@innermogo
Jun 12 2017 08:29
http://www.freecodecamp.cn/challenges/word-blanks#?solution=function wordBlanks(myNoun%2C myAdjective%2C myVerb%2C myAdverb) {%0A var result %3D ""%3B%0A %2F%2F Your code below this line%0A wordBlanks("little cat hit slowly")%0A %2F%2F Your code above this line%0A return result%3B%0A}%0A%0A%2F%2F Change the words here to test your function%0AwordBlanks("dog"%2C "big"%2C "ran"%2C "quickly")%3B%0A
this link I can not do it
Aman
@codeyhere
Jun 12 2017 08:30
Thank you, passed! @forkerino
CamperBot
@camperbot
Jun 12 2017 08:30
codeyhere sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2571 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jun 12 2017 08:30
@innermogo you can copy paste your code here, that link doesn't work for me
Dan Couper
@DanCouper
Jun 12 2017 08:31
@forkerino yeah, Atom now has the best Git integration, github added it in at core level last month I think
Dan Couper
@DanCouper
Jun 12 2017 08:31
Tis their editor, so surprised it didn't come sooner
Aman
@codeyhere
Jun 12 2017 08:31
@DanCouper agree. Atom = love
bayin
@innermogo
Jun 12 2017 08:31
Word Blanks this capture I can not do it
Pieter Stokkink
@forkerino
Jun 12 2017 08:32
@DanCouper I have been using VS Code for a month now and I really like it, also the git integration is a breeze as far as I'm concerned. So both are quite easy to learn (provide you know a bit about git, obviously).
bayin
@innermogo
Jun 12 2017 08:32

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

// Your code above this line
return result;
}

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

@forkerino help me
Pieter Stokkink
@forkerino
Jun 12 2017 08:33
@innermogo you have to use the function parameters (myNoun, and the other three) to compose a sentence. Use + to concatenate them together and add spaces in between and maybe some extra words to make it a functioning sentence.
bayin
@innermogo
Jun 12 2017 08:33
@forkerino thank you
CamperBot
@camperbot
Jun 12 2017 08:33
innermogo sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2572 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jun 12 2017 08:33
Store the result in result
Akash Kandpal
@harrypotter0
Jun 12 2017 08:33
@forkerino How to go about this ?
@forkerino Can you provide me some hint ?
Michiel
@MichielHuijse
Jun 12 2017 08:34
@forkerino I spit through the archive, its there unluckily, it are all links to my codepen, no hardcoded posts... However, I am going for local setup and git. A good practice anyway.
Pieter Stokkink
@forkerino
Jun 12 2017 08:34
@harrypotter0 first make an object called lookup with key value pairs. Then assign the right value to the result variable
Akash Kandpal
@harrypotter0
Jun 12 2017 08:35
what about "val " ?
Pieter Stokkink
@forkerino
Jun 12 2017 08:35
@MichielHuijse aww. Losing code sucks. Chalk it up as a learning experience.
@harrypotter0 that is what you use to access the right value
use bracket notation
Akash Kandpal
@harrypotter0
Jun 12 2017 08:36
@forkerino okk like this : lookup[val]; ?
Pieter Stokkink
@forkerino
Jun 12 2017 08:36
@harrypotter0 exactly
Akash Kandpal
@harrypotter0
Jun 12 2017 08:37
@forkerino thanks man got it !!
CamperBot
@camperbot
Jun 12 2017 08:37
harrypotter0 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2573 | @forkerino |http://www.freecodecamp.com/forkerino
Ogundele Olumide
@Lumexralph
Jun 12 2017 08:39
@forkerino you can say that again...
Samuel Way
@SWbottier
Jun 12 2017 08:44
Hi, is it true I shouldn't use functions in a loop?

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

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

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

// Change this value to test
phoneticLookup("charlie");
doesnt work
Leya
@leyaabebe
Jun 12 2017 08:46
@codeyhere you forgot to set result equal to val
Pieter Stokkink
@forkerino
Jun 12 2017 08:46
@Lumexralph say what?
sorry I think I missed it
myself
Aman
@codeyhere
Jun 12 2017 08:46
@leyaabebe var result = val; ?
Pieter Stokkink
@forkerino
Jun 12 2017 08:47
@SWbottier better not declare them inside. Using them is of course not a problem
Thomas
@sjurs1
Jun 12 2017 08:47
Anyone have any tips or nudges in the right direction for the Smallest common multiplier challenge (https://www.freecodecamp.com/challenges/smallest-common-multiple)? I've sorted and expanded the arrays, but I just can't seem to wrap my head around the method to use
Leya
@leyaabebe
Jun 12 2017 08:47
@codeyhere not there. result is already defined as an empty string. After lookup you should just set result equal to val and that’ll have it update
Chris Juchtmans
@kjuchtmans
Jun 12 2017 08:47

@j0hnc Should you still have time for this, I adapted your proposed solution into this code :

    temperature = json.currently.temperature;

    $("#change-scale").click(function() {

        if(scale === "Fahrenheit") {
            temperature = Math.round(((temperature - 32) * 5/9));
            $("#temperature").text(temperature);
            $("#temp-unit").append("&deg; C");//DEBUG: check !
            scale = "Celsius";
        } else {
            temperature = Math.round(temperature * 9/5 + 32);
            $("#temperature").text(temperature);
            $("#temp-unit").append("&deg; F");
            scqle = "Fahrenheit";
        }        
    });

Why is the toggle not working on click?

Full pen is here: (https://codepen.io/chrisjuchtmans/pen/OmexWB)
Cheers! k

Samuel Way
@SWbottier
Jun 12 2017 08:47
thanks
Leya
@leyaabebe
Jun 12 2017 08:48
@codeyhere result = val;
Pieter Stokkink
@forkerino
Jun 12 2017 08:49
@sjurs1 One idea is to use a .reduce and take them two at a time, it makes the rest of the code not too difficult, because you only need to find the SCM of two numbers, not of a whole range at once. Another is to use a loop to go through multiples of the biggest number and check each number in the range if it is evenly divisible, if not, go to next loop if so, return the result.
@kjuchtmans you have a scqle in your code
Leya
@leyaabebe
Jun 12 2017 08:50
@codeyhere my bad! I wrote that wrong. You have to call on lookup. It would look like result =lookup(val);
Aman
@codeyhere
Jun 12 2017 08:50
@leyaabebe outside of function?
Pieter Stokkink
@forkerino
Jun 12 2017 08:51
@leyaabebe close but not entirely correct. lookup is not a function!
Leya
@leyaabebe
Jun 12 2017 08:51
@forkerino right! result = lookup[val].
@codeyhere and it would be inside the function after lookup is defined
Aman
@codeyhere
Jun 12 2017 08:52
ah thanks! @leyaabebe @forkerino
CamperBot
@camperbot
Jun 12 2017 08:52
codeyhere sends brownie points to @leyaabebe and @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 217 | @leyaabebe |http://www.freecodecamp.com/leyaabebe
:warning: codeyhere already gave forkerino points
Leya
@leyaabebe
Jun 12 2017 08:52
no prob! @codeyhere and thanks @forkerino
CamperBot
@camperbot
Jun 12 2017 08:52
leyaabebe sends brownie points to @codeyhere and @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 209 | @codeyhere |http://www.freecodecamp.com/codeyhere
:star2: 2574 | @forkerino |http://www.freecodecamp.com/forkerino
Dan Couper
@DanCouper
Jun 12 2017 08:52
@kjuchtmans don't have a lot of time to check over this carefully, but it looks like scale is undefined to start off with; you never initialise it. And typo in the else: scqle = Fahrenheit
ozimanik
@ozimanik
Jun 12 2017 08:53
can someone help me im searching for a solution of my code since 3 days and cant find it...