These are chat archives for FreeCodeCamp/HelpJavaScript

18th
Jun 2017
Frank McCroy
@fmccroy
Jun 18 2017 00:01

@PingwinZloty I have:

if (navigator.geolocation){
 navigator.geolocation.getCurrentPosition(function(position)
 {
  $("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);

  });
  }

And it doesn’t give any errors so far.

Diego Mayer
@Chrono79
Jun 18 2017 00:01
@PingwinZloty try some ip geolocation api if native browser geoloction doesn't work, keep in mind accuracy isn't all that good that way
Frank McCroy
@fmccroy
Jun 18 2017 00:02
Under html it uses: <p id="data"></p>
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:02
Hmm, I'm not certain if it doesn't run because of me. Can you guys check my project out and see if it works on your end? @fmccroy I'm going to see if mines is different from yous.
Diego Mayer
@Chrono79
Jun 18 2017 00:03
@PingwinZloty works for me
Frank McCroy
@fmccroy
Jun 18 2017 00:03
And me, although it shows time zone, not really location.
KatSaldivar
@KatSaldivar
Jun 18 2017 00:04
Can someone help with my clock, please? https://codepen.io/KatSaldivar/pen/bRgMvw?editors=0011
Duffy125
@Duffy125
Jun 18 2017 00:04
I feel that I off on this. Should I run LookupProfile under one big IF? and search for firstname and if yes then look for prop? That I started with:
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 1; i> firstName.length; i++){
for (var j = 0;j>prop[i].length; j++)
var find = contacts.firstName[i][j];
}
if
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:05
@fmccroy I can only get the date lol. But if I actually run it from within gitter it works, but not natively in codepen which is odd. Hm
Curtis Turner
@curtis-turner
Jun 18 2017 00:06
hello all can any one offer some help with the Build A Random Quote Machine challenge?
Frank McCroy
@fmccroy
Jun 18 2017 00:06
@PingwinZloty Hmm.. when you run it, do you get a request to use your geolocation? I do, and have to accept it, then the code runs.
Diego Mayer
@Chrono79
Jun 18 2017 00:06
@Duffy125 your loops are wrong, and you only need 1
You need your loop to run through contacts array
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:06
@fmccroy I don't.
@fmccroy I'm trying this on chrome.
Paul Christian L. Catoera
@poncatoera
Jun 18 2017 00:07

function truncateString(str, num) {
  // Clear out that junk in your trunk
  var sliced = "";
  if (str.length > num) {
   sliced = str.slice(0, num - 3) + "...";
  } else { sliced = str.slice(0, num) + "...";

  } return sliced;
}

truncateString("A-", 1);
Frank McCroy
@fmccroy
Jun 18 2017 00:07
@PingwinZloty Possibly it is a setting with your browser, or you disallowed it permanently at some point
Paul Christian L. Catoera
@poncatoera
Jun 18 2017 00:07
i dont understand why this doesnt work
can anyone help?
Duffy125
@Duffy125
Jun 18 2017 00:07
yeah I need to look this over again
Diego Mayer
@Chrono79
Jun 18 2017 00:08
@poncatoera you need to check num against 3 don't you?
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:08
@fmccroy and @Chrono79 Alright, I'm convinced that is is an issue on my browser, thanks for the feedback guys.
CamperBot
@camperbot
Jun 18 2017 00:08
pingwinzloty sends brownie points to @fmccroy and @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 352 | @fmccroy |http://www.freecodecamp.com/fmccroy
:star2: 4318 | @chrono79 |http://www.freecodecamp.com/chrono79
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:08
Just had to make sure that it was working properly.
Diego Mayer
@Chrono79
Jun 18 2017 00:08
:+1:
Frank McCroy
@fmccroy
Jun 18 2017 00:08
@PingwinZloty Your picture is beautiful BTW, and did it wokr under Chrome?
Paul Christian L. Catoera
@poncatoera
Jun 18 2017 00:08
@Chrono79 isnt 3 included in else coz its not greater than num?
or did i not get what you meant?
Diego Mayer
@Chrono79
Jun 18 2017 00:09

@poncatoera
Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.

Note that inserting the three dots to the end will add to the string length.

However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.

you have to check 2 things, string being greater than num and num being less or equal than 3, if it is, you do one thing, if it isn't yo do another thing
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:10
@fmccroy It doesn't work under Chrome or Firefox for me, but I'm on a Linux machine so it could be some kind of security feature on this OS that is preventing me from utilizing geolocation.
Paul Christian L. Catoera
@poncatoera
Jun 18 2017 00:10
right, so i used if > then else.
isnt it correct?
Diego Mayer
@Chrono79
Jun 18 2017 00:10

no, you need nested ifs

if (first condition) {
  if (second condition) {
  else {} // of the second condition
} else {} // of the first condition

Something like that

Paul Christian L. Catoera
@poncatoera
Jun 18 2017 00:11
ohh
ill try thanks @Chrono79
CamperBot
@camperbot
Jun 18 2017 00:11
poncatoera sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4319 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 18 2017 00:12
:+1:
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:12
@fmccroy If you like the picture, you can have any high definition image completely encompass your background. Check out the .bg-image ID to see how to do that via CSS. Its a pretty cool effect.
Holyloch
@Holyloch
Jun 18 2017 00:16
Coy, Better explination. if test is 2 then (a) would have to be 4, if test is 8 then (b) would be 64
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:18

hello everyone!... what's wrong with this function ====> function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++) {
if(contacts[i].hasOwnProperty(firstName)) {
if(contacts[i].hasOwnProperty(prop)) {
return contacts[i].prop;
}
else {
return "No such property";
}
}
}
return "No such contact";

// Only change code above this line
}

Johnny O'Sullivan
@johnnyosullivan
Jun 18 2017 00:19
So...right now I'm trying to use a for loop for my Longest Word in a String challenge, but it's exiting when it comes to the first example of my condition. Obviously, I need to change the condition. Anybody in here with the patience to talk me through my lack of skill?
function findLongestWord(str) {
  var longArr = str.split(" ");
  for (var i = 0; i<longArr.length; i++){
    if (longArr[i].length < longArr[i++].length){
      return longArr[i++];
    } else {
      return longArr[i];
    }
  }
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:20
by the way is there any tag to properly embed code in here?
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:20
@johnnyosullivan Since you are scanning the next element ahead of the iterator, you need to change you condition to:
i < longArr.length-1
Also, you don't want to do [i++] instead you'll want to do [i+1]
Chaitanya Giri
@chaitanyagiri
Jun 18 2017 00:21
Hey can someone help me with setTimeout() and for loop.
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:21
I'm saying this because once you reach the end of iteration, there will be a compairson of the last element in str being compared to a value of undefined.
Diego Mayer
@Chrono79
Jun 18 2017 00:22
@johnnyosullivan don't return inside the loop, that'll prevent it from running more than once (the way you have it)
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:22
@johnnyosullivan So give those two things a try.
lol, and that as well, you are returning inside of the loop.
captainkent
@captainkent
Jun 18 2017 00:23
Hey guys, I need some help with the "Return Largest Numbers in Arrays" challenge. I managed to find the largest number in each array, displayed it, etc. But I'm missing one condition because one of the arrays has a smaller max. number than the previous array.
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:23
@captainkent Show da code!
Diego Mayer
@Chrono79
Jun 18 2017 00:23
@zentech click more info below
CamperBot
@camperbot
Jun 18 2017 00:23
:bulb: to format code use backticks! ``` more info
Diego Mayer
@Chrono79
Jun 18 2017 00:24
it's
```js
your code
```
captainkent
@captainkent
Jun 18 2017 00:24

function largestOfFour(arr) {
  // You can do this!
  var largest = 0;
  var largestSubArr = [];

  for(var i=0;i<arr.length;i++){
    for(var j=0;j<arr[i].length;j++){
      if(arr[i][j] > largest) {
        largest = arr[i][j];
        largestSubArr[i] = largest;
      }
    }
  }
  return largestSubArr;
}

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:24
@Chrono79 thanks...
CamperBot
@camperbot
Jun 18 2017 00:24
zentech sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4320 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 18 2017 00:25
@captainkent you need to reset largest for each subarray
captainkent
@captainkent
Jun 18 2017 00:25
It returns [27,null,39,1001].
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:25

@Chrono79 can you take a look at this function and maybe you can tell me what's wrong ```js function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++) {
if(contacts[i].hasOwnProperty(firstName)) {
if(contacts[i].hasOwnProperty(prop)) {
return contacts[i].prop;
}
else {
return "No such property";
}
}
}
return "No such contact";

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

Diego Mayer
@Chrono79
Jun 18 2017 00:25
sure
captainkent
@captainkent
Jun 18 2017 00:25
I figured it was that, but I'm not sure where. I kept getting strange results, but I'll check it out again!
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:26
ups didn't work (wrong formatting)
Diego Mayer
@Chrono79
Jun 18 2017 00:26
@zentech leave the ``` in their own line (use shift+enter to do a carriage-return)
to edit your posts, click the ... right of the post time -> Edit
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:26
@Chrono79 got it
function lookUpProfile(firstName, prop){
// Only change code below this line
  for(var i = 0; i < contacts.length; i++) {
    if(contacts[i].hasOwnProperty(firstName)) {
    if(contacts[i].hasOwnProperty(prop)) {
      return contacts[i].prop;
    }
    else {
      return "No such property";
    }  
}
}
return "No such contact";

// Only change code above this line
}
captainkent
@captainkent
Jun 18 2017 00:27
@Chrono79 I figured it out! I'm a plonker, cheers for the help/
Diego Mayer
@Chrono79
Jun 18 2017 00:27
:+1:
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:27
jajaja
Diego Mayer
@Chrono79
Jun 18 2017 00:28
@zentech you need to compare the firstName property against the firstName function param
and you can't use dot notation with vars
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:28
contacts[i].firstName == firstName
Diego Mayer
@Chrono79
Jun 18 2017 00:28
yes
captainkent
@captainkent
Jun 18 2017 00:29
@zentech Exactly how I did it to :D
Diego Mayer
@Chrono79
Jun 18 2017 00:29
instead of your first if, that's checking for a property named "John" (that doesn't exist)
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:29
@Chrono79 thanks
CamperBot
@camperbot
Jun 18 2017 00:29
zentech sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: zentech already gave chrono79 points
Johnny O'Sullivan
@johnnyosullivan
Jun 18 2017 00:30
@PingwinZloty @Chrono79 thanks
CamperBot
@camperbot
Jun 18 2017 00:30
johnnyosullivan sends brownie points to @pingwinzloty and @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: @pingwinzloty's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
:star2: 4321 | @chrono79 |http://www.freecodecamp.com/chrono79
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:33
still not working
```js
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:33
You need to add ``` under
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:33
function lookUpProfile(firstName, prop){
// Only change code below this line
  for(var i = 0; i < contacts.length; i++) {
    if(contacts[i].firstName == firstName) {
    if(contacts[i].prop == prop) {
      return contacts[i].prop;
    }
    else {
      return "No such property";
    }  
}
}
return "No such contact";

// Only change code above this line
}
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:33
oh lol
woops
@zentech You forgot to access by [] instead of dot notation because its a parameter.
For instance: contacts[i][prop]
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:35
arrrr @PingwinZloty thanks... can't get the . notation from java out of my mind
CamperBot
@camperbot
Jun 18 2017 00:35
zentech sends brownie points to @pingwinzloty :sparkles: :thumbsup: :sparkles:
:warning: @pingwinzloty's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:36

still not working ```js
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++) {
if(contacts[i][firstName] == firstName) {
if(contacts[i][prop] == prop) {
return contacts[i][prop];
}
else {
return "No such property";
}
}
}
return "No such contact";

// Only change code above this line
}

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

// Only change code above this line
}
Johnny O'Sullivan
@johnnyosullivan
Jun 18 2017 00:38
Any closer? Not sure if I followed your advice correctly or not.
function findLongestWord(str) {
  var longArr = str.split(" ");
  var long;
  for (var i = 0; i<longArr.length-1; i++){
    if (longArr[i].length < longArr[i+1].length){
      long = longArr[i+1].length;
    } else {
      long = longArr[i].length;
    }
  }
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:39
so when should I use dot notation and bracket notation when accessing properties of an object?
Diego Mayer
@Chrono79
Jun 18 2017 00:39
@johnnyosullivan only overwrite long when the current word length is greater than long
You should initialize long
and your function should return
@zentech myObj.property is the same as myObj["property"]
with vars you have to use bracket notation and also when the property name contains a space you should also use bracket notation
Johnny O'Sullivan
@johnnyosullivan
Jun 18 2017 00:41
@Chrono79 I think I understand what you mean.
Duffy125
@Duffy125
Jun 18 2017 00:41
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i =0 ; i< contacts.length; i++){
if (contacts.firstName === firstName[i]){
if (contacts.hasOwnProperty (prop)){
return contact[i][prop];
}else {
return "no such property";
}
}
}
return "No such contact";
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:41
@Chrono79 I know.. so why when I use contacts[i].prop doesn't work?
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:41
you would use bracket notation when the property is a parameter/variable or if the string has a space in it ['this must use bracket']
Diego Mayer
@Chrono79
Jun 18 2017 00:42
@zentech no contact has a "prop" property
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:42
got it... it's a var and has to be used within [] brackets
Diego Mayer
@Chrono79
Jun 18 2017 00:42
exactly
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:42
it needs to be substituted!!!
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:43
But wait a second, he has to check if those exist right? Shouldn't he use .hasOwnProperty()?
Diego Mayer
@Chrono79
Jun 18 2017 00:43
@Duffy125 to access a single contact, you have to use contacts[i]
Check the strings you return too
Duffy125
@Duffy125
Jun 18 2017 00:43
ok thanks
Diego Mayer
@Chrono79
Jun 18 2017 00:44
@PingwinZloty only with prop there, all those contacts have a firstName property
NicholasGalarza
@NicholasGalarza
Jun 18 2017 00:45
Yeah, I'm trying to find out which challenge that was lol
Diego Mayer
@Chrono79
Jun 18 2017 00:45
@zentech contacts[i][prop] == prop this isn't right (and won't ever be true unless a property has the same name/value pair)
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:46
@Chrono79 what's the prop way? ;0)
okk I'm using hasOwnProperty, but still not working
function lookUpProfile(firstName, prop){
// Only change code below this line
  for(var i = 0; i < contacts.length; i++) {
    if(contacts[i][firstName] == firstName) {
    if(contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
    else {
      return "No such property";
    }  
}
}
return "No such contact";

// Only change code above this line
}
Diego Mayer
@Chrono79
Jun 18 2017 00:47
show your current code
@zentech contacts[i][firstName] this isn't right, don't use bracket notation there or add quotes, you want to test "firstName" property, not "John" property
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:48
contacts[i].firstName?
Diego Mayer
@Chrono79
Jun 18 2017 00:48
yes
MysticalSloth
@MysticalSloth
Jun 18 2017 00:49
fgfg.png
hey guys could you help me
my code doesnt return anything
Diego Mayer
@Chrono79
Jun 18 2017 00:50
@MysticalSloth use only one loop, for contacts array, you don't need another
Jorge Luis Vazquez
@zentech
Jun 18 2017 00:50
thanks all ... got it working. Is anybody here completed the frontend dev certicate already?
MysticalSloth
@MysticalSloth
Jun 18 2017 00:50
oh ok
ill try it
MysticalSloth
@MysticalSloth
Jun 18 2017 00:55
Worked!
thanks
CallMeOrange
@EgnaroDev
Jun 18 2017 00:57
@zentech why?
Dovydas Stirpeika
@Giveback007
Jun 18 2017 00:59

hey peeps, I'm trying to do the react local environment setup

in the tutorial I'm fallowing this line I do not understand:
" entry point should be the outermost component class of your React project"

what does that mean, it's talking about webpack
Kyle Holm
@thekholm80
Jun 18 2017 01:00
@Giveback007 it means in the root directory of your project you should have a file designated the entry point
often named index.js or something similar
Simon Cordova
@gbsimon87
Jun 18 2017 01:01
Hey all! :)
Dovydas Stirpeika
@Giveback007
Jun 18 2017 01:02
@thekholm80 ahh I see tnx
CamperBot
@camperbot
Jun 18 2017 01:02
giveback007 sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1094 | @thekholm80 |http://www.freecodecamp.com/thekholm80
Manish Giri
@Manish-Giri
Jun 18 2017 01:07
@thekholm80 I have something that'll make you wana take a shower
Kyle Holm
@thekholm80
Jun 18 2017 01:08
nested ternaries?
Manish Giri
@Manish-Giri
Jun 18 2017 01:08
:smiling_imp:
Kyle Holm
@thekholm80
Jun 18 2017 01:09
i use em, but I don't like em
Manish Giri
@Manish-Giri
Jun 18 2017 01:09
this is just 1 level tho
function getMiddle(s) {
    //Code goes here!

   return s.length % 2 !== 0 ? s[parseInt(s.length / 2)] : s[(s.length /2) - 1] + s[s.length / 2];
}
Kyle Holm
@thekholm80
Jun 18 2017 01:10
have you used the &&?
Simon Cordova
@gbsimon87
Jun 18 2017 01:16
Hey guys, if anyone could help out...
var userInput = 'Lunch';
​
var meals = {  
  mealA: 'Breakfast',
  mealB: 'Lunch',
  mealC: 'Dinner'
};
​
// I'm looking for code that does the following...// if ( userInput is found as a value in one of the keys ) {
//  return that key which holds the userInput value
// }
Dan B
@DannnB
Jun 18 2017 01:23
Hey all, can anyone help point me in the right direction please with Profile Lookup? I'm getting there I think
function lookUpProfile(firstName, prop){
// Only change code below this line

  for(var i = 0; i < contacts.length; i++){
    console.log(contacts[i].firstName == firstName);

    if(contacts[i].firstName == firstName){
        console.log(contacts[i].firstName);
      if(contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop];
      }else {
        return "No such property";
      }
    }else{
      return "No such contact";
    }
  }

// Only change code above this line
}

// Change these values to test your function
// THIS WORKS
// lookUpProfile("Akira", "number");
// THIS DOSEN'T WORK
lookUpProfile("Sherlock", "likes");
Manish Giri
@Manish-Giri
Jun 18 2017 01:25
@DannnB return "No such contact"; - this is in your for loop
that's the problem
Dan B
@DannnB
Jun 18 2017 01:28
@Manish-Giri , I knew it would be something silly, sorry about that. Nice one, thanks for the help :D
CamperBot
@camperbot
Jun 18 2017 01:28
dannnb sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6020 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 18 2017 01:28
:+1:
Frank McCroy
@fmccroy
Jun 18 2017 01:31
How do I get my Weather app to run in the right order? It shows a console.log with my api URL, with the latitude and longitude undefined, when I haven’t even had time to click okay on allowing geodata.
ArchivalBoat50
@ArchivalBoat50
Jun 18 2017 01:37
Why is there nothing going on in the console when i search something up? https://codepen.io/ArchivalBoat50/pen/vZXpPg?editors=1010
Frank McCroy
@fmccroy
Jun 18 2017 01:39
@ArchivalBoat50 I get this error when I try to do a search: TypeError: "#searchTerm".val is not a function
Tai Jones
@taiJones00
Jun 18 2017 01:40
what are the methods that just modify but don't change anything
actually
Alexander Køpke
@alexanderkopke
Jun 18 2017 01:41
@ArchivalBoat50 there is a $ missing
ArchivalBoat50
@ArchivalBoat50
Jun 18 2017 01:42
@alexanderkopke @fmccroy Oh i see, thx guys
CamperBot
@camperbot
Jun 18 2017 01:42
archivalboat50 sends brownie points to @alexanderkopke and @fmccroy :sparkles: :thumbsup: :sparkles:
:star2: 1520 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
:cookie: 353 | @fmccroy |http://www.freecodecamp.com/fmccroy
Nick Danvers
@Ravenor222
Jun 18 2017 01:43
Hey guys, Im doing global scope and functions
Jonathan Mancia
@jonmancia
Jun 18 2017 01:43
Anyone know c++ here?
Simon Cordova
@gbsimon87
Jun 18 2017 01:43
@ArchivalBoat50 im getting output in the console
Nick Danvers
@Ravenor222
Jun 18 2017 01:43

// Declare your variable here

var myGlobal=("10");
function fun1() {
// Assign 5 to oopsGlobal Here

}
oopsGlobal= (5);

myGlobal is = to 10 in the console, however codecamp says "myGlobal should have a value of 10" any ideas
Alexander Køpke
@alexanderkopke
Jun 18 2017 01:45
@Ravenor222 "10" this is a string while 10 is a number.
Nick Danvers
@Ravenor222
Jun 18 2017 01:45
thank you sir
@alexanderkopke What a kind gentleman you are thank you
CamperBot
@camperbot
Jun 18 2017 01:46
ravenor222 sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1521 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Sunny Wong
@swong194
Jun 18 2017 01:46
@fmccroy hey
@fmccroy i think u need to pass the long and lat from the geolocation function onto where u want to pull information through the api
Alexander Køpke
@alexanderkopke
Jun 18 2017 01:49
@Ravenor222 np, but the oopsGlobal should go inside the function. And ( ) are not necessary. var myGlobal = 10; is sufficient.
Frank McCroy
@fmccroy
Jun 18 2017 01:49
I was trying to add it to the end of the URL, with: api = "https://crossorigin.me/https://api.darksky.net/forecast/37b20e267924f791637d860e18fb91b1/" + long + "," + lat; but I can’t tell if it ever worked, I don’t see anything on screen after the longitude and latitude were displayed. I get an invalid function call on console.log now as well
Nick Danvers
@Ravenor222
Jun 18 2017 01:50
@alexanderkopke Thank you
CamperBot
@camperbot
Jun 18 2017 01:50
ravenor222 sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:warning: ravenor222 already gave alexanderkopke points
Sunny Wong
@swong194
Jun 18 2017 01:50

@fmccroy if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
long = position.coords.longitude;
lat = position.coords.latitude;
pass(long,lat);
$("#data").html("latitude: " + lat + "<br>longitude: " + long);
});
}
// This is the end of the geolocation code

// This block of code accesses the darkysky api to get the weather info
function pass(long,lat){
api =
"https://crossorigin.me/https://api.darksky.net/forecast/37b20e267924f791637d860e18fb91b1/" +
long +
"," +
lat;
console.log(api);
}

@fmccroy this will return your longitude and latitude without the undefined
@fmccroy latittude and longitude are displaying fine on my computer with ur codepen code O__O
NMusey
@NMusey
Jun 18 2017 01:52

https://codepen.io/carnivalofcrows/pen/dRNKdX

Can anyone help with my location code in the javascript? It's a similar problem to @fmccroy but I think I did something wrong with the location object

Frank McCroy
@fmccroy
Jun 18 2017 01:53
@swong194 I will add in the pass function that you recommended. Longitude and latitude are the only things that will show for me, the last console.log was supposed to show something from the JSON data
Lance Ward
@Lanceward410
Jun 18 2017 01:54
Glenn Beck's Dreamers and Deceivers is a recommended read...
Sunny Wong
@swong194
Jun 18 2017 01:55
@fmccroy i think its the same problem again, you need to pass ur "api" into the function where u are accessing the JSON DATA
@fmccroy pass the api again to where you want JSON data and it should work, it worked for me
@fmccroy you can then just combine the functions if you want so you dont have to keep passing your variables ;]
@fmccroy i do hope u mean timezone
Cory Ramirez
@CoryARamirez
Jun 18 2017 01:57
Can anyone tell me why my "Repeat a string" challenge is failing? The correct output is in fact being returned:
function repeatStringNumTimes(str, num) {
  var newStr = "";
  var emptyStr = "";

  // repeat after me
  for (var i = 0; i < num; i ++) {
    newStr += str;
  }   
  if (num < 0) {
    return emptyStr;
  }
  else {
    return '\"' + newStr +'\"';
  }

}

repeatStringNumTimes("abc", 3);
Diego Mayer
@Chrono79
Jun 18 2017 02:01
@CoryARamirez don't return the quotes
And you don't need 2 vars, if the loop doesn't run, that happens when num <1, it'll return one empty string
Cory Ramirez
@CoryARamirez
Jun 18 2017 02:01
Tried that, it failed.
The output is expecting the quotes, that's why I added them. It's failing both ways.
Diego Mayer
@Chrono79
Jun 18 2017 02:02
no
Frank McCroy
@fmccroy
Jun 18 2017 02:02
@swong The console.log inside the pass function shows the correct value for api now, no more undefined at the end. So moving the $.getJSON part up should help it run as well?
Lance Ward
@Lanceward410
Jun 18 2017 02:03
@CoryARamirez Instead of an if/else statement within your for loop, just use the += operator to build newStr
Sunny Wong
@swong194
Jun 18 2017 02:03
@fmccroy yep, or u can create a new function to pass ur api
@fmccroy depends how u want to structure it, but thats basically it
Diego Mayer
@Chrono79
Jun 18 2017 02:03
@Lanceward410 the if/else is outside the loop
Cory Ramirez
@CoryARamirez
Jun 18 2017 02:03
@Chrono79 , @Lanceward410 I got it, I didn't add the else until after I already returned the strings, so removing them worked. Thanks for your help!
CamperBot
@camperbot
Jun 18 2017 02:03
coryaramirez sends brownie points to @chrono79 and @lanceward410 :sparkles: :thumbsup: :sparkles:
:cookie: 255 | @lanceward410 |http://www.freecodecamp.com/lanceward410
:star2: 4322 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 18 2017 02:04
:+1:
Lance Ward
@Lanceward410
Jun 18 2017 02:04
@CoryARamirez Oh I see. Yeah you don't need to do what you're doing in the if/else statement, try replacing it and just returning your new string
@CoryARamirez Oh sweet!
fdemaa
@fdemaa
Jun 18 2017 02:05
Once i find my pattern, how can i remove the pattern from my string?
Kyle Holm
@thekholm80
Jun 18 2017 02:05
replace() maybe?
Lance Ward
@Lanceward410
Jun 18 2017 02:05
@CoryARamirez Since you got it, I'll show you my rendition with a while statement:
function repeatStringNumTimes(str, num) {
  // repeat after me
var longstr = "";
  while (num > 0) {
    num--;
    longstr += str;
  }
  return longstr;
}

repeatStringNumTimes("abc", 3);
Frank McCroy
@fmccroy
Jun 18 2017 02:10
@swong194 Thank you for your help! Did adding in the function just slow the program down and make it execute in the proper order? It shows the timezone even though the result is not what I expected, I wanted: "America/New_York” to show.
CamperBot
@camperbot
Jun 18 2017 02:10
fmccroy sends brownie points to @swong194 :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @swong194 |http://www.freecodecamp.com/swong194
Sunny Wong
@swong194
Jun 18 2017 02:12
@fmccroy let me take a look
Frank McCroy
@fmccroy
Jun 18 2017 02:13
Chaitanya Giri
@chaitanyagiri
Jun 18 2017 02:15
Hey, can anyone tell me how to use setTimeout inside for loop. I am stuck in final project (simon game).
Frank McCroy
@fmccroy
Jun 18 2017 02:15
I may have switched the order of longitude and latitude, looking at the darsky comment I wrote at the bottm
Alexander Køpke
@alexanderkopke
Jun 18 2017 02:15
@fmccroy lat goes first then long
Frank McCroy
@fmccroy
Jun 18 2017 02:16
@alexanderkopke Just fixed it :)
Alexander Køpke
@alexanderkopke
Jun 18 2017 02:16
ah nice. Now I'm no longer in Asia :)
Sunny Wong
@swong194
Jun 18 2017 02:16
@alexanderkopke good catch (y)
Nick Danvers
@Ravenor222
Jun 18 2017 02:16
Hey guys, sorry to be a bother, just doing "queue" stand in line assignment
Alexander Køpke
@alexanderkopke
Jun 18 2017 02:17
although I've always wanted to visit Japan. I blew my one chance 8/
Sunny Wong
@swong194
Jun 18 2017 02:17
@fmccroy im not an expert so debugging takes a while for me XD
Nick Danvers
@Ravenor222
Jun 18 2017 02:17
Having trouble understanding the instructions
You missed on the best Ramen in the universe alexander
Frank McCroy
@fmccroy
Jun 18 2017 02:18
@Ravenor222 You need to add the item variable to the end of the array, and then remove the variable at the front of the array, while returning that number.
Nick Danvers
@Ravenor222
Jun 18 2017 02:19
var testArr = [1,2,3,4,5];
This array?
Insert item, and then remove the var?
Frank McCroy
@fmccroy
Jun 18 2017 02:20
Not testArr, that is how FCC runs your functions to test them, you don’t do anything with that. “arr” is your array. and “item” is what you push onto it.
Nick Danvers
@Ravenor222
Jun 18 2017 02:21
ok ty ill give it a go with what youve given me ty
@fmccroy thanks
CamperBot
@camperbot
Jun 18 2017 02:21
ravenor222 sends brownie points to @fmccroy :sparkles: :thumbsup: :sparkles:
:cookie: 354 | @fmccroy |http://www.freecodecamp.com/fmccroy
Alexander Køpke
@alexanderkopke
Jun 18 2017 02:21
😽
Frank McCroy
@fmccroy
Jun 18 2017 02:23
I missed a thanks to @alexanderkopke. Can I see what JSON data I am getting back from darksky? I have a copy from manually visiting the site with FireFox, but I’d like to see whats coming back each call if possible.
CamperBot
@camperbot
Jun 18 2017 02:23
fmccroy sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1522 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Nick Danvers
@Ravenor222
Jun 18 2017 02:23
"then remove the first element of array."
this is what you meant by remove the var?
Joseph
@revisualize
Jun 18 2017 02:25
@Ravenor222 No.
Alexander Køpke
@alexanderkopke
Jun 18 2017 02:25
@fmccroy sure, data holds the data that is sent back. You can console.log it and see what it contains and see the structure.
Joseph
@revisualize
Jun 18 2017 02:25
@Ravenor222 If you have an array. Let's say.. arr ... and arr has the value of [2,4,6,8] How do you remove the first element from the array?
Deroku
@Deroku
Jun 18 2017 02:26
what am i doing wrong here?

// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7, b = 7;
var b = var 'a';

Joseph
@revisualize
Jun 18 2017 02:26
@Deroku Your var declarations are incorrect.
Deroku
@Deroku
Jun 18 2017 02:26
how to I set var a to = var a?
I tried var a = b
var a = var b
Joseph
@revisualize
Jun 18 2017 02:26
@Deroku That's backwards.
Deroku
@Deroku
Jun 18 2017 02:26
var b = a?
Nick Danvers
@Ravenor222
Jun 18 2017 02:26
@revisualize Would I be able to shift it? 2 being the first element
Joseph
@revisualize
Jun 18 2017 02:27
@Deroku You don't do var on the right side if the assignment operator.
Deroku
@Deroku
Jun 18 2017 02:27
var b = a, or var a = b dopesnt work?
Joseph
@revisualize
Jun 18 2017 02:27
@Deroku var b = a should work.
If it doesn't you broke your code somewhere else.
@Deroku How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
Deroku
@Deroku
Jun 18 2017 02:28
i had this

// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7, b = 7;
var b = a;

the first time
and it didnt work
Joseph
@revisualize
Jun 18 2017 02:28
@Deroku because you have , b = 7;
That's breaking the code.
Deroku
@Deroku
Jun 18 2017 02:29
do i need to name it as a seperate variable?
it wont let me through the excercise without that
Joseph
@revisualize
Jun 18 2017 02:29
@Deroku
var a = 7;
var b = a;
Deroku
@Deroku
Jun 18 2017 02:29
var a = 7
var b = 7
var b = a
Joseph
@revisualize
Jun 18 2017 02:29
WHY do you keep doing var b = 7;?
That isn't what you're supposed to be doing at all.
@Deroku How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
Deroku
@Deroku
Jun 18 2017 02:30
i get that
Joseph
@revisualize
Jun 18 2017 02:30
@Deroku
var a = 7;
var b = a;
answer -^
Deroku
@Deroku
Jun 18 2017 02:30
i did that the very first time and it said i didnt assign a value of 7 to be
thats what threw me off
Frank McCroy
@fmccroy
Jun 18 2017 02:30
@alexanderkopke I was hoping to see the JSON data whether data captured it or not. When I try to console.log(data) it gives the value [object][object]
Nick Danvers
@Ravenor222
Jun 18 2017 02:30
It might have been that b = a, not a = b,
Deroku
@Deroku
Jun 18 2017 02:30
got it through now though, thanks for the clarification
Nick Danvers
@Ravenor222
Jun 18 2017 02:30
so maybe when you were trying it out the first time you mixed it up
Joseph
@revisualize
Jun 18 2017 02:31
If 7 is the value of a and you assign the value of a to b you're assigning the value 7 to b
Deroku
@Deroku
Jun 18 2017 02:31
which is why it threw me off when that didnt work
i was probably missing a semicolon or something small
that i didnt noticve
Joseph
@revisualize
Jun 18 2017 02:32
@Deroku Anyhow. I hope you read my text. It should help explain a few things.
Deroku
@Deroku
Jun 18 2017 02:32
i did, thanks fo rthe clarification
Nick Danvers
@Ravenor222
Jun 18 2017 02:33
@revisualize Hey Joseph, Can I ask you a question? you touched on it earlier with my array question
Greg Lawrence
@Chewieez
Jun 18 2017 02:34
@forkerino Thanks for all your help! I understand losing the j variable. It was left over from an earlier formula I was trying and I see how it's not needed. Thanks!
CamperBot
@camperbot
Jun 18 2017 02:34
chewieez sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2650 | @forkerino |http://www.freecodecamp.com/forkerino
Joseph
@revisualize
Jun 18 2017 02:34
@Ravenor222 Sup?
Alexander Køpke
@alexanderkopke
Jun 18 2017 02:35
@fmccroy ok I get an Object that I can click and it opens up. You're using chrome?
Frank McCroy
@fmccroy
Jun 18 2017 02:36
@alexanderkopke No, Firefox.
but I tried clicking it and didn’t see any change
Alexander Køpke
@alexanderkopke
Jun 18 2017 02:39
@fmccroy ok tested it in firefox as well. It is work here too but when I click the object and side bar opens and show the content
Nick Danvers
@Ravenor222
Jun 18 2017 02:40
@revisualize Sorry for the bother I got it done actually
Alexander Køpke
@alexanderkopke
Jun 18 2017 02:42
codepen.png
@fmccroy this is what my firefox prints to console and what happens when I click the object
Ryan Williams
@Ryanwfile
Jun 18 2017 02:43
Can someone please help me with this codepen of the React create a recipe project, I need help creating an onClick function that enables editing mode on the Recipe List side of the page, only the top 2 components in the codepen are relevant to the issue, thank you very much for any help.
https://codepen.io/Ryanwfile/pen/PjWemw
Joseph
@revisualize
Jun 18 2017 02:43
@Ravenor222 Grats.
@Ravenor222 Do you understand it?
Nick Danvers
@Ravenor222
Jun 18 2017 02:43
Yes I understand what the question is asking now >.< a simple shift / push combination
I just get stumped on the wording of the questions sometimes, I dont know what the question wants =)
Joseph
@revisualize
Jun 18 2017 02:44
@Ravenor222 There isn't.
@Ravenor222 Because the .push() method returns the new length.
Nick Danvers
@Ravenor222
Jun 18 2017 02:44
There isn't what sory?
Joseph
@revisualize
Jun 18 2017 02:45
@Ravenor222 You can't do method chaining with .push() and .shift()
Nick Danvers
@Ravenor222
Jun 18 2017 02:45
What I ended up doing was pushing item on to arr
Frank McCroy
@fmccroy
Jun 18 2017 02:45
@alexanderkopke That is strange, when I try clicking nothing expands. Even when I output to the web screen it just shows Object object. At least it shows temperature, etc like it is supposed to
Joseph
@revisualize
Jun 18 2017 02:45
@Ravenor222 I think I read what you wrote wrong.
Nick Danvers
@Ravenor222
Jun 18 2017 02:45
and returning arr.shift();
Joseph
@revisualize
Jun 18 2017 02:45
@Ravenor222 Yeah.
Nick Danvers
@Ravenor222
Jun 18 2017 02:45
=) thanks for the help!
it confused me for a lil bit
Joseph
@revisualize
Jun 18 2017 02:46
@Ravenor222 It's not the best example of a queue.
Nick Danvers
@Ravenor222
Jun 18 2017 02:46
@revisualize thanks
CamperBot
@camperbot
Jun 18 2017 02:46
ravenor222 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4193 | @revisualize |http://www.freecodecamp.com/revisualize
Alexander Køpke
@alexanderkopke
Jun 18 2017 02:46
@fmccroy do you know version of firefox you have? Mine is version 54.
Frank McCroy
@fmccroy
Jun 18 2017 02:47
@alexanderkopke Same here. 54.0 64-bit
Joseph
@revisualize
Jun 18 2017 02:54
la la la la
Frank McCroy
@fmccroy
Jun 18 2017 02:57
Uh oh, @revisualize is really Mouth of Sauron from : https://www.youtube.com/watch?v=x2Ii4BLiR28
Alexander Køpke
@alexanderkopke
Jun 18 2017 02:57
@fmccroy ok try printing it purely to the console. like: console.log(data);
Frank McCroy
@fmccroy
Jun 18 2017 02:59
@alexanderkopke I’ve tried both with the same result. I tried showing data.currently and it showed the object object thing again, but I can print specific variables
Alexander Køpke
@alexanderkopke
Jun 18 2017 02:59
@fmccroy ok what about console.table(data);
although that probably isn't that helpful 8/
@fmccroy ok my last suggestion: console.log(JSON.stringify(data, null, 2)); if this doesn't show something I don't know what will
Frank McCroy
@fmccroy
Jun 18 2017 03:05
@alexanderkopke The last one finally did it! It also overloaded CodePen’s console, so I looked at the browsers console as it recommended
Good night all! Thanks for the help. I bet I have JS nightmares..
Andrea Mammoliti
@AndreusSH
Jun 18 2017 03:11
H everyone, I am having a really hard time with this challenge "Modify the Bike constructor to have a private property called gear and two public methods called getGear and setGear to get and set that value."

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

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

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

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

var Bike = function() {

var gear;

this.setGear = function(val){
gear = val;
};

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

var myCar = new Car();

var myBike = new Bike();

can anyone explain this to me?
Alexander Køpke
@alexanderkopke
Jun 18 2017 03:13
@fmccroy sleep well
@AndreusSH what would you like to know?
Andrea Mammoliti
@AndreusSH
Jun 18 2017 03:18
I think I didn't understand the exercise but if I set this variable var gear=4, actually 4 cannot be changed? by outside code? I managed to pass the challenge finally
@alexanderkopke but didn't understand how it works actually
Arontbt
@Arontbt
Jun 18 2017 03:21

Hi everyone! So I'm trying to create this function that tests for palindromes. I have the code below but the console tells me that "modify.filter is not a function". As far as I can see, I'm doing this exactly as described in previous exercises. What am I doing wrong?

function palindrome(str) {
// Good luck!

var modify = str.toLowerCase();
var modify1 = modify.filter(function(characters){
return characters !== " " || "." || "," || "?" || "!" || ":" || ";" || "\"\"" || "\'\'" || "()" || "{}" || "[]" || "-" || "_" || "'" || "/";
});

if (modify1.split().reverse().join().equals(modify)) {
return true;
}
else {
return false;
}
}

Diego Mayer
@Chrono79
Jun 18 2017 03:22
@Arontbt that's not how you use logical or and split and join need arguments there
filter is an array method too, it doesn't work with strings (hence the error message)
Wyut-Yi
@Wyut-Yi
Jun 18 2017 03:23
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). please help me!
Alexander Køpke
@alexanderkopke
Jun 18 2017 03:24
@AndreusSH ok lets see. What we have here is a constructor function. It means that When we call the constructor function we create a new object. this inside the constructor is being set to the new object. So we have this.setGear =... so setGear is being put on the new object. var myBike = new Bike(); ok so now we can call the setGear method like this: myBike.setGear(4);
Diego Mayer
@Chrono79
Jun 18 2017 03:24
@Wyut-Yi read mad libs link and review the challenge Constructing strings with variables
Arontbt
@Arontbt
Jun 18 2017 03:29
@Chrono79 Oops I was supposed to add something in the split and join arguments. Thanks for that. Anything I can use to eliminate punctuation other than filter?
CamperBot
@camperbot
Jun 18 2017 03:29
arontbt sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4323 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 18 2017 03:29
@Arontbt regular expresions and replace
and where did you get .equals method?
Note that modify still has all those non-alphanumeric chars inside
Abdoullah Alee U
@abdoullfurya
Jun 18 2017 03:33
Good day guys
Andrea Mammoliti
@AndreusSH
Jun 18 2017 03:36
@alexanderkopke thank you very much for the explanation
CamperBot
@camperbot
Jun 18 2017 03:36
andreussh sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1523 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Wyut-Yi
@Wyut-Yi
Jun 18 2017 03:37

Diego Mayer
@Chrono79 it's still wrong. function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";

result = "hay! my " +  myAdjective + ""+ myNoun + " can " + myVerb +" very " + myAdverb +" .Do you know?"; 

return result;
}
wordBlanks("dog", "big", "ran", "quickly");

Diego Mayer
@Chrono79
Jun 18 2017 03:38
@Wyut-Yi "" is an empty string, not a space, so big and dog will output glued together like this bigdog
try using " " instead
ramundson1
@ramundson1
Jun 18 2017 03:41
can anyone offer any help with the profile lookup challenge its super confusing

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

function lookUpProfile(firstName, prop){
// Only change code below this line
if (lookUpProfile = true)
// Only change code above this line
}

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

Diego Mayer
@Chrono79
Jun 18 2017 03:41
@ramundson1 what is contacts? I mean what data type it is
What do you need to access a single contact?
lookUpProfile is your function's name
= is used for asignations, not for comparisons
delete that if (you won't need it)
meslance
@meslance
Jun 18 2017 03:44
@alexanderkopke I'm also on the bike exercise. I'm a bit confused on calling method. Can you explain a little more?
Wyut-Yi
@Wyut-Yi
Jun 18 2017 03:44
Diego Mayer
@Chrono79 thank you! i got it xD
CamperBot
@camperbot
Jun 18 2017 03:44
wyut-yi sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4324 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 18 2017 03:44
:+1:
Jorge Luis Vazquez
@zentech
Jun 18 2017 03:51

little help here!!!
```js

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,1,2);


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,1,2);
it seems a good constructor... why is not running? lol
meslance
@meslance
Jun 18 2017 03:53
@zentech I think you need to change the right side of the =
Ken Haduch
@khaduch
Jun 18 2017 03:54
@zentech within your function, you have to use the function arguments to get the values that are passed in - so instead of this.wheels = 4; try this.wheels = wheels; and similarly for the other values.
function arguments are meant to be used! ;)
Jorge Luis Vazquez
@zentech
Jun 18 2017 03:54
ohh yes, yes... tooo late I guess lol
@meslance thanks
CamperBot
@camperbot
Jun 18 2017 03:55
zentech sends brownie points to @meslance :sparkles: :thumbsup: :sparkles:
:warning: @meslance's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Alexander Køpke
@alexanderkopke
Jun 18 2017 03:55
@meslance so methods are functions inside objects. Here is an example:
var myObj = {
    value: 2,
   oneMethod: function(){
                              return this.value;
                                 }
            }
mrgrizzlie33
@mrgrizzlie33
Jun 18 2017 03:59
myGlobal is supposed to have a value of 10. Any reason it wouldn't? Here's the code:

var myGlobal = [10];

function fun1() {
// Assign 5 to oopsGlobal Here
oopsGlobal = 5;
}

// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

Ken Haduch
@khaduch
Jun 18 2017 03:59
@mrgrizzlie33 - is myGlobalsupposed to be an array?
mrgrizzlie33
@mrgrizzlie33
Jun 18 2017 04:00
@khaduch Nope, a variable
Diego Mayer
@Chrono79
Jun 18 2017 04:00
@mrgrizzlie33 10 isn't the same as [10] or "10"
len lee
@45lenlee
Jun 18 2017 04:00
is anyone doing the twitch tv app project
mrgrizzlie33
@mrgrizzlie33
Jun 18 2017 04:00
and the weird thing is that in the dev console it displays "myGlobal: 10"
@Chrono79
Ken Haduch
@khaduch
Jun 18 2017 04:01
@mrgrizzlie33 - SO, should it be written as [10] or 10? one is an array, one is an integer.
Diego Mayer
@Chrono79
Jun 18 2017 04:01
number / array / string
mrgrizzlie33
@mrgrizzlie33
Jun 18 2017 04:01
@khaduch
Oh maybe thats it
Ken Haduch
@khaduch
Jun 18 2017 04:01
what gets displayed in the console is the result of running test code - they could put it out in any format...
mrgrizzlie33
@mrgrizzlie33
Jun 18 2017 04:02
@khaduch yep that was it thanks. I was doing so much with arrays that I guess I forgot i dont need [] for vars!
CamperBot
@camperbot
Jun 18 2017 04:02
mrgrizzlie33 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3008 | @khaduch |http://www.freecodecamp.com/khaduch
meslance
@meslance
Jun 18 2017 04:02
@alexanderkopke Sorry, I'm still lost :'(
Alexander Køpke
@alexanderkopke
Jun 18 2017 04:02
@meslance ok can you explain what you're confused about?
Ken Haduch
@khaduch
Jun 18 2017 04:03
@mrgrizzlie33 :+1: :grin:
Alexander Køpke
@alexanderkopke
Jun 18 2017 04:03
@meslance and btw this is not easy to get. It takes a while to get it.
meslance
@meslance
Jun 18 2017 04:04
@alexanderkopke I'm trying to call it after var myBike at the bottom and that doesn't seem right.
  var gear;

  this.getGear = function (){
    return gear;

  };
  this.setGear = function (){
    return gear;
  };
Alexander Køpke
@alexanderkopke
Jun 18 2017 04:06
@meslance ok when you call a method in an object you start with the obj and then a dot and then the function/method call. obj.method()
@meslance ok what you posted there is from the constructor function
constructors is like a blue print for new objects. You put in what you want on the new object. Then you call the constructor function with the new key. var myBike = new Bike();
@meslance ok if this is still confusing lets try it in a different way.
@meslance you know how to create a normal object?
meslance
@meslance
Jun 18 2017 04:11
@alexanderkopke Yes
Alexander Køpke
@alexanderkopke
Jun 18 2017 04:12
@meslance good. Are you familiar with the browser's console? hit f12 to open it
meslance
@meslance
Jun 18 2017 04:13
@alexanderkopke Opened it
Alexander Køpke
@alexanderkopke
Jun 18 2017 04:13
ok so you're able to type var obj = {} in the console?
Pimtroja
@jukjik8
Jun 18 2017 04:13

I am stuck on 'stand in line'. Here is my code... function nextInLine(arr, item) {
testArr.push(item);
var removedItem = testArr.shift(item);

return removedItem; // Change this line
}

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

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

Manish Giri
@Manish-Giri
Jun 18 2017 04:14
@jukjik8 use arr instead of testArr..
function nextInLine(arr, item) {
arr is the array being passed to your function
Diego Mayer
@Chrono79
Jun 18 2017 04:14
@jukjik8 shift doesn't need arguments
meslance
@meslance
Jun 18 2017 04:15
@alexanderkopke Yes
Pimtroja
@jukjik8
Jun 18 2017 04:16
i change
Alexander Køpke
@alexanderkopke
Jun 18 2017 04:16
@meslance good hit enter and it will output something like <- undefined. Now type obj and hit enter
Ogundele Olumide
@Lumexralph
Jun 18 2017 04:16
@Manish-Giri :gggggggm :smiling_imp:
Pimtroja
@jukjik8
Jun 18 2017 04:16
I changed 'testArr' to 'arr' and remove that arg for shift. still not working
meslance
@meslance
Jun 18 2017 04:17
@alexanderkopke Returns Obj {}
Alexander Køpke
@alexanderkopke
Jun 18 2017 04:17
@meslance you have now created an object called obj. We will add a value to this method. Type: obj.value = 2; and hit enter
meslance
@meslance
Jun 18 2017 04:18
@alexanderkopke Ok, returned 2
Alexander Køpke
@alexanderkopke
Jun 18 2017 04:18
@meslance we're now able to access this value with obj.value
@meslance the same way we can add functions to the object.. try this: obj.method1 = function(){ return this.value;}
@meslance now call the method like this: obj.method1()
Diego Mayer
@Chrono79
Jun 18 2017 04:20
@jukjik8 show your current code
meslance
@meslance
Jun 18 2017 04:21
VM1720:1 Uncaught TypeError: obj.method1 is not a function
at <anonymous>:1:5
Alexander Køpke
@alexanderkopke
Jun 18 2017 04:21
@meslance obj.method1 = function(){ return this.value;}
meslance
@meslance
Jun 18 2017 04:23
@alexanderkopke I see, forgot the ".". It returned the value.
Pimtroja
@jukjik8
Jun 18 2017 04:25
@Chrono79 it is working now. Thanks everyone!
CamperBot
@camperbot
Jun 18 2017 04:25
jukjik8 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4325 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 18 2017 04:26
:+1:
Alexander Køpke
@alexanderkopke
Jun 18 2017 04:26
@meslance cool. So now I will create a constructor function that will do everything we just did. The result will be the same. One moment please
function createObj(){
this.value = 2; 
this.method1 = function(){
               return this.value;
}
}
Alexander Køpke
@alexanderkopke
Jun 18 2017 04:31
@meslance so now I can create new objects with this constructor just by doing this: var newObj1 = new createObj(); so if we have such a constructor it is much easier to create new objects this way than doing what we did before. Image if you'd have to create 20 objects manually. Instead you could create a constructor and then just call it with new createObj();
meslance
@meslance
Jun 18 2017 04:32
@alexanderkopke PM?
Alexander Køpke
@alexanderkopke
Jun 18 2017 04:32
sure
NielEXXCRO
@EkweviIkeobi
Jun 18 2017 04:35
can someone help me out with some code?
Diego Mayer
@Chrono79
Jun 18 2017 04:38
@EkweviIkeobi what is it?
NielEXXCRO
@EkweviIkeobi
Jun 18 2017 04:39
@Chrono79 Convert the assignments for a, b, and c to use the += operator.

@Chrono79
var a = 3;
var b = 17;
var c = 12;

// Only modify code below this line

a = a + 12;
b = 9 + b;
c = c + 7;

@Chrono79 code so far
Diego Mayer
@Chrono79
Jun 18 2017 04:41
@EkweviIkeobi see the checkmarks:
a should equal 15
b should equal 26
c should equal 19
myVar = myVar + 5;
myVar += 5; //will add 5 to myVar.
if a is initialized as 3 and at the end a should equal 15, how would you use += ?
NielEXXCRO
@EkweviIkeobi
Jun 18 2017 04:42
@Chrono79 my error code is You should use the += operator for each variable
Diego Mayer
@Chrono79
Jun 18 2017 04:42
yes, you didn't use it there at all
see the example code with myVar
NielEXXCRO
@EkweviIkeobi
Jun 18 2017 04:43
@Chrono79 where do i put it how should the whole code lookk
Diego Mayer
@Chrono79
Jun 18 2017 04:43
you need to change the last 3 lines
NielEXXCRO
@EkweviIkeobi
Jun 18 2017 04:44
to what?
Diego Mayer
@Chrono79
Jun 18 2017 04:44
instead of a = a + 12; use += like they did with myVar
Wyut-Yi
@Wyut-Yi
Jun 18 2017 04:44
although I passed above 164 levels(165,166,167..),my challenge level still stop at level 165 . What can i do? please help me!
NielEXXCRO
@EkweviIkeobi
Jun 18 2017 04:44
i did it said it was wrong
Diego Mayer
@Chrono79
Jun 18 2017 04:45
show me how you did that
NielEXXCRO
@EkweviIkeobi
Jun 18 2017 04:45

@Chrono79 var a = 3;
var b = 17;
var c = 12;

// Only modify code below this line

myvar += 12;
myvar += 9;
myvar += 7;

Diego Mayer
@Chrono79
Jun 18 2017 04:46
@EkweviIkeobi right, you should use a, b and c, not myvar in all of those
NielEXXCRO
@EkweviIkeobi
Jun 18 2017 04:46
@Chrono79 thanks
CamperBot
@camperbot
Jun 18 2017 04:46
ekweviikeobi sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4326 | @chrono79 |http://www.freecodecamp.com/chrono79
Varsha Chahal
@VarshaChahal
Jun 18 2017 05:00
function lookUpProfile(firstName, prop){
for(var i=0;i<contacts.length;i++){
if(firstName==contacts[i].firstName && contacts[i].hasOwnProperty(prop)){
return contacts[i].prop;
}
}
challenge 237
can't figure out the code. could someone help me with this?
Diego Mayer
@Chrono79
Jun 18 2017 05:01
@VarshaChahal you can't use dot notation with vars
and that number is not the challenge number, those are your brownie points https://forum.freecodecamp.com/t/free-code-camp-brownie-points/18380
Varsha Chahal
@VarshaChahal
Jun 18 2017 05:02
ohh!!! thanks for informing by the way
Diego Mayer
@Chrono79
Jun 18 2017 05:03
:+1:
Varsha Chahal
@VarshaChahal
Jun 18 2017 05:04
firstName is the name of the property of the object contacts as well as the arguement passed to the function
Diego Mayer
@Chrono79
Jun 18 2017 05:05
@VarshaChahal yes, a little confusing but it is
Varsha Chahal
@VarshaChahal
Jun 18 2017 05:07
i can't figure out the code for this
Diego Mayer
@Chrono79
Jun 18 2017 05:07
@VarshaChahal use nested ifs
check if the firstName matches, then check if the property exists
Sunny Wong
@swong194
Jun 18 2017 05:08
hi every1 can i get some feedback
on my weather app
Diego Mayer
@Chrono79
Jun 18 2017 05:08
return contacts[i].prop; <- here you can't use dot notation
Varsha Chahal
@VarshaChahal
Jun 18 2017 05:10
@Chrono79 thank you so much. It's working now
CamperBot
@camperbot
Jun 18 2017 05:10
varshachahal sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4327 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 18 2017 05:10
:+1:
@swong194 it works, try formatting the output better, the city name shows with an underscore
Griffin-Brome
@Griffin-Brome
Jun 18 2017 05:13
hey guys can i have some help please? I keep getting an "undefined" type error for myArray[0] in my code.
Diego Mayer
@Chrono79
Jun 18 2017 05:14
@Griffin-Brome show your code
Griffin-Brome
@Griffin-Brome
Jun 18 2017 05:14

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

myArray[i].replace(/./, myArray[i].charAt(0).toUpperCase());

}
return myArray.join(' ') ;
}

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

Diego Mayer
@Chrono79
Jun 18 2017 05:16
<= myArray.length is not ok (the last element of an array is at array.length - 1, that's why you get the undefined error)
And replace returns a new string, you have to overwrite the array element
Griffin-Brome
@Griffin-Brome
Jun 18 2017 05:20
ok, that fixed the undefined error, thank you
BlackTiger
@BlackTigerRoar
Jun 18 2017 05:28
Hi community, quick question. If there's 'return' in the for loop, then will it break the loop at first return?
Diego Mayer
@Chrono79
Jun 18 2017 05:31
@ShenyuSun yes
Griffin-Brome
@Griffin-Brome
Jun 18 2017 05:31
function titleCase(str) {
  myArray = str.toLowerCase().split(' ');
  for (var i = 0; i < myArray.length; i++) {
    var newword = myArray[i].split('');
    var first = newword.shift().toUpperCase();
    newword.unshift(first);
    myArray[i] = newword.join('');
  }
  return myArray.join(' ') ;
}

titleCase("I'm a little tea pot");
got it working, thanks Diego!
CosmicWave
@CosmicWave
Jun 18 2017 05:32
Hi Peeps,
Is it compulsory to do the 'front-end-projects' in order to be awarded the 'Front End Development Certificate'?
Diego Mayer
@Chrono79
Jun 18 2017 05:34
@Griffin-Brome myArray[i] = myArray[i].replace(/./, myArray[i].charAt(0).toUpperCase()); works too
BlackTiger
@BlackTigerRoar
Jun 18 2017 05:35
@Chrono79 Thank you
CamperBot
@camperbot
Jun 18 2017 05:35
shenyusun sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4328 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 18 2017 05:37
@CosmicWave Challenges required for certifications are marked with a *
So yes
CosmicWave
@CosmicWave
Jun 18 2017 05:39
@Chrono79
Thanks!
CamperBot
@camperbot
Jun 18 2017 05:39
cosmicwave sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4329 | @chrono79 |http://www.freecodecamp.com/chrono79
CosmicWave
@CosmicWave
Jun 18 2017 05:41
@Chrono79
are you a messi fan? lol
Diego Mayer
@Chrono79
Jun 18 2017 05:41
@CosmicWave It was the first tribute that came to mind ;)
CallMeOrange
@EgnaroDev
Jun 18 2017 05:59
:wave:
:worried:
OldmanVimes
@OldmanVimes
Jun 18 2017 06:03

function findLongestWord(str) {
  var array=[];
  var i=0;
  var newArray=[];
  array=str.split(' ');
  for (i>0;i<array.length;i++){
       newArray.push(array[i].length);
    }
newArray.sort(function(a,b){return b-a;});
}
Where's my mistake?
CallMeOrange
@EgnaroDev
Jun 18 2017 06:04
Sorry I'm rookie at JS
Diego Mayer
@Chrono79
Jun 18 2017 06:07
@OldmanVimes your function doesn't return
and you have to initialize i as 0 in your loop, where you wrote i>0, use var keyword there too
bye
Iris Shields
@calluna
Jun 18 2017 06:09
Hi, I'm looking for a hint with the Caesars Cipher exercise... I'm able to translate the message but some of the letters have been turned into odd characters (letters, "@", and even unicodes) instead of letters (other letters are turned correctly).
OldmanVimes
@OldmanVimes
Jun 18 2017 06:09
@Chrono79 thanks a lot. I got it.
CamperBot
@camperbot
Jun 18 2017 06:09
oldmanvimes sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4330 | @chrono79 |http://www.freecodecamp.com/chrono79
mayoorika
@mayoorika
Jun 18 2017 06:20
why use this symbol ???? ||
Aakriti
@Aakriti94
Jun 18 2017 06:21
@mayoorika it is a symbol for 0r
or
aichellie
@aichellie
Jun 18 2017 06:21
@calluna me too, I'm having difficulty limiting the range to letters and letting spaces and symbols pass through
mayoorika
@mayoorika
Jun 18 2017 06:22
ok thqq @Aakriti94
Iris Shields
@calluna
Jun 18 2017 06:24
@aichellie I found the solution on the interwebs :-P
basically we have to use an if, else statement... if the character is between x and y numbers then shift so much, else if... etc
aichellie
@aichellie
Jun 18 2017 06:27
I'm doing that, but it isn't working properly;;
Iris Shields
@calluna
Jun 18 2017 06:28
What's your code @aichellie ?
I can see if I can give you some hints
Shishir
@shishirmax
Jun 18 2017 06:29

my code not giving desired output:
Output:
FirstLine
\SecondLine\
ThirdLine

Input:
var myStr = "FirstLine\n\SeconLine\\r\nThirdLine"

However this is runing fine in browser console

aichellie
@aichellie
Jun 18 2017 06:30
@calluna I'm still working on getting the output at the bottom, but you can see what I did with the range here
function rot13(str) {
  string='';
  log=[];
  gol=[];
  for (i=0; i<str.length; i++){
    first=str.charCodeAt(i);
    if (77<first<91){
      minus=first-13;
      gol.push(minus);
    }
    else if (64<first<78){
      plus=first+13;
      gol.push(plus);
    }
    else if (first<64) {
      gol.push(first);
    }
    log.push(first);
    String.fromCharCode(log);

  }
 return string;
}
gol should have the codes for new letters, but the range isn't limited the way it should be so all numbers are reduced by 13 instead of only those in the second half of the alphabet
If I change the order of the if else statements, the range shifts likewise
Iris Shields
@calluna
Jun 18 2017 06:34
@aichellie charCode takes other characters too though, not just the alphabet so we have to eliminate those as well. I have very different ranges actually.
schizo99
@shashank1999coder
Jun 18 2017 06:35
how to code second elements in sub-arrays
Iris Shields
@calluna
Jun 18 2017 06:35
My initial code came out with "@" and /u0013 even
schizo99
@shashank1999coder
Jun 18 2017 06:35
plz help
aichellie
@aichellie
Jun 18 2017 06:35
@shashank1999coder do you mean selecting something like array[0][1]?
schizo99
@shashank1999coder
Jun 18 2017 06:37
challenge is to make a shopping list @aichellie
abraham anak agung
@padunk
Jun 18 2017 06:37
@shishirmax what challenge is that? typo in your secon
@shashank1999coder show your code, maybe i can help
Shishir
@shishirmax
Jun 18 2017 06:40
@padunk "Escape Sequences in Strings" challenge, Updated the typo then also its not executing
aichellie
@aichellie
Jun 18 2017 06:42
@shashank1999coder to access sub-arrays, like searching, try nested loops
abraham anak agung
@padunk
Jun 18 2017 06:42
@shishirmax backslash after second \\before second also
schizo99
@shashank1999coder
Jun 18 2017 06:43
var myList = ["Chocolate Bar","energy bar","veggie","milk","oil"]; how to add second element
Shishir
@shishirmax
Jun 18 2017 06:44
@padunk var myStr = "FirstLine\n\SecondLine\\r\nThirdLine"; used but still its not getting passed
abraham anak agung
@padunk
Jun 18 2017 06:45
@shishirmax var myStr = "FirstLine\n\\SecondLine\\\rThirdLine";
Shishir
@shishirmax
Jun 18 2017 06:46
@padunk super :)
abraham anak agung
@padunk
Jun 18 2017 06:46
@shashank1999coder you mean element after chocholate? u could use splice
Greg Duncan
@GregatGit
Jun 18 2017 06:48

@aichellie you should name and declare varibles better and use spacing - so

string=''; // this is bad
var myStr = ''; // this would be better

and don't use words like log, string that get used else where is js - use a clearly name variable

schizo99
@shashank1999coder
Jun 18 2017 06:48
no The second elements in each of your sub-arrays must all be numbers
aichellie
@aichellie
Jun 18 2017 06:49
okay. I know my code is messy :(
Greg Duncan
@GregatGit
Jun 18 2017 06:50
@aichellie first should be var firstLetter
techiespace
@techiespace
Jun 18 2017 06:53

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

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

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

what is wrong with this code?
I'm trying to access properties with . instead of []
mosessaleh
@mosessaleh
Jun 18 2017 06:54
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)
techiespace
@techiespace
Jun 18 2017 06:54
[checkProp] instead of .checkProp works fine! Why?
abraham anak agung
@padunk
Jun 18 2017 06:55
you object don't have checkprop key, checkprop is a parameter. @techiespace
techiespace
@techiespace
Jun 18 2017 06:56
isn't it a variable with the value gift, pet, etc?
abraham anak agung
@padunk
Jun 18 2017 06:59
@techiespace no, if u write myObj.checkProp it will look for checkProp key
techiespace
@techiespace
Jun 18 2017 07:00
okay thanks @padunk
CamperBot
@camperbot
Jun 18 2017 07:00
:cookie: 339 | @padunk |http://www.freecodecamp.com/padunk
techiespace sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
abraham anak agung
@padunk
Jun 18 2017 07:01
@shashank1999coder u just write it [["beer", 2]]
@mosessaleh shw ur code
MrityunjaiMishra
@MrityunjaiMishra
Jun 18 2017 07:09
i cant use praseInt in freecode camps editor
abraham anak agung
@padunk
Jun 18 2017 07:10
it is parseInt not prase
mosessaleh
@mosessaleh
Jun 18 2017 07:11

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

// Your code above this line
return result;
}

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

abraham anak agung
@padunk
Jun 18 2017 07:13
@mosessaleh your result must return a sentence that contains all those words
example result = text + myNoun + text + myVerb + .....etc
Kamal
@kpbro
Jun 18 2017 07:15
Caesars Cipher:
i have created the code which is working perfectly but using a very bad logic and code is long. What can be easier method and simpler of doing this?
function rot13(str) { // LBH QVQ VG!
/*Here what I have done is 

1st: make array of utf-16 codes of all characters of given string using for loop and str.charCodeAt()
2nd: iterate through this array and make newArray using str1.map and if-else if. This returns new array which has decoded value of each alphabets(utf code) and returns the same value for non-alphabets
3rd: again iterate through this newArray and change utf codes to corresponding character using String.fromCharCode()
4th: join this array using newArray.join('')*/
  var str1 =[];
for(var i=0;i<str.length;i++){
 str1.push(str.charCodeAt(i));
}

  var newArray = str1.map(function(x){
   if(x >=65 && x<=77){return x+13;} 
    else if(x>77 && x<=90){return x-13;}
    else{return x;}
  });

  newArray = newArray.map(function(y){
    return String.fromCharCode(y);
  });


 return newArray.join('');
}

// Change the inputs below to test
rot13("LBH QVQ VG");
abraham anak agung
@padunk
Jun 18 2017 07:20
@kpbro ur code is better than me :smile:
Kamal
@kpbro
Jun 18 2017 07:23
@padunk hahaha thanks
CamperBot
@camperbot
Jun 18 2017 07:23
kpbro sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 340 | @padunk |http://www.freecodecamp.com/padunk
abraham anak agung
@padunk
Jun 18 2017 07:23
if u want to know more :caesars cipher
rugano
@rugano
Jun 18 2017 07:26
Hello campers,
mosessaleh
@mosessaleh
Jun 18 2017 07:26

var result = "Cat" + myNoun + "Little" + myAdjective + "Hit" + myVerb + "slowly" + myAdverb;

It didn't work

Kamal
@kpbro
Jun 18 2017 07:28
@padunk logic is same.. just codes are little different
rugano
@rugano
Jun 18 2017 07:29
Can someone help me identify the unexpected token , at the Javascript code since i have tried to delete some commas without success.here: https://codepen.io/Njue/pen/NgbxBa
abraham anak agung
@padunk
Jun 18 2017 07:29
@mosessaleh you need space between word.
rugano
@rugano
Jun 18 2017 07:31
@Chrono79 hi,
abraham anak agung
@padunk
Jun 18 2017 07:31
@rugano line 45 ;?
Manthan Gandhi
@manthangandhi
Jun 18 2017 07:32
stuck at Make Object Properties Private can anyone help?
Dima Doulov
@dimadoulov
Jun 18 2017 07:33

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

What am i doin wrong here?

Oh boy how do i send code so i doesnt look like that
Kamal
@kpbro
Jun 18 2017 07:33
@dimadoulov please use proper format to show your code here
Dima Doulov
@dimadoulov
Jun 18 2017 07:34
How?
Kamal
@kpbro
Jun 18 2017 07:34
:point_up: June 18, 2017 12:45 PM like I did this
Dima Doulov
@dimadoulov
Jun 18 2017 07:34
How to make it so it sends like that
Kamal
@kpbro
Jun 18 2017 07:35
``` then shift+enter then paste your code and send
mosessaleh
@mosessaleh
Jun 18 2017 07:35
@padunk Done thnx
CamperBot
@camperbot
Jun 18 2017 07:35
mosessaleh sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 341 | @padunk |http://www.freecodecamp.com/padunk
Dima Doulov
@dimadoulov
Jun 18 2017 07:35
```
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++){
if (contacts[i].firstName == firstName){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
} else if (!contacts[i].hasOwnProperty(prop)) {
return "No such property";
}
else {
return "No such contact";
}
}
}
// Only change code above this line
}
Didnt work
Kamal
@kpbro
Jun 18 2017 07:36
@dimadoulov check the last one in markdown help.
abraham anak agung
@padunk
Jun 18 2017 07:36
``` after it too @dimadoulov
Kamal
@kpbro
Jun 18 2017 07:36
when we press shift+enter it automatically adds ``` at end
Dima Doulov
@dimadoulov
Jun 18 2017 07:36
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (i = 0; i < contacts.length; i++){
    if (contacts[i].firstName == firstName){
      if(contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop];
      } else if (!contacts[i].hasOwnProperty(prop)) {
        return "No such property";
      }
      else {
        return "No such contact";
      }
    }
  }
// Only change code above this line
}
Casey
@zerowacked
Jun 18 2017 07:36
@dimadoulov Having the same issue. Almost exactly the same code. It feels like it should work but it isn't.
Dima Doulov
@dimadoulov
Jun 18 2017 07:36
nicenicenicenice thank you
Casey
@zerowacked
Jun 18 2017 07:36
My friend says that code works for him.
Dima Doulov
@dimadoulov
Jun 18 2017 07:37
im not getting No such contact to occur
Kamal
@kpbro
Jun 18 2017 07:37
@dimadoulov now lemme look ur code
Casey
@zerowacked
Jun 18 2017 07:37
My issue is that I'm only getting no such property and no such contact. I can't get return prop to work.
Virtually the same code as yours, though.
Kamal
@kpbro
Jun 18 2017 07:38
@dimadoulov whats the error?
Dima Doulov
@dimadoulov
Jun 18 2017 07:38
All the example values are working except for the ones where it should return No such contact
Nesting if statements is screwy for me so im stumped on this one :/
abraham anak agung
@padunk
Jun 18 2017 07:41
maybe you put return no such contact at wrong line @dimadoulov
Kamal
@kpbro
Jun 18 2017 07:43
@dimadoulov instead of else if use else and directly return no such property
you dont need that second else statement
@dimadoulov remove this portion if (!contacts[i].hasOwnProperty(prop))
Dima Doulov
@dimadoulov
Jun 18 2017 07:45
Hmm, where does 'no such contact ' return go then?
abraham anak agung
@padunk
Jun 18 2017 07:46
@dimadoulov you will want it after it check all the contact. after the loop
Baha Eddine RAZGHI
@Rezguii
Jun 18 2017 07:48
Hi guys, my name is Baha eddinne rezgui. I'm from Tunisia. I'm newcomer. I'm a software engineer. I didin't have experience yet and i wish i can find help here.Thank you for all of you.
Kamal
@kpbro
Jun 18 2017 07:48
@Rezguii nice :+1:
abraham anak agung
@padunk
Jun 18 2017 07:49
hi @Rezguii
Dima Doulov
@dimadoulov
Jun 18 2017 07:49
Got it! Thank you guys. Sup @Rezguii
CamperBot
@camperbot
Jun 18 2017 07:49
dimadoulov sends brownie points to @rezguii :sparkles: :thumbsup: :sparkles:
:warning: @rezguii's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
rugano
@rugano
Jun 18 2017 07:50
@padunk I tried to put the semicolon but still ,the bug points to a missing comma,don't know where
abraham anak agung
@padunk
Jun 18 2017 07:50
@rugano yes, your code it too complicated, sorry, it didn't fix it.
Baha Eddine RAZGHI
@Rezguii
Jun 18 2017 07:51
hi @kpbro @padunk @camperbot nice to meet you
Dima Doulov
@dimadoulov
Jun 18 2017 07:52
.
abraham anak agung
@padunk
Jun 18 2017 07:58
@rugano i try to put it on VSCode, it show 11 error
Pieter Stokkink
@forkerino
Jun 18 2017 08:05
morning
Ogundele Olumide
@Lumexralph
Jun 18 2017 08:06
@forkerino Morning Bro!
Pieter Stokkink
@forkerino
Jun 18 2017 08:07
@Lumexralph :wave:
Kamal
@kpbro
Jun 18 2017 08:07
@forkerino morning
rugano
@rugano
Jun 18 2017 08:08
@padunk What is VSCode ,and the errors are pointing to Js?
Pieter Stokkink
@forkerino
Jun 18 2017 08:09
@kpbro what's up?
Ogundele Olumide
@Lumexralph
Jun 18 2017 08:09
@rugano Visual Studio Code a text editor
@forkerino what's happening today?
Kamal
@kpbro
Jun 18 2017 08:09
@forkerino nothin special.. completing js challenges as usual
@forkerino :point_up: June 18, 2017 12:45 PM check my this code
abraham anak agung
@padunk
Jun 18 2017 08:10
vscode is like sublime. you have error in line 64, 152, 157, 161, 406, 410, 575 @rugano
intervolver
@intervolver
Jun 18 2017 08:11
Hey, could I get someone to look at a pen really quick and help me understand why I'm not able to do something within a function?
rugano
@rugano
Jun 18 2017 08:11
@padunk @forkerino @Lumexralph thanks,the js code is driving me crazy,sholud i delete the whole code and start afresh?
CamperBot
@camperbot
Jun 18 2017 08:11
rugano sends brownie points to @padunk and @forkerino and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 342 | @padunk |http://www.freecodecamp.com/padunk
:star2: 1949 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 2651 | @forkerino |http://www.freecodecamp.com/forkerino
Ogundele Olumide
@Lumexralph
Jun 18 2017 08:12
@rugano if you want to and if it won't be too much work creating a new one
abraham anak agung
@padunk
Jun 18 2017 08:12
i really don't know. but with that error, i think you should consider it
Pieter Stokkink
@forkerino
Jun 18 2017 08:14
@kpbro it is not too bad, but you can combine the two .maps into one.
I have a one liner for Caesar's Cipher
rugano
@rugano
Jun 18 2017 08:15
Or maybe i started to break the string from line 64?
Kamal
@kpbro
Jun 18 2017 08:16
@forkerino ohh. i dont know that.. the code became so long, so i thought that my codes/logic is somewhere wrong
@forkerino wow.. what is that oneliner? plz show me
abraham anak agung
@padunk
Jun 18 2017 08:16
@rugano copy all of it first than start from it
rugano
@rugano
Jun 18 2017 08:16
@Lumexralph Can i still correct the mistakes and make it work?
Ogundele Olumide
@Lumexralph
Jun 18 2017 08:17
@rugano if you know why it's not working
rugano
@rugano
Jun 18 2017 08:18
@padunk @Lumexralph ok,
Pieter Stokkink
@forkerino
Jun 18 2017 08:21

@rugano Many of such errors can be prevented by starting every new object property on a new line and using proper indentation. You sometimes start a new property on an object before the previous method is properly closed with a }, which causes such errors.

so :

methodName: function(){
  // do stuff
},
methodMan: function(){
  console.log("CREAM");
},
// etc.

instead of:

methodName: function(){
  // do stuff
}, methodMan: function(){
  console.log("CREAM");
}, // etc.
it goes wrong a couple times when you have if/else blocks inside methods.
@kpbro
const rot13 = (str) => str.replace(/[A-Z]/g, l => String.fromCharCode(l.charCodeAt()%26 + 65));
abraham anak agung
@padunk
Jun 18 2017 08:22

@forkerino @Lumexralph can i ask u about this code?

function GetDate(props) {
    var datenumber = props;
    var date = new Date();
    var tomorrow = date.setDate(date.getDate() + datenumber);
    var options = { weekday: 'long', month: 'long', day: 'numeric' };
    var results = date.toLocaleDateString('en-US', options);

    return results;
}
GetDate(2);

if i comment the tomorrow var // then it shows today date but if it not than it shows n (props) date after today how is it possible?

Kamal
@kpbro
Jun 18 2017 08:22
@forkerino what => does?
Ogundele Olumide
@Lumexralph
Jun 18 2017 08:24
@kpbro ES 6 arrow function
Pieter Stokkink
@forkerino
Jun 18 2017 08:24
@padunk because you set the date to a new date?
pahosler
@pahosler
Jun 18 2017 08:24
it's basically shorthand for function(){
abraham anak agung
@padunk
Jun 18 2017 08:24
@forkerino but i didnt assign tomorrow in result
Thomas
@sjurs1
Jun 18 2017 08:24
With the reduce method, can you set the accumulator to be an empty array?
Pieter Stokkink
@forkerino
Jun 18 2017 08:24

@kpbro it is shorthand:

function (n) {
 return n+2;
}

becomes

n => n+2;
@padunk no, but you do date.setDate
abraham anak agung
@padunk
Jun 18 2017 08:25
@sjurs1 yes
Kamal
@kpbro
Jun 18 2017 08:25
amazing.. @forkerino @pahosler ... will use it in my codes..
Pieter Stokkink
@forkerino
Jun 18 2017 08:26
@kpbro There are some exercises on it in the beta version of fcc (beta.freecodecamp.com, look for ES6 on the map)
abraham anak agung
@padunk
Jun 18 2017 08:26
@forkerino hmm... i see, thanks man
CamperBot
@camperbot
Jun 18 2017 08:26
padunk sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2652 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jun 18 2017 08:26
:+1:
Kamal
@kpbro
Jun 18 2017 08:26
@forkerino thanks buddy..
CamperBot
@camperbot
Jun 18 2017 08:26
kpbro sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2653 | @forkerino |http://www.freecodecamp.com/forkerino
Ogundele Olumide
@Lumexralph
Jun 18 2017 08:26
@kpbro be careful about how you use it..... it's not 100% like the function expression
Kamal
@kpbro
Jun 18 2017 08:27
@Lumexralph yeah sure.
Pieter Stokkink
@forkerino
Jun 18 2017 08:27
@kpbro yeah, there are some subtle changes. this is not the same in arrow vs normal functions
Ogundele Olumide
@Lumexralph
Jun 18 2017 08:27
@kpbro cool
Thomas
@sjurs1
Jun 18 2017 08:27
How do you push items into the array then?

function test(arr) {
  var sum = arr.reduce(function(a, b) {
    return a.push(b);
}, []);
return sum;
}

test([1, 2, 3]);
Pieter Stokkink
@forkerino
Jun 18 2017 08:27
@sjurs1 use .concat instead. .push returns a number
Thomas
@sjurs1
Jun 18 2017 08:28
Ugh, I should know that. @forkerino Thanks
CamperBot
@camperbot
Jun 18 2017 08:28
sjurs1 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2654 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jun 18 2017 08:28
@sjurs1 Not sure if this will give you the sum, though...
Thomas
@sjurs1
Jun 18 2017 08:29
No, I've just been messing around with reduce, haven't bothered changing the variable name
Pieter Stokkink
@forkerino
Jun 18 2017 08:29
@sjurs1 ah, ok
intervolver
@intervolver
Jun 18 2017 08:31
could someone help me understand a problem I'm having with functions in a pen?
Pieter Stokkink
@forkerino
Jun 18 2017 08:32
@intervolver perhaps
ask your question
intervolver
@intervolver
Jun 18 2017 08:35
@forkerino I'm working on grabbing json from the dark sky api for the weather app project. However, I don't seem to even be able to edit a div within a nested function. When I do $('.weather-icon').html(jsonUrl); outside of the $.getJSON function, it works properly, but not within. pen follows: https://codepen.io/intervolver/pen/RgKYMb?editors=1010
Dmitry
@Wasterlord
Jun 18 2017 08:35
hi guys
Why i cant replace dots and commas in this code?
var b = a.replace(/_| |.|,/gi,"");
pls help
stuck on this
Ogundele Olumide
@Lumexralph
Jun 18 2017 08:36
@Wasterlord because . means something special in regEx except in [] or ()
Dmitry
@Wasterlord
Jun 18 2017 08:36
ok thx, now check how fix it
@Lumexralph thx it help
CamperBot
@camperbot
Jun 18 2017 08:37
wasterlord sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1950 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 18 2017 08:38
@Wasterlord . means all characters except white space I think, you can do /[.,]/g
Pieter Stokkink
@forkerino
Jun 18 2017 08:38
@intervolver the getJSON callback function is only run upon a succesfull response with information. Your url doesn't point to a valid API endpoint (it doesn't include the host, for example), so the code inside the callback won't be run.
Dmitry
@Wasterlord
Jun 18 2017 08:38
thx done
Ogundele Olumide
@Lumexralph
Jun 18 2017 08:38
@Wasterlord :+1:
intervolver
@intervolver
Jun 18 2017 08:39
@forkerino I've tried it with a valid api address as well, I'll update it to show you what I mean, one moment
Pieter Stokkink
@forkerino
Jun 18 2017 08:40
@intervolver always check your dev console (not the codepen console, but the one in your browser) to see if there are errors.
some you can ignore for now, but some will indicate what will go wrong.
intervolver
@intervolver
Jun 18 2017 08:41
@forkerino here, update. I didn't realize it had to grab it first, so now the question becomes why isn't it grabbing it properly. If I just use the url created for jsonUrl in a new tab, it shows the raw json, so I know the url and the key are fine https://codepen.io/intervolver/pen/RgKYMb?editors=1010
so the url works as it's being created, but getJSON doesn't seem to be able to pull from it, I'll check my browser console presently
"No 'Access-Control-Allow-Origin' header is present on the requested resource."
I'm not familiar with what this means, I haven't had to use a key before with json
intervolver
@intervolver
Jun 18 2017 08:49
going by dark sky's faq, it means I can't share resources "cross origin". I have no clue why the challenge suggests using dark sky, this is a confusing mess and I'm getting progressively more lost
Pieter Stokkink
@forkerino
Jun 18 2017 08:49
@intervolver it's a very common issue. In the case of darksky API it can be remedied by adding ?callback=? to your url, which turns it into a JSONP request.
intervolver
@intervolver
Jun 18 2017 08:50
place that before the key, or at the end?
at the end
Pieter Stokkink
@forkerino
Jun 18 2017 08:50
yes
intervolver
@intervolver
Jun 18 2017 08:51
okay, that is allowing the function to work
Pieter Stokkink
@forkerino
Jun 18 2017 08:51
:+1:
intervolver
@intervolver
Jun 18 2017 08:51
so now I just have to reference JSONP instead?
Pieter Stokkink
@forkerino
Jun 18 2017 08:51
No that is not necessary. If you then console.log the json you get back, you can see how the data looks
intervolver
@intervolver
Jun 18 2017 08:51
apparently not :D
@forkerino thank you so much, I'm displaying the raw json with stringify now!
CamperBot
@camperbot
Jun 18 2017 08:51
intervolver sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2655 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jun 18 2017 08:52
@intervolver :+1:
intervolver
@intervolver
Jun 18 2017 08:52
I never thought of using inspect to check the console x.x , maybe it's time to take a break
Thomas
@sjurs1
Jun 18 2017 08:55
What's happening here? This logs 0 and then "Cannot read property indexOf of undefined". What happens to the array?
function test(arr) {
  var arrCheck = arr.reduce(function(a, b) {
    console.log(a.indexOf(b));
    //if (a.indexOf(b) === -1) {
      //return a.concat(b);
    //}
}, arguments[0]);
return arrCheck;
}

test([1, 2, 3], [5, 2, 1, 4]);
Pieter Stokkink
@forkerino
Jun 18 2017 08:58
@sjurs1 the default return value of a function is undefined. so the second time your reduce callback runs (for the second element of the array), the accumulator a will be undefined
Ogundele Olumide
@Lumexralph
Jun 18 2017 08:59
@sjurs1 oh! you used the arguments object, missed that
Kelechi Chinaka
@ke1echi
Jun 18 2017 09:00
hi guys
Ogundele Olumide
@Lumexralph
Jun 18 2017 09:00
@kelechichinaka brotherly
Thomas
@sjurs1
Jun 18 2017 09:01
Ah, right @forkerino. I circumvent that problem if I make sure I at least return a before the next iteration
Kelechi Chinaka
@ke1echi
Jun 18 2017 09:01
morning bro @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 18 2017 09:02
@kelechichinaka how area?
Kelechi Chinaka
@ke1echi
Jun 18 2017 09:02
cool @Lumexralph urs?
Ogundele Olumide
@Lumexralph
Jun 18 2017 09:04
@kelechichinaka cool weather so far
Kelechi Chinaka
@ke1echi
Jun 18 2017 09:06
function twoDecimalPlaces(n) {
  return Number(n.toFixed(2));
}
worked for 2.675 - Expected: 2.68, instead got: 2.67
only failed test, what math method can i use @Lumexralph
Pieter Stokkink
@forkerino
Jun 18 2017 09:07
Math.round?
Ogundele Olumide
@Lumexralph
Jun 18 2017 09:08
@kelechichinaka try Math.round....it'll give to nearest integer
whys that not working
Kelechi Chinaka
@ke1echi
Jun 18 2017 09:09
:wave: morning @forkerino
Tarun Garhwal
@eoo
Jun 18 2017 09:10
nvm
Pieter Stokkink
@forkerino
Jun 18 2017 09:10
@kelechichinaka :wave:
koder3
@koder3
Jun 18 2017 09:10
how to enable ES6 in fcc?
Pieter Stokkink
@forkerino
Jun 18 2017 09:11
@koder3 you can just use it and ignore the warning or add //esversion:6 at the top
Tarun Garhwal
@eoo
Jun 18 2017 09:11
nope, still nor working
Pieter Stokkink
@forkerino
Jun 18 2017 09:12
@eoo you missed some quotes around your $('selectors')
Tarun Garhwal
@eoo
Jun 18 2017 09:13
eh lol tyy
koder3
@koder3
Jun 18 2017 09:13
@forkerino thanks
CamperBot
@camperbot
Jun 18 2017 09:13
koder3 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2656 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jun 18 2017 09:14
yw
Kelechi Chinaka
@ke1echi
Jun 18 2017 09:16
am having issues rounding 5.5589 is rounded 5.56 the doc is not too clear to me
Ogundele Olumide
@Lumexralph
Jun 18 2017 09:17
@kelechichinaka how do you want the number returned ?
Kelechi Chinaka
@ke1echi
Jun 18 2017 09:18
2 decimal points
its rounding to an interger
Ogundele Olumide
@Lumexralph
Jun 18 2017 09:18
@kelechichinaka i think there's a workaround provided on that same page for decimals, let me check
Pieter Stokkink
@forkerino
Jun 18 2017 09:19
@kelechichinaka multiply by 100. Math.round(). divide by 100
Kelechi Chinaka
@ke1echi
Jun 18 2017 09:19
i tried to use toFixed(2)
Pedro Diaz
@Pjdaze
Jun 18 2017 09:20
hello early birds i just got off work got home with something that was bothering me at my janitor boring job lol
here is an example
HOURHAND.style.transform = 'rotate(' + hrPosition + 'deg)';
Tarun Garhwal
@eoo
Jun 18 2017 09:25
ugh, another wall
why is that not working
Kelechi Chinaka
@ke1echi
Jun 18 2017 09:32
@kelechichinaka multiply by 100. Math.round(). divide by 100 @forkerino pls i dont understand
Dmitry
@Wasterlord
Jun 18 2017 09:32
guys how change first letter of string?
itsthomas
@itsthomas
Jun 18 2017 09:32
Should the content of a JSON file alwasy starts with an array? or a JSON file might starts with an object or with an array and could be any combination of objects and arrays?
Kelechi Chinaka
@ke1echi
Jun 18 2017 09:33
u can split the string and change it @Wasterlord
Dmitry
@Wasterlord
Jun 18 2017 09:34
@kelechichinaka this one way?
Ogundele Olumide
@Lumexralph
Jun 18 2017 09:35
@kelechichinaka
Math.round(100 * 34.576) /100;
abraham anak agung
@padunk
Jun 18 2017 09:36
@itsthomas look here http://www.json.org/
Ogundele Olumide
@Lumexralph
Jun 18 2017 09:37
@Wasterlord index the first character of the string use the toUpperCase() method then concatenate with the substring of the string excluding the first character
@Wasterlord string[0].toUpperCase() + string(substring excluding the first character)
Kelechi Chinaka
@ke1echi
Jun 18 2017 09:38
how did u do it @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 18 2017 09:38
@itsthomas most JSON i have experienced is a mix of array and objects nested
@kelechichinaka do what?
itsthomas
@itsthomas
Jun 18 2017 09:39
@Lumexralph thanks. It means it might start with an Array and it might start with an Object. Right?
CamperBot
@camperbot
Jun 18 2017 09:39
itsthomas sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1951 | @lumexralph |http://www.freecodecamp.com/lumexralph
Kelechi Chinaka
@ke1echi
Jun 18 2017 09:40
i need to up my math skills @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 18 2017 09:42
@Pjdaze HOURHAND is a constant variable holding a DOM element and the style attribute is accessed and the style attributes also has a method called transform and it's assigned the string which will be how the style will apply the transform attribute to the DOM element held by HOURHAND
@itsthomas yeah, but most I have worked with started with an array
@kelechichinaka same here :smile: just not had had time yet
itsthomas
@itsthomas
Jun 18 2017 09:44
@Lumexralph Great! Thanks
CamperBot
@camperbot
Jun 18 2017 09:44
itsthomas sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: itsthomas already gave lumexralph points
Ogundele Olumide
@Lumexralph
Jun 18 2017 09:44
@itsthomas :+1:
Dmitry
@Wasterlord
Jun 18 2017 09:44
@Lumexralph do it by split but anyway thx
CamperBot
@camperbot
Jun 18 2017 09:44
wasterlord sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1952 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 18 2017 09:44
@Wasterlord okay
Dmitry
@Wasterlord
Jun 18 2017 09:45
@kelechichinaka thx for idea with split
CamperBot
@camperbot
Jun 18 2017 09:45
wasterlord sends brownie points to @kelechichinaka :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @kelechichinaka |http://www.freecodecamp.com/kelechichinaka
Jen
@jenniredfield
Jun 18 2017 09:50

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArr = [];
  var result = [];
  var end = [];
  newArr = arr.slice(0,2);
  result = arr.slice(2);
  arr.push(newArr);
  end.push(newArr);
  end.push(result);



  return end;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
anyone stuck on chunkArrayInGroups?
Kelechi Chinaka
@ke1echi
Jun 18 2017 09:50
that logic was cool..to remove the decimal point first, roundup and get the decimal @Lumexralph
Jen
@jenniredfield
Jun 18 2017 09:50
I know this is not the answer... I just wrote this down to think a bit, but.. how do I get to slice array into the length of size? can't really think
Pieter Stokkink
@forkerino
Jun 18 2017 09:56
@jenniredfield you need a loop. Try to see if you can construct one where every time you start at a point size further in the array than the previous round.
Jen
@jenniredfield
Jun 18 2017 10:05
@forkerino so something like for (var i = 0; i < arr.length; i++)
Sweet Coding :)
@SweetCodingInc
Jun 18 2017 10:06
@jenniredfield right.. and inside your loop, you'll slice the array and add that slice to the newArr
Pieter Stokkink
@forkerino
Jun 18 2017 10:07
@jenniredfield the easiest solution would require you to increase i by something other than 1
Tarun Garhwal
@eoo
Jun 18 2017 10:08
okay need to clear something out.
this is the json object I'm getting using getJSON https://goo.gl/UQBDem
so if i run json.forEach(function(val))
the value for 'val' is a dictionary each time right?
i hope im clear enough
Pieter Stokkink
@forkerino
Jun 18 2017 10:10
javascript doesn't have dictionaries, but yes, they are objects. @eoo
Thomas
@sjurs1
Jun 18 2017 10:10

I'm back with my shitty understanding of replace():


function test(arr) {
  var arrCheck = arr.reduce(function(a, b) {
    if (a.indexOf(b) !== -1) {
      console.log(a.indexOf(b));
      a.splice(a.indexOf(b),1);
      console.log(a);
      return a;
    }
    else return a.concat(b);
}, arguments[0]);
  return arrCheck;
}

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

This returns [2, 4] and logs this:

0
(3) [2, 3, 4]
1
(2) [2, 4]
0
(3) [2, 3, 4]
1
(2) [2, 4]
Jeffrey
@code4meplz
Jun 18 2017 10:10
@jenniredfield iam stuck at the same, though i have a right solution,but it doesnt pass somehow:(
Tarun Garhwal
@eoo
Jun 18 2017 10:11
@forkerino so what is the value of 'val' in the function? i need to know to format it accordingly
Jen
@jenniredfield
Jun 18 2017 10:12
Pieter how do you increase i by something other than 1 ? i+size for example?
Pieter Stokkink
@forkerino
Jun 18 2017 10:13
@jenniredfield yeah, but you need to assign as well, otherwise i will not be updated. You can use i = i + size or i+=size
@eoo it will be a single quote object with a quote and author.
@sjurs1 its a very bad idea to use .splice inside of any loop (and .reduce is also a form of a loop)
Jen
@jenniredfield
Jun 18 2017 10:15
Pieter cheers didnt know that
Pieter Stokkink
@forkerino
Jun 18 2017 10:15
you just have to return the thing you want to pass on to the next round. @sjurs1
Jen
@jenniredfield
Jun 18 2017 10:16
so something like this wouldnt work right
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArr = [];
  var result = [];
  var end = [];

  for (var i = 0; i < arr.length; i++) {
     newArr = newArr.slice(i,size);
     result.push(newArr);
  }

  return result;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
this is giving me a bunch of empty arrays :D
Pieter Stokkink
@forkerino
Jun 18 2017 10:16
@jenniredfield once i will be bigger than size, the .slice will return empty array
if you increase i by size and think about what to use as second argument for .slice (it is the endpoint of the slice, so it should move along as well as i), you'll get a lot closer
yanivlt
@yanivlt
Jun 18 2017 10:17
Pls help with the Counting Cards - https://www.freecodecamp.com/challenges/counting-cards. How do I do that? I guess using switch but do not know what to write in the return or should I add another var...
Sweet Coding :)
@SweetCodingInc
Jun 18 2017 10:18
@jenniredfield : You're mostly on the right track. Only thing is you need to be slicing arr and not newArr
Secondly, you need to increment i by size and not by 1.
Ogundele Olumide
@Lumexralph
Jun 18 2017 10:19
@yanivlt use switch as you said, to increment or decrement count and use a conmditional statement to check if count is positive > 0 or not then you return count + string(Bet or Hold)
Thomas
@sjurs1
Jun 18 2017 10:19
@forkerino Huh. I can still use splice though right, just put it outside of my if statement...? If not I guess my approach to this challenge is off base
Pieter Stokkink
@forkerino
Jun 18 2017 10:19
@yanivlt there are two parts that you need to write:
  • a part where you increase/decrease count based on the value of card.
  • a part where you return the right string based on the value of count.
@sjurs1 it will be much better if you do not use splice at all, because it changes the array you are working on. with .reduce you generally want to create a new array rather than change an existing array. Of course it is possible to do, but bad practice, as anyone reading your code will assume it won't change the input (when in fact it does).
Thomas
@sjurs1
Jun 18 2017 10:22
@forkerino So I should start with an empty array and push values into it instead?
Jen
@jenniredfield
Jun 18 2017 10:25
@forkerino and @SweetCodingInc thanks guys
CamperBot
@camperbot
Jun 18 2017 10:25
jenniredfield sends brownie points to @forkerino and @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 24 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
:star2: 2657 | @forkerino |http://www.freecodecamp.com/forkerino
yanivlt
@yanivlt
Jun 18 2017 10:33

@Lumexralph Thanks. Looks like I did it: function cc(card) {
// Only change code below this line

switch(card){

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

case 7:
case 8:
case 9:
 count +=0;
 break;


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

}

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

CamperBot
@camperbot
Jun 18 2017 10:33
yanivlt sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1953 | @lumexralph |http://www.freecodecamp.com/lumexralph
Pieter Stokkink
@forkerino
Jun 18 2017 10:36
@sjurs1 that's indeed a better way (.concat) is often better inside .reduce
@yanivlt you can safely remove case 7-9 as it doesn't change anything.
@yanivlt you can also do count + " Bet"
yanivlt
@yanivlt
Jun 18 2017 10:39
thanks for the tip
Dmitry
@Wasterlord
Jun 18 2017 10:42

guys code works right - but i cant complete this task.
var newArray = [];

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

  }

}newArray.push(biggest);

}

return newArray;
}
largestOfFour([[100, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]);

just miss it?
abraham anak agung
@padunk
Jun 18 2017 10:43
@Wasterlord your newArray is a global variable
Dmitry
@Wasterlord
Jun 18 2017 10:44
@padunk thx) now complete
CamperBot
@camperbot
Jun 18 2017 10:44
wasterlord sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 343 | @padunk |http://www.freecodecamp.com/padunk
abraham anak agung
@padunk
Jun 18 2017 10:44
:+1:
Thomas
@sjurs1
Jun 18 2017 10:45

@sjurs1 that's indeed a better way (.concat) is often better inside .reduce

If I do it that way (push values into array if they aren't there), I still have to remove values if they ARE there. Or should I execute a comparison of the arguments' array values BEFORE i push?

I miss for loops.....
Pieter Stokkink
@forkerino
Jun 18 2017 10:52
@sjurs1 Normally the .reduce looks at each value in turn. If you just need to push some values to an array, .filter or .forEach would be a better choice. What are you trying to do exactly?
Rinor Bivolaku
@RinorNotorious
Jun 18 2017 10:52

@Wasterlord You could also do it like this:

function largestOfFour(arr) {
// You can do this!
var newArray = [];

for(var i = 0; i < arr.length; i++){
arr[i].sort(function(a, b){
return b-a;
});
newArray.push(arr[i][0]);
}
return newArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
-
That way you wouldn't need two for loops

Pieter Stokkink
@forkerino
Jun 18 2017 10:57
@RinorNotorious .sort() is very innefficient. Math.max would be better.
shuja sayyad
@mesut-shuja
Jun 18 2017 11:05
var myStr="I am a \"double quoted\" string inside\"double quotes\"."; error?
Pieter Stokkink
@forkerino
Jun 18 2017 11:05
@Wasterlord one minor improvement is to just update biggest if it is smaller than arr[i][j], can save unnecessary overwriting of the variable. Another thing is that if all values in an array are negative, you function would return 0 instead of the largest number in there. Initializing biggest to -Infinity or the first value of the subarray would be better.
@mesut-shuja you miss a space after 'inside'
shuja sayyad
@mesut-shuja
Jun 18 2017 11:06
k
Lukáš Hanák
@lukashanak
Jun 18 2017 11:13
@lukashanak
Someone who knows what I do wrong? It's program for calculate surface of pyramid. It should return 6 values, but last 2 (SP and S) are not returned... I use prompt("someQuestion") method.. but when I use instead it this '
var a = 8;
var h = 4;
var v = 0;
var pocetStran = 4;'
so it return all 6 values
where is the problem ? https://codepen.io/lukashanak/pen/yXgRjG?editors=0010
TWoerner94
@TWoerner94
Jun 18 2017 11:15
Sup guys, I got a little problem with the Exact Change challenge
I apologize in advance for the long code lmao

function checkCashRegister(price, cash, cid) {
  var change = [
    ["HUNDRED", 0.00], 
    ["TWENTY", 0.00], 
    ["TEN", 0.00], 
    ["FIVE", 0.00], 
    ["ONE", 0.00],
    ["QUARTER", 0.00],
    ["DIME", 0.00],
    ["NICKEL", 0.00],
    ["PENNY", 0.00]
  ];

  var amount = cash - price;

  if (amount === (cid[8][1] + cid[7][1] + cid[6][1] + cid[5][1] + cid[4][1] + cid[3][1] + cid[2][1] + cid[1][1] + cid[0][1])) {
    return "Closed";
  }

  while (amount > 0) {
    if (amount >= 100 && cid[8][1] >= 100) {
      change[0][1] += 100.00;
      amount -= 100;
      cid[8][1] -= 100;
      continue;
    } else if (amount >= 20 && cid[7][1] >= 20) {
      change[1][1] += 20.00;
      amount -= 20;
      cid[7][1] -= 20;
      continue;
    } else if (amount >= 10 && cid[6][1] >= 10) {
      change[2][1] += 10.00;
      amount -= 10;
      cid[6][1] -= 10;
      continue;
    } else if (amount >= 5 && cid[5][1] >= 5) {
      change[3][1] += 5.00;
      amount -= 5;
      cid[5][1] -= 5;
      continue;
    } else if (amount >= 1 && cid[4][1] >= 1) {
      change[4][1] += 1.00;
      amount -= 1;
      cid[4][1] -= 1;
      continue;
    } else if (amount >= 0.25 && cid[3][1] >= 0.25) {
      change[5][1] += 0.25;
      amount -= 0.25;
      cid[3][1] -= 0.25;
      continue;
    } else if (amount >= 0.1 && cid[2][1] >= 0.1) {
      change[6][1] += 0.1;
      amount -= 0.1;
      cid[2][1] -= 0.1;
      continue;
    } else if (amount >= 0.05 && cid[1][1] >= 0.05) {
      change[7][1] += 0.05;
      amount -= 0.05;
      cid[1][1] -= 0.05;
      continue;
    } else if (amount >= 0.01 && cid[0][1] >= 0.01) {
      change[8][1] += 0.01;
      amount -= 0.01;
      cid[0][1] -= 0.01;
      continue;
    } else {
      return "Insufficient Funds";
    }
  }

  for (i=0; i<change.length; i++) {
    if (change[i][1] === 0) {
      change.splice(i,1);
    }
  }

  return change;
}

checkCashRegister(20.00, 265.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 500.00]]);
It returns
``
[["HUNDRED", 200], ["TWENTY", 40], ["FIVE", 5], ["QUARTER", 0], ["NICKEL", 0]]
So my question is why the quarter and nickel arent being spliced
Pieter Stokkink
@forkerino
Jun 18 2017 11:18
@TWoerner94 splice changes the length of the array, so your loop will mess up and skip some values.
TWoerner94
@TWoerner94
Jun 18 2017 11:19
Oh dang, is there a better way then?
I tried delete but that just turned the subarrays into null
Pieter Stokkink
@forkerino
Jun 18 2017 11:19
@TWoerner94 .filter
TWoerner94
@TWoerner94
Jun 18 2017 11:19
Alright gonna try that out thanks @forkerino
CamperBot
@camperbot
Jun 18 2017 11:19
twoerner94 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2658 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jun 18 2017 11:21
@lukashanak You get an error: ReferenceError: b is not defined (in the ziskat_SP function)
plz help
what to do
Lukáš Hanák
@lukashanak
Jun 18 2017 11:31
@forkerino Thank's.. I am going to repair it. But it still won't work well, still it won't return all 6 values.
CamperBot
@camperbot
Jun 18 2017 11:31
lukashanak sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2659 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jun 18 2017 11:34
@lukashanak It is difficult to understand exactly what each function is supposed to do because I don't understand the language. But make sure to check the console of your browser for errors (often you can access it with F12).
Michał Kozłowski
@kozlovvski
Jun 18 2017 11:44
Just finished a project - looking for feedback: https://mcbiggos.github.io/fireworks-js/
abraham anak agung
@padunk
Jun 18 2017 11:49
great work @McBiggos
Pieter Stokkink
@forkerino
Jun 18 2017 11:49
@McBiggos looks great! fun effect.
Nico
@anwarnico
Jun 18 2017 11:49

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

how can i solve this with nextInLine>
?
Michał Kozłowski
@kozlovvski
Jun 18 2017 11:50
@padunk @forkerino thanks <3
CamperBot
@camperbot
Jun 18 2017 11:50
mcbiggos sends brownie points to @padunk and @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 344 | @padunk |http://www.freecodecamp.com/padunk
:star2: 2660 | @forkerino |http://www.freecodecamp.com/forkerino
Ravi Kishore Thella
@ravikishorethella
Jun 18 2017 11:50
@McBiggos cool, good work man :clap:
abraham anak agung
@padunk
Jun 18 2017 11:50
@anwarnico pakai shift dan push, u speak bahasa?
Pieter Stokkink
@forkerino
Jun 18 2017 11:50
@shashank1999coder @anwarnico You need to use two of the array methods you learned a few exercises ago in the Manipulate Arrays With ... exercises
@McBiggos made from scratch or did you use some library?
Nico
@anwarnico
Jun 18 2017 11:51
@padunk iya, gimana contoh nya ?
Michał Kozłowski
@kozlovvski
Jun 18 2017 11:51
@forkerino everything in vanilla JS
Pieter Stokkink
@forkerino
Jun 18 2017 11:53
@McBiggos awesome. Can I have a look at the source?
Nico
@anwarnico
Jun 18 2017 11:53
@forkerino can you give me an example ? i still dont get it
Pieter Stokkink
@forkerino
Jun 18 2017 11:54
@anwarnico @padunk already told you which to use. If you don't understand how they work, look back at the relevant exercises.
Michał Kozłowski
@kozlovvski
Jun 18 2017 11:54
@forkerino yeah, sure - everything is in repo: https://github.com/McBiggos/fireworks-js
tried to comment everything as clearly as possible :D
Pieter Stokkink
@forkerino
Jun 18 2017 12:02
@McBiggos thanks, will have a closer look at it later. It's something completely different than what I usually like to build and I haven't worked much with canvas, so interested in what kind of patterns you use. :+1:
CamperBot
@camperbot
Jun 18 2017 12:02
forkerino sends brownie points to @mcbiggos :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @mcbiggos |http://www.freecodecamp.com/mcbiggos
Michał Kozłowski
@kozlovvski
Jun 18 2017 12:05
sure - should something be unclear, message me - I will explain and update the comment, so anyone would get what is happening there :D
any help anyone
Saif Ur Rahman
@saifsmailbox98
Jun 18 2017 12:10

@mnksingh create another object similar to the one given and add it to the array myMusic

var myMusic= [ { object 1} , { object 2 } ];

Keon Samuel
@keonsam
Jun 18 2017 12:11
??
myMusic.push()
Saif Ur Rahman
@saifsmailbox98
Jun 18 2017 12:12
no need to push
see the comment // Add record here
@keonsam
Samuel
@MrGreeeen
Jun 18 2017 12:13
hey guys im stuck on the stand
Keon Samuel
@keonsam
Jun 18 2017 12:13
@saifsmailbox98 I see
Samuel
@MrGreeeen
Jun 18 2017 12:13
im stuck on the "Stand in Line" challenge
Samuel
@MrGreeeen
Jun 18 2017 12:14
yeah i have tried using the pop and unshift method but it says its not a function ???
Saif Ur Rahman
@saifsmailbox98
Jun 18 2017 12:15
you first need to insert the item to the end of the array arr using the method push() on the array
And then remove and return the first element of the array using shift() method on the array arr
Amit Nave
@AmiterCodes
Jun 18 2017 12:15
Im trying to do the Repeat a string repeat a string challange
Prajwal100
@Prajwal100
Jun 18 2017 12:15
plz help me:
Amit Nave
@AmiterCodes
Jun 18 2017 12:15
but its only returning it once.

function repeatStringNumTimes(str, num) {
for (var i = 0; i < num; i++) {
return str;
}

}

repeatStringNumTimes("abc", 3);

Prajwal100
@Prajwal100
Jun 18 2017 12:15
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
Amit Nave
@AmiterCodes
Jun 18 2017 12:16
code
Saif Ur Rahman
@saifsmailbox98
Jun 18 2017 12:16

pop(): Remove an item from then end of an array
*pop() returns the removed item.

push(): Add items to then end of an array
*push() returns the new array length.

shift(): Remove an item from then beginning of an array
*shift() returns the removed item.

unshift(): Add items to then beginning of an array
*unshift() returns the new array length.

@MrGreeeen
@Prajwal100 what have you tried?
@AmiterCodes if you are using return it will break the control at the first iteration.
Prajwal100
@Prajwal100
Jun 18 2017 12:18
I am try to convert celsius to fahrenheit
Saif Ur Rahman
@saifsmailbox98
Jun 18 2017 12:19
@Prajwal100 figure out the formula and use celsius to assign the correct temperature in deg. Fahrenheit to the variable fahrenheit
Prajwal100
@Prajwal100
Jun 18 2017 12:20
okey! and thanks
NikolaZimonjic
@NikolaZimonjic
Jun 18 2017 12:21

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

need help, need to add some and remove
do i use pop and push?
Saif Ur Rahman
@saifsmailbox98
Jun 18 2017 12:22
@NikolaZimonjic you first need to insert the item to the end of the array arr using the method push() on the array
And then remove and return the first element of the array using shift() method on the array arr

pop(): Remove an item from then end of an array
*pop() returns the removed item.

push(): Add items to then end of an array
*push() returns the new array length.

shift(): Remove an item from then beginning of an array
*shift() returns the removed item.

unshift(): Add items to then beginning of an array
*unshift() returns the new array length.

NikolaZimonjic
@NikolaZimonjic
Jun 18 2017 12:22
ty
Samuel
@MrGreeeen
Jun 18 2017 12:39
@saifsmailbox98 Finally solved it thankyou!
CamperBot
@camperbot
Jun 18 2017 12:39
mrgreeeen sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 494 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jun 18 2017 12:45
@MrGreeeen yw
Shyamli Arora
@CiaoShyamli
Jun 18 2017 12:46
hey guys please help in solving this question Counting Cards in javascript.
Pieter Stokkink
@forkerino
Jun 18 2017 12:47
@CiaoShyamli did you try something already?
if so, show your code!
Wadie
@wadie
Jun 18 2017 12:49
Can someone explain to me the outcome of this line
Math.round(Math.pow(Math.sqrt(2) + Math.sqrt(2), 2))
Why is it 8 ?
Shyamli Arora
@CiaoShyamli
Jun 18 2017 12:49

var count = 0;

function cc(card) {
// Only change code below this line
if( card >= 2|| card<= 6)
{
count++;

   return count+" Bet";
  }

   else{
     count--;
     return count+" Hold";
   }

}

// Only change code above this lin}

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

Saif Ur Rahman
@saifsmailbox98
Jun 18 2017 12:51
@wadie because it's (√2+√2)² = (2√2)² = 2² x (√2)²= 4 x 2= 8
Pieter Stokkink
@forkerino
Jun 18 2017 12:51
@CiaoShyamli you have to separate the part where you change count from the part where you return.
Shyamli Arora
@CiaoShyamli
Jun 18 2017 12:51
ok
i did that also but not giving exact output
it has to show the final count
Markus Kiili
@Masd925
Jun 18 2017 12:54
@forkerino Yo.
Wadie
@wadie
Jun 18 2017 12:55
@saifsmailbox98 thx
CamperBot
@camperbot
Jun 18 2017 12:55
wadie sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 495 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Pieter Stokkink
@forkerino
Jun 18 2017 13:01
ski resort still open?
@Masd925 Hey!
Paul Christian L. Catoera
@poncatoera
Jun 18 2017 13:01

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var arrNew = [];
  for (var i = 0; i < size; i++) {
  arrNew.push(arr.slice(i * size, (1 + i) * size));
  }
  return arrNew;
}

chunkArrayInGroups(["a", "b", "c", "d"], 4);
Pieter Stokkink
@forkerino
Jun 18 2017 13:01
^apparently asynchronous issues on gitter when the message doesn't go through right away. @Masd925
Paul Christian L. Catoera
@poncatoera
Jun 18 2017 13:01
can anyone help me with this? i get the correct array but it adds empty arrays to match the number
Pieter Stokkink
@forkerino
Jun 18 2017 13:02
@poncatoera the condition of your for loop should probably refer to arr.length somewhere.
Paul Christian L. Catoera
@poncatoera
Jun 18 2017 13:02
@forkerino okay ill try
ty
Paul Christian L. Catoera
@poncatoera
Jun 18 2017 13:10
i did this and it was right
```

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var arrNew = [];
  for (var i = 0; arrNew.length < arr.length / size; i++) {
  arrNew.push(arr.slice(i * size, (1 + i) * size));
  }
  return arrNew;
}

chunkArrayInGroups(["a", "b", "c", "d"], 1);
but not sure if it is lol hahah
Markus Kiili
@Masd925
Jun 18 2017 13:12
@forkerino Not sure. Was open a week ago.
@forkerino I did a breakthrough on a java software I have been writing for 3 years (started it when I started programming with C++). Finally starting to get some fine results out.
Dennis Daubney Jr
@MrOolong
Jun 18 2017 13:14
im having trouble with manipulating Arrays with unshift
it seems easy in the example where it's just one unshifting with "happy", but in my exercise i'm supposed to unshift ["Paul",35"]
schizo99
@shashank1999coder
Jun 18 2017 13:19

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

}
return item ; // Change this line
}

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

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

Diego Mayer
@Chrono79
Jun 18 2017 13:21
@MrOolong ["Paul",35"] that last quote doesn't go there
Dennis Daubney Jr
@MrOolong
Jun 18 2017 13:21

// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.shift(); // ourArray now equals ["J", "cat"]
ourArray.unshift("Happy");
// ourArray now equals ["Happy", "J", "cat"]

// Setup
var myArray = [["John", 23], ["dog", 3]];
myArray.shift();

// Only change code below this line.
myArray.unshift("Paul", 35);

@Chrono79 ty, I typed that wrong, can you look at the message I just posted?
Diego Mayer
@Chrono79
Jun 18 2017 13:22
@MrOolong you need to unshift an array, missed the brackets there
Dennis Daubney Jr
@MrOolong
Jun 18 2017 13:24
@Chrono79 so use brackets instead of parenthesis?
Diego Mayer
@Chrono79
Jun 18 2017 13:24
@shashank1999coder click restart, and review all 4 array manipulation challenges, you need to use 2 of them there
@MrOolong no, inside the parentheses
Dennis Daubney Jr
@MrOolong
Jun 18 2017 13:25
@Chrono79 awesome, thank you
CamperBot
@camperbot
Jun 18 2017 13:25
mroolong sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4331 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 18 2017 13:25
:+1:
techiespace
@techiespace
Jun 18 2017 13:26

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

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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");

Pieter Stokkink
@forkerino
Jun 18 2017 13:26
@Masd925 Nice! I'm currently doing a lot of interesting puzzles over at codewars, so when that final ski resort closes, you might want to take a look as well. Great practice material.
techiespace
@techiespace
Jun 18 2017 13:26
Whats wrong with my code?
Markus Kiili
@Masd925
Jun 18 2017 13:26
@forkerino I promised to start Codewars this summer.
Diego Mayer
@Chrono79
Jun 18 2017 13:27
@techiespace don't use dot notation with vars return contacts[i].prop;
if(!contacts[0].hasOwnProperty(prop))
return "No such property";
why that?
techiespace
@techiespace
Jun 18 2017 13:28
Got it. Thank you @Chrono79
CamperBot
@camperbot
Jun 18 2017 13:28
techiespace sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4332 | @chrono79 |http://www.freecodecamp.com/chrono79
techiespace
@techiespace
Jun 18 2017 13:28
@Chrono79 Because the problem says to return that string is the prop doesn't exist
Diego Mayer
@Chrono79
Jun 18 2017 13:29
@techiespace but why only test contacts[0]? You don't know if the firstName matches yet, that code is before the loop
techiespace
@techiespace
Jun 18 2017 13:30
Okay so i need to put that in the for loop right?
Diego Mayer
@Chrono79
Jun 18 2017 13:30
yes, modified ofc
Pieter Stokkink
@forkerino
Jun 18 2017 13:30
@Masd925 I remember!
techiespace
@techiespace
Jun 18 2017 13:31
:+1: @Chrono79
nit007
@nit007
Jun 18 2017 13:31
Hey guys, i am unable to figure this challenge , any directions ?

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

var props=contacts[prop];
var value = contacts.hasOwnProperty(prop);

if (value === false){
return "No such property";
}

if(props === false){
return "No such contact";
}

return prop;

// Only change code above this line
}

its profile lookup
Markus Kiili
@Masd925
Jun 18 2017 13:31
@forkerino I just started my 1 month vacation, so maybe soon.
nit007
@nit007
Jun 18 2017 13:35
?
Diego Mayer
@Chrono79
Jun 18 2017 13:36
@nit007 contacts is an array, use a loop to access a single contact
Pieter Stokkink
@forkerino
Jun 18 2017 13:36
@Masd925 ah nice. Have a great holiday. Going somewhere?
Markus Kiili
@Masd925
Jun 18 2017 13:37
@forkerino Nothing special. Maybe some short cruise to Estonia and some summer cottage visits in Finland. Mostly hanging out with kids.
Mike Lemuel Bacayo
@mikeelemuel
Jun 18 2017 13:38
image.png
hi I am suppose to achieve those challenges how ever i can't manage to answer it. Can anyone help me through this challenge
Diego Mayer
@Chrono79
Jun 18 2017 13:38
@mikeelemuel review Constructing strings with variables, read mad libs link too
Tsitsi
@Tsitsimelody
Jun 18 2017 13:39

Hi im on the same as @nit007 I have done the loop the problem is the else function lookUpProfile(firstName, prop){
// Only change code below this line

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

if (contacts[i].firstName == firstName){
  var objects = contacts[i];


  for( var pro in objects){

    if(objects.hasOwnProperty(prop)){

      return objects[prop];
    } else {
      return "No such property";
    }
  }


} else {
  return "No such contact";
}

}

Mike Lemuel Bacayo
@mikeelemuel
Jun 18 2017 13:39
@Chrono79 what do you mean?
Diego Mayer
@Chrono79
Jun 18 2017 13:39
@mikeelemuel https://www.freecodecamp.com/challenges/constructing-strings-with-variables <- see that
result is a string, you're trying to add properties to it with what you did <- not ok
@Tsitsimelody you don't need a second loop, and you return No such contact at the first mismatch
Mike Lemuel Bacayo
@mikeelemuel
Jun 18 2017 13:41
@Chrono79 i still cant understand
Pieter Stokkink
@forkerino
Jun 18 2017 13:41
@Masd925 Cool. Days must be getting nice and long up there. Even here in Holland it is light until around 11pm.
Mike Lemuel Bacayo
@mikeelemuel
Jun 18 2017 13:41
can you give me an example?
@Chrono79 can you give me an example?
Diego Mayer
@Chrono79
Jun 18 2017 13:42
@mikeelemuel result = "My "+myAdjective...;
Markus Kiili
@Masd925
Jun 18 2017 13:42
@forkerino Yes. Glad to have some light after long dark winter.
Tsitsi
@Tsitsimelody
Jun 18 2017 13:42
@Chrono79 Thanks ill try again