These are chat archives for FreeCodeCamp/HelpJavaScript

7th
Mar 2017
Prakash Shiwakoti
@pshiwakoti1
Mar 07 2017 00:00
i dont need brace for 1 statement
Jason Luboff
@JLuboff
Mar 07 2017 00:00
@HeebieGeeBee audio works like a champ :+1:
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:00
@JLuboff nice site for free computer game sounds, and they host them too so easy to use the links without signing up and shit
eyesore-
@eyesore-
Mar 07 2017 00:00
@pshiwakoti1 You should also check out .slice for making copies or using the spread operator.
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:00
Jason Luboff
@JLuboff
Mar 07 2017 00:01
@HeebieGeeBee Cool, I'll check it. I'm just using the provided FCC ones for now
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:01
ok cool
@be1mont you need compare par to the strokes
Jason Luboff
@JLuboff
Mar 07 2017 00:03
@HeebieGeeBee Got my computer move working fairly well. Haven't implemented player moves yet but I don't think that part will be too bad
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:03
@JLuboff cool nice one
David Whang
@whangsajang
Mar 07 2017 00:05
OMG I DID IT
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:05
@mike93og93 .filter is pretty easy to understand really you just need to pass in a fucntion in the callback that returns a boolean response
@whangsajang well done
David Whang
@whangsajang
Mar 07 2017 00:05
my code works however I would love to know if there is a better way

function palindrome(str) {
  // Good luck!
  var x =/[^0-9a-zA-Z]/g;
  var lowerCase = str.toLowerCase().replace(x, '');
  var reverseString = str.split('').reverse().join('').toLowerCase().replace(x,'');
  console.log(lowerCase);
  console.log(reverseString);
  if (lowerCase === reverseString){
    return true;
  }else{
    return false;
  }
  return true;
}



palindrome("_eye");
c0d0er2
@c0d0er2
Mar 07 2017 00:06
@JLuboff Thanks for the suggestion
CamperBot
@camperbot
Mar 07 2017 00:06
c0d0er2 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1046 | @jluboff |http://www.freecodecamp.com/jluboff
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:06
@whangsajang you could put it all in one line if you want
Jason Luboff
@JLuboff
Mar 07 2017 00:07

@whangsajang

function palindrome(str) {
  var x =/[^0-9a-zA-Z]/g;
  var lowerCase = str.toLowerCase().replace(x, '');
  var reverseString = lowerCase.split('').reverse().join('');
  return lowerCase === reverseString;
}

A little shorter version

John Nunns
@johnnunns
Mar 07 2017 00:08
having a mental block here

function destroyer(arr) {
  // Remove all the values
 var value = Object.values(arguments);
 var splice = value.splice(1,value.length);
  return arguments[0].filter(function(elem){
    return elem!==splice[1];
  });

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
created a separate array that contains the other arguments separate to the array
David Whang
@whangsajang
Mar 07 2017 00:08
@JLuboff thanks makes sense instead of repeating myself
CamperBot
@camperbot
Mar 07 2017 00:08
whangsajang sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1047 | @jluboff |http://www.freecodecamp.com/jluboff
John Nunns
@johnnunns
Mar 07 2017 00:08
trying to figure out how to filter out the numbers in the spllice array
is this an easy fix or do I need to restart?
Mac
@itchick85
Mar 07 2017 00:11
He guys whats wrong with this?var myStr = "I am a double quoted string" /"inside of/ double quotes";
Escaping Literal Quotes in Strings
Jason Luboff
@JLuboff
Mar 07 2017 00:12
@itchick85 Your quotes and escapes aren't in the right spot. Everytime you have a quote (except for the opening and closing "), you need to have a \ before it
Michael Onyeri
@omichael003
Mar 07 2017 00:12
Hi all.
John Nunns
@johnnunns
Mar 07 2017 00:13
@itchick85 make sure to use the slash button above your enter key -> \, not /
Michael Onyeri
@omichael003
Mar 07 2017 00:14

I have try different code but still can,t pass the codefunction convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var fahrenheit=( 9/5 + 32)

var fahrenheit=((-30 * 9) /5) + 32;

var fahrenheit=( 0 9 /5) + 32
var fahrenheit=( 20
9/5 + 32)
var fahrenheit=( 30 * 9/5 + 32)
// Only change code above this line
return fahrenheit;
}

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

Jason Luboff
@JLuboff
Mar 07 2017 00:14
@omichael003 You should not be hardcoding answer like that. Instead, you need to use the parameter celsius in your equation
John Nunns
@johnnunns
Mar 07 2017 00:14
'''
CamperBot
@camperbot
Mar 07 2017 00:14
:bulb: to format code use backticks! ``` more info
John Nunns
@johnnunns
Mar 07 2017 00:14
@omichael003
click that link as well to make this
Michael Onyeri
@omichael003
Mar 07 2017 00:16
@john nunns I can't see the link
Devman
@devancadman
Mar 07 2017 00:18
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
Bit confussed about this. Looking for answer please??
Michael Onyeri
@omichael003
Mar 07 2017 00:18
@JLuboff can you give me an example of what you taking about
David Whang
@whangsajang
Mar 07 2017 00:19
I cheated but it works someone tell me a better way to do this
Jason Luboff
@JLuboff
Mar 07 2017 00:19
@omichael003 myTemp = myTempToConvert * 9/5 + 32 where myTempToConvert is my parameter from my function..
eyesore-
@eyesore-
Mar 07 2017 00:19
@devancadman What do you have so far?
Devman
@devancadman
Mar 07 2017 00:19
11 % 3 = 2;
Peter Segura
@be1mont
Mar 07 2017 00:19
ok ok we made it pass the gold code
golf*
but what did i screw up here now

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

}

Jason Luboff
@JLuboff
Mar 07 2017 00:20
@be1mont You should assign the value to your variable answer not use console.log
eyesore-
@eyesore-
Mar 07 2017 00:21
@devancadman So when declaring variable remember that the operator happen first and then it assigns it. For example what would a equal in var a = 1 + 1
David Whang
@whangsajang
Mar 07 2017 00:21
function findLongestWord(str) {
  longWord = str.split(' ');
  var myArray = longWord.sort(function(a, b){
    return b.length - a.length;
  });

  return myArray[0].length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Peter Segura
@be1mont
Mar 07 2017 00:21
so it should be answer ('alpha'); etc
Michael Onyeri
@omichael003
Mar 07 2017 00:21
@JLuboff still finding it difficult to understand. can you put in some figures so I can understand it
Devman
@devancadman
Mar 07 2017 00:22
@eyesore- var a = 2
eyesore-
@eyesore-
Mar 07 2017 00:23
@devancadman From your description it looks like it is asking you to set a variable with the remainder of 11 / 3 which you can find out with 11 % 3
Peter Segura
@be1mont
Mar 07 2017 00:23
or am i thinking about this wrong
Jason Luboff
@JLuboff
Mar 07 2017 00:24
@omichael003 Your equation is F = C * 9/5 + 32 so you need to implement that in your code
Wiley Debs
@Colortear
Mar 07 2017 00:25
function getIndexToIns(arr, num) {
  var i = -1;
  arr.sort();
  while (i < arr.length) {
    i++;
    if (arr[i] === num) {
      i = i;
      break;
    }
    if (num > arr[i - 1] && num < arr[i]) {
      break;
    }
  }
  return i;
}

getIndexToIns([5, 3, 20, 3], 5);
Hi, I am not understanding why my logic is incorrect for this. The expected output is 2 but I am getting 3
Peter Segura
@be1mont
Mar 07 2017 00:26
ahhhh
answer = "alpha";
duh
god damn it lol
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:27
@Colortear sort needs a callback function
John Nunns
@johnnunns
Mar 07 2017 00:28

function destroyer(arr) {
  // Remove all the values
 var value = Object.values(arguments);
 var slice = value.slice(1);

  return slice.filter(function(elem){
    return arguments[0].indexOf(elem)>-1;
  });

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:28
@Colortear also dont do the i++ until the bottom of the loop
John Nunns
@johnnunns
Mar 07 2017 00:28
anyone able to see why this doesn't work?
returns arguments[0].indexOf is not a function
Carey Van
@thisiscarey
Mar 07 2017 00:28
I'm trying to understand the arguments object. what is the 1 referencing here:
function myConcat(separator) { var args = Array.prototype.slice.call(arguments, 1); return args.join(separator); }
Devman
@devancadman
Mar 07 2017 00:28
@eyesore- i understand now thanks i forgot to input the Var on left hand side
Answer: var remainder = 11 % 3 = 2;
CamperBot
@camperbot
Mar 07 2017 00:28
devancadman sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 73 | @eyesore- |http://www.freecodecamp.com/eyesore-
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:28
@johnnunns arguments inside that callback function wont refer to the array
John Nunns
@johnnunns
Mar 07 2017 00:29
hm, do i need to set a separate variable to the arguments array then?
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:29
yes
Michael Onyeri
@omichael003
Mar 07 2017 00:30
@JLuboff i have tried everything and it still not working
Jason Luboff
@JLuboff
Mar 07 2017 00:31
@omichael003 Show what you currently have..
Wiley Debs
@Colortear
Mar 07 2017 00:31
@HeebieGeeBee Thanks.
CamperBot
@camperbot
Mar 07 2017 00:31
colortear sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 972 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
John Nunns
@johnnunns
Mar 07 2017 00:32
thanks @HeebieGeeBee
CamperBot
@camperbot
Mar 07 2017 00:32
johnnunns sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 973 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Carey Van
@thisiscarey
Mar 07 2017 00:33
function myConcat(separator) {
  var args = Array.prototype.slice.call(arguments, 1);
  return args.join(separator);
}
what does the 1 represent here? I'm having trouble understanding arguments.
Jason Luboff
@JLuboff
Mar 07 2017 00:34
@thisiscarey The index to end extraction I believe
Henderson-Charles
@Henderson-Charles
Mar 07 2017 00:38

Would anyone here know if there is a way using JavaScript to over ride the default HTML?

I am trying to create a page that will make it easier for my department to keep track of the Username and Passwords for the properties that we support. Since these passwords change frequently, we need to be able to edit the information and it override the default value in the HTML.

Link: http://codepen.io/C-Henderson/full/bgwypa/

Any advice would be much appreciated as I am at a complete loss.

Kurt Smith
@kurtsmith1018
Mar 07 2017 00:38

Can someone please help?..Instructions

Change the code to use the ++ operator on myVar..
var myVar = 87;

// Only change code below this line
87++;

Jason Luboff
@JLuboff
Mar 07 2017 00:39
@kurtsmith1018 You apply the ++ operator directly to the variable name myNumVar++
Kurt Smith
@kurtsmith1018
Mar 07 2017 00:40
@JLuboff Thanks again!
CamperBot
@camperbot
Mar 07 2017 00:40
kurtsmith1018 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1048 | @jluboff |http://www.freecodecamp.com/jluboff
Michael Onyeri
@omichael003
Mar 07 2017 00:40

@JLuboff
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var 0 = (0 9/5) + 32
var Fahrenheit= ((-30
9)/5) + 32;

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

// Change the inputs below to test your code
convertToF(30);
I tried two different method

Jason Luboff
@JLuboff
Mar 07 2017 00:41
@omichael003 You still aren't using the parameter celsius anywhere in your code and Javascript is case sensitive, Fahrenheit is not the same as fahrenheit
Michael Onyeri
@omichael003
Mar 07 2017 00:44

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

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

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

Adam VanZuiden
@adamvz
Mar 07 2017 00:44
@Henderson-Charles are you allowed to edit HTML of the site?
Tyler Lujan
@tlujan
Mar 07 2017 00:44
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = ""; // Change this line
Here is a nested object:

    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"

Instructions

Access the myStorage object and assign the contents of the glove box property to the gloveBoxContents variable. Use bracket notation for properties with a space in their name.
I need help on Accessing Nested objects
Adam VanZuiden
@adamvz
Mar 07 2017 00:45
@Henderson-Charles in other words can you add an id to an element even if you aren't changing the item
Tyler Lujan
@tlujan
Mar 07 2017 00:45
no idea where to start
Henderson-Charles
@Henderson-Charles
Mar 07 2017 00:45
@adamvz Currently I can because it is my pen. But once this gets placed on the internal server, I don't know if they will give me access to the source code.
Jason Luboff
@JLuboff
Mar 07 2017 00:46

@omichael003

@omichael003 You still aren't using the parameter celsius anywhere in your code

Tyler Lujan
@tlujan
Mar 07 2017 00:47
pls....
Josh Wilder
@joshwilder
Mar 07 2017 00:48
What in god's green hell am I doing wrong here...

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {

  // Your code below this line
var result = myAdjective + myNoun + myVerb + myAdverb;  

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:48
@tlujan objects are similar to arrays
Adam VanZuiden
@adamvz
Mar 07 2017 00:49
@Henderson-Charles are you looking to edit them live from an input box?
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:49
so a nested object is just trying to access a nested sub array except they're strings
so have to use the correct notation for strings
Michael Onyeri
@omichael003
Mar 07 2017 00:49

@JLuboff is that what you meanfunction convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var fahrenheit= (0 9/5) + 32;
var fahrenheit = ((celcius -30
9)/5) + 32;
var fahrenheit= ((-10 * 9)/5) + 32;

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

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

HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:50
@joshwilder need to add spaces
Michael Onyeri
@omichael003
Mar 07 2017 00:50

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

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

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

@JLuboff typo function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var fahrenheit= (0 9/5) + 32;
var fahrenheit = ((celsius -30
9)/5) + 32;
var fahrenheit= ((-10 * 9)/5) + 32;

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

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

David Whang
@whangsajang
Mar 07 2017 00:51
hey guys I'm sure I could have done this better could I get some help
Henderson-Charles
@Henderson-Charles
Mar 07 2017 00:52
@adamvz Yes. Since the fields are marked as contenteditable, the idea is that when we need to change the passwords and expiration dates, one person can do that and then others would just need to refresh the page.
Jason Luboff
@JLuboff
Mar 07 2017 00:52
@omichael003 Ok.. this line var fahrenheit = ((celsius -30 9)/5) + 32; is close..but get rid of -30 and remove var as well then remove all the other lines you've added besides this one
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:52
@omichael003 for startes a variable only needs to be declare once with var
Kurt Smith
@kurtsmith1018
Mar 07 2017 00:52

@JLuboff not sure what this is asking...Create a variable myDecimal and give it a decimal value with a fractional part (e.g. 5.7)...var ourDecimal = 5.7;

// Only change code below this line

ourDecimal = 5.7;

HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:52
@kurtsmith1018 read what its asking you to do again
Jason Luboff
@JLuboff
Mar 07 2017 00:53
@kurtsmith1018 You need to create a variable named myDecimal and assign it a value like that of ourDecimal
Kurt Smith
@kurtsmith1018
Mar 07 2017 00:53
got it. ill read more carefully. Thanks
David Whang
@whangsajang
Mar 07 2017 00:53
function titleCase(str) {
  var lowerCase = str.toLowerCase().split(' ');
  var array = []
  for(var x = 0;x < lowerCase.length; x++){
  var Uppercase =lowerCase[x].charAt(0).toUpperCase() + lowerCase[x].slice(1);
      array.push(Uppercase);
  }
return array.join(' ')
}
Adam VanZuiden
@adamvz
Mar 07 2017 00:53
@Henderson-Charles what's on your backend? In javascript we can change items around on the page but I think what you are looking for is something along the lines of PHP or Ruby to make changes to the backend web content.
David Whang
@whangsajang
Mar 07 2017 00:53
improve me please
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:54
@whangsajang why create that array variable an the uppercase variable?
Michael Onyeri
@omichael003
Mar 07 2017 00:55

@JLuboff THISfunction convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var fahrenheit= (0 9/5) + 32;
fahrenheit = celsius
9/5 + 32;
var fahrenheit= ((-10 * 9)/5) + 32;

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

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

HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:55
lowerCase[x] =lowerCase[x].charAt(0).toUpperCase() + lowerCase[x].slice(1); is enough
Jason Luboff
@JLuboff
Mar 07 2017 00:55
@omichael003 fahrenheit = celsius * 9/5 + 32 thats all you need. Remove the line above and below
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:55
@whangsajang no need to push in the otherarray
Adam
@GoingAllTheWayUp
Mar 07 2017 00:55
  // Replace low-upper case to low-space-uppercase
  str = str.replace(/([a-z])([A-Z])/g, '$1 $2');
whats going on here? where can I find more info?
David Whang
@whangsajang
Mar 07 2017 00:56
you're right @HeebieGeeBee
need to work on it
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:56
@GoingAllTheWayUp look at the regex page in in moz
Adam VanZuiden
@adamvz
Mar 07 2017 00:56
@Henderson-Charles well... if your file will have read/write permissions (which really it shouldn't unless this will be kept on LOCAL INTRANET ONLY you keep the information in a JSON and the use something like localStorage.setItem
Michael Onyeri
@omichael003
Mar 07 2017 00:56
@JLuboff thanks a lot, got it now
CamperBot
@camperbot
Mar 07 2017 00:56
omichael003 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1049 | @jluboff |http://www.freecodecamp.com/jluboff
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:57
@GoingAllTheWayUp youre creating to statements one for lower case and one for uppercase so when theres a lowercase next to an uppercase letter youre replacing it with the same letters just with a space in between
Adam
@GoingAllTheWayUp
Mar 07 2017 00:58
@HeebieGeeBee use of '$1 $2' is what I question
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 00:58
why?
the $ refers to the capture group in your regular expression
so $1 is the first capture group and $2 is the secnd
Adam
@GoingAllTheWayUp
Mar 07 2017 01:00
Ok like how arguments captures parameters
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 01:01
not really
Adam
@GoingAllTheWayUp
Mar 07 2017 01:01
ok but i do understand you
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 01:02
(a-z) is a capture group
in regular expression
Adam VanZuiden
@adamvz
Mar 07 2017 01:02
@Henderson-Charles you might be able to do with it node
@Henderson-Charles really it just depends on your system administrator and what he will allow you
he or she
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 01:03
who is that who keeps putting up a message to me an deleting it?
Adam
@GoingAllTheWayUp
Mar 07 2017 01:04
@HeebieGeeBee I do undestand you im just teasing it out.. It just a leap for me since /([a-z])([A-Z])/g in my head means any letter a to z upper or lowwer case, but it realy means an upper and lower case next together
Henderson-Charles
@Henderson-Charles
Mar 07 2017 01:04
@adamvz Okay, so there is no way to do it with codepen?
Josh Wilder
@joshwilder
Mar 07 2017 01:04
Sorry @HeebieGeeBee , that's me. My formatting was off when I was sending it. Wanted to be clear.
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 01:05
@joshwilder just ad spaces in between the variables like + " " +
Josh Wilder
@joshwilder
Mar 07 2017 01:05

@HeebieGeeBee It says I'm still not executing these requirements

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

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

HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 01:06
@GoingAllTheWayUp it all epends how you right the expression and what syntax you use
Adam
@GoingAllTheWayUp
Mar 07 2017 01:06
ugh..
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 01:06
if its between parenthesis its a capturing group
Adam VanZuiden
@adamvz
Mar 07 2017 01:06
@henderson-charles well you can change the content of the page on codepen. but you won't be able to change html file. You could add an asset to it and change the passwords in it as needed though
Adam
@GoingAllTheWayUp
Mar 07 2017 01:07
ok
Thanks @HeebieGeeBee I did miss that it was in ()
CamperBot
@camperbot
Mar 07 2017 01:07
goingallthewayup sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 974 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Adam VanZuiden
@adamvz
Mar 07 2017 01:08
@Henderson-Charles you could probably even pull a JSON from offisite to populate those fields if you don't have access to the server. The problem of course would be is that you are saving non obfuscated passwords on a publically accessible website which is a huge vulnerability
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 01:08
@GoingAllTheWayUp and i think becuase capturing groups are matched and remembered you can then use the $ to refer to them again
when you use them in functions like replace that is
Adam VanZuiden
@adamvz
Mar 07 2017 01:09
@Henderson-Charles and since javascript is publically viewable you won't be able to obfuscate them with anything more than trivial effort.
Adam
@GoingAllTheWayUp
Mar 07 2017 01:09
ok.
Adam
@GoingAllTheWayUp
Mar 07 2017 01:16
@HeebieGeeBee

function spinalCase(phrase) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins

var regEpressionUpperLower = /([a-z][A-Z])/g;
var regEpressionSpaces = /\s/g;
var regEpressionUnderscore = /[_]/g; 
var spinalPhrase = phrase.replace(regEpressionUnderscore, "-").replace(regEpressionUpperLower, '1$ 2$').replace(regEpressionSpaces, "-").toLowerCase();

  console.log ("spinalPhrase" + spinalPhrase);

  return spinalPhrase;
}

spinalCase('This Is Spinal Tap');
Whats the correct way to use the holder?
HeebieGeeBee
@HeebieGeeBee
Mar 07 2017 01:18
@GoingAllTheWayUp dont chain them like that
@GoingAllTheWayUp and that isnt the proper cature group
([a-z])([A-Z])
Adam
@GoingAllTheWayUp
Mar 07 2017 01:20
yes, i did that, success
learning something new here @HeebieGeeBee thanks!
CamperBot
@camperbot
Mar 07 2017 01:21
goingallthewayup sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: goingallthewayup already gave heebiegeebee points
Conor Murphy
@cmurphy580
Mar 07 2017 01:26
@cmurphy580
i was going through my old projects and saw that this was no longer working. Just to be sure. Does anyone mind checking to see if it works with them, and if it doesn't where might the bug be?
https://codepen.io/cmurphy580/pen/rWBJEr?editors=1010
Alexander Køpke
@alexanderkopke
Mar 07 2017 01:28
@cmurphy580 open the console, not the codepen one.
Adam VanZuiden
@adamvz
Mar 07 2017 01:30
@cmurphy580 getCurrentLocation doesn't work on insecure connections
currently working on that project and trying to find a workaround
Brian
@BrianCodes33
Mar 07 2017 01:31
function isPrime(num) {
  var primes = [];
    if(num < 2) return false;
    for (var i = 2; i < num; i++) {
        if(num%i===0) {
            return false;
    }
    return true;
  }
}

function addPrimes(num) {

}

sumPrimes(10);
so i want to grab the truth values and reduce
any ideas
Johnny
@JohnnyBizzel
Mar 07 2017 01:32
Ah, there you are!
Brian
@BrianCodes33
Mar 07 2017 01:33
whats up @JohnnyBizzel
Johnny
@JohnnyBizzel
Mar 07 2017 01:33
@BrianCodes33 is that the correct test for primes? Mine was more complicated.
I probably google'd it!
tyxpow
@tyxpow
Mar 07 2017 01:34
does anyone know a good place to learn about navbars?
Johnny
@JohnnyBizzel
Mar 07 2017 01:35
@tyxpow try W3school's CSS section
Kurt Smith
@kurtsmith1018
Mar 07 2017 01:35

can someone please tell me what I am doing wrong here..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".

var myStr = "I am a \"double quoted"\ string inside \"double quotes\"."; // Change this line

tyxpow
@tyxpow
Mar 07 2017 01:35
Also do we need to know javascript to do the portfolio project?
Adam VanZuiden
@adamvz
Mar 07 2017 01:36
Is there a way to find geolocation without https connection?
Kurt Smith
@kurtsmith1018
Mar 07 2017 01:36
I dont know where the unexpected '\' or the missing semcolon is
Johnny
@JohnnyBizzel
Mar 07 2017 01:36
@kurtsmith1018 would you mind formatting your code?
@tyxpow why?
Kurt Smith
@kurtsmith1018
Mar 07 2017 01:36
can you tell me how to do that
Johnny
@JohnnyBizzel
Mar 07 2017 01:36
@kurtsmith1018 check markdown help >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
or read:
'''
CamperBot
@camperbot
Mar 07 2017 01:37
:bulb: to format code use backticks! ``` more info
Henderson-Charles
@Henderson-Charles
Mar 07 2017 01:37
@adamvz These would not be publicly accessible. This would be placed on a internal server for my department to see, but no one outside of our network would have access to it. I was hoping to be able to get it working so that once it's transferred, we'd be able to start using it.
Johnny
@JohnnyBizzel
Mar 07 2017 01:37
or familiarise yourself with a back tick `
@BrianCodes33
function check_prime(a)
{
   var c = 2;
   for ( c = 2 ; c <= a - 1 ; c++ )
   { 
      if ( a % c === 0 )
           return false;
   }
   if ( c === a )
      return true;
}
Adam VanZuiden
@adamvz
Mar 07 2017 01:38
@Henderson-Charles unfortunately I don't think you can just use javascript for that. You are going to need something on the backend to change the local files. You can import the informaiton from offsite but you won't be able to write to that either. You will have to change the passwords manually from inside of a JSON
Brian
@BrianCodes33
Mar 07 2017 01:38
i dont like that code @JohnnyBizzel
Adam
@GoingAllTheWayUp
Mar 07 2017 01:39
Any one ever use Joolma?
Johnny
@JohnnyBizzel
Mar 07 2017 01:39
@BrianCodes33 neither do I but it works!
@GoingAllTheWayUp Yes, but not for long! WordPress gets my :+1:
Adam
@GoingAllTheWayUp
Mar 07 2017 01:40
@JohnnyBizzel can use incorperate javascript easly in wordpress?
im not sure how it works, i know there are extensions and plugins
Johnny
@JohnnyBizzel
Mar 07 2017 01:40
@GoingAllTheWayUp Sure - and Joomla probably. They both allow you to add custom plugins.
Henderson-Charles
@Henderson-Charles
Mar 07 2017 01:41
@adamvz Okay.. While it's disappointing, I guess it's a good thing because that would mean that I've done everything I can. So if management like it, I could work with our actual developer to get everything working once it's on our internal server.
how does one give kudos?
Johnny
@JohnnyBizzel
Mar 07 2017 01:42
@Henderson-Charles mention with a thanks
CamperBot
@camperbot
Mar 07 2017 01:42
:cookie: 182 | @henderson-charles |http://www.freecodecamp.com/henderson-charles
johnnybizzel sends brownie points to @henderson-charles :sparkles: :thumbsup: :sparkles:
Johnny
@JohnnyBizzel
Mar 07 2017 01:42
like that
Henderson-Charles
@Henderson-Charles
Mar 07 2017 01:42
@adamvz thanks
CamperBot
@camperbot
Mar 07 2017 01:42
henderson-charles sends brownie points to @adamvz :sparkles: :thumbsup: :sparkles:
:cookie: 266 | @adamvz |http://www.freecodecamp.com/adamvz
Henderson-Charles
@Henderson-Charles
Mar 07 2017 01:42
sweet! thanks!
Sophie
@sophie3669
Mar 07 2017 01:43
hello. pls can i have some help with using objects for lookups
Kurt Smith
@kurtsmith1018
Mar 07 2017 01:43
var myStr = "I am a \"double quoted"\ string inside \"double quotes\"."; // Change this line
Henderson-Charles
@Henderson-Charles
Mar 07 2017 01:44
Now I guess it's time for me to work on my third project. Got to figure out what JavaScript I will need to get further.
Joseph
@revisualize
Mar 07 2017 01:44

If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format: ..... PLEASE try with a small block of code before you try to make a bigger one.
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

...
@kurtsmith1018 quoted"\ not correct.
Andrew Charlebois
@andrewchar
Mar 07 2017 01:46
@revisualize whats up
Joseph
@revisualize
Mar 07 2017 01:46
@andrewchar Chillin' How are you?
acarosell1
@acarosell1
Mar 07 2017 01:46

Looking for advice on the Mutations challenge. Here is my code which passes most of the tests but not all: function mutation(arr) {
var first ="";
var second ="";

first = arr[0].toLowerCase();
second = arr[1].toLowerCase().split('');

for (i=0; i<second.length;i++){
if (((first).indexOf(second[i]))!== -1){check = true;}
else if (((first).indexOf(second[i])) == -1){check = false;}
}

return check;

}
// true
mutation(["hello", "neo"]);

Andrew Charlebois
@andrewchar
Mar 07 2017 01:46
@revisualize good good. new project on the go. Building a site to help new coders
Joseph
@revisualize
Mar 07 2017 01:47
@andrewchar How's that developer life treating you?
@andrewchar Oh.
Adam VanZuiden
@adamvz
Mar 07 2017 01:47
@acarosell1 put your code between ``` and ```
Sophie
@sophie3669
Mar 07 2017 01:47
hello, can someone pls help explain the using objects for lookup challange?
Alexander Køpke
@alexanderkopke
Mar 07 2017 01:47
@cmurphy580 forked it and made it work by using http on the codepen url, adding a latitude, longitude api, and adding callback=? to it and to the openweather api: forked
Joseph
@revisualize
Mar 07 2017 01:47
@sophie3669 What have you done?
Andrew Charlebois
@andrewchar
Mar 07 2017 01:47
@revisualize i just started it a few days ago
@revisualize i can pm you the link.
Joseph
@revisualize
Mar 07 2017 01:48
@andrewchar Please.
Sophie
@sophie3669
Mar 07 2017 01:48
// Setup
function phoneticLookup(val) {
  var result =

  // Only change code below this line
  {
   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("");
Joseph
@revisualize
Mar 07 2017 01:48
@sophie3669 Great.. You have to actually assign the { } to a variable.
@sophie3669 The variable name is in the instructions.
@sophie3669 Then... I'd say to you...
@sophie3669 Your function has declared and initialized the variable result to "". You are not modifying result and your function is returning result. Ergo, you're returning "". You need to modify result to be the value of the property from the object that you created.
Sophie
@sophie3669
Mar 07 2017 01:49
@revisualize here it is
ok let me try
Joseph
@revisualize
Mar 07 2017 01:52
@sophie3669 Do you know what function parameters are?
Ross
@staadecr
Mar 07 2017 01:52
 //make sure task and due date are entered and correct
    if (event.length === 0 || dt.length === 0) {
        message.nodeValue = "Please enter both a name and a date.";
    } else {
        //make sure due date string has slashes and a 4-digit year
        //if (dt.indexOf("/") === -1) {

         //   message.nodeValue = "Please enter the date in MM/DD/YYYY format.";
        //}
        //the below code makes sure that
        if ((dt.indexOf("/") === -1) || dt.indexOf("/", 3)){
            message.nodeValue = "Please enter the date in MM/DD/YYYY format."
        }
Can someone hlep me understand why the non-commented code is correct for making sure the code validates that there are two forward slashes in the date format? I’m working out of a text but don’t undestand what exacltly “(dt.indexOf(“/“) === -1 || dt.index(“/“, 3)” is doing. I get that “indexOf (search, start)” first searches for the string for the first occurrence, but I don’t understand how that works in the context of the line I just put in quotes. Thanks!!
Sophie
@sophie3669
Mar 07 2017 01:54
@revisualize , i guess it should mean arguments
Joseph
@revisualize
Mar 07 2017 01:54
@sophie3669 Parameters and Arguments are different.
Sophie
@sophie3669
Mar 07 2017 01:54
ok pls put me through
Joseph
@revisualize
Mar 07 2017 01:55
@sophie3669 function phoneticLookup(val) { } ... So you have the function declaration. the function name is phoneticLookup and val is the parameter.
Sophie
@sophie3669
Mar 07 2017 01:56
ok, guess i mixed it up then
Joseph
@revisualize
Mar 07 2017 01:56
@sophie3669 If you have function addThree (num) { } .. You have the function declaration, the function name is addThree and the parameter is num.
@sophie3669 In short, Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).
@sophie3669 If I did addThree(10); ... addThree() would be the function call with the argument of 10
@sophie3669 The argument can become the parameter.
@sophie3669 But, you can pass more arguments than you have parameters for.
@sophie3669 Anyhow. The reason I bring this all up is because.
@sophie3669 After you name your object. You need to access the object property with a variable parameter.
Sophie
@sophie3669
Mar 07 2017 01:59
ohh ok, thnks let me try and see if i can get it
hugo
@hramos0910
Mar 07 2017 02:01
how is this wrong?

var myVar = 87;

// Only change code below this line
myVar = 87++;

var myVar = 87;

// Only change code below this line
myVar = 87++;

Andrew Charlebois
@andrewchar
Mar 07 2017 02:02
no need to use an assignment @hramos0910
Joseph
@revisualize
Mar 07 2017 02:02

@hramos0910

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

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

@acarosell1 The ```s need to be on their own line.
```
// code comment
```
Gilbert Gaviola
@singleparin
Mar 07 2017 02:07
Hey guys,
I need help with this one. I am not a card player and I have no clue as to how this is going to be done. Any ideas? thanks.
Joseph
@revisualize
Mar 07 2017 02:09
@singleparin Which one?
Gilbert Gaviola
@singleparin
Mar 07 2017 02:10

var count = 0;

function cc(card) {
// Only change code below this line
if (card==2 || card==3 || card==4 || card==5 || card==6) {
return "5 Bet";
} else if (card==10 || card=="J" || card=="Q" || card=="K" || card=="A") {
return "-5 Hold";} else

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

Joseph
@revisualize
Mar 07 2017 02:10
@singleparin
Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
Gilbert Gaviola
@singleparin
Mar 07 2017 02:10
I am not sure if I am doing this right
Joseph
@revisualize
Mar 07 2017 02:10
@singleparin You're not quite doing it correctly But, you don't have to change much to get yourself situated
Ross
@staadecr
Mar 07 2017 02:12
//make sure task and due date are entered and correct
    if (event.length === 0 || dt.length === 0) {
        message.nodeValue = "Please enter both a name and a date.";
    } else {
        //make sure due date string has slashes and a 4-digit year
        //if (dt.indexOf("/") === -1) {

         //   message.nodeValue = "Please enter the date in MM/DD/YYYY format.";
        //}
        //the below code makes sure that two forward slashes are check for
        if ((dt.indexOf("/") === -1)|| dt.indexOf("/", 3)) {
            message.nodeValue = "Please enter the date in MM/DD/YYYY format.";
        }
        // my code above this line
Can someone help, please. I’m trying ot get the code to result in an error if two forward slashes aren’t places in a date textbox. I’m just learning how to to use the indexOf method and totally lost.
Gilbert Gaviola
@singleparin
Mar 07 2017 02:12
Thanks @revisualize, let me think this through more.
CamperBot
@camperbot
Mar 07 2017 02:12
singleparin sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3441 | @revisualize |http://www.freecodecamp.com/revisualize
acarosell1
@acarosell1
Mar 07 2017 02:23
function mutation(arr) {
var first ="";
var second ="";

first = arr[0].toLowerCase();
second = arr[1].toLowerCase().split('');

   for (i=0; i<second.length;i++){
     if (((first).indexOf(second[i]))!== -1){check = true;}
     else if (((first).indexOf(second[i])) == -1){check = false;}  
   }







  return check;





}
// true
mutation(["hello", "neo"]);
I am looking for advice on the "Mutations" Basic Algorithm Scripting challenge. My code passes all but two tests. Does anyone see the error(s) in my code? Thanks.
Adam VanZuiden
@adamvz
Mar 07 2017 02:27
@acarosell1 try running it through this: http://www.pythontutor.com/visualize.html#mode=edit to see you error
@acarosell1 you are on the right path though!
hugo
@hramos0910
Mar 07 2017 02:31
whats wrong with this?
var remainder = 2;
11 % 3 =2;
Christopher McCormack
@cmccormack
Mar 07 2017 02:31
@acarosell1 I can't get freecodecamp.com to work right now for some reason so I can't bring up the exercise - what is the goal?
@hramos0910 Are you testing inequality? You'll need ==, not =
Gulsvi
@gulsvi
Mar 07 2017 02:32
@staadecr indexOf will only return one index even if there are multiple matches. You'll be better off validating mm/dd/yyyy with regular expressions
eyesore-
@eyesore-
Mar 07 2017 02:32
@acarosell1 It doesn't look like you are defining check anywhere.
hugo
@hramos0910
Mar 07 2017 02:32
Instructions
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
Victoria Zambrano
@vzambrano98
Mar 07 2017 02:32
hey, so i'm trying to understand apis and get json and jquery....I thought I had it but after three straight days of trying to get this to work I've decided I need help. Could someone check out my code and just tell me why I can't get it.
http://codepen.io/vzambrano98/pen/gmrLZw?editors=1010
Coy Sanders
@coymeetsworld
Mar 07 2017 02:32
@acarosell1 I think theres a problem with the logic
Ross
@staadecr
Mar 07 2017 02:32
@SkyCoder01 thanks for the response. I’ve toyed around a lot. Could you provide me an example?
CamperBot
@camperbot
Mar 07 2017 02:32
staadecr sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 454 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Adam VanZuiden
@adamvz
Mar 07 2017 02:33
@vzambrano98 I just finished that one I will take a look!
Coy Sanders
@coymeetsworld
Mar 07 2017 02:33
you give yourself a chance to reset the check back to true, but if you encounter even one false instance the answer should be false
Victoria Zambrano
@vzambrano98
Mar 07 2017 02:33
@adamvz thanks!
CamperBot
@camperbot
Mar 07 2017 02:33
vzambrano98 sends brownie points to @adamvz :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @adamvz |http://www.freecodecamp.com/adamvz
Christopher McCormack
@cmccormack
Mar 07 2017 02:33
@hramos0910 you're second statement isn't assigning anything, it's just using literals
Coy Sanders
@coymeetsworld
Mar 07 2017 02:33
for instance, n isn't in hello so you set check as false. But both e and o are checked later and will set check to true, so your mutation function will return true
Gulsvi
@gulsvi
Mar 07 2017 02:33
@staadecr There are some regular expression examples here: http://stackoverflow.com/questions/15491894/regex-to-validate-date-format-dd-mm-yyyy
hugo
@hramos0910
Mar 07 2017 02:34
@cmccormack so would this be right? var remainder 11 % 3 = 2;
Christopher McCormack
@cmccormack
Mar 07 2017 02:35
@hramos0910 you want to make 'remainder' equal to something so you would do var remainder = x, where x is what you want to assign to remainder
in this case x would be 11 % 3
Ross
@staadecr
Mar 07 2017 02:36
@SkyCoder01 thanks. I’ll see if I can figure it out
CamperBot
@camperbot
Mar 07 2017 02:36
staadecr sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:warning: staadecr already gave skycoder01 points
eyesore-
@eyesore-
Mar 07 2017 02:37
@staadecr If you want to practice some regular expressions check out https://regex101.com/
Ross
@staadecr
Mar 07 2017 02:37
@eyesore- thanks
CamperBot
@camperbot
Mar 07 2017 02:37
staadecr sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 74 | @eyesore- |http://www.freecodecamp.com/eyesore-
eyesore-
@eyesore-
Mar 07 2017 02:38
No problem!
hugo
@hramos0910
Mar 07 2017 02:39
@cmccormack thankyou
CamperBot
@camperbot
Mar 07 2017 02:39
hramos0910 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 339 | @cmccormack |http://www.freecodecamp.com/cmccormack
acarosell1
@acarosell1
Mar 07 2017 02:40
Mutations
Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

For example, ["hello", "Hello"], should return true because all of the letters in the second string are present in the first, ignoring case.

The arguments ["hello", "hey"] should return false because the string "hello" does not contain a "y".

Lastly, ["Alien", "line"], should return true because all of the letters in "line" are present in "Alien".

Remember to use Read-Search-Ask if you get stuck. Write your own code.

Here are some helpful links:

String.prototype.indexOf()
Run tests (ctrl + enter)
  Reset      Help      Bug

/**
  * Your output will go here.
  * Any console.log() -type
  * statements will appear in
  * your browser's DevTools
  * JavaScript console as well.
  */

mutation(["hello", "hey"]) should return false.
mutation(["hello", "Hello"]) should return true.
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]) should return true.
mutation(["Mary", "Army"]) should return true.
mutation(["Mary", "Aarmy"]) should return true.
mutation(["Alien", "line"]) should return true.
mutation(["floor", "for"]) should return true.
mutation(["hello", "neo"]) should return false.
mutation(["voodoo", "no"]) should return false.
Gulsvi
@gulsvi
Mar 07 2017 02:40
@vzambrano98 A few issues:
  • You haven't added jQuery to your project
  • Add the # sign in jQuery to select elements by ID: $('#quote-content').....
  • Your API responses are getting cached - you'll need to disable cache with getJSON or you'll keep getting the same quote over and over again
Some minor issues aside from that - but I think you can figure those out :) if not ask away and we'll help
Ross
@staadecr
Mar 07 2017 02:40
@eyesore- @SkyCoder01 I’m working my way through Murach’s JavaScript book. The example app I’m working on says that I must store the result of the “indexOf method” and use it to first check for the first slash and then use it as a starting point for trying to find the second. This is all pretty confusing to me still. I can still do this with regular expressions?
Victoria Zambrano
@vzambrano98
Mar 07 2017 02:41
@SkyCoder01 :clap: thank you so much!!!! I was seriously going crazy over this thing!
CamperBot
@camperbot
Mar 07 2017 02:41
vzambrano98 sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 455 | @skycoder01 |http://www.freecodecamp.com/skycoder01
KharmaZ
@KharmaZ
Mar 07 2017 02:42
hey so I'm doing the javascript madlibs part and I'm not too sure what I'm actually suppose to do I understood the string lessons up to this part but I don't get it.. :/ anyone able to throw me a hint?
eyesore-
@eyesore-
Mar 07 2017 02:42
@staadecr I'm sorry, I just jumped in on the regex part so I'm not sure which lesson you are working. Which one is it?
@KharmaZ Where are you confused?
Gulsvi
@gulsvi
Mar 07 2017 02:42
@staadecr In that case, you probably want to check if there's at least one /, .split('/') the date and then use a for loop to go through the resulting array
Conor Murphy
@cmurphy580
Mar 07 2017 02:42
@alexanderkopke @JohnnyBizzel @adamvz sweet thanks for the help everybody
CamperBot
@camperbot
Mar 07 2017 02:42
cmurphy580 sends brownie points to @alexanderkopke and @johnnybizzel and @adamvz :sparkles: :thumbsup: :sparkles:
:star2: 1441 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
acarosell1
@acarosell1
Mar 07 2017 02:42
@adamvz OK. Thank you.
CamperBot
@camperbot
Mar 07 2017 02:42
:cookie: 268 | @adamvz |http://www.freecodecamp.com/adamvz
:star2: 1176 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Ross
@staadecr
Mar 07 2017 02:42

```
//make sure task and due date are entered and correct
if (event.length === 0 || dt.length === 0) {
message.nodeValue = "Please enter both a name and a date.";
} else {
//make sure due date string has slashes and a 4-digit year
//if (dt.indexOf("/") === -1) {

     //   message.nodeValue = "Please enter the date in MM/DD/YYYY format.";
    //}
    //the below code makes sure that two forward slashes are check for
    if ((dt.indexOf("/") === -1)|| dt.indexOf("/", 3)) {
        message.nodeValue = "Please enter the date in MM/DD/YYYY format.";
    }
    // my code above this line

```
@eyesore-

Can someone help, please. I’m trying ot get the code to result in an error if two forward slashes aren’t places in a date textbox. I’m just learning how to to use the indexOf method and totally lost.

KharmaZ
@KharmaZ
Mar 07 2017 02:42
@eyesore more or less just what I'm actually suppose to do as code wise sorta lost in it .
acarosell1
@acarosell1
Mar 07 2017 02:43
@cmccormack I put the exercise up. Thanks
CamperBot
@camperbot
Mar 07 2017 02:43
acarosell1 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 340 | @cmccormack |http://www.freecodecamp.com/cmccormack
Adam VanZuiden
@adamvz
Mar 07 2017 02:43
@vzambrano98 You need to load jquery into the settings
acarosell1
@acarosell1
Mar 07 2017 02:44
@coymeetsworld OK. Thanks
CamperBot
@camperbot
Mar 07 2017 02:44
acarosell1 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2284 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Adam VanZuiden
@adamvz
Mar 07 2017 02:44
@vzambrano98 click on the gear next to javascript go to bottom to quick add and add jquery. Right now the framework isn't loaded so javascript has no idea what to do with the $ you have
eyesore-
@eyesore-
Mar 07 2017 02:44
@staadecr When it comes to strings you could definitely just use a regex to validate that it is the format you want. So something like this /^\d{2}[./-]\d{2}[./-]\d{4}$/ will validate a date.
@staadecr [./-] would be the separator so if you just want it to be / then you would do [/]
Victoria Zambrano
@vzambrano98
Mar 07 2017 02:45
thanks @adamvz i seriously was living on the struggle bus.
CamperBot
@camperbot
Mar 07 2017 02:45
vzambrano98 sends brownie points to @adamvz :sparkles: :thumbsup: :sparkles:
:warning: vzambrano98 already gave adamvz points
eyesore-
@eyesore-
Mar 07 2017 02:46
@KharmaZ Which one are you on? Have you started with any code?
Adam VanZuiden
@adamvz
Mar 07 2017 02:46
@vzambrano98 no problem! I sat there looking at it and couldn't figure it out myself until I opened the browsers console
Ross
@staadecr
Mar 07 2017 02:47
@eyesore- this is above my level at the moment. Are you saying this would all be within the indexOf method? And, if you don’t mind, could you break that down more for me?
Christopher McCormack
@cmccormack
Mar 07 2017 02:48
@acarosell1 If you consider that the first instance you run into where the indexOf value returns -1 means the entire test fails, then you know at that point you can return from your function with that same result. you don't want to keep checking after the first failure.
Kurt Smith
@kurtsmith1018
Mar 07 2017 02:49

Can someone please help, I am trying to build a "Mad Lib" with word blanks.```
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result = ("dog", "big", "ran", "quickly");

// Your code above this line
return result;
}

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

Victoria Zambrano
@vzambrano98
Mar 07 2017 02:49
@adamvz yeah, i really need to force myself to use that a lot more. Good Call
eyesore-
@eyesore-
Mar 07 2017 02:49
@staadecr sorry, I was scared it would just confuse you more. Using indexOf for this and using regex would be two different things. Regex is it's own language you could say. So basically in d{4} you are saying that there will be 4 digits.
Adam VanZuiden
@adamvz
Mar 07 2017 02:50
@kurtsmith1018 reread what the challenge instrucitons. You should be building a madlibs type sentence. They will pass you words that you put into a sentence you make.
Kurt Smith
@kurtsmith1018
Mar 07 2017 02:50
@adamvz thank you
CamperBot
@camperbot
Mar 07 2017 02:50
kurtsmith1018 sends brownie points to @adamvz :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @adamvz |http://www.freecodecamp.com/adamvz
eyesore-
@eyesore-
Mar 07 2017 02:50
@staadecr if you are just starting I would advice checking out regex at a later time. Personally I think it's one of the most confusing things in programming.
KharmaZ
@KharmaZ
Mar 07 2017 02:50
@eyesore @kurtsmith1018 and I are on the exact same one
@kurtsmith1018 I'm having the same issues haha not too sure what the heck I'm suppose to do ! :(
Kurt Smith
@kurtsmith1018
Mar 07 2017 02:52
@KharmaZ I think I know, I'll let you know if I got it
Ross
@staadecr
Mar 07 2017 02:52
@eyesore- yeah, i think it’s best to stear away for now. Would you mind helping me continuing using the instructions I mentioned. The text seems to have exercises that are more advanced than the examples they actually provide.
eyesore-
@eyesore-
Mar 07 2017 02:52
@KharmaZ @kurtsmith1018 Cool. So if you look at your code. You are have arguments myNoun, myAdjective ... Those are basically variables for what you pass into the function
Adam VanZuiden
@adamvz
Mar 07 2017 02:52
@KharmaZ The function will give you a list of strings named myNoun, myAjective, myVerb, my Adverb, your job is to put those into sentence, any sentence really.
eyesore-
@eyesore-
Mar 07 2017 02:53
@KharmaZ @kurtsmith1018 So if you were to do return myNoun with wordBlanks("dog", "big", "ran", "quickly") then it would return dog
@staadecr sure thing. Shoot me a PM.
Adam VanZuiden
@adamvz
Mar 07 2017 02:54
@KharmaZ So a very basic sentence is "My myNoun and myAdjective cat myVerb myAdverb". So add the arguments that are passed in the example to see what the completed sentence will look like.
David Amanze
@GodKingShogun
Mar 07 2017 02:56
hello everyone :smile:
Peter Segura
@be1mont
Mar 07 2017 02:56
hi! I need a tad bit of help
Adam VanZuiden
@adamvz
Mar 07 2017 02:56

@KharmaZ now you can't say

var a = "My dog and big cat ran quickly.";
return a;

because the next arugments will be different. So you could be cough adding the arugments into your sentence.

Peter Segura
@be1mont
Mar 07 2017 02:56

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";
break;
}

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

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

what happened lol
David Amanze
@GodKingShogun
Mar 07 2017 02:58
@be1mont i believe your last break doesnt need a ; and you need to replace : with ; in a couple places
or maybe keep the colon. its been a while since i used a switch
Adam VanZuiden
@adamvz
Mar 07 2017 02:59
@KharmaZ here's an example out of some code I am working on now:
 var lat = pos.coords.latitude;
     var lon = pos.coords.longitude;
     var api = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&appid=a3fc50a7d66cfe424fc25184cdd469ba"
Peter Segura
@be1mont
Mar 07 2017 02:59
yea im not getting any syntax errors @GodKingShogun
im just getting nothing in the console
acarosell1
@acarosell1
Mar 07 2017 03:00
@cmccormack Right. I see that problem. At this point I am at a loss for how to put into code to return out false at the first instance of failure while at the same time scanning through for matches.
KharmaZ
@KharmaZ
Mar 07 2017 03:00
@adamvz appreciate the help I mis understood it ! haha
Adam VanZuiden
@adamvz
Mar 07 2017 03:01
@KharmaZ No problems!
Peter Segura
@be1mont
Mar 07 2017 03:01
like idk what i did wrong at all
David Amanze
@GodKingShogun
Mar 07 2017 03:01
@be1mont what are you supposed to do in the challenge
Peter Segura
@be1mont
Mar 07 2017 03:02
replacing if else chains with switch
Adam VanZuiden
@adamvz
Mar 07 2017 03:02
@be1mont check your = compare them to example
Peter Segura
@be1mont
Mar 07 2017 03:03
-__- thanks @adamvz
CamperBot
@camperbot
Mar 07 2017 03:03
be1mont sends brownie points to @adamvz :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @adamvz |http://www.freecodecamp.com/adamvz
Adam VanZuiden
@adamvz
Mar 07 2017 03:04
@be1mont No problem!
KharmaZ
@KharmaZ
Mar 07 2017 03:04
@adamvz what does it mean by wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib). ?? specifically the should contain all of the passed in words sperated by non-word characters?
David Amanze
@GodKingShogun
Mar 07 2017 03:04
@adamvz lol i was just about to explain but have you completed the fibonnaci challenge
Adam VanZuiden
@adamvz
Mar 07 2017 03:05
@GodKingShogun nope! I don't think I can look at it though.
David Amanze
@GodKingShogun
Mar 07 2017 03:05
@adamvz ok nvm then. i guess i will have to come back tomorrow
@KharmaZ here is an example of the partial answer. "My "+noun
Adam VanZuiden
@adamvz
Mar 07 2017 03:07
@KharmaZ it's describing how to pass multiple strings in an argument. For instance worldBlanks("dogs","cat","purple") is much different than wordBlanks("dog , cat, purple")
@KharmaZ in the first one i put up I am passing 3 strings to the function, the second example i put up I am only passing one.
David Amanze
@GodKingShogun
Mar 07 2017 03:08
@KharmaZ your basically taking your own words and combining them with params already given
Kurt Smith
@kurtsmith1018
Mar 07 2017 03:08
@adamvz can you explain what the problem is here..```

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

// Your code above this line
return result;
}

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

David Amanze
@GodKingShogun
Mar 07 2017 03:08
you're*
KharmaZ
@KharmaZ
Mar 07 2017 03:08
@GodKingShogun yea I did it I overthought it to the max haha
David Amanze
@GodKingShogun
Mar 07 2017 03:09
@KharmaZ so did you get it right
KharmaZ
@KharmaZ
Mar 07 2017 03:09
@GodKingShogun yea I got it haha I thought whats the most absolute simplistic way to do this and it worked haha
David Amanze
@GodKingShogun
Mar 07 2017 03:09
@KharmaZ great job. keep going
Adam VanZuiden
@adamvz
Mar 07 2017 03:09
@kurtsmith1018 you are forgetting a " " (space character) in your strings. If I pass "My" + myNoun + "is fat." and myNoun = dog it will return "Mydogis fat."
KharmaZ
@KharmaZ
Mar 07 2017 03:10
@adamvz @GodKingShogun thanks appreciate all the help guys
CamperBot
@camperbot
Mar 07 2017 03:10
kharmaz sends brownie points to @adamvz and @godkingshogun :sparkles: :thumbsup: :sparkles:
:cookie: 271 | @adamvz |http://www.freecodecamp.com/adamvz
:cookie: 146 | @godkingshogun |http://www.freecodecamp.com/godkingshogun
Adam VanZuiden
@adamvz
Mar 07 2017 03:11
@kurtsmith1018 if I use "My " + myNoun + " is fat." it will return "My dog is fat"
@kurtsmith1018 see the difference?
Adam VanZuiden
@adamvz
Mar 07 2017 03:12
@Kenard0 post your code in the chat
@Kenard0 use ``` before and after your code for readability
I wonder '''
CamperBot
@camperbot
Mar 07 2017 03:13
:bulb: to format code use backticks! ``` more info
Adam VanZuiden
@adamvz
Mar 07 2017 03:14
@camperbot Thanks bro. You are invited to birthday party.
CamperBot
@camperbot
Mar 07 2017 03:14
adamvz sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 3072 | @camperbot |http://www.freecodecamp.com/camperbot
Joseph
@revisualize
Mar 07 2017 03:14
Yo.
@Kenard0 Yes.
Kurt Smith
@kurtsmith1018
Mar 07 2017 03:15
@adamvz kind of. I still don't see where I am missing the ""
Joseph
@revisualize
Mar 07 2017 03:15
@Kenard0 Look when you take a number and concatenate it to a string. It becomes a string.
@Kenard0 So...

@Kenard0

  var n = count.toString();
  if (count>0){
   return n+" Bet";
  }else
  return n+" Hold";

Could just be...

  if (count>0){
   return count + " Bet";
  } else {
   return count + " Hold";
  }
Kenard Ellis
@Kenard0
Mar 07 2017 03:17
thanks @revisualize
CamperBot
@camperbot
Mar 07 2017 03:17
kenard0 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3442 | @revisualize |http://www.freecodecamp.com/revisualize
Adam VanZuiden
@adamvz
Mar 07 2017 03:17
@kurtsmith1018 in your return line, each of the strings after the first need a space before and after.
Joseph
@revisualize
Mar 07 2017 03:17
@Kenard0 Also, don't be a savage. If you're going to do if (condition) { } use { }s all the way down.
Adam VanZuiden
@adamvz
Mar 07 2017 03:17
@kurtsmith1018 try looking at your result in the console to see what it is returning
Altan Sahin
@AldoSahin
Mar 07 2017 03:21

Hi all, I am stuck with the JavaScript unit Stand in Line. Completely blacked out don't even understand the task. Please can anybody help?
'''
function nextInLine(arr, item) {
// Your code here
nextInLine([],1);
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));

Thanks for any suggestions.

CamperBot
@camperbot
Mar 07 2017 03:21
:bulb: to format code use backticks! ``` more info
Kurt Smith
@kurtsmith1018
Mar 07 2017 03:21
@adamvz how do I look at the result in the console?
Adam VanZuiden
@adamvz
Mar 07 2017 03:22
@kurtsmith1018 which browser are you using?
Kurt Smith
@kurtsmith1018
Mar 07 2017 03:22
firefox
Alen Hu
@Alen-h
Mar 07 2017 03:23
Hi, can anyone tell me what happened with the Twitch TV's JSON API? It doesnt work now, returning 400 error...
Adam VanZuiden
@adamvz
Mar 07 2017 03:23
@kurtsmith1018 uhhh I am not sure. let me install it really quick
Alen Hu
@Alen-h
Mar 07 2017 03:24
{"error":"Bad Request","status":400,"message":"No client id specified"}
eyesore-
@eyesore-
Mar 07 2017 03:24
@kurtsmith1018 Ctrl + Shift + K or Command + Option + K
Manish Giri
@Manish-Giri
Mar 07 2017 03:26
@Alen-h you need an API key, as the error message says
Adam VanZuiden
@adamvz
Mar 07 2017 03:26
@kurtsmith1018 or click on the menu and click "developer" and then click browser console.
man firefox's console is way handier
not handy enough to move from chrome...
Alen Hu
@Alen-h
Mar 07 2017 03:27
@Manish-Giri Where can I get the API key?
Alen Hu
@Alen-h
Mar 07 2017 03:28
@Manish-Giri Cheers, I will try it.
Uros Tadic
@urketadic
Mar 07 2017 03:29
Can someone help me optimize the website? http://www.universityofempathy.com/
When i click Enter the website, it flicker for a moment before it actually loads the page fully. How can i fix this?
Kurt Smith
@kurtsmith1018
Mar 07 2017 03:32
@adamvz still not getting it. result = "My " + myNoun + "is " + myAdjective + "and he " + myVerb + " " + myAdverb";
console states - SyntaxError: unterminated string literal
Adam VanZuiden
@adamvz
Mar 07 2017 03:32
@kurtsmith1018 you don't need the last "
its throwing a syntax error
acarosell1
@acarosell1
Mar 07 2017 03:33
@cmccormack Finally got it. I did an "if" not true return false. THEN an "else if" true check = true and returned out of the for loop with check. Thanks for your help. You reminded me that at one point I was able to pass all of the true tests and none of the false. Thanks again.
CamperBot
@camperbot
Mar 07 2017 03:33
acarosell1 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: acarosell1 already gave cmccormack points
Adam VanZuiden
@adamvz
Mar 07 2017 03:37
I have a question, I am working on the local weather project. In order for me to getCurrentPosition Chrome requires me to be on https:// but when I make the api call to openweathermap Chrome won't load it because it's a mismatch. And when I try to make the call to openweathermap api over https:// my call gets blocked.
Wes
@wpr2004
Mar 07 2017 03:37
how do you split a string by it spaces? how do you indicate a "space"
Adam VanZuiden
@adamvz
Mar 07 2017 03:38
@wes ' '
or " "
Wes
@wpr2004
Mar 07 2017 03:38
@adamvz thanks
CamperBot
@camperbot
Mar 07 2017 03:38
wpr2004 sends brownie points to @adamvz :sparkles: :thumbsup: :sparkles:
:cookie: 272 | @adamvz |http://www.freecodecamp.com/adamvz
Moisés Man
@moigithub
Mar 07 2017 03:40
@adamvz try https://www.wunderground.com/
which is also free and have support for httpS
Adam VanZuiden
@adamvz
Mar 07 2017 03:40
@moigithub perfect thanks!
CamperBot
@camperbot
Mar 07 2017 03:40
adamvz sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2801 | @moigithub |http://www.freecodecamp.com/moigithub
Kurt Smith
@kurtsmith1018
Mar 07 2017 03:41
@adamvz i think im almost there result = "My " + myNoun + " " ;"is " + myAdjective + "and he " + myVerb + " " + myAdverb;
I am not sure why I was suggested to place a semi colon before "is ". Console only states My dog now
Moisés Man
@moigithub
Mar 07 2017 03:43
why ; in middle of ur string ?
David Miolard
@GwadaKing
Mar 07 2017 03:43

Hi all ! I'm new in Javascript and I wonder why my code doesn't work (I get an error firstName unidentified) :

' for (var a=0;a<contacts.length;a++) {
if ((firstName==contacts.firstName[a])&&(contacts.hasOwnProperty(prop))) {
return contacts.prop[a];
}
else if (firstName!=contacts.firstName[a]) {
return "No such contact";
}
if (!contacts.hasOwnProperty(prop)) {
return "No such property";
}'

Adam VanZuiden
@adamvz
Mar 07 2017 03:43
@kurtsmith1018 pull that semi colon out.
Kurt Smith
@kurtsmith1018
Mar 07 2017 03:45
@adamvz When I pull that semi colon out there is a SyntaxError: missing ; before statement.
Adam VanZuiden
@adamvz
Mar 07 2017 03:45
post the rest of your code
Kurt Smith
@kurtsmith1018
Mar 07 2017 03:45
@adamvz ```
result = "My " + myNoun + " " "is " + myAdjective + "and he " + myVerb + " " + myAdverb;
Adam VanZuiden
@adamvz
Mar 07 2017 03:46
@kurtsmith1018 the whole thing
eyesore-
@eyesore-
Mar 07 2017 03:46
@kurtsmith1018 this is an error " " "is "
Adam VanZuiden
@adamvz
Mar 07 2017 03:47
good call @eyesore- didn't see it. @kurtsmith1018 you have 3 " in a row.
eyesore-
@eyesore-
Mar 07 2017 03:47
@kurtsmith1018 you don't have to add the space as a separate string.
@adamvz No problem
Kurt Smith
@kurtsmith1018
Mar 07 2017 03:48
@eyesore- @adamvz result = "My " + myNoun + "is " + myAdjective + "and he " + myVerb + " " + myAdverb;
console now shows My dogis bigand he ran quickly
Adam VanZuiden
@adamvz
Mar 07 2017 03:49
@kurtsmith1018 without adding any new "'s where can you add those spaces?
@kurtsmith1018 look over your code carefully you did it correctly in the rest of the sentence
Kurt Smith
@kurtsmith1018
Mar 07 2017 03:52
@adamvz @eyesore- Thank You So Much!!!! That one was a doozy!!!
CamperBot
@camperbot
Mar 07 2017 03:52
kurtsmith1018 sends brownie points to @adamvz and @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 75 | @eyesore- |http://www.freecodecamp.com/eyesore-
:cookie: 273 | @adamvz |http://www.freecodecamp.com/adamvz
eyesore-
@eyesore-
Mar 07 2017 03:54
No problem!
Adam VanZuiden
@adamvz
Mar 07 2017 03:54
@kurtsmith1018 No problem! They only get tougher from there!
haha
Prakash Shiwakoti
@pshiwakoti1
Mar 07 2017 03:55

function sym(args) {
  var myArr = [];
  for (var i = 0; i < arguments.length; i++)
    myArr.push(arguments[i]);


  var symmetric = [];
  if ((arguments[0]) !== arguments[1]) {
    symmetric.push(arguments[0]);
    symmetric.push(arguments[1]);
  }

  return symmetric;
}

sym([1, 2, 3], [5, 2, 1, 4]);
How to use reduce() method on this challenge?
Kurt Smith
@kurtsmith1018
Mar 07 2017 03:55
haha. glad to have you all here to help!
Prakash Shiwakoti
@pshiwakoti1
Mar 07 2017 03:58
anyone here to help?
anybody did Symmetric Difference challenge?
Tolga Dur
@tolgadur
Mar 07 2017 04:05
I am doing the "Arguments Optional" Challenge. What's wrong with my code? I feel like I do not understand the instructions fully ...
function addTogether(prop1, prop2) {
if(Boolean(prop2) === true && Boolean(prop1) === true){
return prop1 + prop2;
}
else if(Boolean(prop2) === false){
return function sumTwoAnd(prop3){
return prop1 + prop3;
};
}
}
Prakash Shiwakoti
@pshiwakoti1
Mar 07 2017 04:06
Togla you are missing parentheses check carefully
@tolgadur
for each opening parentheses you need a closing one
Tolga Dur
@tolgadur
Mar 07 2017 04:07
where?
Prakash Shiwakoti
@pshiwakoti1
Mar 07 2017 04:08
else if(Boolean(prop2) === false){
Daniel
@N3ATOSK3TO
Mar 07 2017 04:08
var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 5;
  this.engines = 1;
};

//Try it out here
var myCar = new Car(4,5,1);
having trouble understanding this. any pointers?
Tolga Dur
@tolgadur
Mar 07 2017 04:08
how is there a paranthese missing
Prakash Shiwakoti
@pshiwakoti1
Mar 07 2017 04:08
that looks allrite @tolgadur my bad
keerthika-dr
@keerthika-dr
Mar 07 2017 04:09
@N3ATOSK3TO you should assign the arg to the values instead;
Prakash Shiwakoti
@pshiwakoti1
Mar 07 2017 04:10
are you using JS closure to access prop1 on the last return statement
Kamal
@kpbro
Mar 07 2017 04:10
@N3ATOSK3TO you have to add nickname property. All other properties are already there
keerthika-dr
@keerthika-dr
Mar 07 2017 04:10
this.wheels = wheels;
this.seats = seats;
this.engines = engines;
Ogundele Olumide
@Lumexralph
Mar 07 2017 04:10
@N3ATOSK3TO look at this example, I want other instance object created to be able to have their own values
function Ball(type, name, colour){
  this.type = type;
  this.name = name;
  this.colour = colour
}
Prakash Shiwakoti
@pshiwakoti1
Mar 07 2017 04:12
@tolgadur surround your code with back codes ``` so that you get nice view like Ogundele has done it
before code and after code
Tolga Dur
@tolgadur
Mar 07 2017 04:13

```function addTogether() {
//check if given values are numbers. If not, return undefined.
for(var key in arguments){
if(typeOf arguments[key] !== "number"){
return undefined;
}
}

if(Boolean(arguments[0]) === true && Boolean(arguments1) === true){
return arguments[0] + arguments1;
}
else if(Boolean(arguments1) === false){
return function sumTwoAnd(prop3){
return arguments1 + prop3;
};
}
return arguments[0];
} ```

Prakash Shiwakoti
@pshiwakoti1
Mar 07 2017 04:13
put a new line
Tolga Dur
@tolgadur
Mar 07 2017 04:13
```
Prakash Shiwakoti
@pshiwakoti1
Mar 07 2017 04:13
before and after
Tolga Dur
@tolgadur
Mar 07 2017 04:13
ok wait
function addTogether() {
  //check if given values are numbers. If not, return undefined. 
  for(var key in arguments){
    if(typeOf arguments[key] !== "number"){
      return undefined;
    }
  }

  if(Boolean(arguments[0]) === true && Boolean(arguments[1]) === true){
    return arguments[0] + arguments[1];
  }
  else if(Boolean(arguments[1]) === false){
    return function sumTwoAnd(prop3){
      return arguments[1] + prop3;
    };
  }
  return arguments[0];
}
Prakash Shiwakoti
@pshiwakoti1
Mar 07 2017 04:14
there you go
Daniel
@N3ATOSK3TO
Mar 07 2017 04:16
like this @Lumexralph , @kpbro , @keerthika-dr ?
var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 5;
  this.engines = 1;
};

//Try it out here
var myCar = new Car(wheels, seats, engines);{
  this.wheels = 3;
  this.wheels = 1;
  this.engines = 2;
}
Ogundele Olumide
@Lumexralph
Mar 07 2017 04:18
@N3ATOSK3TO assign every property of the constructor function to the corresponding parameters like this.... this.wheels = wheels;
Altan Sahin
@AldoSahin
Mar 07 2017 04:19
Thanks solved it.
Tolga Dur
@tolgadur
Mar 07 2017 04:21
ok guys, this code works:
function addTogether() {
  //check if given values are numbers. If not, return undefined. 
  for(var key in arguments){
    if(typeof arguments[key] !== "number"){
      return undefined;
    }
  }
  //store first original argument into variable "num" for clarity.
  var num = arguments[0];

  if(Boolean(arguments[0]) === true && Boolean(arguments[1]) === true){
    return arguments[0] + arguments[1];
  }
  else if(Boolean(arguments[1]) === false){
    return function sumTwoAnd(prop3){
      //check if the new argument is a number
      for(var key in arguments){
        if(typeof arguments[key] !== "number"){
        return undefined;
      }
      return num + prop3;
    }
  };
}
}
but this doesnt:
function addTogether() {
  //check if given values are numbers. If not, return undefined. 
  for(var key in arguments){
    if(typeof arguments[key] !== "number"){
      return undefined;
    }
  }
  //store first original argument into variable "num" for clarity.
  var num = arguments[0];

  if(Boolean(arguments[0]) === true && Boolean(arguments[1]) === true){
    return arguments[0] + arguments[1];
  }
  else if(Boolean(arguments[1]) === false){
    return function sumTwoAnd(prop3){
      //check if the new argument is a number
      for(var key in arguments){
        if(typeof arguments[key] !== "number"){
        return undefined;
      }
      return arguments[0] + prop3;
    }
  };
}
}
why?
Daniel
@N3ATOSK3TO
Mar 07 2017 04:22
var Car = function() {
  //Change this constructor
  this.wheels = 4;
  this.seats = 5;
  this.engines = 1;
};

//Try it out here
var myCar = new Car(wheels, seats, engines);{
  this.wheels = wheels;
  this.seats = seats;
  this.engines = engines;
}
still coming back with 'error'
@Lumexralph
Kamal
@kpbro
Mar 07 2017 04:23
@N3ATOSK3TO what is error?
Ogundele Olumide
@Lumexralph
Mar 07 2017 04:24
@N3ATOSK3TO remove the ; here engines);{, remember ; ends a statement in JS
Andrew Shieh
@andrewlikes
Mar 07 2017 04:25

Use the map function to add 3 to every value in the variable oldArray, and save the results into variable newArray. oldArray should not change.

var oldArray = [1,2,3,4,5];

// Only change code below this line.

oldArray.map(function(val) {
  return val + 3;
});

var newArray = oldArray;

My code isn't adding 3 to each value, not sure why.

Daniel
@N3ATOSK3TO
Mar 07 2017 04:25
if I remove that semicolon, it says "missing semicolon"
Kamal
@kpbro
Mar 07 2017 04:25
@N3ATOSK3TO remove semicolon from new Car()
Ogundele Olumide
@Lumexralph
Mar 07 2017 04:26
@andrewlikes remove this line at the bottom of your code var newArray = oldArray; and assign the mapped array to var newArray
@N3ATOSK3TO show your code
David Miolard
@GwadaKing
Mar 07 2017 04:27

```function lookUpProfile(firstName, prop){
// Only change code below this line
for (var a=0;a<contacts.length;a++) {

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

}

// Only change code above this line
}```

sorry for wrong post
Kamal
@kpbro
Mar 07 2017 04:28
What's the problem @GwadaKing
Claudio Restifo
@Marmiz
Mar 07 2017 04:28
Guys, quick tip:
Anyone knows a shorter syntax (ES6 or whatever) for this:
if(name == 'x' || name =='y' || name == 'y') return true
David Miolard
@GwadaKing
Mar 07 2017 04:28
I get a TypeError firstName is undefined
when trying to iterate on the array
Kamal
@kpbro
Mar 07 2017 04:30
@GwadaKing you have to return "no such contact" at the end. After the iteration . When loop can't find any such name
Andrew Shieh
@andrewlikes
Mar 07 2017 04:30
@Lumexralph of course... thanks!
CamperBot
@camperbot
Mar 07 2017 04:30
andrewlikes sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1264 | @lumexralph |http://www.freecodecamp.com/lumexralph
Daniel
@N3ATOSK3TO
Mar 07 2017 04:30
var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 5;
  this.engines = 1;
};

//Try it out here
var myCar = new Car(wheels, seats, engines) {
  this.wheels = wheels;
  this.seats = seats;
  this.engines = engines;
}
@kpbro @Lumexralph @keerthika-dr : I took out that semicolon and says 'missing semicolon' now.
Alexander Køpke
@alexanderkopke
Mar 07 2017 04:30
@tolgadur I think it is because arguments are what is passed to the function, so the last argument[0] will return to what is passed to the sumTwoAnd function while num will return to what was passed to the out function. That is my take on it ,which might be incorrect but I gave it a try ;)
Ogundele Olumide
@Lumexralph
Mar 07 2017 04:31
@N3ATOSK3TO you have not changed your constructor to what i told you
@N3ATOSK3TO and that's not how you create an instance from a constructor
David Miolard
@GwadaKing
Mar 07 2017 04:33
@kpbro Thank you so much ;)
CamperBot
@camperbot
Mar 07 2017 04:33
gwadaking sends brownie points to @kpbro :sparkles: :thumbsup: :sparkles:
:cookie: 229 | @kpbro |http://www.freecodecamp.com/kpbro
Ogundele Olumide
@Lumexralph
Mar 07 2017 04:33
@N3ATOSK3TO
function Ball(type, name, colour){  // this is the constructor
  this.type = type;
  this.name = name;
  this.colour = colour
}

var ball1 = new Ball("A", "Nike", "blue");//  i created an instance object of the Ball constructor
Kamal
@kpbro
Mar 07 2017 04:33
👍👍 @GwadaKing
Daniel
@N3ATOSK3TO
Mar 07 2017 04:46
finally got it right ! thanks @Lumexralph :smile:
CamperBot
@camperbot
Mar 07 2017 04:46
n3atosk3to sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1265 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Mar 07 2017 04:50
@N3ATOSK3TO :+1:
Dylan Smith
@DylPickle96
Mar 07 2017 04:56

function palindrome(str)
{
var newstr = str.replace(/\W/g, '').toLowerCase();
var test = str.split('').replace().join('');

if (test === newstr)
{
return true;
}

really lost on why I keep getting a typeError
str.split is not a function
Alexander Køpke
@alexanderkopke
Mar 07 2017 05:05
@Marmiz /x|y|y/.test(name)
Ogundele Olumide
@Lumexralph
Mar 07 2017 05:05
@DylPickle96 = str.split('').replace().join(''); you reverse str not replace
Claudio Restifo
@Marmiz
Mar 07 2017 05:06
@alexanderkopke thanks! :)
CamperBot
@camperbot
Mar 07 2017 05:06
marmiz sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1177 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Ogundele Olumide
@Lumexralph
Mar 07 2017 05:07
@Marmiz what's the difference? name =='y' || name == 'y'
Ryan Steen
@Rsteen76
Mar 07 2017 05:08
I can't figure out why I can't access the data in collection. I get an error of type undefined.
  var test = Object.keys(source);

  for(var i = 0; i < collection.length; i++) {
    if (collection[i].test === source[i].test){
      arr[i] = collection[i];
    }
  }
Sachin
@sachinp92
Mar 07 2017 05:10
Hello, I'm on an exercise but I can't quite understand what it's asking from me.
I don't know how to show it on here though
Claudio Restifo
@Marmiz
Mar 07 2017 05:11
@Lumexralph that's probably a typo. My actual values are all diffrent strings. But since they are not relevant for my question I've just switched to a placeholder.
Mitchell Wise
@Mitchellswise
Mar 07 2017 05:11

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

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

Note
Don't worry too much about the function and return statements as they will be covered in future challenges. For now, only use operators that you have already learned.

need help
Ogundele Olumide
@Lumexralph
Mar 07 2017 05:11
@Marmiz :+1:
thats the exercise I'm not understanding
Ogundele Olumide
@Lumexralph
Mar 07 2017 05:12
@Mitchellswise use the celsius parameter with the formula and assign it to the fahrenheit variable
@sachinp92 have you tried anything?
Mitchell Wise
@Mitchellswise
Mar 07 2017 05:13
thanks @Lumexralph
CamperBot
@camperbot
Mar 07 2017 05:13
mitchellswise sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1266 | @lumexralph |http://www.freecodecamp.com/lumexralph
Sachin
@sachinp92
Mar 07 2017 05:13
I've pushed the item into the arr, and run the shift method onto arr
but thats not what its asking
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.
David Miolard
@GwadaKing
Mar 07 2017 05:14
@sachinp92 yes that's it
Sachin
@sachinp92
Mar 07 2017 05:14
thats the instruction
David Miolard
@GwadaKing
Mar 07 2017 05:14
just use push and shift
Sachin
@sachinp92
Mar 07 2017 05:14
yeahs its telling me I'm wrong
arr.push(item);
arr.shift();
Ken Haduch
@khaduch
Mar 07 2017 05:15
@sachinp92 - the link that you posted shows arr.push(), but you need to put the item inside the parens. Then you want to get the element that is returned from arr.shift() and return that.
Sachin
@sachinp92
Mar 07 2017 05:15
thats exactly what I ty[ed
Ken Haduch
@khaduch
Mar 07 2017 05:16
@sachinp92 - then your .push(item) would be correct. You are not properly handling the .shift()
Sachin
@sachinp92
Mar 07 2017 05:16
i tried that first, then a few other things
does it want me to store the shifted value into a variable?
Alexander Køpke
@alexanderkopke
Mar 07 2017 05:17
@Rsteen76 Object.keys() method returns an array, so test is an array of source's property names. collection[i].test <-- this will look for a a property name of test. When using variables with object use [ ]collection[i][variable]. collection[i][test] won't work because test is an array.
Ken Haduch
@khaduch
Mar 07 2017 05:17
@sachinp92 @sachinp92 - you can just directly return it, or store it in a variable and then return that.
Sachin
@sachinp92
Mar 07 2017 05:18
so return item?
Ken Haduch
@khaduch
Mar 07 2017 05:19
@sachinp92 - no, arr.shift() takes the first element out of the array, which is not necessarily the same as item (although it is, in some cases) - you want to get the value that is returned from arr.shift() and return that. You can do it with return arr.shift(); or store it in a variable and then return the variable's value.
David Miolard
@GwadaKing
Mar 07 2017 05:19
or use shift
oops like he said
example : function nextInLine(arr, item) {
// Your code here
arr.push(item);
var removed=arr.shift();
return removed; // Change this line
}
Ryan Steen
@Rsteen76
Mar 07 2017 05:21
Thank you @alexanderkopke. That has been killing me. I kept checking the output but there was only 1 value in test so it didn't look like an array.
CamperBot
@camperbot
Mar 07 2017 05:21
rsteen76 sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1178 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Sachin
@sachinp92
Mar 07 2017 05:21
okay that worked
returned the value shifted from the Array
Ken Haduch
@khaduch
Mar 07 2017 05:21
@sachinp92 - do you understand it, though?
Sachin
@sachinp92
Mar 07 2017 05:22
I understand the JavaScript, but the way the exercise was worded confused me
I wasn't sure what it was asking of me
Ken Haduch
@khaduch
Mar 07 2017 05:23
@sachinp92 - now that you see the solution, maybe spend a minute to re-read the instructions and see how they relate to the code that worked... it's important to get the wording and explanations to the point where you understand what's being said (although some are easier than others, for sure!)
Sachin
@sachinp92
Mar 07 2017 05:24
okay my bad
there was nothing confusing about that at all
It actually says "The nextInLine function should then return the element that was removed."
I think I need a cup of coffee or something
Ryan Steen
@Rsteen76
Mar 07 2017 05:27
@alexanderkopke So I should be able to access collection[i].last. If I know that last is a key value of the array correct?
Daniel
@N3ATOSK3TO
Mar 07 2017 05:43
iterate over arrays with map challenge:
what am I doing wrong?
var oldArray = [1,2,3,4,5];

// Only change code below this line.

var newArray = oldArray;var plusThree =
    newArray.map(function(val) {
  return val + 3; 
});

console.log(plusThree); //returns [4, 5, 6, 7, 8]
console.log(newArray); //returns [1, 2, 3, 4, 5]
h1tag
@h1tag
Mar 07 2017 06:04
@N3ATOSK3TO
... and save the results into variable newArray...
Markus Kiili
@Masd925
Mar 07 2017 06:13
@N3ATOSK3TO You are saving results in plusThree, not newArray as you should.
Edgar Pan
@edgaryp
Mar 07 2017 06:29
Hi how do I use this.$display on line 22. I tried to use bind but did not work.
$(document).ready(function() {
  (function() {
    var current = "", result = 0;
    var calculator = {
      init: function() {
        this.cacheDom();
        this.render();
        this.bindEvents();
      },
      cacheDom: function() {
        this.$button = $(".button p, .zero p");
        this.$display = $("#display p");
      },
      bindEvents: function() {
        this.$button.on("click", this.updateResult);
      },
      updateResult: function() {
        var temp = $(this).text();
        if (parseInt(temp) > 0 == false) {
          if (temp == "÷") {
            current += "/";
            $("#display p").text(temp);
          } else if (temp == "×") {
            current += "*";
            $("#display p").text(temp);
          } else if (temp == "-") {
            current += temp;
            $("#display p").text(temp);
          } else if (temp == "+") {
            current += temp;
            $("#display p").text(temp);
          } else if (temp == "=") {
            current = eval(current);
            $("#display p").text(current);
          } else if (temp == "C") {
            current = "";
            temp = "";
            result = 0;
            $("#display p").text(result);
          } else if (temp == "%") {
            current = current / 100;
            $("#display p").text(current);
          } else if (temp == "√") {
            $("#display p").text(Math.sqrt(parseInt(current[current.length - 1])));
            var sqrt = Math.sqrt(parseInt(current[current.length - 1]));
            current = current.substring(0, current.length - 1)
            current += sqrt;
          }
        } else {
          $("#display p").text(temp);
          current += temp;
        }
        console.log(current);
      },
      render: function() {

      },
    };
    calculator.init();
  })()
});
JuicyITer
@juicyiter
Mar 07 2017 06:29
cant understand the test "stand in line". cant figure it out. is there anyone who can help out, please

function nextInLine(arr, item) {
// Your code here
nextInLine([4],4);
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));

Jaydev Shiroya
@jaydev1997
Mar 07 2017 06:30
what error?
Markus Kiili
@Masd925
Mar 07 2017 06:30
@ethanman Use parameters arr and item, not [4] and 4.
JuicyITer
@juicyiter
Mar 07 2017 06:30
i dont know waht to type in
Markus Kiili
@Masd925
Mar 07 2017 06:31
@ethanman You need to find the two array methods that do those things asked.
Jaydev Shiroya
@jaydev1997
Mar 07 2017 06:31
use shift()
Markus Kiili
@Masd925
Mar 07 2017 06:31
@jaydev1997 Giving the answer is not helping.
Jaydev Shiroya
@jaydev1997
Mar 07 2017 06:31
i just want to explain him well
retern shifted value of arr
JuicyITer
@juicyiter
Mar 07 2017 06:33
now i guess i understand what it means: its trying to let know that only the last element can be removed in the queue?
or i can only add an element in the first place in a queue?
is that correct
JuicyITer
@juicyiter
Mar 07 2017 06:43
sorry
i m really stuck here...

function nextInLine(arr, item) {
// Your code here
arr=[1,2,4,6];
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, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Sarfaraz Amin Progga
@SA-P
Mar 07 2017 06:46
@ethanman You need to push() the items in your arr.
Jaydev Shiroya
@jaydev1997
Mar 07 2017 06:46
@ethanman What error you got?
JuicyITer
@juicyiter
Mar 07 2017 06:47
how to push that
still dunno what to type
Sarfaraz Amin Progga
@SA-P
Mar 07 2017 06:50
@ethanman just like you used shift() but you have to use item as the parameter.
_xiaotian
@xiaotiandada
Mar 07 2017 07:10

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

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

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

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

How to jump out of the loop
return
Manish Giri
@Manish-Giri
Mar 07 2017 07:11
@xiaotiandada first of all, it's not both a and b, it's either
Muhammad Hasham
@MohammadHasham
Mar 07 2017 07:11
Like in images.google.com when we click an image it expands and fices user information to visit page open image etc , can it be made on vanilla js.How would they have implemented it?
Manish Giri
@Manish-Giri
Mar 07 2017 07:11
and you need to return undefined
@xiaotiandada
_xiaotian
@xiaotiandada
Mar 07 2017 07:12
任务
修改函数abTest当a或b小于0时,函数立即返回一个undefined并退出。
Kishan Khakhar
@kishankhakhar
Mar 07 2017 07:15

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testobj[12]; // Change this Line
var player = testObj; // Change this Line

How am i supposed to access the playerNumber?
Manish Giri
@Manish-Giri
Mar 07 2017 07:16
@kishankhakhar you put the number in playerNumber
then you use playerNumber to access the value in testObj and assign the result toplayer`
Kishan Khakhar
@kishankhakhar
Mar 07 2017 07:17
oh let me try it
Markus Kiili
@Masd925
Mar 07 2017 07:17
@MohammadHasham Click event and some DOM manipulation.
Daniel
@N3ATOSK3TO
Mar 07 2017 07:18
@fortMaximus , @Masd925 ; I'm so lost on that challenge
Kishan Khakhar
@kishankhakhar
Mar 07 2017 07:19
@Manish-Giri Thanks for the help. Solved it
CamperBot
@camperbot
Mar 07 2017 07:19
kishankhakhar sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4630 | @manish-giri |http://www.freecodecamp.com/manish-giri
Daniel
@N3ATOSK3TO
Mar 07 2017 07:19
```
var oldArray = [1,2,3,4,5];

// Only change code below this line.

var newArray = oldArray;var plusThree =
    newArray.map(function(val) {
  return val + 3; 
});

console.log(plusThree); //returns [4, 5, 6, 7, 8]
console.log(newArray); //returns [1, 2, 3, 4, 5]
h1tag
@h1tag
Mar 07 2017 07:20
@N3ATOSK3TO did you take what we've told you into consideration?
Markus Kiili
@Masd925
Mar 07 2017 07:21
@N3ATOSK3TO var newArray = oldArray.map(...
kesavage
@kesavage
Mar 07 2017 07:24
with something like document.write("Hello, World!");, what are the names for each part? document=, write=, and ("Hello, World!");? I'm not connecting these individual parts with their definitions.
Markus Kiili
@Masd925
Mar 07 2017 07:26
@kesavage The Document interface represents any web page loaded in the browser and serves as an entry point into the web page's content. Write is a method and "Hello, World!" a string literal passed as an argument to write method.
Kishan Khakhar
@kishankhakhar
Mar 07 2017 07:27

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

// Only change code below this line
var result = {
"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");

what is the problem in this code?
Manish Giri
@Manish-Giri
Mar 07 2017 07:28
@kishankhakhar what are you supposed to return?
Kishan Khakhar
@kishankhakhar
Mar 07 2017 07:29
the value to corresponding to called value in the lookup table?
kesavage
@kesavage
Mar 07 2017 07:29
I got write is a method and what's between the parentheses is a string. What's in front of the period is called a ___?
Manish Giri
@Manish-Giri
Mar 07 2017 07:30
and what are you returning? @kishankhakhar
Kishan Khakhar
@kishankhakhar
Mar 07 2017 07:30
i m returning that value that is result
i suppose
Manish Giri
@Manish-Giri
Mar 07 2017 07:31
@kesavage it's usually an object.
@kishankhakhar you're returning the whole object itself.
Kishan Khakhar
@kishankhakhar
Mar 07 2017 07:31
what do i need to return?
Manish Giri
@Manish-Giri
Mar 07 2017 07:32
the value to corresponding to called value in the lookup table?
kesavage
@kesavage
Mar 07 2017 07:32
Cool. Thanks.
Kishan Khakhar
@kishankhakhar
Mar 07 2017 07:32
and also it says i m not supposed to change the code below that line
i.e. i m not supposed to change the return value
i think i found the mistake
thanks @Manish-Giri
CamperBot
@camperbot
Mar 07 2017 07:33
kishankhakhar sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: kishankhakhar already gave manish-giri points
Spyrantis Theodoros
@thodorisanta
Mar 07 2017 07:47
which one of the following projects should i start first? like which one is easier or more simple than the others?

Build a Pomodoro Clock Incomplete   *

Build a Tic Tac Toe Game Incomplete   *

Build a Simon Game Incomplete   *
Prerit Mittal
@PreritM
Mar 07 2017 07:49
Hi, could somebody please tell me where am I going wrong here:

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = "apple";
break;
case b:
answer = "bird";
break;
case c:
answer = "cat";
break;
default:
answer = "stuff";
}

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

Markus Kiili
@Masd925
Mar 07 2017 07:50
@PreritM If you are checking val being "a" you need the quotes there.
Prerit Mittal
@PreritM
Mar 07 2017 07:50
thank you Markus :)
Nanang Hidayat
@nanankhidayat
Mar 07 2017 08:11
hi any idea how to solve "counting card" ?
Kamal
@kpbro
Mar 07 2017 08:12
@nanankhidayat yes
Post here code
Jor
@joreyesl
Mar 07 2017 08:13
@nanankhidayat series of if else if statements or a switch to check the card value and update count appropriately. Then use an if statement to check the count value and return the appropriate return message.
Nanang Hidayat
@nanankhidayat
Mar 07 2017 08:14

var count = 0;

function cc(card) {
// Only change code below this line
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
return "5 Bet";
break;

case 7:
case 8:
case 9:
  return "Hold";
  break;

case 10:
case "J":
case "Q":
case "K":
  return "Bet";
  break;

}

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(7); cc(8); cc(9); cc(); cc();

Kamal
@kpbro
Mar 07 2017 08:15
@nanankhidayat you have to increment or decrement counter in switch case
Markus Kiili
@Masd925
Mar 07 2017 08:15
@nanankhidayat The code should have two parts. card changes count, and count determines the return value. So no retuns inside switch.
Jor
@joreyesl
Mar 07 2017 08:15
@nanankhidayat the switch should not be returning anything. it should increment/decrement count depending on the case.
Nanang Hidayat
@nanankhidayat
Mar 07 2017 08:16
ok i try it
055IRI5
@055IRI5
Mar 07 2017 08:22
hi guys
can someone help me am stuck on "Comparison with the Greater Than Operator"
Kamal
@kpbro
Mar 07 2017 08:25
@055IRI5 yea sure. What is problem?
Aliaksandr Falkouski
@falk42
Mar 07 2017 08:29
hi guys, i need to help. In FCC work String.fromCodePoint() ?
Kamal
@kpbro
Mar 07 2017 08:30
Idk that
That is not completed yet.
Jor
@joreyesl
Mar 07 2017 08:45
@falk42 you should be able to use String.fromCharCode() but String.fromCodePoint() will work too
Pieter Stokkink
@forkerino
Mar 07 2017 09:18
morning
Alex
@Joshua-A-Smith
Mar 07 2017 09:18
@055IRI5
The insructions were confusing...

function testGreaterThan(val) {
  if (val > 100) {  // Change this line
    return "Over 100";
  }

  if (val > 10) {  // Change this line
    return "Over 10";
  }

  return "10 or Under";
}

// Change this value to test
testGreaterThan(10);
WiseKodama
@WiseKodama
Mar 07 2017 09:20
@forkerino morning
WiseKodama
@WiseKodama
Mar 07 2017 09:26
If anyone has time to check through my tictactoe game and explain why multiplayer is not working, let me know. Thank you
vaishnavi prasad
@vaishnaviprasad
Mar 07 2017 09:47
@vaishnaviprasad
Is any body here familiar with keystone js?
http://keystonejs.com/
achudoz
@achudoz
Mar 07 2017 09:47
Hi, I am doing the AA challenge "Exact Change" and started off by making a loop that counts all the change. However the loop, instead of returning 335.41, returns 335.40999999999997. It will be an easy fix, but I am wondering why it is so. Did I just encounter the floating point number sorcery?
Pieter Stokkink
@forkerino
Mar 07 2017 09:50
@achudoz yes, the problem is that many floating points cannot be represented properly in binary. So you will have to round everything at the end.
nowled
@nowled
Mar 07 2017 09:50
Hello I am a little frustrated could anyone tell me what is wrong with this code:

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

   default:

// Only change code above this line
return answer;
}
}
// Change this value to test
caseInSwitch(1);

Pieter Stokkink
@forkerino
Mar 07 2017 09:51
@nowled this: case caseInSwitch(4): and the closing bracket of your switch should be before the return statement.
Jor
@joreyesl
Mar 07 2017 09:52
@achudoz I would suggest you multiple everything by 100 and do your calculations this way, this will help avoid floating point rounding errors. Then at the end when you are ready to return the answer, you just divide everything by 100.
achudoz
@achudoz
Mar 07 2017 09:52
@forkerino awesome. I thought that the problems with FP numbers emerge only in some really complex stuff with huge numbers
Pieter Stokkink
@forkerino
Mar 07 2017 09:52
@achudoz it is as simple as adding 0.1 to 0.2 :(
nowled
@nowled
Mar 07 2017 09:53
THank you Pieter Stokkink, fresh eyes always helps
Pieter Stokkink
@forkerino
Mar 07 2017 09:53
:+1:
achudoz
@achudoz
Mar 07 2017 09:54
@joreyesl yeah for this exercise, where the array of numbers is pretty small, I just added Math.floor(count*100+0.5)/100. I know that when adding more numbers, it would be a problem, but whatevs. As long as I realize it, it should be ok
Pieter Stokkink
@forkerino
Mar 07 2017 09:55
@achudoz to be clear, multiplying everything by 100 is probably a better way to deal with it than Math.round or .toFixed or something. But for this exercise both work.
Eyej
@Eyej
Mar 07 2017 09:55

hi, i need some help with counting cards, Pls see my code below

function cc(card) {
// Only change code below this line
var count = 0;
var answer="";
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count= +1;
answer= "Bet";
break;

  case 10:
case 'J':
case 'Q':
  case'K':
case 'A':
  count= -1;
  answer="Hold";
  break;

}

return "count answer";
// 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');

Pieter Stokkink
@forkerino
Mar 07 2017 09:57
@Eyej you have to separate the part where you alter count from the part where you decide what to return (the answer). After altering count, do a check to see if it is bigger than 0 or not and return the count and proper advice.
Also, for this exercise it is important to keep var count = 0; outside of your function.
Cookies to the one that can tell me why PvP behaves like that
achudoz
@achudoz
Mar 07 2017 09:57
@forkerino I just have an unreasonable love for the Math.round(x+0.5) method. It was one of the first solutions that I came up with all by myself in the first days of learning, so I use it here whenever I know it will be sufficient :D
Dan Couper
@DanCouper
Mar 07 2017 09:58
@achudoz it appears with any FP calculation because He only has one number type, which is FP. Basically, never use FP for money, ever (it only causes problems - for example a few of the bitcoin exchanges used FP in their calculations, which inevitably caused incorrect calculations, still causing fallout now), and as it's unavoidable in JS, always multiply by 100
achudoz
@achudoz
Mar 07 2017 09:58
*math floor i mean
Sonja
@sonjaSch
Mar 07 2017 09:58
@Masd925 hey I want to send browniepoints to you :smile: thx
CamperBot
@camperbot
Mar 07 2017 09:58
sonjasch sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3527 | @masd925 |http://www.freecodecamp.com/masd925
Dan Couper
@DanCouper
Mar 07 2017 09:58
*JS, not He, autocorrect
Nathan Vu
@NathanVu
Mar 07 2017 10:00

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

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

I have this down so far. What am I doing wrong? function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
celsius * 9/5 + 32;

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

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

Markus Kiili
@Masd925
Mar 07 2017 10:01
@sonjaSch What did I do ;)
Pieter Stokkink
@forkerino
Mar 07 2017 10:01
@NathanVu almost there. you have to assign the result of the formula to fahrenheit

Use the variable fahrenheit already defined and apply the algorithm to assign it the corresponding temperature in Fahrenheit

That's what that means.

Sonja
@sonjaSch
Mar 07 2017 10:03
@Masd925 I solved the Roman numeral Converter you gave me a hint yesterday :wink:
achudoz
@achudoz
Mar 07 2017 10:04
@DanCouper I was thinking more of a sending astronauts along a wrong vectors at wrong speeds, but your example is probably better. I will just use the Math.floor(x+0.5) method here for the last time and then I will follow your advice religiously
Markus Kiili
@Masd925
Mar 07 2017 10:04
@sonjaSch ok :+1:
Hughy
@HMDuDe
Mar 07 2017 10:07

Hi all can anyone help me out with this Javascript, I've been struggling for a few days now. The Instruction is: 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. (The code given is:)function nextInLine(arr, item) {
// Your code here

return item; // Change this line
}

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

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

I've tried multiple things and just can't get it right :worried:
h1tag
@h1tag
Mar 07 2017 10:10
@HMDuDe review push() and shift()
Markus Kiili
@Masd925
Mar 07 2017 10:10
and shift()
Eyej
@Eyej
Mar 07 2017 10:11
@HMDuDe You have to put item into the arr ie arr.push(item);
WiseKodama
@WiseKodama
Mar 07 2017 10:11
you push the given element
then you arr.shift()
Hughy
@HMDuDe
Mar 07 2017 10:11
@fortMaximus I've tried that by saying inside the function block: testArr.pop(arr).push(item);
WiseKodama
@WiseKodama
Mar 07 2017 10:12
and finally return the one you shifted
You cant chain them
testArr.push(item);
Markus Kiili
@Masd925
Mar 07 2017 10:12
@HMDuDe Don't use testArr, just arr and item.
WiseKodama
@WiseKodama
Mar 07 2017 10:12
oh yeah arr is given
arr.push(item);
return arr.shift();
is that everything?
Hughy
@HMDuDe
Mar 07 2017 10:15
@WiseKodama thanks so much you were very helpful, it worked now
CamperBot
@camperbot
Mar 07 2017 10:15
:cookie: 310 | @wisekodama |http://www.freecodecamp.com/wisekodama
hmdude sends brownie points to @wisekodama :sparkles: :thumbsup: :sparkles:
WiseKodama
@WiseKodama
Mar 07 2017 10:15
@HMDuDe No worries at all :)
Hughy
@HMDuDe
Mar 07 2017 10:15
@Masd925 Thanks, you also helped a lot!
CamperBot
@camperbot
Mar 07 2017 10:15
hmdude sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3528 | @masd925 |http://www.freecodecamp.com/masd925
WiseKodama
@WiseKodama
Mar 07 2017 10:15
I am stuck with my TTT anyway, waiting if anyone can help...
Markus Kiili
@Masd925
Mar 07 2017 10:20
@WiseKodama That is it.
WiseKodama
@WiseKodama
Mar 07 2017 10:20
:+1:
@Masd925 Any chance you can look at my TTT project and maybe figure out why PvP isn't working?
Ben Carp
@carpben
Mar 07 2017 10:24
In the Spinal Tap challenge I'm having a difficult time figuring out how to replace the sequence space followed by a capital letter with the sequence - folloed by the same small letter. Any suggestions?
Markus Kiili
@Masd925
Mar 07 2017 10:24
@WiseKodama Sorry, too busy at work.
WiseKodama
@WiseKodama
Mar 07 2017 10:24
No worries
Robert J Barbush
@rjbarbush
Mar 07 2017 10:27
Hey I'm stuck on Testing Objects for Properties. Do I use if/else to solve this?
Markus Kiili
@Masd925
Mar 07 2017 10:28
@rjbarbush Yes.
Robert J Barbush
@rjbarbush
Mar 07 2017 10:28
Thanks
WiseKodama
@WiseKodama
Mar 07 2017 10:28
@carpben I think what I did is that first off all set the first letter to lowercase
Then I replaced spaces and _ with dashes
and then I found all the other uppercase letters and replaced them with a dash and lowercase letter
finally I got rid of any double dashes
Baz86
@Baz86
Mar 07 2017 10:39
Can anyone help me with the converting Celcius to Fahrenheit challenge?
here is my code
var remainder = 9 % 5;
var myVar = remainder + 32;
fahrenheit = convertToF * myVar;
Pieter Stokkink
@forkerino
Mar 07 2017 10:40
@Baz86 why in the world would you use a remainder?
WiseKodama
@WiseKodama
Mar 07 2017 10:41
its 9/5
divided
Baz86
@Baz86
Mar 07 2017 10:41
because the equation for Fahrenheit is Celsius times 9/5 plus 32
Pieter Stokkink
@forkerino
Mar 07 2017 10:41
@Baz86 yeah / is not a remainder
it is division
WiseKodama
@WiseKodama
Mar 07 2017 10:41
so fahrenheit = convertToF*(9/5)+32;
9%5 is 4
Pieter Stokkink
@forkerino
Mar 07 2017 10:42
NOOO!
convertToF is the function name
WiseKodama
@WiseKodama
Mar 07 2017 10:42
Oh my bad :)
Pieter Stokkink
@forkerino
Mar 07 2017 10:42
hahaha
WiseKodama
@WiseKodama
Mar 07 2017 10:42
That's what he had written
didn't check what it was
Pieter Stokkink
@forkerino
Mar 07 2017 10:42
yeah, just take it one line at a time. :)
Jacoby Dueck
@dueckjp
Mar 07 2017 10:42
can somoen helpme

function testGreaterThan(val) {
if (val 101 > 100); { // Change this line
return "Over 100";
}

if (val 11 > 10) { // Change this line
return "Over 10";
}

return "10 or Under";
}

// Change this value to test
testGreaterThan(10);

thats what i have
my instrutions are to Add the greater than operator to the indicated lines so that the return statements make sense.
Pieter Stokkink
@forkerino
Mar 07 2017 10:43
@dueckjp what is 101 and 11 doing there?
WiseKodama
@WiseKodama
Mar 07 2017 10:43
@Baz86 grab the celsius amount and multiply by (9/5) and just add 32
Jacoby Dueck
@dueckjp
Mar 07 2017 10:43

function testGreaterThan(val) {
if (val 100 > 100); { // Change this line
return "Over 100";
}

if (val 10 > 10) { // Change this line
return "Over 10";
}

return "10 or Under";
}

// Change this value to test
testGreaterThan(10);

Pieter Stokkink
@forkerino
Mar 07 2017 10:43
ie what is val 101
WiseKodama
@WiseKodama
Mar 07 2017 10:43
That will be your farhrenheit
Pieter Stokkink
@forkerino
Mar 07 2017 10:44
@dueckjp what is val 100
?
I can go on
@dueckjp just compare val to a number
don't add extra numbers
Jacoby Dueck
@dueckjp
Mar 07 2017 10:44

function testGreaterThan(val) {
if (val) {100 > 100; // Change this line
return "Over 100";
}

if (val) {10 > 10; // Change this line
return "Over 10";
}

return "10 or Under";
}

// Change this value to test
testGreaterThan(10);

ok hows this?
Pieter Stokkink
@forkerino
Mar 07 2017 10:44
worse
much worse
:(
how would you write val is greater than 1 in JS
?
Jacoby Dueck
@dueckjp
Mar 07 2017 10:45

function testGreaterThan(val) {
if (val > 100) { // Change this line
return "Over 100";
}

if (val > 10) { // Change this line
return "Over 10";
}

return "10 or Under";
}

// Change this value to test
testGreaterThan(10);

Thomas Faller
@thomasfaller
Mar 07 2017 10:45
Hey guys, I'm trying to set a function where an ellipse is created while hovering with my mouse, but the shapes are coming up super fast. I'm trying to slow it down with a setTimeout method but it's not working. I'm probably using that wrong, it's supposed to call the function again but I just want to slow the loop down here :)
function draw() {
  var w = Math.floor((Math.random() * 175)+55);
  var h = Math.floor((Math.random() * 45)+15);
  ellipse(mouseX, mouseY, w, h);
  setTimeout(draw(), 5000);
}
Pieter Stokkink
@forkerino
Mar 07 2017 10:45
@dueckjp there we go
Jacoby Dueck
@dueckjp
Mar 07 2017 10:46
oh i got it thanks
Thomas Faller
@thomasfaller
Mar 07 2017 10:46
(and yeah that looks like a pile of dishes-generator aha)
Jacob
@jaqobk
Mar 07 2017 10:46
if(val>100) not val 100>100
Baz86
@Baz86
Mar 07 2017 10:46
Cheers @WiseKodama!
That was the one
overthinking it
WiseKodama
@WiseKodama
Mar 07 2017 10:47
@Baz86 We all did :) Glad you got it working
Pieter Stokkink
@forkerino
Mar 07 2017 10:47
@thomasfaller you probably have an eventlistener firing of draw again and again.
WiseKodama
@WiseKodama
Mar 07 2017 10:48
@thomasfaller why dod you have setTimeout inside your draw function?
is that ok? @forkerino
Pieter Stokkink
@forkerino
Mar 07 2017 10:48
not super useful if draw is called multiple times
@thomasfaller One idea is to remove the eventListener until the user stops hovering
WiseKodama
@WiseKodama
Mar 07 2017 10:49
SHapes are coming superfast because the mousex and y is changing I would guess?
Pieter Stokkink
@forkerino
Mar 07 2017 10:50
yup
and hover event is triggered upon every move
probably
have to see more code to be 100% sure
WiseKodama
@WiseKodama
Mar 07 2017 10:50
I can't help more since I am not sure what he wants to do to exactly
Baaah, I am going to lose my mind with this bloody TTT...
Thomas Faller
@thomasfaller
Mar 07 2017 10:53

@forkerino @WiseKodama That's the whole thing here:

function setup() {
    createCanvas(600, 600);
}


function draw() {
  var w = Math.floor((Math.random() * 175)+55);
  var h = Math.floor((Math.random() * 45)+15);
  ellipse(mouseX, mouseY, w, h);
  setTimeout(draw(), 5000);
}

function mousePressed() {
  clear();
}

Ideally I would like it to "pick" the mouse coordinate a little slower but I'm not sure the ellipse method can be slowed down at all ... btw this is p5.js (https://p5js.org/)

I just added a mousePressed function after the draw() so I can reset the canvas
WiseKodama
@WiseKodama
Mar 07 2017 10:54
@thomasfaller What are you trying to achieve exactly? Is it supposed to draw only one elipse?
Because once you move the mouse the coordinates change and it needs to redraw I guess
Thomas Faller
@thomasfaller
Mar 07 2017 10:55
not just one, was just trying to see if I could have it draw one every 1 or 2 sec instead of every framecount if that makes sense, it's just me fooling around and trying to get the geist of that :D
WiseKodama
@WiseKodama
Mar 07 2017 10:55
Hmmm ok
setInterval(draw(),1000)
Try that?
Calls the function every 1000 miliseconds
Thomas Faller
@thomasfaller
Mar 07 2017 10:56
oh will try that
Do something like this var drawHover = setInterval(draw(),1000);
and on mouse click you can do clearInterval(drawHover);
Tiago Pereira
@TiagoX9
Mar 07 2017 10:59
Hey there. It says that this is wrong "myMusic1 should contain a release_year property which is a number"

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

},

{"artist": "Korn",
"title": "Life is Peachy",
"release year": 1998,
"formats": [
"CS",
"CD",
"DVD"
],
"gold": true,

}

];

it was missing the underscore
got it
Thomas Faller
@thomasfaller
Mar 07 2017 11:01
@WiseKodama Thanks!
WiseKodama
@WiseKodama
Mar 07 2017 11:01
@thomasfaller No worries at all :)
Now draw those elipses you mad elipse drawing coder
:smile:
Eyej
@Eyej
Mar 07 2017 11:03

Hey @forkerino, I'm still stuck , can u pls point out the error and correction?
var count = 0;

function cc(card) {
// Only change code below this line
var result="";
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count= + 1;
break;

case 10:
case 'J':
case 'Q':
  case'K':
case 'A':