These are chat archives for FreeCodeCamp/HelpJavaScript

31st
May 2017
makista2
@makista2
May 31 2017 00:03
please help about Return a Value from a Function with Return
is this correct
function timesFive(num) {
return num * 5;
}
danghv
@danghv
May 31 2017 00:05
@makista2 yeah it's right
Carlos Melero
@fcc-cmelblan
May 31 2017 00:06
I am a "double quoted" string inside "double quotes". How did you solve this exercise ?
Manish Giri
@Manish-Giri
May 31 2017 00:07
@fcc-cmelblan post the url
danghv
@danghv
May 31 2017 00:07
@fcc-cmelblan use "single quote" or \
MJ
@mjcello
May 31 2017 00:11

eek! looks like i'm not really grasping the "access multidimensional arrays with indexes" concept.....here's what i've got:

// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][2][1];

I think I'm misunderstanding what it's asking for....

MordecaiMan
@MordecaiMan
May 31 2017 00:11

So I am fairly early on and its saying that 'a' is not assigned to 'b' with '=' even though it is
// Setup
var a;
var b = 2;

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

Anyone know what I'm doing wrogn?
*wrong?
Manish Giri
@Manish-Giri
May 31 2017 00:12
@mjcello myArray[0][2][1];
why do you have 3 indices?
MJ
@mjcello
May 31 2017 00:12
oh! the return should be 8
Manish Giri
@Manish-Giri
May 31 2017 00:12
@MordecaiMan a=b;
here you're assigning b to a
doesn't it ask for the reverse?
MordecaiMan
@MordecaiMan
May 31 2017 00:13
Wait, shit
dannysanchez559
@dannysanchez559
May 31 2017 00:13
can anyone spot whats wrong with my getGear constructor:
MordecaiMan
@MordecaiMan
May 31 2017 00:13
Youre right
dannysanchez559
@dannysanchez559
May 31 2017 00:13

var Bike = function() {

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

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

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

Manish Giri
@Manish-Giri
May 31 2017 00:13
@dannysanchez559 gear += change;
should be just =
dannysanchez559
@dannysanchez559
May 31 2017 00:13
thanks!
MJ
@mjcello
May 31 2017 00:13
ah, i think i miscounted a bracket. thank you!
that's correct; i should've had 2 brackets. thank you very much!
MordecaiMan
@MordecaiMan
May 31 2017 00:15
Being someone who took APCS which uses java and learning JavaScript is so weird. Like its familiar but it is still completely different.
Carlos Melero
@fcc-cmelblan
May 31 2017 00:15
solved, I forgot the dot between "." at the end. Silly error !
Ken Haduch
@khaduch
May 31 2017 00:17
@Chrono79 - re: :point_up: May 30, 2017 11:15 AM - yes, there is a lot of reading to do! I figured that having access to various books would be potentially useful. Thanks for the comment!
CamperBot
@camperbot
May 31 2017 00:17
khaduch sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4145 | @chrono79 |http://www.freecodecamp.com/chrono79
Keith Thor
@kthor
May 31 2017 00:19
On the symmetric difference problem, why use the reduce() function?
Sidafa Conde
@sconde
May 31 2017 00:24
Hello
I'm having trouble with jquery.

$.getJSON(api, function(data){
alert("sidafa");
});

the alert is not being executed

Joel Korcsmaros
@lossness
May 31 2017 00:25
hey guys need some advice: Stuck on the "Profile Lookup" problem in the javascript basic 10 Hours section. I've got the right code for firstName but can't figure out how to combine the prop into the answer. When I get stuck on stuff like this i've been giving up and googling the title of the problem then telling myself i'll learn from it. Is it better to stick to it and keep running things through my head till I figure it out or is it a waste of time in the grand scheme of things?
Also, what does it mean if the test area shows nothing when I run tests?
Sidafa Conde
@sconde
May 31 2017 00:27
I could really use some help
Alvin-Capello
@Alvin-Capello
May 31 2017 00:30
I @lossness Could you post your code so we can see?
doridarien
@doridarien
May 31 2017 00:37

HI, working on Mutations challenges,
function mutation(arr) {
return arr[1].toLowerCase()
.split('')
.every(function(letter) {
return arr[0].toLowerCase()
.indexOf(letter) != -1;
});
}
mutation(["hello", "he"]);

In this case is arr[1] stored inside "letter" parameter inside the function to compare with arr[0] ?

Stephen James
@sjames1958gm
May 31 2017 00:39
@doridarien letter is each letter from arr[1] in turn
Alvin-Capello
@Alvin-Capello
May 31 2017 00:41
I actually could use some help myself. I am on the Caesars Cipher challenge. I am trying to convert all of the characters in the given string to Unicode, but I cannot seem to keep the nonalphanumeric characters as they are. Here is my code...
function rot13(str) { // LBH QVQ VG!
var strArray = [];
for (var i = 0; i <= str.length; i++) {
if (str.charCodeAt(i) >= 64 && str.charCodeAt(i) <= 90) {
strArray.push(str.charCodeAt(i));
} else {
strArray.push(str[i]);
}
}
return strArray;
}
Could anyone help?
To give some more info, the code I do have converts punctuation marks to a null value, when the code clearly says to leave them as they are.
Caleb Cox
@CalebCox
May 31 2017 00:43
Good Evening everyone!

Working on the weather app project and I'm having an odd problem with taking JSON data and converting it to HTML on my page. On page load it only displays the latitude and longitude on the first html+= on line 12. However, if I go into developer tools and ask it to tell me what 'html' is defined as it shows all the proper information. Forcing the $(".jumbotron").html(html) via console commands updates the page properly. I'm unsure as to why on page load this doesn't just work?

Here's my code below, API Keys left out.

var latitude, longitude;
var html = "";

$(document).ready(function() {


  if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position){
      latitude = position.coords.latitude;
      longitude = position.coords.longitude;

      html += "<p>Latitude: " + latitude + "<br>Longitude: " + longitude + "</p>";

      $.getJSON("https://maps.googleapis.com/maps/api/geocode/json?latlng=" + latitude + "," + longitude + "&key=[API KEY HERE]", function(location) {
        html += "<h2 class='text-center'> Location: " + location.results[0].address_components[3].long_name + ", " + location.results[0].address_components[5].short_name + ", " + location.results[0].address_components[6].long_name;
      });

      $.getJSON("https://crossorigin.me/https://api.darksky.net/forecast/[API KEY HERE]/" + latitude + "," + longitude, function(weather) {
        html += "<p id='temp'>" + weather.currently.temperature + "&deg; F</p><br><p id='conditions'>" + weather.currently.summary + "</p>";
      });

      $(".jumbotron").html(html);

    });
  }
});
doridarien
@doridarien
May 31 2017 00:47
@sjames1958gm Thank you. how does JavaScript knows to store each letters of arr[1] into the "letter"..?
CamperBot
@camperbot
May 31 2017 00:47
doridarien sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7554 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 31 2017 00:47
@Alvin-Capello Why not just do the whole cipher inside the if and then push the ciphered character. If you don't you will have an array of strings and numbers
@doridarien That is how every works. It calls the function you give it with each value in the array.
then if every call to the function returns true every returns true.
Alvin-Capello
@Alvin-Capello
May 31 2017 00:50
@sjames1958gm Ok, I will try that. But how is my code not leaving the nonalphanumeric characters as they are?
Stephen James
@sjames1958gm
May 31 2017 00:50
@CalebCox Because the getJSON are asynchronous this $(".jumbotron").html(html); runs
before either of the html += inside the getJSON callbacks
Caleb Cox
@CalebCox
May 31 2017 00:51
Oh, I didn't think that would be an issue as I had the .html(html) at the bottom. Without giving me an answer, what should i search to resolve the issue?
Nick Gray
@nicholasnbg
May 31 2017 00:51
hey all, can anyone help with an es6 question?
I can't remember if there was a better way of writing if statements with arrow functions
Stephen James
@sjames1958gm
May 31 2017 00:52
@CalebCox You are going to have to embed the second getJSON in the callback for the first and then the
jumbotron line inside that callback.
@Alvin-Capello I ran your code at it left the spaces alone (the undefined is because you have <= str.length
rot13("SERR PBQR PNZC");
(15) [83, 69, 82, 82, " ", 80, 66, 81, 82, " ", 80, 78, 90, 67, undefined]
Alvin-Capello
@Alvin-Capello
May 31 2017 00:54
@sjames1958gm Oh I see, thank you very much!
CamperBot
@camperbot
May 31 2017 00:54
alvin-capello sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7555 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 31 2017 00:54
@Alvin-Capello :+1:
Caleb Cox
@CalebCox
May 31 2017 00:55
That did the trick, thanks @sjames1958gm
CamperBot
@camperbot
May 31 2017 00:55
calebcox sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7556 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 31 2017 00:55
@CalebCox :+1:
Nishant Koli
@roxxid
May 31 2017 00:55
Hey guys, I am stuck on Find the Longest Word in a String, I think my code is correct but its not satisfying the last test case.
my code is
Caleb Cox
@CalebCox
May 31 2017 00:55
I appear to need a better understanding of the heirarchy of JS and how things work with eachother.
Nishant Koli
@roxxid
May 31 2017 00:55

function findLongestWord(str) {
var count=0;
var newCount=0;

for(var i=0; i<str.length; i++){ var alpha = str.charAt(i); if(str.charAt(i)==" " || i==str.length-1){ if(newCount < count){ newCount = count; } // else if(newCount > count){

 // }
  count = 0;
  continue;
}
count++;

}
return newCount;
//return str.length;
}

findLongestWord("What if we try a super-long word such as otorhinolaryngology");

Stephen James
@sjames1958gm
May 31 2017 00:55
@CalebCox Async code can be confusing at first.
Caleb Cox
@CalebCox
May 31 2017 00:56
Any good resources you would recommend to get a good jump start on that?
Ken Haduch
@khaduch
May 31 2017 00:56
@roxxid - it's easier to split the sentence into an array of words and loop over that array, getting the length of individual words.
Stephen James
@sjames1958gm
May 31 2017 00:57
@CalebCox There are lots of good videos on youtube on ajax and async
Nishant Koli
@roxxid
May 31 2017 00:58
Yes, but I thought that would require a lot of memory, thats why I tried this approach! Anyways thanks.
doridarien
@doridarien
May 31 2017 00:58
@sjames1958gm thank u
Stephen James
@sjames1958gm
May 31 2017 01:00
@roxxid Looks like you aren't counting the last letter.
Ken Haduch
@khaduch
May 31 2017 01:00
@roxxid - I think that the tradeoff in code complexity vs. the amount of memory used is probably worthwhile.
and who knows how much memory is going to be used either way? It's a one-shot function call so really memory usage should not be a concern at this point.
Nishant Koli
@roxxid
May 31 2017 01:03
Okay thanks, I'll try correcting this code for some while, or else would do it your suggested way. Thank you very much @sjames1958gm @khaduch
CamperBot
@camperbot
May 31 2017 01:03
roxxid sends brownie points to @sjames1958gm and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2928 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 7557 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ken Haduch
@khaduch
May 31 2017 01:05
@roxxid - no problem with trying different approaches, you always learn something from trying it different ways. You can take your code to http://pythontutor.com and plug it in and step through and see the execution of it - helpful for figuring things out.
Stephen James
@sjames1958gm
May 31 2017 01:07
@ThisUserDominates
myVar++;
ThisUserDominates
@ThisUserDominates
May 31 2017 01:08
thanks
tyonum peter
@tvpeter
May 31 2017 01:10
Thanks @leftynaut for your help with Checkpoint: Profile Lookup
CamperBot
@camperbot
May 31 2017 01:10
tvpeter sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
:cookie: 642 | @leftynaut |http://www.freecodecamp.com/leftynaut
zippy
@ShaimaTheBlueberry
May 31 2017 01:19
I need lots of help on Reverse a String does anybody know this challenge and can explain the answer to me?
Jay
@DatumEight
May 31 2017 01:19
image.png
Roxroy
@roxroy
May 31 2017 01:19
@ThisUserDominates , to add one to a variable use the ++ operator.
Jay
@DatumEight
May 31 2017 01:19
can someone error check for me?
zippy
@ShaimaTheBlueberry
May 31 2017 01:19
hello
I need lots of help on Reverse a String does anybody know this challenge and can explain the answer to me?
Roxroy
@roxroy
May 31 2017 01:20
@DatumEight , Tip. 'no such contact' should be out side the for loop. It goes at the very end.
Stephen James
@sjames1958gm
May 31 2017 01:20
@ShaimaTheBlueberry Using split and join you can change a string to/from an array and array has a reverse function.
zippy
@ShaimaTheBlueberry
May 31 2017 01:20
how?
can you show me your code
and why you wrote each part of the code
Stephen James
@sjames1958gm
May 31 2017 01:21
@DatumEight You are not accessing the contacts as in contacts[stuff]
zippy
@ShaimaTheBlueberry
May 31 2017 01:22
@sjames1958gm how did you write it
Stephen James
@sjames1958gm
May 31 2017 01:22
@ShaimaTheBlueberry
function reverse(str) {
var arr = str.split('');  // Convert string to array use '' to split on characters
arr.reverse(); // reverse the array
return arr.join('');  // join the letters back into a string
}
Jay
@DatumEight
May 31 2017 01:23
thanks @sjames1958gm
CamperBot
@camperbot
May 31 2017 01:23
datumeight sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7558 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
zippy
@ShaimaTheBlueberry
May 31 2017 01:23
the return statement is illeagal
illegal
Stephen James
@sjames1958gm
May 31 2017 01:24
@ShaimaTheBlueberry Well it assumes that that code is inside a function
zippy
@ShaimaTheBlueberry
May 31 2017 01:25
what do you mean
should I put it in a function or not
Stephen James
@sjames1958gm
May 31 2017 01:25
@ShaimaTheBlueberry I editted it above
zippy
@ShaimaTheBlueberry
May 31 2017 01:26
it still doesn't work
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
May 31 2017 01:27
@sjames1958gm I made a Tribute page. can you tell me what I could improve? https://s.codepen.io/Ace_Monkey_Ilium/debug/VbJNJp/PBrNWxneDdoA
Stephen James
@sjames1958gm
May 31 2017 01:27
@ShaimaTheBlueberry
function reverse(str) {
var arr = str.split('');  // Convert string to array use '' to split on characters
arr.reverse(); // reverse the array
return arr.join('');  // join the letters back into a string
}
reverse("test string")
"gnirts tset"
zippy
@ShaimaTheBlueberry
May 31 2017 01:28
still doesnt work
Stephen James
@sjames1958gm
May 31 2017 01:28
@Ace-Monkey-Ilium Music is good - maybe make the text a little larger.
That one line that extends to the end of the page is distracting.
@ShaimaTheBlueberry The function reverses a string.
What you are doing with that function, I don't know
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
May 31 2017 01:30
@sjames1958gm I did not mean to put that line
zippy
@ShaimaTheBlueberry
May 31 2017 01:30
never mind it works thanks @sjames1958gm
CamperBot
@camperbot
May 31 2017 01:30
shaimatheblueberry sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7559 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
May 31 2017 01:30
I will make the text larger right now
Stephen James
@sjames1958gm
May 31 2017 01:30
@Ace-Monkey-Ilium :+1:
zippy
@ShaimaTheBlueberry
May 31 2017 01:32
it returns the correct thing but it doesn't do anything to the challenge @sjames1958gm
Stephen James
@sjames1958gm
May 31 2017 01:32
@ShaimaTheBlueberry Didn't they give you the function skeleton in the editor - what was the function name -
zippy
@ShaimaTheBlueberry
May 31 2017 01:33
ummm.... I don't know
the did give the function skeleton in the editor
* they
this is what they gave:

function reverseString(str) {
return str;
}

reverseString("hello");

Ace-Monkey-Ilium
@Ace-Monkey-Ilium
May 31 2017 01:35
@sjames1958gm I made the text larger and also got rid of the white line at the bottom
Kris Baillargeon
@krisb1220
May 31 2017 01:37
Hey guys stuck on "Return Early Patterns for Functions" send code?

// Setup
function abTest(a, b) {
  // Only change code below this line
  if(a || b === 0) {
    return undefined;
  // Only change code above this line
  }
  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
 }


// Change values below to test your code
abTest(2,2);
zippy
@ShaimaTheBlueberry
May 31 2017 01:38
@krisb1220 I am stuck on Reverse a String can u help
Manish Giri
@Manish-Giri
May 31 2017 01:39
@krisb1220 does it ask you to check if it's equal to zero?
Kris Baillargeon
@krisb1220
May 31 2017 01:39
Errrrrr probably not but send the code anyways and I can try :P
Manish Giri
@Manish-Giri
May 31 2017 01:39
or less than 0?
@krisb1220
zippy
@ShaimaTheBlueberry
May 31 2017 01:39
k
Kris Baillargeon
@krisb1220
May 31 2017 01:39
Ohhhhhhhhh
zippy
@ShaimaTheBlueberry
May 31 2017 01:39

function reverseString(str) {
return str;
}

reverseString("hello");

Ace-Monkey-Ilium
@Ace-Monkey-Ilium
May 31 2017 01:39
I got hacked on codepen
Kris Baillargeon
@krisb1220
May 31 2017 01:39
I was using === on the last challenge
Ace-Monkey-Ilium
@Ace-Monkey-Ilium
May 31 2017 01:39
I got logged out
Jay
@DatumEight
May 31 2017 01:40
@ShaimaTheBlueberry can you send a screenshot so we can read the problem?
Kris Baillargeon
@krisb1220
May 31 2017 01:40
@Manish-Giri updated code still not working?
zippy
@ShaimaTheBlueberry
May 31 2017 01:41
my computer doesn't screenshoot
Kris Baillargeon
@krisb1220
May 31 2017 01:41

// Setup
function abTest(a, b) {
  // Only change code below this line
  if(a || b < 0) {
    return undefined;
  // Only change code above this line
  }
  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
 }


// Change values below to test your code
abTest(2,2);
Manish Giri
@Manish-Giri
May 31 2017 01:41
yes
you need to check for both a and b
@krisb1220
Kris Baillargeon
@krisb1220
May 31 2017 01:41
in seperate if's?
Jay
@DatumEight
May 31 2017 01:41
@ShaimaTheBlueberry hit ctrl + printscreen and then paste it into the chat, or use a snip tool if you have it.
zippy
@ShaimaTheBlueberry
May 31 2017 01:42
I have a chromebook so I don't have printscreen
Manish Giri
@Manish-Giri
May 31 2017 01:42
@krisb1220 same if
zippy
@ShaimaTheBlueberry
May 31 2017 01:42

Reverse the provided string.

You may need to turn the string into an array before you can reverse it.

Your result must be a string.

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

Here are some helpful links:

Global String Object
String.prototype.split()
Array.prototype.reverse()
Array.prototype.join()

Gene
@bginop
May 31 2017 01:42

hey guys I am working on the chunky monkey challenge. I'm really close to solving this challenge. So i was hoping this group can point me in the right direction as to where my algorithim isnt working.:function chunkArrayInGroups(arr, size) {
// Break it up.
var newArray = [];

if (arr.length > size ){
for (var i = 0; i < arr.length; i++){
var slice = arr.slice(i, size+i);
newArray.push(slice);
// var dice = arr.slice(size, size+i);
// newArray.push(dice);

}
return newArray ;
}

}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2);

shoot let me clean that up
zippy
@ShaimaTheBlueberry
May 31 2017 01:42
these are the things I should do
reverseString("hello") should return a string.
reverseString("hello") should become "olleh".
reverseString("Howdy") should become "ydwoH".
reverseString("Greetings from Earth") should return "htraE morf sgniteerG".
Kris Baillargeon
@krisb1220
May 31 2017 01:43
@Manish-Giri doesn't using || constitute that?
if a or b < 0 return undefined correct?
Manish Giri
@Manish-Giri
May 31 2017 01:43
no
Gene
@bginop
May 31 2017 01:43

function chunkArrayInGroups(arr, size) {
var newArray = [];

if (arr.length > size ){
for (var i = 0; i < arr.length; i++){
var slice = arr.slice(i, size+i);
newArray.push(slice);

}
return newArray ;
}
}
chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2);

Manish Giri
@Manish-Giri
May 31 2017 01:43
what that does is check if a is truthy
or b is less than 0
it reads like - if a is true or b is less than 0
Kris Baillargeon
@krisb1220
May 31 2017 01:44
Ohh. How would I do that, or which direction should I go in at least ? :P
Manish Giri
@Manish-Giri
May 31 2017 01:44
:disappointed:
if a is less than 0 or b is less than 0
you already have the 2nd part
Kris Baillargeon
@krisb1220
May 31 2017 01:45
Oh so would I do if a < 0 || b < 0 ?
Manish Giri
@Manish-Giri
May 31 2017 01:45
yes
Kris Baillargeon
@krisb1220
May 31 2017 01:46
Ah thanks man! @Manish-Giri
CamperBot
@camperbot
May 31 2017 01:46
krisb1220 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5734 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
May 31 2017 01:46
:+1:
Jay
@DatumEight
May 31 2017 01:46
@ShaimaTheBlueberry have you tried "" return str.reverse(); "" ?
zippy
@ShaimaTheBlueberry
May 31 2017 01:46
can you show me the code you would fill in with that
Jay
@DatumEight
May 31 2017 01:47

@ShaimaTheBlueberry
function reverseString(str) {
return str.reverse();
}

reverseString("hello");

Manish Giri
@Manish-Giri
May 31 2017 01:48
you sure that would work?
Jay
@DatumEight
May 31 2017 01:48
not at all. hahahahahhahaha
Manish Giri
@Manish-Giri
May 31 2017 01:48
isn't .reverse() an array function?
zippy
@ShaimaTheBlueberry
May 31 2017 01:48
it says function str.reverse is not a function
Manish Giri
@Manish-Giri
May 31 2017 01:49
precisely why
FlashHero
@FlashHero
May 31 2017 01:49
.reverse only works with arrays
zippy
@ShaimaTheBlueberry
May 31 2017 01:49
what @FlashHero said
Manish Giri
@Manish-Giri
May 31 2017 01:49
@ShaimaTheBlueberry split the string first into an array
then reverse
then join it back to form a string
zippy
@ShaimaTheBlueberry
May 31 2017 01:49
I tried that
Manish Giri
@Manish-Giri
May 31 2017 01:50
then show it here
Matthew Greene
@mattkgreene
May 31 2017 01:50
Hey guys, I am on the counting cards challenge and am confused on how to proceed. My approach is:
if (card > 1 && card < 7) {
count = + 1;
return "Hold";
} else if (card > 6 && card < 10) {
return "Bet";
} else if (card >= 10) {
count = - 1;
return "Hold";
}
But I don't know what I am doing wrong
zippy
@ShaimaTheBlueberry
May 31 2017 01:50
function reverse(str) {
var arr = str.split(''); // Convert string to array use '' to split on characters
arr.reverse(); // reverse the array
return arr.join(''); // join the letters back into a string
}
reverse("hello")
"olleh"
Manish Giri
@Manish-Giri
May 31 2017 01:50
@ShaimaTheBlueberry so it does work
your output says so
zippy
@ShaimaTheBlueberry
May 31 2017 01:51
yes
Aakriti
@Aakriti94
May 31 2017 01:51
@Manish-Giri hey
zippy
@ShaimaTheBlueberry
May 31 2017 01:51
but the
Manish Giri
@Manish-Giri
May 31 2017 01:51
@mattkgreene you return outside the if else
Aakriti
@Aakriti94
May 31 2017 01:51
@Manish-Giri good morning
Manish Giri
@Manish-Giri
May 31 2017 01:51
@Aakriti94 hello
good morning
Aakriti
@Aakriti94
May 31 2017 01:51
@Manish-Giri btw, i was going! bye
zippy
@ShaimaTheBlueberry
May 31 2017 01:51
but the instructions say no
@Manish-Giri
Manish Giri
@Manish-Giri
May 31 2017 01:52
lol
@Aakriti94 going?
you just came
Matthew Greene
@mattkgreene
May 31 2017 01:52
@Manish-Giri what do you mean I return outside the if else?
Aakriti
@Aakriti94
May 31 2017 01:52
@Manish-Giri nah, its been more then 3 hrs
Manish Giri
@Manish-Giri
May 31 2017 01:53
@mattkgreene inside the if/else, you should only adjust count based on value of card. Once outside, based on value of count, you return the right value.
@Aakriti94 ah okay
ThisUserDominates
@ThisUserDominates
May 31 2017 01:53
o
Proconsul
@proconsu1
May 31 2017 01:53

@mattkgreene you might try stacking if conditions that will produce the same result:

if (card == 2)
if (card == 3){
whatever is supposed to happen to the count if the card is a 2 or a 3
}

This might prove a valuable approach when you get to cards that have strings for value, like face cards.

Manish Giri
@Manish-Giri
May 31 2017 01:53
@Aakriti94 itni subah subah coding?
Aakriti
@Aakriti94
May 31 2017 01:54
@Manish-Giri can i get u on twitter? ha i have a exam tomrw so winded up my 1 hr of coding
Manish Giri
@Manish-Giri
May 31 2017 01:54
@Aakriti94 1_infinite_loop
is the ID
good luck for exam!
Aakriti
@Aakriti94
May 31 2017 01:54
@Manish-Giri ty
CamperBot
@camperbot
May 31 2017 01:54
aakriti94 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5736 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
May 31 2017 01:55
:+1:
Nick Gray
@nicholasnbg
May 31 2017 01:58
function palindrome(str) {
  // Good luck!
  var regex = /[a-z0-9]/ig;
  var clean = str.toLowerCase().match(regex);
  var reverse = clean;
  reverse.reverse();
  console.log(clean);

  if(clean === reverse){
    return true;
  }
  else {
    return false;
  }
}



palindrome("not a palindrome");
can someone explain why the var clean is getting reversed in the above?
allison++
@allisonPlusPlus
May 31 2017 01:58
Hello friends! I have been tearing my hair out trying to get my wikipedia viewer ajax call to return without an error. Anyone have any different ideas? https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=
sorry wrong link
Manish Giri
@Manish-Giri
May 31 2017 01:58
@nicholasnbg reverse is just a reference to clean
Nick Gray
@nicholasnbg
May 31 2017 01:58
console.logging clean in palindrome('abc') loggs ['c','b','a']
Manish Giri
@Manish-Giri
May 31 2017 01:59
var reverse = clean;
they point to same array
Nick Gray
@nicholasnbg
May 31 2017 02:00
I want to make a copy of clean, that I can then reverse, and check against each other, would i be better just setting var reverse = str.toLowerCase().match(regex).reverse()?
Manish Giri
@Manish-Giri
May 31 2017 02:01
many ways to make a copy
.slice()
Array.from
etc
Matthew Greene
@mattkgreene
May 31 2017 02:02
@Manish-Giri @proconsu1 how do I return "5 bet" though? like how do I return the count and the string "Hold" or "Bet" within the same return?
Here is what I have now:
if (card == 2)
if (card == 3)
if (card == 4)
if (card == 5)
if (card == 6) {
count = card;
return "Hold";
}
Manish Giri
@Manish-Giri
May 31 2017 02:02
you're still returning in the same if block
and you sure this is right?
if (card == 2)
if (card == 3)
if (card == 4)
if (card == 5)
if (card == 6)
Csaba Balogh
@JasonCorp84
May 31 2017 02:02
Hello everyone, I finished the "Basic algorithm scripting" section, but I feel being stuck with the "Intermediate Front End Development Projects" part.
Manish Giri
@Manish-Giri
May 31 2017 02:03
no logical operators?
Nick Gray
@nicholasnbg
May 31 2017 02:03
@Manish-Giri thanks i'll check them out
CamperBot
@camperbot
May 31 2017 02:03
nicholasnbg sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5737 | @manish-giri |http://www.freecodecamp.com/manish-giri
Matthew Greene
@mattkgreene
May 31 2017 02:04
@Manish-Giri I had them as < and > statements before but I wanted to try it that way; however, I might as well switch it back since they do the same thing
Csaba Balogh
@JasonCorp84
May 31 2017 02:04
I am able to generate random quotes with no problem, but little-bit confused on how to go forward on the webpage side.
Proconsul
@proconsu1
May 31 2017 02:05

OK, I think I am running into syntax problems with bracket notations in objects. I am supposed to get this function to check the firstName argument against the firstName key-values in the object, and if the name is found, then check whether the property argument exists for that entry. if the name is not present, I am supposed to return "no contact" (this part works); if the name is there but the property isnt associated with it, I return "no property"(also works): And if the name is in there and it has the property, then i am supposed to return the value of that property. that last bit is the one part I cant get working correctly, and i think its something simply but tragically wrong about my syntax in the first return statement, but I'm not sure. any1 got some wisdom to smack me with?

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 {
      return "No such property";
    }
  } else {
    return "No such contact";
  }
}
// Only change code above this line
}

note: I left out the portion of the pre-provided code that defined the object, but I can paste that too if its needed to debug this function

Csaba Balogh
@JasonCorp84
May 31 2017 02:06
@proconsu1 for (var i = 0)
Manish Giri
@Manish-Giri
May 31 2017 02:06
@proconsu1 move return "No such contact"; outside the for loop
Keith Thor
@kthor
May 31 2017 02:08
I have a very annoying problem, whenever I run this code, I get a crazy rounding error. Its supposed to be change (value of 96.74) - 60 = 36.74, but the console shows it as 36.739999995.
function checkCashRegister(price, cash, cid) {
  var change = cash - price;
  console.log(change);
  var totalInRegister = 0;
  // Here is your change, ma'am.
  var retArr = [];
  var currencyVal = {
    "PENNY": 0.01,
    "NICKEL": 0.05,
    "DIME": 0.10,
    "QUARTER": 0.25,
    "ONE": 1.00,
    "FIVE": 5.00,
    "TEN": 10.00,
    "TWENTY": 20.00,
    "ONE HUNDRED": 100.00
  };

  cid.forEach(function(cashArr) {
    totalInRegister += cashArr[1];
  });

  if (change > totalInRegister)
    return "Insufficient Funds";
  else if (change === totalInRegister)
    return "Closed";

  for (var i = cid.length - 1; i >= 0; i--) {
    if (currencyVal[cid[i][0]] <= change) {
      // If change due is greater than current total
      if (change - cid[i][1] >= 0) {
        retArr.push(cid[i]);
        change = change - cid[i][1];
      }
      // If not, take correct number of bills out
      else if (Math.floor(change / currencyVal[cid[i][0]]) > 0) {
        retArr.push([cid[i][0], currencyVal[cid[i][0]] * Math.floor(change / currencyVal[cid[i][0]])]);
        change -= currencyVal[cid[i][0]] * Math.floor(change / currencyVal[cid[i][0]]);
      }
      console.log(change);
    }
  }


  if (change > 0)
    return "Insufficient Funds";
  else
    return retArr;
}

// Example cash-in-drawer array:
// [["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", 100.00]]

checkCashRegister(3.26, 100.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", 100.00]]);
Proconsul
@proconsu1
May 31 2017 02:08
@mattkgreene concatenate the variable (count) and the word ("bet")
Csaba Balogh
@JasonCorp84
May 31 2017 02:10
@kthor you need to round it up first
"36.739999995." this part
Proconsul
@proconsu1
May 31 2017 02:12
@JasonCorp84 not following what you mean there. should i not start my for loop at 0 so that I begin checking from record 0 in the object?
@Manish-Giri hmm. moved that outside the loop right before the close of the function, same results: the "no such" results return as expected, but no return of the value of prop ever gets return for those cases where it should
:worried:
Csaba Balogh
@JasonCorp84
May 31 2017 02:13
```for (i=0;i<contacts.length;i++) ----> for (var i=0;i<contacts.length;i++){
for (var i=0;i<contacts.length;i++){
Manish Giri
@Manish-Giri
May 31 2017 02:13
@proconsu1 post the url
click "run tests" first
Keith Thor
@kthor
May 31 2017 02:14
@JasonCorp84 that seems like duct taping the problem though, i know where the problem is occuring, but it does not make any logical sense that 96.74 - 60 = 36.73999995
Proconsul
@proconsu1
May 31 2017 02:15
@JasonCorp84 ah, so i need to declare the i var... trying that. then if i still have probs I'll post that url @Manish-Giri
Csaba Balogh
@JasonCorp84
May 31 2017 02:16
@kthor it is all about floating points... this is how computer counts. It is not really accurate on that level
Proconsul
@proconsu1
May 31 2017 02:17
@Manish-Giri @JasonCorp84 - still no joy. Profile Lookup Challenge
tinyurl choked on the spaces, too, but one of its suggested fixes seems to work. put that in the link
ok, butchered that
Manish Giri
@Manish-Giri
May 31 2017 02:18
post the url correctly
Proconsul
@proconsu1
May 31 2017 02:19
trying to figure out how. the spaces in it seem to be tripping up the markdown for a link
Manish Giri
@Manish-Giri
May 31 2017 02:19
Matthew Greene
@mattkgreene
May 31 2017 02:19
@Manish-Giri @proconsu1 thanks!
CamperBot
@camperbot
May 31 2017 02:19
mattkgreene sends brownie points to @manish-giri and @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 111 | @proconsu1 |http://www.freecodecamp.com/proconsu1
:star2: 5738 | @manish-giri |http://www.freecodecamp.com/manish-giri
Csaba Balogh
@JasonCorp84
May 31 2017 02:22
@proconsu1 you are close to the solution.
Joel Korcsmaros
@lossness
May 31 2017 02:22
is there anyway to go back to check to find my mentions
DrK971
@DrK971
May 31 2017 02:22
Hello everyone !!
I'm stuck at the Word Blanks challenge
I completed all the challenges before, but this one really got me lost
I don't know where to start
can someone give me a hint plz?
Manish Giri
@Manish-Giri
May 31 2017 02:24
@DrK971 you need to form a string, and assign it to result, using string concatenation (+). The string has to be formed by concatenating the four parameters in your function - myNoun, myAdjective, etc, along with spaces and (optionally) some words of your own - to form a coherent sentence.
Proconsul
@proconsu1
May 31 2017 02:24
@DrK971 the idea is that you need to concatenate the different variables use + and putting in the necessary spaces using " " wherever appropriate
ThisUserDominates
@ThisUserDominates
May 31 2017 02:28
what wrong with my code

// Example
var firstName = "Alan";
var lastName = "Turing";

// Only change code below this line

var myFirsName = "Jose";
var myLastName = "Ashrafi";

Manish Giri
@Manish-Giri
May 31 2017 02:28
@ThisUserDominates myFirsName
typo here
ThisUserDominates
@ThisUserDominates
May 31 2017 02:28
ohhhhhhhhhhh
wow lol thanks
GhelardiniLLC
@GhelardiniLLC
May 31 2017 02:29
Hola! Has anyone done the javascript convert celsius to fahrenheit challenge?
Proconsul
@proconsu1
May 31 2017 02:29
@JasonCorp84 hmm...is this bit a correct use of bracket notation?
return contacts[i][prop];
Manish Giri
@Manish-Giri
May 31 2017 02:29
yes
ThisUserDominates
@ThisUserDominates
May 31 2017 02:29
i have
Manish Giri
@Manish-Giri
May 31 2017 02:29
what's the problem
@GhelardiniLLC
GhelardiniLLC
@GhelardiniLLC
May 31 2017 02:29

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

fahrenheit= celsius*=(9/5) + 32;

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

Manish Giri
@Manish-Giri
May 31 2017 02:29
@GhelardiniLLC celsius*=(9/5) +
remove the =
GhelardiniLLC
@GhelardiniLLC
May 31 2017 02:30
thank you!
Csaba Balogh
@JasonCorp84
May 31 2017 02:30
@proconsu1 yes that is perfect
GhelardiniLLC
@GhelardiniLLC
May 31 2017 02:30
bc otherwise it would continuously multiply, right?
Csaba Balogh
@JasonCorp84
May 31 2017 02:31
@proconsu1 you need to return no such contact outside of EVERY loop
Proconsul
@proconsu1
May 31 2017 02:33
@JasonCorp84 yeah, i did what you said before and moved the no such contact return statement to be right before the close of the entire function, outside the for loop. same deal still happening tho
Csaba Balogh
@JasonCorp84
May 31 2017 02:33
@proconsu1 in other words: where is your loop starts and where is it ends ?
Proconsul
@proconsu1
May 31 2017 02:35
@JasonCorp84 aha! i had NOT moved it far enough. i needed to go one close curly bracket further. mistook the end of loop curly for the end of function one, cuz the end of function one was further down below the comments. Thanks ! to both you and @Manish-Giri
CamperBot
@camperbot
May 31 2017 02:35
proconsu1 sends brownie points to @jasoncorp84 and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 265 | @jasoncorp84 |http://www.freecodecamp.com/jasoncorp84
:star2: 5739 | @manish-giri |http://www.freecodecamp.com/manish-giri
Csaba Balogh
@JasonCorp84
May 31 2017 02:36
I had the same problem about 1 month ago
Ogundele Olumide
@Lumexralph
May 31 2017 02:38
@Manish-Giri Bro! ggggm :smiling_imp:
Manish Giri
@Manish-Giri
May 31 2017 02:49
@Lumexralph :sunny: :smiling_imp:
GhelardiniLLC
@GhelardiniLLC
May 31 2017 02:50
Anyone know this one: var myStr = "<a href='http://www.example.com' target='blank'>Link</a>";
var myStr = "<a href='http://www.example.com' target='blank'>Link</a>";
was told to remove the double "s
Manish Giri
@Manish-Giri
May 31 2017 02:52
@GhelardiniLLC post the URL
Claudio Restifo
@Marmiz
May 31 2017 02:52
@GhelardiniLLC what challenge are you on?
Claudio Restifo
@Marmiz
May 31 2017 02:53
oh hey @Manish-Giri .
How's Java :coffee: ? :)
Ogundele Olumide
@Lumexralph
May 31 2017 02:53
@Manish-Giri how's the thesis coming up?
GhelardiniLLC
@GhelardiniLLC
May 31 2017 02:53
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Manish Giri
@Manish-Giri
May 31 2017 02:53
try single quotes out
double inside
@GhelardiniLLC
GhelardiniLLC
@GhelardiniLLC
May 31 2017 02:53
thank you!
Manish Giri
@Manish-Giri
May 31 2017 02:54
@Marmiz @Lumexralph going into a coma everyday with my datasets
:weary:
Claudio Restifo
@Marmiz
May 31 2017 02:54
@GhelardiniLLC you should work with the provided string tho.
GhelardiniLLC
@GhelardiniLLC
May 31 2017 02:54
@Manish-Giri !!! thank you!
CamperBot
@camperbot
May 31 2017 02:54
ghelardinillc sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5740 | @manish-giri |http://www.freecodecamp.com/manish-giri
GhelardiniLLC
@GhelardiniLLC
May 31 2017 02:54
@Marmiz thank you! this worked: var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';
CamperBot
@camperbot
May 31 2017 02:54
ghelardinillc sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 910 | @marmiz |http://www.freecodecamp.com/marmiz
Manish Giri
@Manish-Giri
May 31 2017 02:54
@GhelardiniLLC :+1:
Claudio Restifo
@Marmiz
May 31 2017 02:54
nvm that's the provided :|

@Manish-Giri

coma everyday with my datasets

So everything's good :)

foxthor
@foxthor
May 31 2017 03:01
can i have some hints regarding Card Counting, this is what i have so far

var count = 0;

function cc(card) {
// Only change code below this line
switch (card) {
case 1:
var count = count +1;
break;
case 2:
count = count +1;
break;
case 3:
count = count +1;
break;
case 4:
count = count +1;
break;
case 5:
count = count +1;
break;
case 10:
count = count -1;
break;
case 'J':
count = count -1;
break;
case 'Q':
count = count -1;
break;
case 'K':
count = count -1;
break;
case 'A':
count = count -1;

    if (count >1) {
  return (count + " Hold");
}

else return (count + " Bet");
}

// Only change code above this line
}

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

its returning NaN Bet
Ogundele Olumide
@Lumexralph
May 31 2017 03:02
@foxthor don't declare a new variable count it's already declared
foxthor
@foxthor
May 31 2017 03:04
if i dont declare it, count goes white, and then the arithmetic inside the switch doesnt add or subtract to the global count
Proconsul
@proconsu1
May 31 2017 03:04
what's the functional difference between a carriage return (\r) and newline(\n)?
@foxthor that could be a lot shorter if you dropped the switch and used stacked if conditions with a single count adjustment operation after each block of similar cards
Ogundele Olumide
@Lumexralph
May 31 2017 03:04
@foxthor and you have to check if count is greater than 0,
@foxthor count is a global variable
foxthor
@foxthor
May 31 2017 03:06
ok im not sure we have learnt stacked conditions yet, will look that up. thanks @Lumexralph @proconsu1
CamperBot
@camperbot
May 31 2017 03:06
foxthor sends brownie points to @lumexralph and @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 119 | @proconsu1 |http://www.freecodecamp.com/proconsu1
:star2: 1844 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
May 31 2017 03:07
@proconsu1 carriage-return reminds me of typewriter, when the machine as exhausted it's space or gets to the end, the typewriter moves back to the beginning of next line on the page
Claudio Restifo
@Marmiz
May 31 2017 03:07
@foxthor no need to declare count inside the function since it's already available.
also make sure to place the if statement outside the switch
foxthor
@foxthor
May 31 2017 03:09
thanks @Marmiz thats where i originally had them and changed it to test, now moving it back it has worked for 2 card sequences, although the others dont work... some more tinkering
CamperBot
@camperbot
May 31 2017 03:09
foxthor sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 911 | @marmiz |http://www.freecodecamp.com/marmiz
Ogundele Olumide
@Lumexralph
May 31 2017 03:09
@proconsu1 to me you don't need to get to the end of the page to have a newline \n but \r when it get's to the end of the page it's called to action....using a typewriter perspective, you can search online for comprehensive explanation
Proconsul
@proconsu1
May 31 2017 03:10
@Lumexralph yeah, that's the image that i got, too. just cant see how it is functionally different from newline, but i know it is because I threw an error in one exercise by using the wrong one. think i'll surf over to mozilla and have a shifty at their version of the definition. thanks
CamperBot
@camperbot
May 31 2017 03:10
proconsu1 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1845 | @lumexralph |http://www.freecodecamp.com/lumexralph
Claudio Restifo
@Marmiz
May 31 2017 03:12

@foxthor also a couple of tip for better readability:
you can group cases together if they have the same output in a switch statement. and to add or subtract you can use the ++ and -- notation as you have learned:

case a:
case b:
case c:
  something++;
  break;

so the code is slimmer and easier to read :)

Moisés Man
@moigithub
May 31 2017 03:13
switch(true){
  case card>=2 && card <=4:  i++; break;
}
jmariomejiap
@jmariomejiap
May 31 2017 03:13

hey guys. I am finally finish "intermediate algorithms " on the very last challenge = "Arguments optional", I am not 100% I understand how the return function is able to get a hold of the argument.
this is my code, It works but I am more concerned about learning that just passing the test.
can someone please helpme out.


function addTogether() {

  var a = arguments[0];
  var b = arguments[1];
  console.log(arguments);

  function validate (value) {
    return typeof value === "number" ? value : undefined;
  }

  if (arguments.length === 2) {
    if (validate(a) && validate(b)) {
      return a + b;
    }
    else {
      return undefined;
    }
  }
  else if (arguments.length === 1) {
    // potential second individual argument.
    if (validate(a)) {
      return function (oneMore) {
        if (validate(oneMore)) {
          return a + oneMore;
        }
        else {
          return undefined;
        }
      };
    }
  }



}

addTogether(2)(3);

thanks in advance.

foxthor
@foxthor
May 31 2017 03:13
yes thanks, i have now done this and much slimer.
Claudio Restifo
@Marmiz
May 31 2017 03:13
@foxthor also don't forget the 6 ;)
foxthor
@foxthor
May 31 2017 03:14
yeah i started at 1, instead of 5 just realised
instead of 22
2
Ogundele Olumide
@Lumexralph
May 31 2017 03:15
@jmariomejiap do you know closure ?
DrK971
@DrK971
May 31 2017 03:15
@Manish-Giri , thanks, thats what I tried to do already but still stuck
CamperBot
@camperbot
May 31 2017 03:15
drk971 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5743 | @manish-giri |http://www.freecodecamp.com/manish-giri
DrK971
@DrK971
May 31 2017 03:15
should I use the word itself or the variables ?
Manish Giri
@Manish-Giri
May 31 2017 03:16
@DrK971 the variables
myNoun
etc
Ogundele Olumide
@Lumexralph
May 31 2017 03:16
@Manish-Giri always lurking :smirk:
Manish Giri
@Manish-Giri
May 31 2017 03:16
@Lumexralph :smiling_imp:
@Lumexralph how're things your end?
Ogundele Olumide
@Lumexralph
May 31 2017 03:18
@Manish-Giri i'm good, had to do some travels past weeks, was transferred to another location by my company, getting settled and used to this is a bit much at the moment
jmariomejiap
@jmariomejiap
May 31 2017 03:18
@Lumexralph I thought i did.... but im second guessing myself on this one. I know a closure is a mechanism that allows access to elements that are not accessible because of the scope.
but again, i can see that my understanding is not there yet.
Manish Giri
@Manish-Giri
May 31 2017 03:19
@Lumexralph which city?
Ogundele Olumide
@Lumexralph
May 31 2017 03:19
@jmariomejiap closure is a situation where a function remembers where it was declared and has access to the whole of the environment it was declared
jmariomejiap
@jmariomejiap
May 31 2017 03:20
@Lumexralph lexical environment... ok. please keep going.
Ogundele Olumide
@Lumexralph
May 31 2017 03:20
@Manish-Giri remember I'm in Nigeria, where do you know :wink: or your power has extended beyond Europe
jmariomejiap
@jmariomejiap
May 31 2017 03:21
@Lumexralph I have never seen a function being invoked like that addTogether(2)(3);
Manish Giri
@Manish-Giri
May 31 2017 03:21
:smiling_imp:
my power extends even beyond earth
Ogundele Olumide
@Lumexralph
May 31 2017 03:21
@jmariomejiap your code returned functions that used the data in the function or environment it was declared and that's where closure happened
@Manish-Giri beyond earth ?
DrK971
@DrK971
May 31 2017 03:21
@Manish-Giri result= "The"+ myAdjective+ myNoun+" got"+ myVerb+ myAdverb. ; these """"""" are killing me
Manish Giri
@Manish-Giri
May 31 2017 03:22
@DrK971 add spaces
I told you already
Ogundele Olumide
@Lumexralph
May 31 2017 03:22
@jmariomejiap because a function is returned and remember function can be passed around like values in JS
DrK971
@DrK971
May 31 2017 03:23
@Manish-Giri but I did after each +
i'll try again tomorrow
Ogundele Olumide
@Lumexralph
May 31 2017 03:23

@jmariomejiap

if (validate(a)) {
      return function (oneMore) {
        if (validate(oneMore)) {
          return a + oneMore;
        }

you returned a function that can only be executed when you call it

DrK971
@DrK971
May 31 2017 03:23
thanks for taking hte time to answer
(y)
jmariomejiap
@jmariomejiap
May 31 2017 03:24

@Lumexralph

if (validate(a)) {
      return function (oneMore) {
        if (validate(oneMore)) {
          return a + oneMore;
        }
        else {
          return undefined;
        }
      };

question..... how is it. that anonymous function gets access to (oneMore).

Ogundele Olumide
@Lumexralph
May 31 2017 03:25
@jmariomejiap so addTogether returns a function that's expecting an argument which you executed with the second parenthesis ()()
Manish Giri
@Manish-Giri
May 31 2017 03:25
@DrK971 "The"+ myAdjective+ myNoun+
not even one space here
the spaces in the editor don't count
+" got"
this does
@Lumexralph are you close to Lagos?
DrK971
@DrK971
May 31 2017 03:26
@Marmiz yes thanks for the explanation ; same result but different process ;)
CamperBot
@camperbot
May 31 2017 03:26
drk971 sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 912 | @marmiz |http://www.freecodecamp.com/marmiz
Ogundele Olumide
@Lumexralph
May 31 2017 03:26
@jmariomejiap oneMore is a parameter for your anonymous function lambda or what's it called
@Manish-Giri i stay in Lagos but got transferred to Osun, like 3 states away from Lagos
jmariomejiap
@jmariomejiap
May 31 2017 03:29
@Lumexralph ok, im getting there.
but, normally when you invoked a function you pass on the argument like addTogether(2) but the return function I feel is like a declaration.... in the sense that I am not invoking it..... is the return what "activates" it.
?
Manish Giri
@Manish-Giri
May 31 2017 03:30
@Lumexralph ooh some killings out there in the news
stay safe
Ogundele Olumide
@Lumexralph
May 31 2017 03:30
@jmariomejiap look at it this way
let returnedFunction =  addTogether(2);   //what do you think returnedFunction holds ?
@Manish-Giri :joy: .... nah it's exaggerated in the news
jmariomejiap
@jmariomejiap
May 31 2017 03:31
@Lumexralph returnFunction will be equal to 2
Ogundele Olumide
@Lumexralph
May 31 2017 03:32
@Manish-Giri just a tiny bug in the far North and it's a state, asides normal social vices in other countries
@jmariomejiap nope, remember a function returns a value, a function can be passed as a value
jmariomejiap
@jmariomejiap
May 31 2017 03:33
@Lumexralph well, looking at the full script. it will be undefined.
Ogundele Olumide
@Lumexralph
May 31 2017 03:33
@jmariomejiap check what your addTogether function is returning
@jmariomejiap
return function (oneMore) {
        if (validate(oneMore)) {
          return a + oneMore;
        }
jmariomejiap
@jmariomejiap
May 31 2017 03:36
@Lumexralph I said undefined because in that case addTogether(2) will have only one argument so when the return function looks for the second arguemtn it will find that there isn't one, so it will come back as undefined.
@Lumexralph mmmm, i think.
@Lumexralph by the way, thanks a lot for helping me, i truly appreciated.
CamperBot
@camperbot
May 31 2017 03:38
jmariomejiap sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1846 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
May 31 2017 03:38
@jmariomejiap return typeof value === "number" a becomes 2, so it's a number don't you think ?
Joy Bhalla
@JoyBhalla
May 31 2017 03:39
Eloquent JavaScript: A Modern Introduction to Programming 2nd Edition

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
('The' +"." + myAdjective +"."+ myNoun +"." + myVerb +"." + myAdverb);
// Your code above this line
return result;
}

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

i have to print out a sentence in
what am i doing wrong?
Ogundele Olumide
@Lumexralph
May 31 2017 03:39
@JoyBhalla you need to separate them with spaces and assign it to result
jmariomejiap
@jmariomejiap
May 31 2017 03:40
@Lumexralph yes that is true.
Ogundele Olumide
@Lumexralph
May 31 2017 03:41
@jmariomejiap so your validate function returns a value and your if statement is ran which does this
if (validate(a)) {
      return function (oneMore) {
        if (validate(oneMore)) {
          return a + oneMore;
        }
Joy Bhalla
@JoyBhalla
May 31 2017 03:41
it would be result('The' + myNoun + myAdjective....) ; ?
Ogundele Olumide
@Lumexralph
May 31 2017 03:41
@jmariomejiap so returnedFunction contains a function
@JoyBhalla result = "The " + myNoun + " "...... take note of the spaces
Joy Bhalla
@JoyBhalla
May 31 2017 03:43
@Lumexralph Thank You !
CamperBot
@camperbot
May 31 2017 03:43
joybhalla sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1847 | @lumexralph |http://www.freecodecamp.com/lumexralph
aRtoo
@artoodeeto
May 31 2017 03:44
hi guys. after 5hrs of trial and error and playing everwing in between i finally got the answer. if you have other solutions can you send it to me privately so i can study it?? im going to sleep. thank you. heres the code.
function mutation(arr) {

 var test1 = arr[0].toLowerCase().split(''); 
 var test2 = arr[1].toLowerCase().split('');  


 for(var i=0; i<test2.length; i++){
   // for(var c=0; c<test2.length; c++){

        //console.log(test1[i] + " " + test2[c]);  

            var bolVal = test1.indexOf(test2[i]) !== -1;

            if(bolVal === false){
              return false;
            }

    //}
 }
  return true;
}

//mutation(["hello", "hey"]); //should return false.
//mutation(["HELLO", "Hello"]); //should return true.
//mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]); //should return true.
//mutation(["Mary", "Army"]); //should return true.
mutation(["Mary", "Aarmy"]); //should return true.
//mutation(["Alien", "line"]); //should return true.
//mutation(["floor", "for"]); //should return true.
//mutation(["hello", "neo"]); //should return false.
//mutation(["voodoo", "no"]); //should return false.
caarlos29
@caarlos29
May 31 2017 03:45
Guys, I need help with the Escape Sequences in Strings
im writing this.. var myStr ="FirstLine\n\SecondLine\\rThridLine";
and it says theres and error
Adam Kim
@resv
May 31 2017 03:46
thank you @proconsu1 @cmccormack
CamperBot
@camperbot
May 31 2017 03:46
resv sends brownie points to @proconsu1 and @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 122 | @proconsu1 |http://www.freecodecamp.com/proconsu1
:cookie: 701 | @cmccormack |http://www.freecodecamp.com/cmccormack
danghv
@danghv
May 31 2017 03:48
guys, plz help me out of this
Manish Giri
@Manish-Giri
May 31 2017 03:49
@caarlos29 typo
Ogundele Olumide
@Lumexralph
May 31 2017 03:49
@caarlos29 have you escaped backslash \\ and there's a typo ThridLine

function displayUnit(num){
switch(num){
case 0: str += "";
break;
case 1: str += "I";
break;
case 2: str += "II";
break;
case 3: str += "III";
break;
case 4: str += "IV";
break;
case 5: str += "V";
break;
case 6: str += "VI";
break;
case 7: str += "VII";
break;
case 8: str += "VIII";
break;
case 9: str += "IX";
break;
}

}

function displayTenth(num){
switch(num){
case 0: str+= "";
break;
case 1: str+= "X";
break;
case 2: str+= "XX";
break;
case 3: str+= "XXX";
break;
case 4: str+= "XL";
break;
case 5: str+= "L";
break;
case 6: str+= "LX";
break;
case 7: str+= "LXX";
break;
case 8: str+= "LXXX";
break;
case 9: str+= "XC";
break;
}
}

function displayHundred(num){
switch(num){
case 0: str+= "";
break;
case 1: str+= "C";
break;
case 2: str+= "CC";
break;
case 3: str+= "CCC";
break;
case 4: str+= "CD";
break;
case 5: str+= "D";
break;
case 6: str+= "DC";
break;
case 7: str+= "DCC";
break;
case 8: str+= "DCCC";
break;
case 9: str+= "CM";
break;
}
}
function displayThousand(num){
for(var i = 0; i<num;i++){
str += "M";
}
}

var str = "";
function convertToRoman(num) {
var numStr = num.toString();
var numArr = numStr.split("");
console.log(numArr);
if(numArr.length == 1){
displayUnit(Number(numArr[0]));
} else if(numArr.length == 2){

  displayTenth(Number(numArr[0]));
  displayUnit(Number(numArr[1]));

} else if(numArr.length == 3){
  displayThousand(Number(numArr[0]));
  displayTenth(Number(numArr[1]));
  displayUnit(Number(numArr[2]));
}

else{
var numArr = num.toString().split("");
var numThousand = numArr.splice(0,numArr.length - 3).join("");
console.log(numThousand);
displayThousand(Number(numThousand));
displayHundred(Number(numArr[numArr.length-3]));
displayTenth(Number(numArr[numArr.length-2]));
displayUnit(Number(numArr[numArr.length -1]));
}
return str;
}

console.log(convertToRoman(3999));

Ogundele Olumide
@Lumexralph
May 31 2017 03:49
@caarlos29 ThridLine ==> ThirdLine
danghv
@danghv
May 31 2017 03:50
i try it at codepen and it works, but when i copy to freecodecamp its not work
Joseph Amoroso
@SoulSkrix
May 31 2017 03:52
did 14/17 basic algorithm challenges in one sitting. Now my brain hurts a lot :/
danghv
@danghv
May 31 2017 03:54
@SoulSkrix what do u mean, dude?
anyone can help me out of this
caarlos29
@caarlos29
May 31 2017 03:55
var myStr ="FirstLine\r\n\SecondLine\ThirdLine";
fixed it.. still same error
Request-Off-Work
@Request-Off-Work
May 31 2017 03:55
Trying to remove the first element of the array, so group 1 === group[1].
    <!-- List of Contacts.html -->
    <div ng-repeat="panels in vm.contacts[0].groups.shift()">
but shift() isn't working in ng-repeat
caarlos29
@caarlos29
May 31 2017 03:55
var myStr ="FirstLine\r\n\SecondLine\ThirdLine";
Ravi Kishore Thella
@ravikishorethella
May 31 2017 03:56
@caarlos29 that's wrong. please read the instructions
caarlos29
@caarlos29
May 31 2017 03:56
never mind... just noticed
thanks
Ravi Kishore Thella
@ravikishorethella
May 31 2017 03:56
:thumbsup:
fathurrahman alif fahrezi
@fathurrahmanaf
May 31 2017 04:02
 function laugh(num){
     while (num > 0){
         console.log ('ha');
         num = num - 1;
     }
 }

return laugh(3);
Markus Ivancsics
@ivancsicsmarkus
May 31 2017 04:02
@fathurrahmanaf :sparkles:
fathurrahman alif fahrezi
@fathurrahmanaf
May 31 2017 04:02
can anybody help how to make the output to be "hahaha!'
Markus Ivancsics
@ivancsicsmarkus
May 31 2017 04:03
@fathurrahmanaf You have to display it in the same time, not three time "ha".
@fathurrahmanaf You have learned about arrays, haven’t you?
Claudio Restifo
@Marmiz
May 31 2017 04:04
@fathurrahmanaf are you sure about return laugh(3);
and not just call the function?
Ogundele Olumide
@Lumexralph
May 31 2017 04:04
@fathurrahmanaf do you want it to increase with iteration of the loop or at once?
Manish Giri
@Manish-Giri
May 31 2017 04:04
@fathurrahmanaf you've got to have a variable
Markus Ivancsics
@ivancsicsmarkus
May 31 2017 04:04
@Marmiz The problem is not that.
Manish Giri
@Manish-Giri
May 31 2017 04:04
if you need to build up a string
@fathurrahmanaf
Ogundele Olumide
@Lumexralph
May 31 2017 04:05
@fathurrahmanaf using return out of the scope it's meant will result in illegal syntax error
Manish Giri
@Manish-Giri
May 31 2017 04:05
^
Ogundele Olumide
@Lumexralph
May 31 2017 04:05
@Manish-Giri hungry here but it's too early
Claudio Restifo
@Marmiz
May 31 2017 04:06
@ivancsicsmarkus using return outside scope is a illegal syntax
Manish Giri
@Manish-Giri
May 31 2017 04:06
@Lumexralph lol, any shops open at 5 am?
Claudio Restifo
@Marmiz
May 31 2017 04:06
@Lumexralph beat me on that :)
Ogundele Olumide
@Lumexralph
May 31 2017 04:07
@Manish-Giri nope......
@Marmiz :wink:
Markus Ivancsics
@ivancsicsmarkus
May 31 2017 04:07
@Marmiz Who cares? There are bigger problems.
fathurrahman alif fahrezi
@fathurrahmanaf
May 31 2017 04:07
@Manish-Giri yes i thought of creating a new var, i'll try it first
thx for the input guys
Manish Giri
@Manish-Giri
May 31 2017 04:07
@fathurrahmanaf inside the loop, keep adding to the variable
that's how you'll build the string
Claudio Restifo
@Marmiz
May 31 2017 04:08
@ivancsicsmarkus like world hunger? I agree on that :P
Markus Ivancsics
@ivancsicsmarkus
May 31 2017 04:08
@Marmiz Yes and php.
Claudio Restifo
@Marmiz
May 31 2017 04:08
:laughing:
Claudio Restifo
@Marmiz
May 31 2017 04:23
@Manish-Giri you know if that laugh function is a FCC challenge?
Manish Giri
@Manish-Giri
May 31 2017 04:25
@Marmiz no I don't think it is
prolly from codewars
fathurrahman alif fahrezi
@fathurrahmanaf
May 31 2017 04:25
@Manish-Giri you know if that laugh function is a FCC challenge?
no it's not hehe
Claudio Restifo
@Marmiz
May 31 2017 04:26
@fathurrahmanaf @Manish-Giri thanks.
I was curious cos I came up with a solution. Can you loop me in the requirements so I can see If I was a good boy? :smile:
CamperBot
@camperbot
May 31 2017 04:26
marmiz sends brownie points to @fathurrahmanaf and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 242 | @fathurrahmanaf |http://www.freecodecamp.com/fathurrahmanaf
:star2: 5747 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
May 31 2017 04:27
lol
@fathurrahmanaf has the challenge details, I think
Claudio Restifo
@Marmiz
May 31 2017 04:28
*solution that does not involve loops or var slots. Only a native method :)
Nothing out of this world... I was just curious
Manish Giri
@Manish-Giri
May 31 2017 04:29
hm
maybe .concat() would work
Claudio Restifo
@Marmiz
May 31 2017 04:29
or repeat() :)
fathurrahman alif fahrezi
@fathurrahmanaf
May 31 2017 04:29
haha i am really new with javascript actually, and now im still trying to figure it out lol
Manish Giri
@Manish-Giri
May 31 2017 04:30
ooh yes .repeat() would be beter
Claudio Restifo
@Marmiz
May 31 2017 04:30
@Manish-Giri PM my solution ^^
@fathurrahmanaf the while idea was nice :)
keep on working with that! :+1:
Jeremy
@JeremyAntonoff
May 31 2017 04:41
can someone help me
Bharathiraja
@bharathi04
May 31 2017 04:41
Hi Guys!, I can't solve two more conditions in Counting Card section, can anyone please why i got stuggle. Here the code i written for it below:

var count = 0;

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

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

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

Dan Skelly
@dskell88
May 31 2017 04:42

Needhelp w/ "Golf Code" Javascript.

It won't return Par, bogey, double bogey, and go home.

function golfScore(par, strokes) {
// Only change code below this line
if (strokes == 1){
return "Hole-in-one!";
}
else if (strokes <= (par-2)){
return "Eagle";
}
else if (par-1){
return "Birdie";
}
else if (strokes == par) {
return "Par";
}
else if (strokes >= (par + 1)){
return "Bogey";
}
else if (strokes == (par + 2)){
return "Double Bogey";
}
else if (strokes >= (par + 3)){
return "Go Home!";
}
else {

return "Par";
}
// Only change code above this line
}

anirudh duggal
@anirudhdggl
May 31 2017 04:42
How can I store the first element of an array in a variable?
Bharathiraja
@bharathi04
May 31 2017 04:43
In that last two cases, i have a doubt is that right or not. Without the last two cases, code should solve 5 conditions. But i can't able solve the two conditions only
Jeremy
@JeremyAntonoff
May 31 2017 04:43
var x = array[0];
bstahler123
@bstahler123
May 31 2017 04:44
take my javaScript/frontend developer test and post your score XD https://calm-savannah-51322.herokuapp.com/
anirudh duggal
@anirudhdggl
May 31 2017 04:44
@JToddFL Oops, seems I was acting too careless to have a look at the solution :p anyways, thanks @JToddFL
CamperBot
@camperbot
May 31 2017 04:44
anirudhdggl sends brownie points to @jtoddfl :sparkles: :thumbsup: :sparkles:
:cookie: 259 | @jtoddfl |http://www.freecodecamp.com/jtoddfl
anirudh duggal
@anirudhdggl
May 31 2017 04:44
How to send brownie points?
Jeremy
@JeremyAntonoff
May 31 2017 04:44
you're good man no problem
Claudio Restifo
@Marmiz
May 31 2017 04:45
@bharathi04 in your logic as soon as I pass a value eg cc(2) the first statement gets evaluated count became 1 and the function return 1 Bet
What you want to do instead is to modify the values of count.
At the end of everything evaluates it and then decide if it's time to bet or hold
Ravi Kishore Thella
@ravikishorethella
May 31 2017 04:45
click on their name and say thanks
Ogundele Olumide
@Lumexralph
May 31 2017 04:45
@bharathi04 just increment or decrement count do your checking later to know if count is greater than 0 or not to return count + string
anirudh duggal
@anirudhdggl
May 31 2017 04:45
Okay, thanks @ravikishorethella
CamperBot
@camperbot
May 31 2017 04:45
anirudhdggl sends brownie points to @ravikishorethella :sparkles: :thumbsup: :sparkles:
:cookie: 347 | @ravikishorethella |http://www.freecodecamp.com/ravikishorethella
Ravi Kishore Thella
@ravikishorethella
May 31 2017 04:45
@anirudhdggl :thumbsup:
Sam Soucie
@samdsou
May 31 2017 04:45
can someone take a look at some code to see what's going wrong?
bstahler123
@bstahler123
May 31 2017 04:46
https://calm-savannah-51322.herokuapp.com/ if you have time please help me debug my app and take my quiz
Jeremy
@JeremyAntonoff
May 31 2017 04:46
can someone tell me why this code wont work
Dan Skelly
@dskell88
May 31 2017 04:46
Has anyone solf the "Golf Code" Javascript challenge? I'm stuck on it
Jeremy
@JeremyAntonoff
May 31 2017 04:46
function destroyer(arr) {
  var args = arr.slice.call(arguments).slice(1);
  var newArray = [];

  for (var i = 0; i < arr.length; i++) {
    for (var j=0; j < args.length; j++) {
      if (arr[i] !== args[j]) {
          newArray.push(arr[i]);
      }

  }
Dan Skelly
@dskell88
May 31 2017 04:46
It won't return all my conditions..
Jeremy, how did you display your code like that? rookie freecodecamp user btw
Jeremy
@JeremyAntonoff
May 31 2017 04:47
@dskell88 do /'''/code/'''/
CamperBot
@camperbot
May 31 2017 04:47
:bulb: to format code use backticks! ``` more info
Jeremy
@JeremyAntonoff
May 31 2017 04:47
without the forward slashes
oops
'```'
those I mean
Claudio Restifo
@Marmiz
May 31 2017 04:47
@dskell88 this condition will be true no matter how big strokes is.
Imagine strokes to be 8 and par 2.
8 is bigger than 2+1 so will return Bogey.
But as a matter of fact you don't want that :)
this condition:
else if (strokes >= (par + 1)){
return "Bogey";
}
Sam Soucie
@samdsou
May 31 2017 04:48

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

// Only change code below this line.

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

Dan Skelly
@dskell88
May 31 2017 04:48
okay, thanks @Marmiz
CamperBot
@camperbot
May 31 2017 04:48
dskell88 sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 913 | @marmiz |http://www.freecodecamp.com/marmiz
Claudio Restifo
@Marmiz
May 31 2017 04:50
@samdsou what exactly you want to accomplice with that code?
Bharathiraja
@bharathi04
May 31 2017 04:50
@Lumexralph Sry, I can't understand. How do i directly increament or decrement the count without checking the conditions. Thank you!
CamperBot
@camperbot
May 31 2017 04:50
bharathi04 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1848 | @lumexralph |http://www.freecodecamp.com/lumexralph
Sam Soucie
@samdsou
May 31 2017 04:51
@Marmiz add three to each value in the array
Ogundele Olumide
@Lumexralph
May 31 2017 04:52
@samdsou remove this statement var newArray = oldArray; and change addThree to var newArray
@bharathi04 you need separate if statements for that, just separate it
Claudio Restifo
@Marmiz
May 31 2017 04:53
@samdsou well addThree returns the correct value, but are you sure those are the variable names the challenge expect?
Sam Soucie
@samdsou
May 31 2017 04:56
@Marmiz @Lumexralph that's it, thanks
CamperBot
@camperbot
May 31 2017 04:56
samdsou sends brownie points to @marmiz and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 914 | @marmiz |http://www.freecodecamp.com/marmiz
:star2: 1849 | @lumexralph |http://www.freecodecamp.com/lumexralph
Rosco verheij
@Jiehrev
May 31 2017 04:56
can someone please tell me whats wrong with this =

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

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

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

Ogundele Olumide
@Lumexralph
May 31 2017 04:57
@Jiehrev use celsius parameter with the formula and assign it to fahrenheit
Claudio Restifo
@Marmiz
May 31 2017 04:57
@JToddFL in your code you are not removing anything from the original array.. only pushing into a new one
arr.filter() is great in this challenge
mrszop
@mrszop
May 31 2017 05:04
Hello guys. Is there someone who can help me out with "Using Objects for Lookups"? My solution so far:
// Setup
function phoneticLookup(val) {
  var result = lookup[val];

  // Only change code below this line

  var lookup = {
    "alpha": "Adams",
    "bravo": "Boston",
    "charlie":"Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot": "Frank",
    "": undefined,
  };

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

// Change this value to test
phoneticLookup("charlie");
Manish Giri
@Manish-Giri
May 31 2017 05:06
@mrszop return result;
still returns an empty string
result = lookup[val];
assign this after the object is created
boxcardrew
@boxcardrew
May 31 2017 05:09
var code="formatted"
R.Ragupathi
@rrpathi
May 31 2017 05:15
hello
Concatenating Strings with the Plus Equals Operator
i am in stuck
Ogundele Olumide
@Lumexralph
May 31 2017 05:22
@rrpathi
let word = "I am ";
word += "me."
word; // I am me.
mrszop
@mrszop
May 31 2017 05:26
@Manish-Giri Thanks mate :)
CamperBot
@camperbot
May 31 2017 05:26
mrszop sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5749 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ginger
@gingerwilliams
May 31 2017 05:33
i am working on the weather app and having trouble accessing the api
What is the answer to this
Tried like everything
Ginger
@gingerwilliams
May 31 2017 05:33
both codepin and the api url are secured
any ideas?
Sivarama Krishnan
@kvsrkrishnan
May 31 2017 05:33
got rid of the escape sequence and replaced with single quotes. still errors out
Khuram Niaz
@Gsync
May 31 2017 05:34

```function lookUpProfile(firstName, prop){
// Only change code below this line
var result = '';

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

     if (contacts[i].firstName == firstName) {
       result = contacts[i][prop];
       break;

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

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

Proconsul
@proconsu1
May 31 2017 05:34
@kvsrkrishnan if you enclose the entire string in single quotes, then you don't need to escape all the double quotes within the string
Khuram Niaz
@Gsync
May 31 2017 05:35
can someone help me spot the error
Aniculaesei
@Aniculaesei
May 31 2017 05:35
Hello guys.How can I store an quote from an extern api in a variable?I send you my code!Thank you

$(document).ready(function(){
    $('#getMessage').on("click",function (){

         $.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&_jsonp=?", function(data){
   $("#quote").html("");
   $("#quote").append(data[0].content);

        });

    });


$("#tweetQuote").on("click", function(){

          var baseURL = 'https://twitter.com/intent/tweet?hashtags=YOURTAGHERE&text=';
        var quote = data[0].content;
        var URL = baseURL + encodeURIComponent('"' + quote + '"  ' );
    //open new window
        window.open(URL, 'Tweet about it!', 'width=600,height=500');
Not working
var quote = data[0].content;
Ginger
@gingerwilliams
May 31 2017 05:36
@kvsrkrishnan var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';
055IRI5
@055IRI5
May 31 2017 05:37
hey guys, does anyone know how to code switch statements am confused on the whole concept of it
Sivarama Krishnan
@kvsrkrishnan
May 31 2017 05:37

@proconsu1 Thank you.. this is the string i changed to (var myStr = "<a href='http://www.example.com' target='_blank'>Link</a>";

) from being (var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";) to clear the exercise. new to JS

CamperBot
@camperbot
May 31 2017 05:37
kvsrkrishnan sends brownie points to @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 123 | @proconsu1 |http://www.freecodecamp.com/proconsu1
Ginger
@gingerwilliams
May 31 2017 05:38
no problem man
Mohit Nandwani
@mohitnandwani
May 31 2017 05:38
Hey guys I'm stuck at bracket notation
Wavememories
@wavememories
May 31 2017 05:38
Hey guys, I'm doing the Javascript waypoint called Profile Lookup. The code I wrote passes tests but was wondering if you guys have recommendations on how to write it more efficiently:
//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

var contactObject = "";
var result = "No such contact";

  for (var i=0;i<contacts.length;i++) {
  contactObject=contacts[i];
  if (contactObject.firstName==firstName && contactObject.hasOwnProperty(prop)) {
    result=contactObject[prop];
    return result;
  }
    else if (contactObject.firstName==firstName) {
      result="No such property";
      return result;
    }
}

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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Bob", "number");
Proconsul
@proconsu1
May 31 2017 05:38
@Gsync oh man, i was just up against that one a coupla hours ago for partly the same reason as you. first, your total fail case, i.e. "no such contact" should be outside the for loop, i.e. the default result if no iteration of the loop gives any matches to either argument
Sivarama Krishnan
@kvsrkrishnan
May 31 2017 05:39
@gingerwilliams :( same error. keeps saying that "remove all backslashes", "You should have two single quotes and four double quotes".. something wrong with the compiler?
Khuram Niaz
@Gsync
May 31 2017 05:40
thanks @proconsu1
CamperBot
@camperbot
May 31 2017 05:40
gsync sends brownie points to @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 124 | @proconsu1 |http://www.freecodecamp.com/proconsu1
Ginger
@gingerwilliams
May 31 2017 05:40
yes remove the \
055IRI5
@055IRI5
May 31 2017 05:40
guys am stuck on switch statements
Ogundele Olumide
@Lumexralph
May 31 2017 05:40
@wavememories here's another way
Here's an outline, if you follow it step-wise it'll help a great deal in telling you what to do or step you missed
1. you need a loop to pick each objects in the contacts array
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                  return the value of prop in the object
                 1.1.1.2  return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
Ginger
@gingerwilliams
May 31 2017 05:40
and change the outer quotes from “” to ''
Proconsul
@proconsu1
May 31 2017 05:41
@Gsync and you don't need a break in a for loop. it automatically moves on if you get a false, and the whole function breaks on a return, so just return your output instead of assigning it to a variable. just if you want to tidy it up a bit
Ogundele Olumide
@Lumexralph
May 31 2017 05:41
Sivarama Krishnan
@kvsrkrishnan
May 31 2017 05:41
@gingerwilliams Thanks! had to type it instead of pasting :P (i did that to test).
CamperBot
@camperbot
May 31 2017 05:41
kvsrkrishnan sends brownie points to @gingerwilliams :sparkles: :thumbsup: :sparkles:
:cookie: 183 | @gingerwilliams |http://www.freecodecamp.com/gingerwilliams
Wavememories
@wavememories
May 31 2017 05:41
Awesome, thanks @Lumexralph
also @Gsync just realized you were on the same waypoint
Ginger
@gingerwilliams
May 31 2017 05:42
Awesome !
055IRI5
@055IRI5
May 31 2017 05:43
@Lumexralph i have, i still dont get it
Ogundele Olumide
@Lumexralph
May 31 2017 05:44
@055IRI5 show your code
Nick Gray
@nicholasnbg
May 31 2017 05:44

im going through the intermediate JS algorithms again, to try and write more concise code, but am struggling with the implementation of .forEach.

anyone care to comment on my code:

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

  var arr = str.toLowerCase().split('');
  arr.forEach(function(x){
    if(x===' '){
      return '-';
    }
  });
  console.log(arr.join(''));
}

spinalCase('This Is Spinal Tap');
kumar
@BSkumar2017
May 31 2017 05:45
Do not change code above the line.

var a=7;
var b = 2;

// Only change code below this line
b=a;

what is the error
Ginger
@gingerwilliams
May 31 2017 05:45
having trouble accessing the weather api. any ideas what im doing wrong?
the api and cp are both secured
kumar
@BSkumar2017
May 31 2017 05:47

@Gsync ca n you tell me the bug in this error.var a=7;
var b = 2;

// Only change code below this line
b=a;

Baibhav Gautam
@baibhavx
May 31 2017 05:47
@BSkumar2017 send a link to the problem
Baibhav Gautam
@baibhavx
May 31 2017 05:49
I see that you changed code above the line
Proconsul
@proconsu1
May 31 2017 05:49
@BSkumar2017 you changed code above the line. you need to do the value assignment for a below the line
055IRI5
@055IRI5
May 31 2017 05:49

@Lumexralph this what i've done so far function caseInSwitch(val) {
var answer = "";
// Only change code below this line
case"alpha ":
statement1;
break;
case"beta":
statement2;
break;
case"gamma":
statement1;
break;
case"delta":
statement2;
break;

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

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

kumar
@BSkumar2017
May 31 2017 05:49
@baibhavx I got the answer. thanks for helping
CamperBot
@camperbot
May 31 2017 05:49
bskumar2017 sends brownie points to @baibhavx :sparkles: :thumbsup: :sparkles:
:cookie: 326 | @baibhavx |http://www.freecodecamp.com/baibhavx
Baibhav Gautam
@baibhavx
May 31 2017 05:50
@nicholasnbg you are having trouble understanding forEach ?
Proconsul
@proconsu1
May 31 2017 05:50
@055IRI5 you haven't initialized the switch
maakiel
@maakiel
May 31 2017 05:50
var myStr="I am a \"double quoted\" string inside \"double quotes\" ; I need help please. I'm on the escaping literal quotes in Strings Challenge. What am I doing wrong?
Sivarama Krishnan
@kvsrkrishnan
May 31 2017 05:50

@BSkumar2017 // Setup
var a;
var b = 2;

// Only change code below this line

a=7;
b=a;

055IRI5
@055IRI5
May 31 2017 05:50
@proconsu1 how do i do that
Nick Gray
@nicholasnbg
May 31 2017 05:51
@baibhavx yes very much, i have already solved this in the past with for loops, but want to know who to use forEach
Sivarama Krishnan
@kvsrkrishnan
May 31 2017 05:51
@maakiel You missed a double quote at the end, before the semi colon.
Proconsul
@proconsu1
May 31 2017 05:51

@055IRI5

switch (val) {
case "alpha":
//etc more cases
}

it's that switch line that kicks things off by pulling in the argument for val against which the cases are going to test for true/false

Baibhav Gautam
@baibhavx
May 31 2017 05:53
@nicholasnbg
var array = [12, 13, 14, 15];

//use forEach loop to iterate through the array

array.forEach(function(number) {
  console.log(number);
});
// outputs
// 12
// 13
// 14
// 15
//So you have access to each element in the array
//you can name it whatever you like
@nicholasnbg It looks complicated in the beggining but once you get the hang of it its a piece of cake
055IRI5
@055IRI5
May 31 2017 05:54

@proconsu1 this is what i've done function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val) {
case"alpha ":
statement1;
break;
case"beta":
statement2;
break;
case"gamma":
statement1;
break;
case"delta":
statement2;
break;
}
// Only change code above this line
return answer;
}

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

Baibhav Gautam
@baibhavx
May 31 2017 05:54
I recommend trying to implement your own forEach method
Nick Gray
@nicholasnbg
May 31 2017 05:54
@baibhavx that seems straight forward to me, and i used forEach successfully only an hour or so ago here:
function diffArray(arr1, arr2) {
  var answer = [];

  function checkInd(x,y){
    x.forEach(function(i){
      if (y.indexOf(i) === -1){
        answer.push(i);
      }
    });
  }
  checkInd(arr1, arr2);
  checkInd(arr2, arr1);

  return answer;
}
Wavememories
@wavememories
May 31 2017 05:55
@Lumexralph , thanks for your help. It helped a lot. So much simpler.
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i=0; i<contacts.length; i++) {
  if (firstName==contacts[i].firstName) {
    if (contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
    else {
      return "No such property";
    }
  }
}
  return "No such contact";
CamperBot
@camperbot
May 31 2017 05:55
wavememories sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1850 | @lumexralph |http://www.freecodecamp.com/lumexralph
Nick Gray
@nicholasnbg
May 31 2017 05:55
In my above porblem, i want to replace spaces with '-', I just can't see where I'm going wrong with it this time:
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins

  var arr = str.toLowerCase().split('');
  arr.forEach(function(x){
    if(x===' '){
      return '-';
    }
  });
  console.log(arr.join(''));
}

spinalCase('This Is Spinal Tap');
Proconsul
@proconsu1
May 31 2017 05:55
@055IRI5 what are statement1 and statement2 referring to in that exercise?
Baibhav Gautam
@baibhavx
May 31 2017 05:58
@nicholasnbg the problem is that you are returning
you should not return inside a forEach
Nick Gray
@nicholasnbg
May 31 2017 05:58
@baibhavx should i replace with arr[x] = '-';?
Baibhav Gautam
@baibhavx
May 31 2017 05:59
@nicholasnbg what are you trying to achieve?
Nick Gray
@nicholasnbg
May 31 2017 05:59
actually, id need to use the index parameter, and then arr[index] = '-'
Wavememories
@wavememories
May 31 2017 05:59
Nick Gray
@nicholasnbg
May 31 2017 05:59
I'm trying to replace all " " (spaces), with "-" (dashes)
Baibhav Gautam
@baibhavx
May 31 2017 06:00
I see so you can pass an additional parameter to forEach to get access to the index.
```
var array = [1, 2, 3];
array.forEach(function(number, index) {
   console.log(number, index);
});
Wavememories
@wavememories
May 31 2017 06:01
The arguments you pass in to the caseInSwitch function should correspond with the case values
You basically execute the "statements" in the case with value that equals val and then the "break;" line allows you to exit the switch
Nick Gray
@nicholasnbg
May 31 2017 06:02
yeah, it worked, but it seems I've misread the question slightly, in anycase, you helped me understand forEach a bit better, no more returns haha, thanks again @baibhavx
CamperBot
@camperbot
May 31 2017 06:02
nicholasnbg sends brownie points to @baibhavx :sparkles: :thumbsup: :sparkles:
:cookie: 327 | @baibhavx |http://www.freecodecamp.com/baibhavx
Baibhav Gautam
@baibhavx
May 31 2017 06:02
@nicholasnbg , check out this implementation of forEach method. This is what's going on under the hood.
Array.prototype.myForEach = function(callback) {
  for(var i = 0; i < this.length; i++) {
    callback(this[i], i, this);
  }
}

var array = [1, 2, 3];

array.myForEach(function(number) {
  console.log(number)
});
sure goodluck!
Nick Gray
@nicholasnbg
May 31 2017 06:03
cheers!
Proconsul
@proconsu1
May 31 2017 06:03
@055IRI5 yeah, you need to test the cases against the possible numeric values of val, e.g. 1,2,3,and 4. and then set the variable result to the word corresponding, e.g. alpha, beta, etc.
Wavememories
@wavememories
May 31 2017 06:04
^nice
maakiel
@maakiel
May 31 2017 06:06
I'm still stuck on this challenge. Can someone please help me?
var myStr= I am a "\double quoted\" string inside \"double quotes\";
How is this nor correct? ^^^^
Proconsul
@proconsu1
May 31 2017 06:07
@maakiel it's a string. the entire string needs to also be in quotes, but quotes that are not escaped
Sandip Shrestha
@saninmersion
May 31 2017 06:07
@maakiel var myStr= "I am a "\double quoted\" string inside \"double quotes\""; . forgot the initaial and finishing " The whole string needs to be inside " " for string defination
Proconsul
@proconsu1
May 31 2017 06:07
@saninmersion heh. he forgot the closing one, too
Sandip Shrestha
@saninmersion
May 31 2017 06:08
@proconsu1 yup you are right.
maakiel
@maakiel
May 31 2017 06:09
Thanks
pedrognrd
@pedrognrd
May 31 2017 06:19

Hello you all!

I am starting with the Basic Java Script lesson and I don't understand the "Finding a Remainder in JavaScript" lesson. Could any of you help me?

Thank you very much
Shaik Saif Ali
@Saif-Shines
May 31 2017 06:19

Anyone please help, I've gone half a way
Objectives
` "Kristian", "lastName" should return "Vos"

"Sherlock", "likes" should return ["Intriguing Cases", "Violin"]

"Harry","likes" should return an array

"Bob", "number" should return "No such contact"

"Akira", "address" should return "No such property"`

my code is:

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


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

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

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

I'm not able to get where to add "No such contact " statement!

pedrognrd
@pedrognrd
May 31 2017 06:20

The instructions for the exercise are not clear for me :/

"Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator."

Shaik Saif Ali
@Saif-Shines
May 31 2017 06:21

@pedrognrd

var remainder  = 11 % 3;

An example is given in the instrutions, anyway :)

Thomas Mullen
@t-mullen
May 31 2017 06:22
@Saif-Shines You aren't returning "No such contact"
pedrognrd
@pedrognrd
May 31 2017 06:22
My god, @Saif-Shines it was easier than it seemed!
thanks a lot, @Saif-Shines ! :)
CamperBot
@camperbot
May 31 2017 06:22
pedrognrd sends brownie points to @saif-shines :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @saif-shines |http://www.freecodecamp.com/saif-shines
Shaik Saif Ali
@Saif-Shines
May 31 2017 06:23
@RationalCoding Yeah, can you help where to return.? I'm so unclear about it.!
Thomas Mullen
@t-mullen
May 31 2017 06:23
If you finish the for-loop, you know that you never found a matching firstName
Because a return will end the loop
So what should you return after the loop has completed?
Shaik Saif Ali
@Saif-Shines
May 31 2017 06:25
If you finish the for-loop, you know that you never found a matching firstName
exactly, thanks @RationalCoding !!
CamperBot
@camperbot
May 31 2017 06:25
saif-shines sends brownie points to @rationalcoding :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @rationalcoding |http://www.freecodecamp.com/rationalcoding
Proconsul
@proconsu1
May 31 2017 06:25
@pedrognrd think of it as grade school arithmetic...no decimals or fractions allowed. so 11 divided by 3 would equal 3 with a remainder of 2, i.e. 3x3=9 then 11-9 equals the remainder of 2
Thomas Mullen
@t-mullen
May 31 2017 06:25
:)
Shaik Saif Ali
@Saif-Shines
May 31 2017 06:25
@RationalCoding that hint helped !!
Thomas Mullen
@t-mullen
May 31 2017 06:28
@pedrognrd What would be left of the first number if you removed the second number until you couldn't anymore? 7 % 2 would be 1 because 7-2-2-2 = 1
1 is the remainder
Rosco verheij
@Jiehrev
May 31 2017 06:34

could someone please help me with this
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

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

Ashish Patel
@ashishpatelcs
May 31 2017 06:35
@Jiehrev just use to formula to calculate Fahrenheit from Celsius.
Markus Kiili
@Masd925
May 31 2017 06:36
@Jiehrev So use parameter celsius and the formula and assign it to var fahrenheit = ...
Ivan Leo
@yaaaas
May 31 2017 06:37
Hey guys kinda need some help with the julius Caesar assignment

function rot13(str) { // LBH QVQ VG!
var number;
var numbers = " ";
var final;
for(var i = 0 ; i < str.length ; i ++) {
number[i] = (str.charCodeAt(0) - 39 - 13) % 26 + 65;
numbers += number;

}
return String.fromCharCode(numbers);

}

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

How can I get numbers to be accepted by FromCharCode
Proconsul
@proconsu1
May 31 2017 06:38
@Jiehrev actually don't assign on the var line, as that is out of bounds for the exercise. just change the fahrenheit variable by a simple fahrenheit = (your conversion formula here)
Ivan Leo
@yaaaas
May 31 2017 06:38
I've tried converting numbers to an array and a string but both dont seem to work?
Dmitry-Kim
@Dmitry-Kim
May 31 2017 06:38
hello there! Can some1 say pls, what's wrong here Escape Sequence in strings trial
var myStr = FirstLine \n \SecondLine\ \r Thirdline;
Thomas Mullen
@t-mullen
May 31 2017 06:40
@yaaaas What kind of conversion? What would the start and end result look like?
Saif Ur Rahman
@saifsmailbox98
May 31 2017 06:40
@Dmitry-Kim\SecondLine\ this line should have literal \ so you need \\ and wrap the whole thing in " "
Benjamin
@XenoCoding
May 31 2017 06:40
Logging API data but not being able to display it? I've tried multiple different techniques to get the data in the box, but it's not working for some strange reason. https://codepen.io/XenoCoder/pen/EmqKNP
Markus Kiili
@Masd925
May 31 2017 06:40
@yaaaas For turning an array of charcodes to a string, you can use String.fromCharCode.apply(null,[65,66,67]); // 'ABC'
Thomas Mullen
@t-mullen
May 31 2017 06:40
@Dmitry-Kim You need quotes around strings. "A string" vs not a string
Saif Ur Rahman
@saifsmailbox98
May 31 2017 06:43
How to know whether a word starts with a lowercase letter or an uppercase letter?
Markus Kiili
@Masd925
May 31 2017 06:43
@saifsmailbox98 If you uppercase a character and it stays the same, it was uppercase at first.
Saif Ur Rahman
@saifsmailbox98
May 31 2017 06:44
@Masd925 oh yes.
Markus Kiili
@Masd925
May 31 2017 06:44
@saifsmailbox98 You could also use regexp.
Dmitry-Kim
@Dmitry-Kim
May 31 2017 06:44
thx, but the problem left var myStr = "FirstLine \n \\SecondLine\\ \r Thirdline";
Saif Ur Rahman
@saifsmailbox98
May 31 2017 06:45
@Dmitry-Kim Thirdline --> ThirdLine
Dmitry-Kim
@Dmitry-Kim
May 31 2017 06:46
myStr should have encoded text with the proper escape sequences and no spacing.z
Saif Ur Rahman
@saifsmailbox98
May 31 2017 06:46
@Dmitry-Kim yes
Dmitry-Kim
@Dmitry-Kim
May 31 2017 06:47
@saifsmailbox98 well, this problem left)
inspite i changed the capital letter as u mentioned
Saif Ur Rahman
@saifsmailbox98
May 31 2017 06:48
@Dmitry-Kim show the corrected code
Dmitry-Kim
@Dmitry-Kim
May 31 2017 06:48
var myStr = "FirstLine \n \\SecondLine\\ \r ThirdLine"; // Change this line
Saif Ur Rahman
@saifsmailbox98
May 31 2017 06:48
@Dmitry-Kim remove spaces
Dmitry-Kim
@Dmitry-Kim
May 31 2017 06:49
@saifsmailbox98 that's it, thx a lot :)
CamperBot
@camperbot
May 31 2017 06:49
:cookie: 307 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
dmitry-kim sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
Saif Ur Rahman
@saifsmailbox98
May 31 2017 06:49
@Dmitry-Kim yw
Yulia
@GJMarvel
May 31 2017 06:51
hi people!
jmariomejiap
@jmariomejiap
May 31 2017 06:51

hello guys.
I was working on a function that removes all non-numeric values from a string..

function keepNumbers (str) {
  var arr = str.split("").filter( function (element) {
    return parseInt(element);
  });
  console.log(arr);
  return arr
}

console.log(keepNumbers("2 a5568 1"));

I realised that on my filter function. when I return parseInt(element) I thought, that var arr will have an array of numbers but it turns out to be an array of strings (ex. ["2", "5", "5", "6", "8", "1"]).
can someone please share some knowledge with me?

Yulia
@GJMarvel
May 31 2017 06:51
need your advice
Sandip Halder
@sandip38
May 31 2017 06:52
how i suppose to complete the challenge no 146?
Manish Giri
@Manish-Giri
May 31 2017 06:53
@jmariomejiap why don't you use typeof instead
like return typeof element === "number"
Saif Ur Rahman
@saifsmailbox98
May 31 2017 06:54
@jmariomejiap you can use regex [0-9]
Yulia
@GJMarvel
May 31 2017 06:54

function showInput ()
{
var isChecked = document.getElementById('R001G2').value;
if (isChecked)
{
document.getElementById('HKBUY').style.display = "table-row";
} else
{
document.getElementById('HKBUY').style.display = "none";
}
}

need to show an input when checkbox is checked. for the first time it works well, input is hidden and after i check it shows up. but when i get it away, an input is still seen

what should i change to fix it?
jmariomejiap
@jmariomejiap
May 31 2017 06:55
@Manish-Giri but element will be a string. wouldn't it?
Markus Kiili
@Masd925
May 31 2017 06:55
@jmariomejiap Numeric can mean many things.
Saif Ur Rahman
@saifsmailbox98
May 31 2017 06:56
@jmariomejiap use regex man
jmariomejiap
@jmariomejiap
May 31 2017 06:58
@Masd925 yes, what I am after is the (255681) .
@saifsmailbox98 you are right, regex is more adequately.
I was just wondering why the behaviour I described was happening.
Saif Ur Rahman
@saifsmailbox98
May 31 2017 06:59
jmariomejiap
@jmariomejiap
May 31 2017 07:00
if i do a type check before the return I can see that it will be typeof .. number but when the array is created after the filter is done. the elements turn to be strings
function keepNumbers (str) {
  var arr = str.split("").filter( function (element) {
    var test = parseInt(element);
    console.log("typeof ", typeof test, test); /// number. 
    return parseInt(element);
  });
  console.log(arr);
  return arr
}

console.log(keepNumbers("2 a5568 1"));
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:03
try parseInt(); on every element and log it to the console and see what you get
["2"," ","a","5","5","6","8"," ","1"]
Markus Kiili
@Masd925
May 31 2017 07:04
@jmariomejiap From the filter callback function, you should be returning true/false depending whether you wan't to keep or discard the character.
tahashin
@tahashinegp
May 31 2017 07:05

function palindrome(str) {

// Good luck!
var newstring=str.replace(/[^A-Z0-9]/g,'');
newstring= newstring.toLowerCase();
var reverseString=[];
reverseString=newstring.split("",string.length);
reverseString.reverse();
var actualString= reverseString.join('');
if(actualString==newstring){
return true;
}

}

palindrome("eye"); // can anyone help me to find out the problem?

Manish Giri
@Manish-Giri
May 31 2017 07:06
@jmariomejiap I tried this
  var arr = str.split("").filter( function (element) {
    return !isNaN(element);
  });
this filters the integers, but also the spaces
Ashish Patel
@ashishpatelcs
May 31 2017 07:06
I'd try something like typeof(Number(element)) == 'number' or typeof(parseInt(element)) == 'number'
Manish Giri
@Manish-Giri
May 31 2017 07:07
@ashishpatelcs I did think of this typeof(parseInt(element)) == 'number'
but it won't work
coz typeof parseInt("a") this returns "number"
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:08
Manish Giri
@Manish-Giri
May 31 2017 07:09
?
already seen it
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:09
okay
all spaces and number will return number
only characters will return NaN
jmariomejiap
@jmariomejiap
May 31 2017 07:13
you guys are all cool, and helpful; i honestly was just curious as of why var arr becomes [ '2', '5', '5', '6', '8', '1' ] instead of [2,5,5,6,8,1].
it is probably just a waste of time. it was just something I noticed and couldn't answer myself
Dan Couper
@DanCouper
May 31 2017 07:14
char.charCodeAt() > 47 || char.charCodeAt() < 58
Will give you the numbers
Then parseint or whatever to covert them
Manish Giri
@Manish-Giri
May 31 2017 07:14
@jmariomejiap this worked for me
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:14
@DanCouper &&
Manish Giri
@Manish-Giri
May 31 2017 07:15
str = str.replace(/\s/g, '');
var arr = str.split("").filter(element =>!isNaN(element)).map(element => parseInt(element));
[2, 5, 5, 6, 8, 1]
Markus Kiili
@Masd925
May 31 2017 07:15
@jmariomejiap Filter removes some characters from the array. It doesn't transform them.
Manish Giri
@Manish-Giri
May 31 2017 07:15
@jmariomejiap
jmariomejiap
@jmariomejiap
May 31 2017 07:15
@Manish-Giri yes, I actually thought that could be an extra step.
@Masd925 Ohhhh, really... actually makes sense.
didn't think of that. ... that way
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:17
@gribanova what have you done till now?
jmariomejiap
@jmariomejiap
May 31 2017 07:17
@saifsmailbox98 @Manish-Giri @Masd925 thank you guys a lot. i appreciate the help
CamperBot
@camperbot
May 31 2017 07:17
jmariomejiap sends brownie points to @saifsmailbox98 and @manish-giri and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 309 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
:star2: 5755 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 4169 | @masd925 |http://www.freecodecamp.com/masd925
Dan Couper
@DanCouper
May 31 2017 07:17
@saifsmailbox98 yes should be &&, I hit enter too soon ☺️
gribanova
@gribanova
May 31 2017 07:20
@saifsmailbox98 I do not understand this task
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:21
@gribanova you need to convert temperature given in Celsius to Fahrenheit
@saifsmailbox98 you just need a simple formula for conversion
@gribanova
Manish Giri
@Manish-Giri
May 31 2017 07:22
@gribanova in future, pls don't post in multiple rooms at the same time.
gribanova
@gribanova
May 31 2017 07:23
@saifsmailbox98 yes, for example?
Dan Couper
@DanCouper
May 31 2017 07:23
The formula is in the explanation on the left
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:24
yes :smile:
gribanova
@gribanova
May 31 2017 07:24
@saifsmailbox98 I need answer, please?
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:25
@gribanova try it yourself
@gribanova that will help you.
then ask
gribanova
@gribanova
May 31 2017 07:26
@saifsmailbox98 thanks
CamperBot
@camperbot
May 31 2017 07:26
gribanova sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
rapido26
@rapido26
May 31 2017 07:32
a should be defined and have a value of 6
a should be defined and have a value of 6?
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:32
@rapido26 define awith a value of 6;
use var and assignment operator
rapido26
@rapido26
May 31 2017 07:33
@saifsmailbox98 u mean like this ?a=6;
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:33
@rapido26 yes var a =6;
r2d2
@UsamaHameed
May 31 2017 07:33
Hi people. Everyone who is having trouble passing the algorithm challenges can join https://gitter.im/AlgorithmsJedi/Algorithms
I feel like there is a lot of noise in all these rooms and there should be a dedicated space for questions about algorithms. People need a lot of help when it comes to algorithms. It is better to work on the problem than quitting altogether.
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:34
@rapido26 it must be in the examples or in the descriptions
Romaric Zounlome
@rzounlom
May 31 2017 07:35
Hi all, I am trying to test creating an array that counts backwards in the "Factorialize a number" basic algorithm challenge. For some reason when I try to use this code var myArray = [];
for (var i = 5; i > 0; i -=1) {
myArray.push(i);
}
I get the number 5
Markus Kiili
@Masd925
May 31 2017 07:35
@UsamaHameed I don't think this room has too much noise. Usually discussion over JS, algorithms and algorithm challenges.
Romaric Zounlome
@rzounlom
May 31 2017 07:35
instead of an array
any clue what I am doing wrong?
Akash Das
@akashjohn1111
May 31 2017 07:36
@rapido26 var a = 6;
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:37
@rzounlom try return myArray to get the whole array and then debug
r2d2
@UsamaHameed
May 31 2017 07:37
@Masd925 only if people show interest... if not, I will shift over here and join you guys.
Ogundele Olumide
@Lumexralph
May 31 2017 07:40
@Masd925 Good Morning, was wondering what @UsamaHameed meant by noise
Chris Juchtmans
@kjuchtmans
May 31 2017 07:41
A jolly good morning to all! :wave:
Markus Kiili
@Masd925
May 31 2017 07:41
@Lumexralph Morning. Most like stuff I talk. Bad jokes. Talk about my pretty nose etc.
r2d2
@UsamaHameed
May 31 2017 07:41
@Lumexralph @Masd925 noise is noise :P
Ogundele Olumide
@Lumexralph
May 31 2017 07:42
@Masd925 or quiz or puzzles :smirk:
@UsamaHameed Music is sound, noise is sound
Markus Kiili
@Masd925
May 31 2017 07:43
@Lumexralph Very few puzzles lately.
r2d2
@UsamaHameed
May 31 2017 07:43
Don't get too technical now
Chris Juchtmans
@kjuchtmans
May 31 2017 07:43

kicking off the working day with a general JQuery question :

  • assume .JSON file located at (url) :

will $.getJSON(url) return exactly the same as $.get(url) ?

cheers, k

r2d2
@UsamaHameed
May 31 2017 07:43
I am a Mechanical Engineer. I know sound. :smile:
Ogundele Olumide
@Lumexralph
May 31 2017 07:43
@UsamaHameed :wink:
Markus Kiili
@Masd925
May 31 2017 07:45
@kjuchtmans getJSON does automatic parsing to JS object.
Chris Juchtmans
@kjuchtmans
May 31 2017 07:46
okay @Masd925 so that's an obvious difference, and very good to keep in mind, thanks
CamperBot
@camperbot
May 31 2017 07:46
kjuchtmans sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4170 | @masd925 |http://www.freecodecamp.com/masd925
Alex
@Senius123
May 31 2017 07:49

hello people, help me please Correct the assignment to myStr to achieve the desired effect. // Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me

Markus Kiili
@Masd925
May 31 2017 07:49
@kjuchtmans So $.getJSON(url,[,data],[,success]) is a shorthand of $.ajax({dataType:"json", url:url, data:data,success:success});
Manish Giri
@Manish-Giri
May 31 2017 07:50
@Senius123 myStr[0] = "H"; // Fix Me
delete this
@Senius123
Alex
@Senius123
May 31 2017 07:51
@Manish-Giri senks
pedrognrd
@pedrognrd
May 31 2017 07:52

Hi again!

In the exercise "Find the Length of a String" I think that the solution is:

// Setup
var lastNameLength = 0;
var lastName = "Lovelace";

// Only change code below this line.

lastNameLength = lastName.lenght;

Is it correct?
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:53
@pedrognrd no
Alex
@Senius123
May 31 2017 07:53
@pedrognrd yes
Ashish Patel
@ashishpatelcs
May 31 2017 07:53
Only correct the spellings
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:53
lenght;
Grant Clark
@kwdzr3
May 31 2017 07:53
@pedrognrd except for the small typo at the end >)
pedrognrd
@pedrognrd
May 31 2017 07:53
@saifsmailbox98 it doesn't seem to work :S
Chris Juchtmans
@kjuchtmans
May 31 2017 07:54
@Masd925 great. Side-question re GET:
"Local Weather App"
If I obtain geolocation data, add them into a query string, and submit that string to weather site API, am I still perfoming a GET request?
In my logic I am posting data to server, rather than just getting?
Ashish Patel
@ashishpatelcs
May 31 2017 07:54
Length
Not lenght
Saif Ur Rahman
@saifsmailbox98
May 31 2017 07:54
@pedrognrd lastNameLength = lastName.length;
pedrognrd
@pedrognrd
May 31 2017 07:54
Oh my god again... I wrote lenght XD
thank you, peopel!
people!
I am a writing-dyslexic XD
Markus Kiili
@Masd925
May 31 2017 07:55
@UsamaHameed Sorry, I didn't get that you were talking about a new channel. Might be a good idea.
Ashish Patel
@ashishpatelcs
May 31 2017 07:55
Nope u are requesting some resource at an URL @kjuchtmans
Not posting, it's a get request
r2d2
@UsamaHameed
May 31 2017 07:56
Yeah lol @Masd925 no problem. I tried adding a channel to the FCC community but could not for some reason.
Chris Juchtmans
@kjuchtmans
May 31 2017 07:57
@ashishpatelcs okay, even though that request means I am actually adding geolocation data to API ?
@ashishpatelcs just trying to straighten out my reasoning
Ashish Patel
@ashishpatelcs
May 31 2017 07:58
@kjuchtmans it's still a URL, no matter what is added or what it looks like.
Chris Juchtmans
@kjuchtmans
May 31 2017 07:58
@ashishpatelcs will keep that in mind - thanks
CamperBot
@camperbot
May 31 2017 07:58
kjuchtmans sends brownie points to @ashishpatelcs :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @ashishpatelcs |http://www.freecodecamp.com/ashishpatelcs
Markus Kiili
@Masd925
May 31 2017 07:59
@kjuchtmans You can add data to a get request. Data that is sent to the server is appended to the URL as a query string. With jQuery, you can define that data as an JS object.
Ashish Patel
@ashishpatelcs
May 31 2017 07:59
@kjuchtmans you are not use POST to send any additional data. Everything is in the URL and that's a GET request
Chris Juchtmans
@kjuchtmans
May 31 2017 08:00
@Masd925 right. I'm beginning to sense the power of JQuery et al.
@Masd925 it seems to me an aweful lot of good / bad can happen from the query string?
Ashish Patel
@ashishpatelcs
May 31 2017 08:03
@kjuchtmans yes a lot of good, it can do. But bad things can be dealt with good practices.
Saif Ur Rahman
@saifsmailbox98
May 31 2017 08:04
how to convert "thisIsSpinalTap" into "this Is Spinal Tap"?
Ashish Patel
@ashishpatelcs
May 31 2017 08:06
@saifsmailbox98 maybe everytime you encounter a capital letter, u add a space before it. And the rejoin.
Tiago Correia
@tiagocorreiaalmeida
May 31 2017 08:06

function reverseString(str) {
str = str.split().reverse().join("");
}

reverseString("hello");

Reverse the provided string.

You may need to turn the string into an array before you can reverse it.

Your result must be a string.

what's missing?