16th
May 2016
Jim Strickland
@JStrick999
May 16 2016 00:00
the first element in the array pair, I think.
Diego Mayer
@Chrono79
May 16 2016 00:00
In that function call `arr = [[1,2],[3,4],[5,6,7]], arr[0] is [1,2], arr[1] is [3,4] and arr[2] is [5,6,7]`
So product = product * arr[i]; doesn't make much sense when product and arr[i] ar arrays
tekac
@tekac
May 16 2016 00:02
sorry @wishe for delayed response, got busy here at work. Its supposed to return 3 .. since 3 would be the position of 15 if it was added to the array
Diego Mayer
@Chrono79
May 16 2016 00:03
@JStrick999 you're not far from the solution, but you want to multiply every single number, and to do that, you have to access the inner arrays
how do you access, let's say 5 in arr?
Jim Strickland
@JStrick999
May 16 2016 00:05
arr [2,1]
Diego Mayer
@Chrono79
May 16 2016 00:05
@JStrick999 no, you have to use two sets of brackets, and remember the indexes start with 0
Jim Strickland
@JStrick999
May 16 2016 00:07
@Chrono79 arr [2][0]. I am also on the phone with a relative.
Diego Mayer
@Chrono79
May 16 2016 00:07
@JStrick999 no problem, leave no space between arr and the first bracket
now you have to run through arr indexes and the inner arrays indexes too, that's why you need nested loops there
get rid of this line: `product = product * arr[i];`
and modify this: `product = product * arr[j];`
Michelle Woods
@woomiche
May 16 2016 00:14
So, this seems like a silly question to be asking...I'm just really not quite sure why this isn't working. It's asking to split the string by its spaces.
``````var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split(' ');``````
CamperBot
@camperbot
May 16 2016 00:14
Diego Mayer
@Chrono79
May 16 2016 00:15
@InkWoods that should work. Refresh your browser and try again
Michelle Woods
@woomiche
May 16 2016 00:19
thanks, yeah, I had refreshed the page before and it didn't work, but i exited out and got back in and it went through
Catherine Kim
@Catherinesjkim
May 16 2016 00:20
anthonyjl92
@anthonyjl92
May 16 2016 00:20

Hey guys I was wondering how to go about using regex to extract specific values from a string?

For example:

``````var str = `<script type='text/javascript'>
if (!true) { var arr=[];}
arr.push({ 'id': '537967591' });
</script>
<script type='text/javascript' src='img.jpg></script>`;``````

How would the regex expression look like to extract the value stored in id and the src? 537967591 and img.jpg

Coy Sanders
@coymeetsworld
May 16 2016 00:21
sure @Catherinesjkim what do you have so far?
Catherine Kim
@Catherinesjkim
May 16 2016 00:22
var remainder = 11 % 3; // 2
Coy Sanders
@coymeetsworld
May 16 2016 00:22
the math looks right
is that your only line of code?
Catherine Kim
@Catherinesjkim
May 16 2016 00:22
yes
it just worked. thanks!
Coy Sanders
@coymeetsworld
May 16 2016 00:23
try refreshing your browser, that should be right
Catherine Kim
@Catherinesjkim
May 16 2016 00:23
Thanks! @coymeetsworld
CamperBot
@camperbot
May 16 2016 00:23
catherinesjkim sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 16 2016 00:23
np lol but you had it
Catherine Kim
@Catherinesjkim
May 16 2016 00:23
I guess : )
tekac
@tekac
May 16 2016 00:25
Coy Sanders
@coymeetsworld
May 16 2016 00:25
sure @tekac
tekac
@tekac
May 16 2016 00:25
I'm doing the "Where do I belong" challenge
``````
function getIndexToIns(arr, num) {
arr.sort(function(a,b) {
return a-b;
});
for (var i=0;i<arr.length;i++) { // cycles through the array
if (arr[i] >= num) { // if array value is bigger than num
return i; // return index pos of num bigger than value
}
arr.push(num); // push to array
return arr.indexOf(); // return index pos of new num <-- should return 3 in this case
}
}
}

getIndexToIns([2, 20, 10], 19);

//getIndexToIns([2, 5, 10], 15) should return 3.``````

Return the lowest index at which a value (2nd arg) should be inserted into an array (firstarg) once it has been sorted.

I've got everything right except for when the arg is not in the array. so I push it in, and it should return 3 which is the position of the newly inserted value

``return arr.indexOf(num);``
oops, I have this in there. This returns to 2
Jim Strickland
@JStrick999
May 16 2016 00:27
@Chrono79 I got it to work!! Stage Clear!!
Diego Mayer
@Chrono79
May 16 2016 00:28
@JStrick999 :+1:
Coy Sanders
@coymeetsworld
May 16 2016 00:28
yeah @tekac I don't think your arr[i] === undefined will ever hit right?
Diego Mayer
@Chrono79
May 16 2016 00:28
@anthonyjl92 `/(?:src=')(.+)(?:')/` for the src
and `/(?:'id': ')(\d+)(?:')/` for the id
Coy Sanders
@coymeetsworld
May 16 2016 00:29
also you don't technically need to push the item in the array either, and not sure if you can do indexOf() without specifying an element
tekac
@tekac
May 16 2016 00:30
@coymeetsworld would arr[i] === undefined not hit because I have return I? should I remove that?
Fatma Ali
@Fatmali
May 16 2016 00:31
hi guys how do I access the extract property without knowing the page id: {"batchcomplete":"","continue":{"grncontinue":"0.830480837397|0.830481121202|5587281|0","continue":"grncontinue||"},"query":{"pages":{"508152":{"pageid":508152,"ns":0,"title":"Juneau Empire","extract":"The Juneau Empire is a newspaper in Juneau, Alaska, United States.\nIt was founded on November 2, 1912 as the Alaska Daily Empire. In 1969 Morris Communications bought the newspaper. Mark Bryan was appointed publisher in 2009, but left the paper in 2013. In June of that year, Rustan Burton was named the new publisher and continues to run the paper today."}}},"limits":{"pageimages":50}}
Coy Sanders
@coymeetsworld
May 16 2016 00:31
yeah, don't *think that case will ever hit
jonphinguyen
@jonphinguyen
May 16 2016 00:32
I don't see where it says how to set var a to var b
any help?
Coy Sanders
@coymeetsworld
May 16 2016 00:33
what do you have @jonphinguyen ?
jonphinguyen
@jonphinguyen
May 16 2016 00:33
var a = var b;
Coy Sanders
@coymeetsworld
May 16 2016 00:33
This message was deleted
jonphinguyen
@jonphinguyen
May 16 2016 00:34
var a = 7;
Diego Mayer
@Chrono79
May 16 2016 00:34
@Fatmali you could try using Object.keys() to obtain the id value
jonphinguyen
@jonphinguyen
May 16 2016 00:34
var b = 7;
Coy Sanders
@coymeetsworld
May 16 2016 00:34
what you want to do is assign b to a instead of 7
since a=7, b will also equal 7 that way
so instead of 7 replace it with a
jonphinguyen
@jonphinguyen
May 16 2016 00:34
that was it
Diego Mayer
@Chrono79
May 16 2016 00:34
@jonphinguyen this isn't right: var a = var b;
var should appear (if it's needed) always in the left side of the assignation
Fatma Ali
@Fatmali
May 16 2016 00:35
Thanks @Chrono79
CamperBot
@camperbot
May 16 2016 00:35
fatmali sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 16 2016 00:35
oh missed that part @Chrono79, yeah
jonphinguyen
@jonphinguyen
May 16 2016 00:35
@Chrono79 @coymeetsworld Thanks so much!
CamperBot
@camperbot
May 16 2016 00:35
jonphinguyen sends brownie points to @chrono79 and @coymeetsworld :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 16 2016 00:35
shouldn't be a var on the right side of the equals (assignment) operator
KoToZ
@Mohamedtareque
May 16 2016 00:37

## hello guys

i stuck here , i can't find the reason .
``````function diffArray(arr1, arr2) {
var newArr = [];
// Same, same; but different.
var arr= arr1.concat(arr2);
arr=arr.sort(function(a,b){return a-b ;});
console.log(arr);
for( var i =0 ; i<=arr.length;i++){
if(arr[i]!==arr[i++]){
newArr.push(arr[i]);
}

}

console.log(newArr);
//return newArr;

}
diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);``````
i wanna make a symetric array from two arrys
Coy Sanders
@coymeetsworld
May 16 2016 00:38
is this the symmetric difference challenge @Mohamedtareque ?
anthonyjl92
@anthonyjl92
May 16 2016 00:38
@Chrono79 ty!
CamperBot
@camperbot
May 16 2016 00:38
anthonyjl92 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
KoToZ
@Mohamedtareque
May 16 2016 00:39
ya [Diff Two Arrays]
Coy Sanders
@coymeetsworld
May 16 2016 00:39
oh no thats another challenge
I think you need to go through both arrays to do this @Mohamedtareque
Diego Mayer
@Chrono79
May 16 2016 00:40
@Mohamedtareque looks at the expected result of that function call:[1, 2, 3, 5], [1, 2, 3, 4, 5] should return [4].
Your function only eliminate repeats, but it returns [1,2,3,4,5]
Coy Sanders
@coymeetsworld
May 16 2016 00:40
oh wait i see what you did, you concat and sorted it hmm
KoToZ
@Mohamedtareque
May 16 2016 00:41
ya my could has finshed when it find [ 4, 5, 5 ]
ya i cancat then sort it then shift it pairs
Coy Sanders
@coymeetsworld
May 16 2016 00:42
so when your index gets to 4
i.e. i=6
KoToZ
@Mohamedtareque
May 16 2016 00:42
but when it reaches to 4 it stop revealing
Coy Sanders
@coymeetsworld
May 16 2016 00:43
compares it to next one in line (and increments i again)
realizes 4 != 5, pushes 4
now you're at i=8
it doesn't compare it to the other 5 (i=7)
KoToZ
@Mohamedtareque
May 16 2016 00:43
ya , let me try it right now
Coy Sanders
@coymeetsworld
May 16 2016 00:43
actually hmm another problem
alright yeah look at it you need to add additional logic if you find a difference
i wouldn't increment i again inside the for loop
Diego Mayer
@Chrono79
May 16 2016 00:44
I think this is a mistake: if(arr[i]!==arr[i++]){
you wanted to put i+1 there, and with that, it would do what I told
Coy Sanders
@coymeetsworld
May 16 2016 00:44
yeah
then running arr.push(arr[i]) after
because when you compare 4 to 5, its pushing in 5 not 4, im not sure how 4 got in there i must be missing something
Diego Mayer
@Chrono79
May 16 2016 00:47
@Mohamedtareque @coymeetsworld I think you should start again from the start, that sorting is for numbers, and the test cases include some strings too
Coy Sanders
@coymeetsworld
May 16 2016 00:48
yeah I did it a bit differently, although at that point my code isn't that good either, I could rewrite it to be alot better
KoToZ
@Mohamedtareque
May 16 2016 00:49
hmmm , ya @Chrono79
i'm gonna start from scratch right now , but i wanna wonder about looping , how can i get rid of it when i reaches my goal , ?
Diego Mayer
@Chrono79
May 16 2016 00:50
@Mohamedtareque I'll share what I did the first time I did it, I used 2 for loops and indexOf to check if the elements of the array I was looping were or not in the other
anthonyjl92
@anthonyjl92
May 16 2016 00:53
@Chrono79 when I input
do something like /(?:src=')(.+)(?:')/ to find the src, how is that returned to me?, it it broken up into an array?
Greg Duncan
@GregatGit
May 16 2016 00:54
@Mohamedtareque do you mean you want to stop the loop if certain conditions are met?
anthonyjl92
@anthonyjl92
May 16 2016 00:55
@Chrono79
would it look something like this?
[src='][img.jpg][']
Diego Mayer
@Chrono79
May 16 2016 00:57
@anthonyjl92 https://repl.it/CRGU/0
Greg
@GregJacoby
May 16 2016 00:57
can someone explain this? i don't understand how this creates a max and a min
``````function ourFunction(ourMin, ourMax) {

return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}``````
Diego Mayer
@Chrono79
May 16 2016 00:58
@GregJacoby Math.random returns a number between 0 (inclusive) and 1 (not inclusive)
if it returns 0, you get ourMin
if it returns almost 1, you'll get almost (ourMax - ourMin + 1) and that + ourMin would be (almost)ourMax + 1, when you apply Math.floor, that falls to ourMax
Any other value of Math.random makes all that to fall between ourMin and ourMax
Greg Duncan
@GregatGit
May 16 2016 00:59
Greg
@GregJacoby
May 16 2016 01:00
i sort of get it
hm, okay
i see it now
it makes it impossible to go above that number
and the + 1 makes it impossible to go below the minimum number?
Diego Mayer
@Chrono79
May 16 2016 01:03
@anthonyjl92 I excluded the src=' and ' part of the capture, if you need them modify the regex to include them
Greg Duncan
@GregatGit
May 16 2016 01:04
here is the js for 1 to 100 inclusive `Math.floor((Math.random() * 100) + 1);` instead of hard coding 100 and 1 you use varibles - so 1 become min and 100 max so you can alter the range
Greg
@GregJacoby
May 16 2016 01:05
gotcha
Diego Mayer
@Chrono79
May 16 2016 01:05
@GregJacoby the +1 is to use it with Math.floor because Math.random will not return 1
Greg
@GregJacoby
May 16 2016 01:05
@Chrono79 @GregatGit thank you
CamperBot
@camperbot
May 16 2016 01:05
gregjacoby sends brownie points to @chrono79 and @gregatgit :sparkles: :thumbsup: :sparkles:
Greg
@GregJacoby
May 16 2016 01:05
ahhh okay
Diego Mayer
@Chrono79
May 16 2016 01:06
@GregJacoby in the example @GregatGit gave you, Math.random() * 100 will get, at most 99.99999999, +1 it'll be 100.99999999 and applying Math.floor it becomes 100
Greg
@GregJacoby
May 16 2016 01:06
right, that makes sense
oh oh oh
okay
i just fully got it
anthonyjl92
@anthonyjl92
May 16 2016 01:07
@Chrono79 ty so much!
CamperBot
@camperbot
May 16 2016 01:07
anthonyjl92 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: anthonyjl92 already gave chrono79 points
Diego Mayer
@Chrono79
May 16 2016 01:07
Greg
@GregJacoby
May 16 2016 01:07
and the +minimum after the equation means that if it returns 0, it ill simply be the minimum defined
if math.random returns 0 i mean
thanks :)
Diego Mayer
@Chrono79
May 16 2016 01:08
@anthonyjl92 if you become the next Zuckerberg, just give me some actions of your company :+1:
@GregJacoby yes, exactly
Fatma Ali
@Fatmali
May 16 2016 01:13
hi guys Wikipedia refuses to connect to the a href
links i put in my pen
Tati
@tdoyle01
May 16 2016 01:13
This message was deleted
Fatma Ali
@Fatmali
May 16 2016 01:13
Is this a security issue
Diego Mayer
@Chrono79
May 16 2016 01:13
Greg Duncan
@GregatGit
May 16 2016 01:14
@Fatmali Hey - you should post in helpfrontend - you'll get more help there
Fatma Ali
@Fatmali
May 16 2016 01:14
after you search
Diego Mayer
@Chrono79
May 16 2016 01:14
help rooms
CamperBot
@camperbot
May 16 2016 01:14

# FreeCodeCamp Chat Rooms

### Help Rooms

Chat Room Description Chat Room
HTML/CSS/Bootstrap `FreeCodeCamp/Help`
JavaScript/Algorithms `FreeCodeCamp/HelpJavaScript`
Front End `FreeCodeCamp/HelpFrontEnd`
Data Visualization `FreeCodeCamp/HelpDataViz`
Back End `FreeCodeCamp/HelpBackEnd`

Choose the right room for your questions!

*`back to top`&#8593;

Fatma Ali
@Fatmali
May 16 2016 01:14
more*
Tati
@tdoyle01
May 16 2016 01:15
Hi, I'm having some issues setting the input of a text box to a javascript variable. Any clue why this might be so? Here's my code:
``````  var query = \$('#question').val();

\$("#submit").click(function() {
});``````
Bobby McDonald
@BobbyMcWho
May 16 2016 01:15
``                                                                                                                                                                                    use .val                                     ``
use .val
Tati
@tdoyle01
May 16 2016 01:15
``````<input type="text" class="form-control" id="question" placeholder="ask your stupid question">
<input type="submit" class="btn btn-primary" id="submit" value="Ask ">``````
Diego Mayer
@Chrono79
May 16 2016 01:15
@Fatmali mispelling wikipedia: href="https://en.wikipidea.org/ fix that, it'll work
Fatma Ali
@Fatmali
May 16 2016 01:16
@GregatGit Tried. No1 responding
Bobby McDonald
@BobbyMcWho
May 16 2016 01:16
@tdoyle01 set the value in the input first for testing
Tati
@tdoyle01
May 16 2016 01:16
@BobbyMcWho What do you mean?
Bobby McDonald
@BobbyMcWho
May 16 2016 01:17
@tdoyle01 you don't have any value in the text input to start with
the placeholder isn't a value
Tati
@tdoyle01
May 16 2016 01:17
@BobbyMcWho I'm entering a value into the text and hitting the submit button manually.
Bobby McDonald
@BobbyMcWho
May 16 2016 01:17
make that a function instead then
Bobby McDonald
@BobbyMcWho
May 16 2016 01:19
``````function query(){
var query = \$('#question').val();
Tati
@tdoyle01
May 16 2016 01:19
@BobbyMcWho I see, it isn't aware of the variable outside of the function. Thank you so much!
CamperBot
@camperbot
May 16 2016 01:19
tdoyle01 sends brownie points to @bobbymcwho :sparkles: :thumbsup: :sparkles:
Bobby McDonald
@BobbyMcWho
May 16 2016 01:20
@tdoyle01 when you call the var initially, it takes whatever the value of the text box was on page load
Justin Woodward
@jwoo92
May 16 2016 01:20
my weather conditions are not showing up like i want. please ignore the alert text, ill be putting my weather icon there. can anyone look over my code and assist me on finding out my problem please? https://codepen.io/jwoo/pen/PNgdyO?editors=1010
Bobby McDonald
@BobbyMcWho
May 16 2016 01:20
so you want to put it in the click function
Tati
@tdoyle01
May 16 2016 01:21
@BobbyMcWho Makes a lot of sense, can't believe I didn't realize that.
Greg Duncan
@GregatGit
May 16 2016 01:21
@Fatmali You have a typo - you've spelt wikipedea wrong
Bobby McDonald
@BobbyMcWho
May 16 2016 01:21
@jwoo92 theres an issue with geolocation in chrome, I would use http://ip-api.com
Christina
@cgraham74
May 16 2016 01:21
help everything be true
CamperBot
@camperbot
May 16 2016 01:21

# Explanation:

The program needs to check if the second argument is a truthy element, and it must check this for each object in the first argument.

### Hint: 1

Remember to iterate through the first argument to check each object.

### Hint: 2

Only if all of them are truth will we return true, so make sure all of them check.

### Hint: 3

You could use loops or callbacks functions, there are multiple ways to solve this problem.

Fatma Ali
@Fatmali
May 16 2016 01:21
thanks @Chrono79 @GregatGit its working now
CamperBot
@camperbot
May 16 2016 01:21
:warning: fatmali already gave chrono79 points
fatmali sends brownie points to @chrono79 and @gregatgit :sparkles: :thumbsup: :sparkles:
Catherine Kim
@Catherinesjkim
May 16 2016 01:22
I think I finished Convert Celsius to Fahrenheit test but it's not going the next level. Do you know why?
Justin Woodward
@jwoo92
May 16 2016 01:22
@BobbyMcWho i was able to retrieve my lat and lon coordinates. but it seemed that when i called the api and used jquery to display the json data i wanted, that it did not place the html at all.
Diego Mayer
@Chrono79
May 16 2016 01:22
Greg Duncan
@GregatGit
May 16 2016 01:22
@Fatmali Cool
Bobby McDonald
@BobbyMcWho
May 16 2016 01:23
@jwoo92 let me look again
Catherine Kim
@Catherinesjkim
May 16 2016 01:23

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

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

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

Justin Woodward
@jwoo92
May 16 2016 01:24
@BobbyMcWho the alert text will only remain if the geolocation is not collected. if it is, that text will be replaced by the relating weather icon.
but i have not gotten that far yet.
Diego Mayer
@Chrono79
May 16 2016 01:24
@Catherinesjkim you're not using celsius in your formula, so no matter which value you use when you call your function, the answer will be the same
Greg Duncan
@GregatGit
May 16 2016 01:25
@Fatmali i think you can have this `<a href="https://en.wikipedia.org/wiki/'+ item.title +'`
Bobby McDonald
@BobbyMcWho
May 16 2016 01:25
@jwoo92 I used the .ajax instead of .getJson do I'm not so familiar
Greg Duncan
@GregatGit
May 16 2016 01:25
@Fatmali instead of `<a href="https://en.wikipedia.org/wiki/'+item.title.replace(" ","_")+'`
Justin Woodward
@jwoo92
May 16 2016 01:26
@BobbyMcWho i am not too familiar with .ajax yet. .getJson is relatively new to me as well being i have only used it once on my random quote generator.
Greg Duncan
@GregatGit
May 16 2016 01:26
@Fatmali If I am right it would be one more function that doesn't need executing
@jwoo92 I believe that getJSON is shorthand for ajax
Bobby McDonald
@BobbyMcWho
May 16 2016 01:27
it is, the usage is just a bit different
Catherine Kim
@Catherinesjkim
May 16 2016 01:27
Done. Thank you @Chrono79!
CamperBot
@camperbot
May 16 2016 01:27
catherinesjkim sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Justin Woodward
@jwoo92
May 16 2016 01:28
@BobbyMcWho @GregatGit thanks for the input, do you believe that my main issue for my jquery commands not processing lies in the fact of the issue with geolocation in chrome?
CamperBot
@camperbot
May 16 2016 01:28
jwoo92 sends brownie points to @bobbymcwho and @gregatgit :sparkles: :thumbsup: :sparkles:
Greg Duncan
@GregatGit
May 16 2016 01:30
no http or https
Justin Woodward
@jwoo92
May 16 2016 01:34
@GregatGit how does it look now? i attempted to convert over to the API http://ip-api.com/ as well. i still do not see it working with my updated code.
Greg Duncan
@GregatGit
May 16 2016 01:35
@jwoo92 http://ip-api.com/json put the json on the end
@jwoo92
``````\$.getJSON("http://ip-api.com/json", function(json) {
console.log(json);``````
@jwoo92 Then have a look at the json in the console to see how to get the lat and long
Justin Woodward
@jwoo92
May 16 2016 01:40
@GregatGit thanks again. i updated it with no luck. would my weather api be incorrect in some way?
CamperBot
@camperbot
May 16 2016 01:40
jwoo92 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:warning: jwoo92 already gave gregatgit points
OneRandomJamie
@OneRandomJamie
May 16 2016 01:41
Could someone explain a challenge to me? It is Escaping Literal Quotes in Strings.It seems simple but it just isnt connecting with my brain for some reason.
Diego Mayer
@Chrono79
May 16 2016 01:42
@OneRandomJamie what do you have so far?
OneRandomJamie
@OneRandomJamie
May 16 2016 01:43
@Chrono79 var myStr = "I am a \"double quoted\"string inside \"double quotes"\";
Diego Mayer
@Chrono79
May 16 2016 01:43
@OneRandomJamie look out for spaces and the last one escaped is wrong
`quoted\"string` here, missing a space before string
`double quotes"\";` here, escaped the wrong double quotes
Greg Duncan
@GregatGit
May 16 2016 01:43
@jwoo92 you have a bracket right after the url
and call it function(json) not function(latlong)
Bobby McDonald
@BobbyMcWho
May 16 2016 01:45
I did mine like this
``````function getTemp() {
\$.ajax({
type: 'GET',
url: ('http://api.openweathermap.org/data/2.5/weather?zip=' + zip + ',us' + '&appid=MYAPIKIEY&units=' + units),
success: function(e) {
weatherStat = e.weather[0].main;
deg = Math.round(e.main.temp);
cityName = e.name;
fillTemp();
},
complete: function(){changeIcon();}
});
}``````
OneRandomJamie
@OneRandomJamie
May 16 2016 01:50
@Chrono79 What do you mean by escaped the wrong double quotes?
Greg Duncan
@GregatGit
May 16 2016 01:50
@jwoo92 this is wrong `\$.getJSON("http://ip-api.com/json"), function(json)`
Diego Mayer
@Chrono79
May 16 2016 01:51
@OneRandomJamie instead of this: `"\"` you should have this: `\""`
Greg Duncan
@GregatGit
May 16 2016 01:51
@jwoo92 it should be `\$.getJSON("http://ip-api.com/json", function(json)`
@jwoo92 the correct one has no closing bracket
OneRandomJamie
@OneRandomJamie
May 16 2016 01:52
@Chrono79 thank you
CamperBot
@camperbot
May 16 2016 01:52
onerandomjamie sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Justin Woodward
@jwoo92
May 16 2016 01:55
@GregatGit whoops you are right, i missed that. i updated still with no luck on the results. i believe i must be doing something wrong with my weather API. im thinking my weather api has the incorrect url text format.
Greg Duncan
@GregatGit
May 16 2016 01:56
@jwoo92 no - its fine -
@jwoo92 for starters click the 'tidy' on the js panel - it will make your code look neat
Justin Woodward
@jwoo92
May 16 2016 01:57
@GregatGit wow i did not know that existed on there. nice tip!
Greg Duncan
@GregatGit
May 16 2016 01:58
@jwoo92 once you have done that put this as your first line for the response `console.log(response);`
Diego Mayer
@Chrono79
May 16 2016 01:58
@GregatGit :clap:
Greg Duncan
@GregatGit
May 16 2016 01:59
@jwoo92 tell me once thats done
Justin Woodward
@jwoo92
May 16 2016 01:59
@GregatGit done
Greg Duncan
@GregatGit
May 16 2016 01:59
are you using chrome?
Justin Woodward
@jwoo92
May 16 2016 01:59
yes
Greg Duncan
@GregatGit
May 16 2016 01:59
shft + control + i
click on console
Justin Woodward
@jwoo92
May 16 2016 02:00
@GregatGit lots of errors, most with this saying: This request has been blocked; the content must be served over HTTPS.
Greg Duncan
@GregatGit
May 16 2016 02:01
ignore them
we're looking for object
Object
you should have 2 Object in the console - if the console is too full clear it
or scroll to the bottom
have you found Object?
Justin Woodward
@jwoo92
May 16 2016 02:03
Greg Duncan
@GregatGit
May 16 2016 02:03
click clear
or control l
Justin Woodward
@jwoo92
May 16 2016 02:04
Kyle W Pilkinton
May 16 2016 02:04
hey guys how would i add different icons that would change according to weather in the weather forcast zipline? is ther something in the api i can compare to get different icons?
Bobby McDonald
@BobbyMcWho
May 16 2016 02:05
Use them like glyphs or fa icons
Greg Duncan
@GregatGit
May 16 2016 02:05
@jwoo92 just save and reload page - leave the debugger open
Justin Woodward
@jwoo92
May 16 2016 02:06
@GregatGit jquery.min.js:4 Mixed Content: The page at 'https://codepen.io/jwoo/pen/PNgdyO?editors=0110' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://ip-api.com/json'. This request has been blocked; the content must be served over HTTPS.l.cors.b.crossDomain.send @ jquery.min.js:4n.extend.ajax @ jquery.min.js:4n.(anonymous function) @ jquery.min.js:4n.extend.getJSON @ jquery.min.js:4(anonymous function) @ pen.js:15i @ jquery.min.js:2j.fireWith @ jquery.min.js:2n.extend.ready @ jquery.min.js:2J @ jquery.min.js:2
jquery.min.js:4 XMLHttpRequest cannot load http://ip-api.com/json. Failed to start loading.l.cors.b.crossDomain.send @ jquery.min.js:4n.extend.ajax @ jquery.min.js:4n.(anonymous function) @ jquery.min.js:4n.extend.getJSON @ jquery.min.js:4(anonymous function) @ pen.js:15i @ jquery.min.js:2j.fireWith @ jquery.min.js:2n.extend.ready @ jquery.min.js:2J @ jquery.min.js:2
Kyle W Pilkinton
May 16 2016 02:07
ive used them but i only have one. i dont know how i can make them change according to the weather??? @BobbyMcWho
Bobby McDonald
@BobbyMcWho
May 16 2016 02:08
@tadake when you're pulling from the weather api, there is a part of the JSON that refers to current weather condition
set that to a variable, and make a function that sets the icon based on the value of that variable
@tadake here is how I did it:
``````function changeIcon(){
var \$weatherIcon = \$('#weatherIcon');
if (weatherStat == 'Thunderstorm'){
\$weatherIcon.attr('class',"wi wi-thunderstorm");
}
if (weatherStat == 'Drizzle' || 'Rain'){
\$weatherIcon.attr('class',"wi wi-showers");
}
if (weatherStat == 'Snow'){
\$weatherIcon.attr('class',"wi wi-snow");
}
if (weatherStat == 'Atmosphere'){
\$weatherIcon.attr('class',"wi wi-smoke");
}
if (weatherStat == 'Clear'){
\$weatherIcon.attr('class',"wi wi-wu-clear");
}
if (weatherStat == 'Extreme'){
\$weatherIcon.attr('class',"wi wi-windy");
}
}``````
Kyle W Pilkinton
May 16 2016 02:09
is there a place i can look up all the possible parameters? i know it has cloudy and light rain but im not sure what the other values are.
@BobbyMcWho
Bobby McDonald
@BobbyMcWho
May 16 2016 02:10
@tadake the group names are the main part that I looked for. I didn't get super complicated
Mike Moss
@MMux
May 16 2016 02:30
help missing letters
CamperBot
@camperbot
May 16 2016 02:30

# Problem Explanation:

• You will create a program that will find the missing letter from a string and add it. If there is not missing letter it will return undefined. There is currently no test case for it missing more than one letter, but if anything recursion can be implemented or a second or more calls to the same function as needed. Also the letters are always provided in order so there is no need to sort them.
buiphuking
@buiphuking
May 16 2016 02:32
guys, help me, i do calculator, but i don't know with my js code, i click button but nothing show up
http://codepen.io/buiphuking/pen/qZwpjE?editors=1010
OneRandomJamie
@OneRandomJamie
May 16 2016 02:42
Can someone help me with this one: Escape Sequences in Strings?
Vibhor Batra
@batravibhor
May 16 2016 02:43
@OneRandomJamie yes
which challenge
OneRandomJamie
@OneRandomJamie
May 16 2016 02:44
@batravibhor Escape Sequences in Strings
Diego Mayer
@Chrono79
May 16 2016 02:48
@buiphuking it's getElementsByTagName, you're missing the s of Elements
buiphuking
@buiphuking
May 16 2016 02:56
@Chrono79
i love you , thanks so much, codepen can't check that
CamperBot
@camperbot
May 16 2016 02:56
buiphuking sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Justin Woodward
@jwoo92
May 16 2016 03:05
is there a way to find out all the available weather options for the open weather API? i want to get a list of all potential options so i can know what icons to use and when.
Diego Mayer
@Chrono79
May 16 2016 03:09
Kyle W Pilkinton
May 16 2016 03:09
thanks Robert! @BobbyMcWho
CamperBot
@camperbot
May 16 2016 03:09
tadake sends brownie points to @bobbymcwho :sparkles: :thumbsup: :sparkles:
Justin Woodward
@jwoo92
May 16 2016 03:10
@Chrono79 thanks
CamperBot
@camperbot
May 16 2016 03:10
jwoo92 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Norvin Burrus
@ndburrus
May 16 2016 03:11
@OneRandomJamie can you post your code so far?
pauoola
@pauoola
May 16 2016 03:11
Not sure what is being asked of me"Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr"
abaplover
@abaplover
May 16 2016 03:12
what you need to code is this: "\, \t, \r, \n
OneRandomJamie
@OneRandomJamie
May 16 2016 03:12
@ndburrus var myStr = \ \t \t \r \n;
@pauoola @ndburrus is helping me with the same thing.
Norvin Burrus
@ndburrus
May 16 2016 03:13
@OneRandomJamie ok, let's pay particular attention to the last word in the instructions: "Instructions - Encode the following sequence, separated by spaces" Hint: use the Code/Output chart.... also, let's not forget to enclose the entire string in quotes... @pauoola also :) ...does this help?
pauoola
@pauoola
May 16 2016 03:15
@abaplover @OneRandomJamie thank you, I am trying that.
CamperBot
@camperbot
May 16 2016 03:15
pauoola sends brownie points to @abaplover and @onerandomjamie :sparkles: :thumbsup: :sparkles:
buiphuking
@buiphuking
May 16 2016 03:16
@Chrono79
could you help me with my C button, remove last character
http://codepen.io/buiphuking/pen/qZwpjE?editors=1010
OneRandomJamie
@OneRandomJamie
May 16 2016 03:17
@ndburrus Thank you
CamperBot
@camperbot
May 16 2016 03:17
onerandomjamie sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Amanda Daley
@DaisyDream
May 16 2016 03:17
having some issues with the weather challenge. Got the geolocation coordinates, but I'm not sure if I'm getting the json information correctly
`` \$.getJSON("http://api.openweathermap.org/data/2.5/weather?lat="+lati+"&lon="+long+"&APPID=5f3a20c72ab970efb7f91be749b86d8f");``
Norvin Burrus
@ndburrus
May 16 2016 03:18
@OneRandomJamie you're welcome, anytime! nice work! :+1:
Ben Smith
@bensm1th
May 16 2016 03:24
@DaisyDream did you get help on the weather challenge yet?
Amanda Daley
@DaisyDream
May 16 2016 03:28
@bensm1th not yet.
I wonder if it has to do with my browser, the console says something about failing to load
Ben Smith
@bensm1th
May 16 2016 03:29
@DaisyDream Ok, when I used JSON for this challenge, I found it easier to declare variables for the API, data, and callback function, then put the variables in
acgillette
@acgillette
May 16 2016 03:29
Hey guys, anyone willing to give me pointers on the Where do I Belong challenge?
Ben Smith
@bensm1th
May 16 2016 03:29
@DaisyDream sometimes chrome has issues
Chris Lacaille
@ChrisL108
May 16 2016 03:30
@DaisyDream There's been problems with that challenge. It needs updated
Ben Smith
@bensm1th
May 16 2016 03:30
just try firefox, and if you get the same thing, then it's not your browers
Chris Lacaille
@ChrisL108
May 16 2016 03:30
@DaisyDream What's you issue though?
@DaisyDream What @bensm1th sai
said
Ben Smith
@bensm1th
May 16 2016 03:30
But, I quit using the standard geolocation for it because it only worked in chrome
pauoola
@pauoola
May 16 2016 03:30
@OneRandomJamie I tried to encode this several ways. var myStr= \backlash \t tab \t, tab \r, carriage-return \n, new-line; and var myStr= \, \t, \t, \r, \n; Do notice anything I am doing wrong.
Chris Lacaille
@ChrisL108
May 16 2016 03:31

If I have this string

``["1", "3", "7", "calf", "piglet", "filly"]``

How do I convert just the number strings to number elements

Amanda Daley
@DaisyDream
May 16 2016 03:32
@bensm1th @ChrisL108 what about Explorer? should it work on the new 'microsoft edge' ?
Ben Smith
@bensm1th
May 16 2016 03:32
@DaisyDream I used this separate API to get the lat and lon
'''\$.getJSON("http://ip-api.com/json/?callback=?", function(data) {
var lat = data.lat;
var lon = data.lon;
CamperBot
@camperbot
May 16 2016 03:32
Norvin Burrus
@ndburrus
May 16 2016 03:33
@pauoola ok, would you agree that myStr should be a string? also, match the output code very carefully to the requirement... :)
Ben Smith
@bensm1th
May 16 2016 03:33
oops
```
Bobby McDonald
@BobbyMcWho
May 16 2016 03:33
I just used zip code lol
Ben Smith
@bensm1th
May 16 2016 03:33
``````\$.getJSON("http://ip-api.com/json/?callback=?", function(data) {
var lat = data.lat;
var lon = data.lon;``````
that api will a lat and lon in chrome
pauoola
@pauoola
May 16 2016 03:34
yes
@ndburrus yes
Norvin Burrus
@ndburrus
May 16 2016 03:35
@pauoola alright, how are strings generally represented (with respect to punctuation)?
Chris Lacaille
@ChrisL108
May 16 2016 03:35
@ndburrus Do you know how I would convert
```
oops
Amanda Daley
@DaisyDream
May 16 2016 03:35
@bensm1th and you plug lat and lon into the weathermap.org address to get the weather, right?
Chris Lacaille
@ChrisL108
May 16 2016 03:35
["1", "3", "7", "calf", "piglet", "filly"] to [1, 3, 7, "calf", "piglet", "filly"]
Ben Smith
@bensm1th
May 16 2016 03:35
@DaisyDream yes
Chris Lacaille
@ChrisL108
May 16 2016 03:36
Not just that one, other arrays with numbers and strings (all as strings)
Norvin Burrus
@ndburrus
May 16 2016 03:38
@ChrisL108 which challenge is that?
Jason Keenan
@raavin
May 16 2016 03:39
@ChrisL108 maybe iterate with map and check with isNaN
@ydeepk
May 16 2016 03:41

code reveiwers help me out with this " Weather API Challange "

my code pen:

http://codepen.io/ydeepk/full/eZoOzJ/

P.S- please tell me where I'm going wrong.

Chris Lacaille
@ChrisL108
May 16 2016 03:42
@ndburrus Diff Two Arrays @raavin I'll try that
Amanda Daley
@DaisyDream
May 16 2016 03:43
@bensm1th @ChrisL108 okay, I had added 'https' to my codepen webaddress to get the 'navigator.geolocation' to work. But that caused some sort of mismatch that made it impossible to get the weather api. I feel bad, actually, because I think the person who told be about https was about to warn me about that problem when I left the chatroom. going back to http and using the ip-api seems to work better
Chris Lacaille
@ChrisL108
May 16 2016 03:43
@DaisyDream There's a IP API that fixes the https issue I think
Haven't looked into it personally but heard about it and seen it used
Amanda Daley
@DaisyDream
May 16 2016 03:44
this is what I have now
``````\$.getJSON("http://ip-api.com/json/?callback=?", function(data) {
var lat = data.lat;
var lon = data.lon;
\$.getJSON("http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon+"&APPID=5f3a20c72ab970efb7f91be749b86d8f", function(response){
console.log(response);
});

});``````
:P
Justin Woodward
@jwoo92
May 16 2016 03:46
i am having trouble flipping back and fourth between my F and C temperatures. my conversions are there, but i cant seem to figure out how to flip flop between the two. would anyone like to take a look at my code please? http://codepen.io/jwoo/pen/PNgdyO
Chris Lacaille
@ChrisL108
May 16 2016 03:47
@jwoo92 Have you tried adding `&appid=metric` & `&appid=OtherOne` to url?
This message was deleted
not appid `&units=metric`
Chris Lacaille
@ChrisL108
May 16 2016 03:53
`&units=imperial` i think is the other one

@raavin @ndburrus

``````  result.map(function(v) {
if (isNaN(v)) {
return parseInt(v);
} else {return v;}
});``````

I'm doing something wrong here lol

pauoola
@pauoola
May 16 2016 03:56
@ndburrus quotation marks and spaces
Chris Lacaille
@ChrisL108
May 16 2016 03:56
i think?
buiphuking
@buiphuking
May 16 2016 03:56
plz someone help me with my C button, calculator
http://codepen.io/buiphuking/pen/qZwpjE
Chris Lacaille
@ChrisL108
May 16 2016 03:58
Oh wait I have that backwards :worried:
BOOM got it
Jason Keenan
@raavin
May 16 2016 04:00
@ChrisL108 nice 😊
Greg Duncan
@GregatGit
May 16 2016 04:01
@jwoo92 when you get your data you store them both in variable like var tempC and var tempF. You make a boolean like var isFahrenheit = true; then when someone clicks on the temperature it checks to see what it is and an if/else statment
Justin Woodward
@jwoo92
May 16 2016 04:03
@GregatGit thanks, im currently trying to implement that.
CamperBot
@camperbot
May 16 2016 04:03
jwoo92 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
Greg Duncan
@GregatGit
May 16 2016 04:04
``````if (isFahrenheit){
// change it all to celicus
isFahrenheit = false;
}else{
// change it all to fahrenheit
isFahrenheit = true;
}``````
@jwoo92 your pen is looking really good
Chris Lacaille
@ChrisL108
May 16 2016 04:08
@GregatGit @jwoo92 Agreed
:thumbsup:
Justin Woodward
@jwoo92
May 16 2016 04:09
@ChrisL108 thanks :)
CamperBot
@camperbot
May 16 2016 04:09
jwoo92 sends brownie points to @chrisl108 :sparkles: :thumbsup: :sparkles:
Justin Woodward
@jwoo92
May 16 2016 04:11
@GregatGit i am having trouble on figuring out where to put that exactly. i originally used a jquery grab when clicked upon to change to celius, but with the new if/else statement...i am getting a little confused.
Greg Duncan
@GregatGit
May 16 2016 04:18
@jwoo92 at the start just choose whether you start with F or C
@jwoo92 and do that by declaring either `var isFahrenheit = true;` on line 2 of your code
@jwoo92 then you write a function that changes the html from F to C (the else if from before)
then when someone click the temp it fires off that function
Justin Woodward
@jwoo92
May 16 2016 04:28
@GregatGit okay, give me a moment i am writing the code.
Jorge
@liberaltech
May 16 2016 04:29
https://codepen.io/liberaltech/pen/PNggzW?editors=0010
can someone help me figure out how to output the minutes to the timer correctly
Greg Duncan
@GregatGit
May 16 2016 04:32
@jwoo92 you need to declare your temperatures outside of function calls
the function also should be written outside the other function calls
Jorge
@liberaltech
May 16 2016 04:33
never mind figured it out
Kodanda
@bankurukodanda
May 16 2016 04:40
Hi Guys small help
How to convert number to Binary Number in javascript
devpaaji
@devpaaji
May 16 2016 04:52
@bankurukodanda i think they have an in built method
num.toString()
but you need to check if it will work with negative or not
Number(34).toString(2);
check it out
Kodanda
@bankurukodanda
May 16 2016 04:55
It is for Number to string
dhuddleston
@dhuddleston
May 16 2016 04:56
I'm working on the "Everything Be True" Intermediate Algorithm. My code passes most test cases, but there are two instances where the test returns false when it should be true, and I'm having difficulty understanding why this is the case. Any pointers?
``````function truthCheck(collection, pre) {
// Is everyone being true?

var preFlagCount = 0;

for(var i = 0; i < collection.length; i++)
{
if(collection[i].hasOwnProperty(pre))
{
if(collection[i][pre] === true)
{
preFlagCount++;
}
}
}

if(preFlagCount === collection.length)
{
return true;
}
else
{
return false;
}

}

console.log(truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex"));``````
devpaaji
@devpaaji
May 16 2016 04:56
ok yes
devpaaji
@devpaaji
May 16 2016 05:02
@bankurukodanda i think you need to pass the radix
in between
it gives the binary output
``````   var num = 15;
var n = num.toString(2);``````
console.log(n); // 1111
but it converts to string
Kodanda
@bankurukodanda
May 16 2016 05:04
@devpaaji Tanks for Response It gives String I need number
Is there any javascript function which gives us binary number
devpaaji
@devpaaji
May 16 2016 05:06
does Java has that method
acgillette
@acgillette
May 16 2016 05:06
Anyone up for helping me with Where Do I Belong?
dhuddleston
@dhuddleston
May 16 2016 05:07
I might be able to help with that one, @acgillette
Kodanda
@bankurukodanda
May 16 2016 05:08
@devpaaji I don’t know Java, I know basics of it
acgillette
@acgillette
May 16 2016 05:08
``````
function getIndexToIns(arr, num) {
arr.sort(function(a, b) {
return a-b;
});

var whereBelong = 0;
for (var i = 1; i < arr.length; i++) {
if (num > i && num < i) {
whereBelong = arr.indexOf(i + 1);
} else if (num == i) {
whereBelong = arr.indexOf(i);
} else {
whereBelong = whereBelong;
}
}

return whereBelong;
}

getIndexToIns([60, 40], 50);``````
here is my code so far
Frank XC
@tenkdayz
May 16 2016 05:09
@acgillette what does it need to do?
acgillette
@acgillette
May 16 2016 05:10
it's supposed to return the index where the value given should be inserted (in this case, 50 should be in between 40 and 60 ) but I just keep returning 0 for some reason
eeflores
@eeflores
May 16 2016 05:12
@acgillette do you need to start for loop - initialise i to 0?
acgillette
@acgillette
May 16 2016 05:13
oh yeah that was from me fiddling with it, but even with i = 0 it always returns 0
eeflores
@eeflores
May 16 2016 05:14
@acgillette also you may want to do `num > arr[i]`
etc
acgillette
@acgillette
May 16 2016 05:15
ohhhhh maaannnnnnnn
such a dumb mistake but yeah, this is why I ask in chat so people can point out my dumb mistakes
devpaaji
@devpaaji
May 16 2016 05:16
@dhuddleston how do you convert a number to binary in JS
dhuddleston
@dhuddleston
May 16 2016 05:16
@acgillette What you might want to try is pushing the number onto the array before sorting the array, and then use a loop and a counter to find the location where the number got sorted to. It's similar to your approach but more streamlined. Basically it allows you to make the sort function do the hard work for you, which is always fun. :smile:
eeflores
@eeflores
May 16 2016 05:17
This message was deleted
acgillette
@acgillette
May 16 2016 05:17
that is a great idea and one I didn't think of! thx @dhuddleston
CamperBot
@camperbot
May 16 2016 05:17
acgillette sends brownie points to @dhuddleston :sparkles: :thumbsup: :sparkles:
devpaaji
@devpaaji
May 16 2016 05:18
@eeflores how do I convert a number to binary value in JS
acgillette
@acgillette
May 16 2016 05:19
``````
function getIndexToIns(arr, num) {
arr.push(num);
arr.sort(function(a, b) {
return a-b;
});

return arr.indexOf(num);
}

getIndexToIns([60, 40], 50);``````
much cleaner
eeflores
@eeflores
May 16 2016 05:19
Bobby McDonald
@BobbyMcWho
May 16 2016 05:19
dhuddleston
@dhuddleston
May 16 2016 05:20
@acgillette Very nice work!
devpaaji
@devpaaji
May 16 2016 05:20
@eeflores i dont need to use toString method
it converts to str
and then gives the value of binary
is binary value that JS outputs is that of anumber
eeflores @eeflores afk
devpaaji
@devpaaji
May 16 2016 05:21
or a string
var n = 15;
var x = n.toStrimg(2);
dhuddleston
@dhuddleston
May 16 2016 05:23
@BobbyMcWho Very nice! My only suggestion would be renaming the "Random Quote" section to "Random Article" to avoid confusion. Also, FreeCodeCamp has an official CodeReview Gitter chat room for critiques, you might find some other good advice over there. :smile:
Bobby McDonald
@BobbyMcWho
May 16 2016 05:24
@dhuddleston I tried there and no one was saying anything, and thanks haha it's late and I had my quote machine in my head
CamperBot
@camperbot
May 16 2016 05:24
bobbymcwho sends brownie points to @dhuddleston :sparkles: :thumbsup: :sparkles:
henrywashere
@henrywashere
May 16 2016 05:26
need help with this
Instructions
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.
``````// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup = {

"bravo": "Boston",

"charlie": "Chicago",

"delta": "Denver",

"echo": "Easy",

"foxtrot":  "Frank"

};

// Only change code above this line
return result;``````
didnt go through
Coy Sanders
@coymeetsworld
May 16 2016 05:30
@henrywashere result is still an empty string
you need to assign it a value to what you're looking for inside the lookup object you now created
buiphuking
@buiphuking
May 16 2016 05:35
is anybody help me with CE button plz
http://codepen.io/buiphuking/pen/qZwpjE
henrywashere
@henrywashere
May 16 2016 05:38
``var result = "";``
Justin Woodward
@jwoo92
May 16 2016 05:38
@GregatGit big thanks for helping me solve out an issue from start to finish.
CamperBot
@camperbot
May 16 2016 05:38
jwoo92 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 16 2016 05:39
that line is fine @henrywashere, you just need to modify that value
which you aren't, you defined lookup and that looks good, but then right after you just return result, which at this point is still an empty string
@Siderr
May 16 2016 05:39
help Pairwise
CamperBot
@camperbot
May 16 2016 05:39

# Explanation:

The program should look for the numbers in the array which would add to make the number from the arg. Then instead of adding those numbers up, you will add their indices which is the reason why you get 11 on the example from detail.

Remember that arrays start at index 0 and go from there so from [1,4,2,3,0,5] if we switch to their indices it would be [0,1,2,3,4,5] then we add indices 1 + 2 + 3 + 5 and we get 11. That is what we need to return.

Coy Sanders
@coymeetsworld
May 16 2016 05:40
@buiphuking what's up with your HTML? its just text
Frank XC
@tenkdayz
May 16 2016 05:40
@buiphuking what do you want it to do?
Coy Sanders
@coymeetsworld
May 16 2016 05:40
or is that some preprocessor ive never heard of?
buiphuking
@buiphuking
May 16 2016 05:45
html i use jade, click view compiled to see all @coymeetsworld
@tenkdayz
i want to click on C button and it remove last number
help me plz
Coy Sanders
@coymeetsworld
May 16 2016 05:45
is that what the clear button should do?
actually user story doesn't specify you need to do that, just need a way to clear the input field
Frank XC
@tenkdayz
May 16 2016 05:46
@buiphuking you can do something like this.
``str = str.substring(0,str.length-1);``
buiphuking
@buiphuking
May 16 2016 05:47
@coymeetsworld
i use AC to clear all , and C to remove last number
@tenkdayz
yes, but suitable with my code, plz help me guys
Frank XC
@tenkdayz
May 16 2016 05:49
@buiphuking just change str with result.innerHTML
Coy Sanders
@coymeetsworld
May 16 2016 05:49
when you hit clear button, so you need to slice that off and the digit so need it to be slice(0,-2)
or, just don't add C to result
SuryaKavutarapu
@SuryaKavutarapu
May 16 2016 05:50
guys i'm stuck over here can anybody help on problem no 208
Coy Sanders
@coymeetsworld
May 16 2016 05:50
which is probably the better way
also while testing your code noticed some of the digits add spaces between the numbers (i.e. 8, 6,3)
and last thing I will say is you should look into using jQuery instead of some of these other functions (i.e. getElementById, innerHTML). It will make less code and easier to run, also help you avoid some browser inconsistencies
Frank XC
@tenkdayz
May 16 2016 05:53
@SuryaKavutarapu what is problem 208?
buiphuking
@buiphuking
May 16 2016 05:53
@tenkdayz
won't works
@coymeetsworld
when i finish this thing, i will do another calculator with jquery
Coy Sanders
@coymeetsworld
May 16 2016 05:55
ok but it's not any more difficult @buiphuking, i would suggest just doing it now, you don't even have to change alot.
look at what I said about slice though that was the issue, adding C to your result when you press it
there is no problem 208 @tenkdayz @SuryaKavutarapu 208 refers to your brownie points, the challenges are not id'd by a number its by name
Frank XC
@tenkdayz
May 16 2016 05:56
@buiphuking works with me..
buiphuking
@buiphuking
May 16 2016 05:57
@tenkdayz
``result.innerHTML = result.innerHTML.substring(0, result.innerHTML.length -1);``
Frank XC
@tenkdayz
May 16 2016 05:58
@buiphuking exactly
buiphuking
@buiphuking
May 16 2016 06:00
@tenkdayz
why your computer works but mine?
Coy Sanders
@coymeetsworld
May 16 2016 06:01
@SuryaKavutarapu you need to check if a or b is less than 0
just need to check for those edge cases
SuryaKavutarapu
@SuryaKavutarapu
May 16 2016 06:06
thanks @coymeetsworld
CamperBot
@camperbot
May 16 2016 06:06
suryakavutarapu sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 16 2016 06:06
np @SuryaKavutarapu
Kyle W Pilkinton
May 16 2016 06:20
hey guys for some reason my loops arent iterating. when i use console.log i just get repeated 0's
`````` for(var i = 0; i < arr1.length; i++){

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

if(arr1[i] == arr2[j]){

filter = arr1[i];

console.log(j);
}
}
}``````
ahh wait im adding up by i instead of j lol sorry. why is this an infinite loop though?
@Siderr
May 16 2016 06:25
help Exact Change
CamperBot
@camperbot
May 16 2016 06:25

# Problem Explanation:

• You have to create a program that will handle when the register does not have
enough cash or will have no cash after the transaction. Other than that it
needs to return an array of the change in the form of an array, so that will
be a 2D array.
Coy Sanders
@coymeetsworld
May 16 2016 06:27
oh also you're setting i < arr2.length, should be j
Kyle W Pilkinton
May 16 2016 06:29
thanks @coymeetsworld lol i noticed it right after i posted lol XD.
CamperBot
@camperbot
May 16 2016 06:29
tadake sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 16 2016 06:29
ah ok
Greg
@GregJacoby
May 16 2016 06:47
hi everyone, I'm doing the algorithm challenge "find the longest word in a string," and the last X im trying to fix is "may the force be with you" should return 5. and when I test my function, it does!! what's wrong? :(
``````var length = 0;
function findLongestWord(str) {
var array = str.split(" ");

for(var i = 1; i < array.length; i++) {
if(array[i].length > length) {

length = array[i].length;

}

}
return length;
}

findLongestWord("May the force be with you");``````
ah, i got it! i guess i had to reset length at the top of the function for it to work
thanks for the moral support =P
devpaaji
@devpaaji
May 16 2016 06:49
var length should have local scope
and not global
should be declared inside the function
Greg
@GregJacoby
May 16 2016 06:49
@devpaaji tahnks :)
Coy Sanders
@coymeetsworld
May 16 2016 06:50
yeah in general @GregJacoby should avoid global variables
some tests wont pass if you use them, unless they're given to you specifically like count was in Counting Cards
its also not good practice to make them unless you have to
Greg
@GregJacoby
May 16 2016 06:51
ohh
okay
@coymeetsworld thanks
CamperBot
@camperbot
May 16 2016 06:51
gregjacoby sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 16 2016 06:51
yeah I believe its because they will run the tests back to back with the same code you ran
so since nothing resets your global variable then it can retain information from previous runs and screw up your results
or maybe they just have something in the parser that checks for global variables idk :)
Kyle W Pilkinton
May 16 2016 06:53
hey guys how would i filter an array that has all values by an array that has only the values i dont want?
devpaaji
@devpaaji
May 16 2016 06:55
how do you convert a number to binary in JS
not number to string
Jay
@lantiwonka
May 16 2016 06:56
hello people, i am stuck on this question for some time now, help me please
``````function chunkArraInGroups(arr, size) {
// Break it up.
var array = [];
for(var i = 0; i < size; i++){
array.push(arr[i]);
}
return array;
}

console.log(chunkArraInGroups(["a", "b", "c", "d"], 2));``````
Kyle W Pilkinton
May 16 2016 06:58
do you want binary or ascii values? @devpaaji
Coy Sanders
@coymeetsworld
May 16 2016 07:00
@tadake JavaScript actually has some functional programming that can be used to filter an array, aptly named filter: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
that would be the most elegant way i would say using that
devpaaji
@devpaaji
May 16 2016 07:00
binary
Kyle W Pilkinton
May 16 2016 07:00
devpaaji
@devpaaji
May 16 2016 07:00
``````var num = 13;
num.toString(2); // '1101'``````
May 16 2016 07:00
Hey guys, on the wiki challenge. I'm building the search bar, and I built the html framework, and got the API request sorted, now linking them up. I want the search function to trigger if they either press the search icon or press enter. I know how to do "onclick" for search button, but how do I make it so it triggers on enter if the cursor is in the search bar?
devpaaji
@devpaaji
May 16 2016 07:01
this is binary str
not binary int
Coy Sanders
@coymeetsworld
May 16 2016 07:01
Markus Kiili
@Masd925
May 16 2016 07:02
@lantiwonka You could iterate the arr elements with for and increment by +=size. Then make slices of arr with .slice() and push them into result array.
May 16 2016 07:02
@coymeetsworld thanks Coy
CamperBot
@camperbot
May 16 2016 07:02
radascript sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 16 2016 07:03
devpaaji
@devpaaji
May 16 2016 07:03
slice wont change the array
but splice will
be cautious when using them
Kyle W Pilkinton
May 16 2016 07:04
``(num >>> 0).toString(2);``
try this @devpaaji
devpaaji
@devpaaji
May 16 2016 07:04
can you tell why we use >>>
Kyle W Pilkinton
May 16 2016 07:05
num >>> 0 (right logical shift) coerces its arguments to unsigned integers, which is why you get the 32-bit two's complement representation of num. @devpaaji
Tatum
@OrmusELdesu
May 16 2016 07:06
help I'm stuck...
CamperBot
@camperbot
May 16 2016 07:06
no wiki entry for: `im stuck`
Jay
@lantiwonka
May 16 2016 07:06
@Masd925 thanks
CamperBot
@camperbot
May 16 2016 07:06
lantiwonka sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1508 | @masd925 |http://www.freecodecamp.com/masd925
Tatum
@OrmusELdesu
May 16 2016 07:06
help?
CamperBot
@camperbot
May 16 2016 07:06

# Gitter CamperBot `topic` Command

This is an example. You should replace `topic` with the thing you want to find info on. For example:

``````wiki css    # find a wiki page on css
find js     # find all pages related to css``````
Tatum
@OrmusELdesu
May 16 2016 07:07
``````
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if(value !== "" && prop !== 'tracks') {
value = collection[id][prop];
}
else if(!value) {
delete collection[id][prop];
}
else {
collection[id][prop].push(value);
}
return collection;
}

// Alter values below to test your code
updateRecords(5439, 'artist', "\"ABBA\"");``````
Jay
@lantiwonka
May 16 2016 07:10
@Masd925
``````function chunkArrayInGroups(arr, size) {
// Break it up.
//You could iterate the arr elements with for and increment by +=size.
//Then make slices of arr with .slice() and push them into result array.
var resultArray = [];
for(var i = 0; i < arr.length; i+=size){
resultArray.push(arr.slice(0,size));
}
return resultArray;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);``````
still not there yet
Jonathan Mitchell
@Vanhealen
May 16 2016 07:10
Anybody do the Destroyer function yet?
Markus Kiili
@Masd925
May 16 2016 07:10
@lantiwonka Figure out the slice arguments.
Jay
@lantiwonka
May 16 2016 07:10
@Masd925 alrighty
Markus Kiili
@Masd925
May 16 2016 07:10
@Vanhealen Yes.
Tatum
@OrmusELdesu
May 16 2016 07:10
anybody help me?
Jonathan Mitchell
@Vanhealen
May 16 2016 07:11
Got any tips?
lol
whats confusing to me is that it takes in an array right
zoeyle
@zoeyle
May 16 2016 07:12
Help please!!!!! I'm stuck on Seek and Destroy. I don't know why the function has 1 parameter but the examples have an array and other parameters >.<
CamperBot
@camperbot
May 16 2016 07:12
no wiki entry for: `please im stuck on seek and destroy i dont know why the function has 1 parameter but the examples have an array and other parameters`
Markus Kiili
@Masd925
May 16 2016 07:12
@zoeyle Use the arguments object for those extra arguments.
@Vanhealen Use arguments object. `.filter()` method helps.
Jonathan Mitchell
@Vanhealen
May 16 2016 07:14
`function Destroyer(arr) {}`
how does that take in the array
oh i see
zoeyle
@zoeyle
May 16 2016 07:15
@Masd925 ohhh I see it now. Thanks Markus
CamperBot
@camperbot
May 16 2016 07:15
zoeyle sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1509 | @masd925 |http://www.freecodecamp.com/masd925
Tatum
@OrmusELdesu
May 16 2016 07:15
``````
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if(value !== "" && prop !== 'tracks') {
value = collection[id][prop];
}
else if(!value) {
delete collection[id][prop];
}
else {
collection[id][prop].push(value);
}
return collection;
}

// Alter values below to test your code
updateRecords(5439, 'artist', "\"ABBA\"");``````
anyone help code is above
bhirmbani
@bhirmbani
May 16 2016 07:19
anyone know how to solve this? why I cant return sequence 2,3,4,5 to ‘5 bet’?
``````var count = 0;

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

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

}

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

// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);``````
Son Dang
@viiiprock
May 16 2016 07:20
cuz you didn't return it
Santosh Kumar Toleti
@Santosh456
May 16 2016 07:21
hi
Tatum
@OrmusELdesu
May 16 2016 07:22
@viiprock do you have a negative one case?
Santosh Kumar Toleti
@Santosh456
May 16 2016 07:22
can anyone help me
Tatum
@OrmusELdesu
May 16 2016 07:23
@viiiprock do you have a negative one case?
Keone Martin
@Athaman
May 16 2016 07:23
the <= 0 will pick up negs
when the card is 0 your setting your count variable to an empty string
@bhirmbani count = ""; will get rid of the counts number. in the 7 8 9 case just break.
Santosh Kumar Toleti
@Santosh456
May 16 2016 07:24
Change the code to use the ++ operator on myVar.

var myVar = 87;

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

Tatum
@OrmusELdesu
May 16 2016 07:25
@bhirmbani you are assigning count to blank not zero...
Markus Kiili
@Masd925
May 16 2016 07:25
@Santosh456 `x++` is the same as `x=x+1`
Tatum
@OrmusELdesu
May 16 2016 07:25
@Santosh456 ^ whatever this guy said
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 07:26
same dought here
myVar = myVar should be changed, anyone can explain what i have to change here..
Keone Martin
@Athaman
May 16 2016 07:27
@bhirmbani also in switches it's good practice to have a default statement.
Tatum
@OrmusELdesu
May 16 2016 07:27
@lokeshdewangan you are assigning myVar to itself bro...
@lokeshdewangan which is basically none...
Keone Martin
@Athaman
May 16 2016 07:27
``````myVar = myVar + 1;
myVar++; // these two lines are identical``````
Tatum
@OrmusELdesu
May 16 2016 07:28
@lokeshdewangan ^There this guy
Santosh Kumar Toleti
@Santosh456
May 16 2016 07:28
but its notcoming
Keone Martin
@Athaman
May 16 2016 07:28
you only need one of those lines
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 07:29
no its not happening
Keone Martin
@Athaman
May 16 2016 07:29
Santosh Kumar Toleti
@Santosh456
May 16 2016 07:29
same problem with me also
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 07:29
hey santosh this is lokesh from Apex
@Athaman yeah i done it but not working
Tatum
@OrmusELdesu
May 16 2016 07:29
@lokeshdewangan like @Athaman said you are RAISING myVar by 1... so you only need one statement
Keone Martin
@Athaman
May 16 2016 07:29
show me your code though, just copy paste it in here
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 07:30
show me your code though, just copy paste it in here
Tatum
@OrmusELdesu
May 16 2016 07:30
@lokeshdewangan :FACEPALM:
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 07:30

var myVar = 87;

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

Santosh Kumar Toleti
@Santosh456
May 16 2016 07:30

var myVar = 87;

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

Keone Martin
@Athaman
May 16 2016 07:30
yeah, so right now you have both the statements
so myVar is getting increased by 2
Ashwin
@ashwins93
May 16 2016 07:30
@Santosh456 @lokeshdewangan it says "CHANGE THE CODE" not write below it
Santosh Kumar Toleti
@Santosh456
May 16 2016 07:31
ok
Keone Martin
@Athaman
May 16 2016 07:31
... delete myVar = myVar + 1;
Tatum
@OrmusELdesu
May 16 2016 07:31
@Athaman ^do what this guy said
@lokeshdewangan do what @Athaman said...
Santosh Kumar Toleti
@Santosh456
May 16 2016 07:31

var myVar = 87;

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

Son Dang
@viiiprock
May 16 2016 07:31
@OrmusELdesu what if value !== "" && prop == 'tracks' ?
Keone Martin
@Athaman
May 16 2016 07:31
i only included bother lines to show that they were the same thing. ++ is just a lazy way to write = itself + 1;
that should do it @Santosh456
wait... no
sorry... get rid of the myVar =
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 07:32
thanks done it
Tatum
@OrmusELdesu
May 16 2016 07:32
@viiiprock what you mean? i mentioned you by mistake...
Keone Martin
@Athaman
May 16 2016 07:32
you just need myVar++;
Son Dang
@viiiprock
May 16 2016 07:32
oh
:D
Santosh Kumar Toleti
@Santosh456
May 16 2016 07:33
hey lokesh whatt u have done can u tell me
Keone Martin
@Athaman
May 16 2016 07:33
myVar++;
that is what he has
Tatum
@OrmusELdesu
May 16 2016 07:35
@Athaman can you help me as well? my code is right above @bhirmbani 's
Keone Martin
@Athaman
May 16 2016 07:35
oh, sure i'll look
Santosh Kumar Toleti
@Santosh456
May 16 2016 07:35
i m trying but its not coming
Keone Martin
@Athaman
May 16 2016 07:37
shouldn't i just be collection[id][prop] = value; in the first if?
bhirmbani
@bhirmbani
May 16 2016 07:38

@Athaman now im only change this and the 2,3,4,5,6 succedd in return to “5 bet”

`````` ```
if(count >= 1) {
return count + " Bet";
}
else if(count <= 0) {
return count + " Hold";
}``````

}

return count + " Bet";
// Only change code above this line

```
}

Keone Martin
@Athaman
May 16 2016 07:39
@bhirmbani higher in your code you tell it to set count to a string if the input is between 6 and 9 that's where it will be bugging
bhirmbani
@bhirmbani
May 16 2016 07:39
but the problem is 7,8,9 return “0 Bet” instead of “0 Hold"
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 07:40
yeah santosh just delete all the codes below the line and write there
myVar++;
only
what i have to do for remainder
Tatum
@OrmusELdesu
May 16 2016 07:41
@Athaman I did what you said I changed
``` ```
Keone Martin
@Athaman
May 16 2016 07:41
How'd it go?
Tatum
@OrmusELdesu
May 16 2016 07:41
``collection[id][prop] = value;``
@Athaman why does it make difference in the assignment?
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 07:42

// Only change code below this line

var remainder;
what have to do here

Keone Martin
@Athaman
May 16 2016 07:42
because value is just the temporary name of the thing being passed into the function. collection[id][prop] is the name of the permanent location of that record entry.
Tatum
@OrmusELdesu
May 16 2016 07:43
``````//Why does
collection[id][prop] = value;
//different from
value = collection[id][prop]``````
Keone Martin
@Athaman
May 16 2016 07:44
think of it like this
``````var x = 5;
var y = 10;
y = x; // y now equals 5``````
``````var x = 5;
var y = 10;
x = y; // both would now equal 10;``````
remember that single equals is an assignment operator not an equality operator. by using = you're telling the thing on the left to remember the information that the thing on the right is
@lokeshdewangan you need to spend at least a little time trying to google answers before asking for help here. it's much more educational and will help you improve better than just getting the answers given to you.
in fact, you don't even need to google this one it has the information on the left hand side, read it through a few times and if you don't follow it ask a more specific question about what is confusing you.
Eldar Tinjić
@EldarT90
May 16 2016 07:47
need quick help with putting variable inside double quoted string format
this wont work
a is variable
Keone Martin
@Athaman
May 16 2016 07:49
i was just going to suggest you simplify the message... what error are you getting?
should you be closing the html tag?
Eldar Tinjić
@EldarT90
May 16 2016 07:50
thats not problem
if i use string inside alert its good
i get blabla
Jonathan Mitchell
@Vanhealen
May 16 2016 07:50

Need some help with Destroyer
```function Destro(arr) {
arr.filter(function (a) {
for (var i = 1; i < arguments.length; i++) {
if (arguments[i] !== a) {
return true;
} return false;
}
});
}

Destro([1,2,4,5],3,5);
```

Eldar Tinjić
@EldarT90
May 16 2016 07:50
i dont get anything
i dont get any error
but i dont get alert message at all
Jonathan Mitchell
@Vanhealen
May 16 2016 07:50

function Destro(arr) {
arr.filter(function (a) {
for (var i = 1; i < arguments.length; i++) {
if (arguments[i] !== a) {
return true;
} return false;
}
});
}

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

``````function Destro(arr) {
arr.filter(function (a) {
for (var i = 1; i < arguments.length; i++) {
if (arguments[i] !== a) {
return true;
}  return false;
}
});
}

Destro([1,2,4,5],3,5);``````
shit dont work right
Keone Martin
@Athaman
May 16 2016 07:51
what is stored in a?
Jonathan Mitchell
@Vanhealen
May 16 2016 07:51
ummmm
crap
Eldar Tinjić
@EldarT90
May 16 2016 07:51
normal number
Keone Martin
@Athaman
May 16 2016 07:51
do you just need to parse it to a string @EldarT90 ?
Eldar Tinjić
@EldarT90
May 16 2016 07:51
or string
either way wont work
Keone Martin
@Athaman
May 16 2016 07:52
well then i'm out of ideas sorry :) i haven't done much htmling with js yet.
Jonathan Mitchell
@Vanhealen
May 16 2016 07:52
I can make it i
but I somehow need to have arguments[start at 1]
then arr[start at 0]
to compare them to each other
Eldar Tinjić
@EldarT90
May 16 2016 07:52
okay thanks anyway @Athaman
CamperBot
@camperbot
May 16 2016 07:52
eldart90 sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
Keone Martin
@Athaman
May 16 2016 07:54
@Vanhealen not entirely sure where you're going with it but if you want to use i for 1 and still access the first element you can use array[i-1];
Jonathan Mitchell
@Vanhealen
May 16 2016 07:55
im not that sure ither
either
haha
Keone Martin
@Athaman
May 16 2016 07:55
to be honest i think you probably want to take a look at indexOf()
Jonathan Mitchell
@Vanhealen
May 16 2016 07:55
is it bad to put a loop inside of my filter function
Keone Martin
@Athaman
May 16 2016 07:56
not that i'm aware of. you're just rewriting the wheel a little bit. indexOf() searches an array for a value.
Jonathan Mitchell
@Vanhealen
May 16 2016 07:56
and if I did .indexOf(‘something’) then how would I compare that to whats inside the arr (first argument)
oh i can do arguments1
.indexOf(arguments1)
Keone Martin
@Athaman
May 16 2016 07:57
yeah sort of
(sorry, i'm reading my solution trying to remember :))
Jonathan Mitchell
@Vanhealen
May 16 2016 07:58
See this won’t work though
``````function Destro(arr) {
arr.filter(function() {
if (arr.indexOf('arguments[i]') !== -1) {
return true;
}  return false;
})
}``````
because filter doesn’t recognize my i
Keone Martin
@Athaman
May 16 2016 07:59
yeah, you need to turn the arguments into a proper array first
and also inside your filter you need to pass the value.
Jonathan Mitchell
@Vanhealen
May 16 2016 08:00
yeah I need like function (a,b)
Keone Martin
@Athaman
May 16 2016 08:00
on an aside not with your current function using if(statement) {return true;} else {return false;} can just be written as return statement;
note*
slfweb
@zelol
May 16 2016 08:02
Is this ok for 'search and replace' bonfire

function myReplace(str, before, after) {

var temp = '/'+before+'/i';
console.log(temp);
var newstr = str.replace(temp, "leaped");
return newstr;

}

Keone Martin
@Athaman
May 16 2016 08:02
instead of looking for arguments[i] in arr, look for arr[filter value] in arguments
at least that's how i did it, that way if they wanted to pass more arguments they can
Coy Sanders
@coymeetsworld
May 16 2016 08:03
also you're missing a semicolon @Vanhealen, arr.filter needs to end w/ semicolon after `})`
Keone Martin
@Athaman
May 16 2016 08:04
@zelol you need to write the solution to be open to completing all the challenges, you shouldn't use hard values in your code like "leaped"
@coymeetsworld that's true but i think he was just writing it as an example
slfweb
@zelol
May 16 2016 08:05

function myReplace(str, before, after) {

var temp = '/'+before+'/i';
console.log(temp);
var newstr = str.replace(temp, after);
return newstr;

}

i did a mistake here is my solution but it still doesnt work
Keone Martin
@Athaman
May 16 2016 08:05
that looks better, but honestly i'm terrible with regular expressions
also you need to account for preserving the case of the replacement word which i think is probably what is tripping you up now. if you replace "Before" with "after" it'll fail the test.
Coy Sanders
@coymeetsworld
May 16 2016 08:06
@zelol that won't work because you need to keep case
myReplace("His name is Tom", "Tom", "john") should return "His name is John".
you need to write a little more logic into your function
slfweb
@zelol
May 16 2016 08:08
@coymeetsworld thank you
CamperBot
@camperbot
May 16 2016 08:08
zelol sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
Jonathan Mitchell
@Vanhealen
May 16 2016 08:08
@Athaman Would something like this be a good way
``````function toDestroy(value) {
for (var i = 0; i < arguments.length; i++) {
if (value === arguments[i]) {
return true;
};

}
}``````
Coy Sanders
@coymeetsworld
May 16 2016 08:08
I see @Athaman wrote that as I did lol
Jonathan Mitchell
@Vanhealen
May 16 2016 08:08
wait crap nvm
``````
function Dest(arr) {
var filtered =     arr.filter(toDestroy
return arr;
}

function toDestroy(value) {
for (var i = 0; i < arguments.length; i++) {
if (value === arguments[i]) {
return true;
};

}
}

Dest([1,2,3,4],3,4);``````
Kelvin-penang
@Kelvin-penang
May 16 2016 08:09
``````
function palindrome(str) {

var newStr;
var reversedNewStr;
newStr = str.replace(" ","").toLowerCase();
reversedNewStr = newStr.revese;
if (newStr == reversedNewStr){
return true;
}
else {return false;}
}

palindrome("eye");``````
Hi, Can anybody help identify what's wrong with my algorithm?
Jonathan Mitchell
@Vanhealen
May 16 2016 08:11
```function Dest(arr) { var filtered = arr.filter(function elem(a) { console.log("is arguments here arguents of Dest function or or the filter function?" + arguments) }) }```
``````function Dest(arr) {
var filtered = arr.filter(function elem(a) {
console.log("is arguments here arguents of Dest function or or the filter function?" + arguments)
})
}``````
Sanchit
@skhattar
May 16 2016 08:12

function whereAreYou(collection, source) {
// What's in a name?
var arr = [];
var chk = [];
chk= Object.keys(source);
// Only change code below this line
for(var i = 0 ; i<collection.length; i++){
for(var j = 0 ; j<chk.length; j++){

if(source["check[j]"]==collection[i]["check[j]"]){arr.push(collection[i]);}
}}
// Only change code above this line
return arr;
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

AbbieOlarte
@AbbieOlarte
May 16 2016 08:13
excuse me ._. in falsy bouncer, how can i check if NaN is equal to NaN? xD arr[indexofNaN] === NaN doesn't seem to work. i've been googling for a long time already XD seems like i can't find the right words lol
Keone Martin
@Athaman
May 16 2016 08:15
@Vanhealen you can turn the arguments feature into a proper array using var array = Array.from(arguments);
@AbbieOlarte you can test for all false values at once using filter(Boolean) which will get rid of anything 'falsy' in one go
@skhattar what challenge are you on? it helps to check my solution.
Sanchit
@skhattar
May 16 2016 08:18
@Athaman its Where art tou
Keone Martin
@Athaman
May 16 2016 08:18
@Vanhealen i can send you my solution if you wanna take a look at it.
Jonathan Mitchell
@Vanhealen
May 16 2016 08:18
sure
and what is .from
Keone Martin
@Athaman
May 16 2016 08:19
``````
function destroyer(arr) {
var args = Array.from(arguments);

return arr.filter(function(val){return args.indexOf(val) < 0;});
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);``````
from is one of the Array class methods that helps you construct arrays from existing information
also no guarantee the above is the best solution to the puzzle, but i figure it's not too bad.
@skhattar did you add the chk = [] line?
Sanchit
@skhattar
May 16 2016 08:21
@Athaman yeah i did that
Keone Martin
@Athaman
May 16 2016 08:21
cos you're not meant to change code til after the // change code below this line
not sure if it will check and enforce it but usually they do that so that you have to use the solutions that they want you to practice using
Sanchit
@skhattar
May 16 2016 08:21
@Athaman changed as per the instruction
Keone Martin
@Athaman
May 16 2016 08:22
``````  // What's in a name?
var arr = [];
// Only change code below this line``````
is the original right?
AbbieOlarte
@AbbieOlarte
May 16 2016 08:22
@Athaman thanks :)
CamperBot
@camperbot
May 16 2016 08:22
abbieolarte sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
Sanchit
@skhattar
May 16 2016 08:23
@Athaman It looks like this now -

function whereAreYou(collection, source) {
// What's in a name?

// Only change code below this line
var arr = [];
var chk = [];
chk= Object.keys(source);
for(var i = 0 ; i<collection.length; i++){
for(var j = 0 ; j<chk.length; j++){

if(source[chk[j]]==collection[i][chk[j]]){arr.push(collection[i]);}
}}
// Only change code above this line
return arr;
}

Keone Martin
@Athaman
May 16 2016 08:24
my solution to this one isn't very neat, but the basics are i grab all the keys and store them in an array, then i open a filter() on the collection and in the function loop through all the keys to check if they exist in the collection item, if they do i check if they equal, if they do i return true and all else return false.
Ovidiu Grigoras
@Oviduzz
May 16 2016 08:24
help Falsy Bouncer
CamperBot
@camperbot
May 16 2016 08:24

# Problem Explanation:

Remove all falsy values from an array.

Keone Martin
@Athaman
May 16 2016 08:25
that's offensive @camperbot I worked as a bouncer for years
... although i am a redhead, so maybe you're onto something
Sanchit
@skhattar
May 16 2016 08:25
@Athaman yeah that can be done as well..thanks a lot :)
Keone Martin
@Athaman
May 16 2016 08:25
@AbbieOlarte no problem :) got it sorted?
no worries @skhattar let me know if you have any problems. and again, no guarantee mine is an efficient solution.
@Vanhealen howsit going?
Sanchit
@skhattar
May 16 2016 08:29
@Athaman - doen with the challenge..there was a minor logical error in mine. Thanks anyways for the alternate solution
CamperBot
@camperbot
May 16 2016 08:29
skhattar sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
Keone Martin
@Athaman
May 16 2016 08:32
@skhattar no problem, what was your end code? i'm curious to alternatives on mine
Jonathan Mitchell
@Vanhealen
May 16 2016 08:34
@Athaman umm
@Athaman trying to figure it out
Keone Martin
@Athaman
May 16 2016 08:34
anything i can help with?
Jonathan Mitchell
@Vanhealen
May 16 2016 08:34
I forgot how filter works
so I cant move on until I learn that
Keone Martin
@Athaman
May 16 2016 08:35
filter works in confusing and magical ways... black magical ways
Jonathan Mitchell
@Vanhealen
May 16 2016 08:35
because I dont know what the callback has to do when I call it anonymously
I used to know but I forgot haha
elminsterrr
@elminsterrr
May 16 2016 08:35
Hi, Can anyone tell me please why my twitter button doesn't work?
https://codepen.io/elminsterrr/pen/jqRQJL
Jonathan Mitchell
@Vanhealen
May 16 2016 08:35
havent coded in like 3 months
Keone Martin
@Athaman
May 16 2016 08:36
so filter() as i understand it in my relative layman sense iterates over each element of an array, and sends each value off to a function to be assessed, if that function returns false the element is deleted from the array.
Jonathan Mitchell
@Vanhealen
May 16 2016 08:40
yeah
i get that part
so if I go function elem(a,b) return a, what is A
is it a parameter of the function to be assessed
I need to practice a basic filter problem first
Keone Martin
@Athaman
May 16 2016 08:41
hmm, if the first value in your function call will be the value of the array being passed i believe
so arr.filter(function(val){return val;}); just sends back the value
i'm not actually sure if you can send multiple arguments into filter... i've not had a cause to try yet
Jonathan Mitchell
@Vanhealen
May 16 2016 08:43
the first index of the filter callback function is one of the array elements
AbbieOlarte
@AbbieOlarte
May 16 2016 08:45
@Athaman slr yes :D it worked ^^
AhmedNezar
@AhmedNezar
May 16 2016 08:46
``````function truthCheck(collection, pre) {
// Is everyone being true?
for(var i = 0; i < collection.length; i++) {
if(!collection[i].hasOwnProperty(pre)) return false;
else if(collection[i][pre] === 0 || collection[i][pre] === "" || collection[i][pre] === null || collection[i][pre] === undefined || isNaN(collecection[i][pre]) return false;
}
return true;
}``````
When I delete isNaN it passes all the tests ecxept the isNaN one and when I add it it fails it two tests!
Jonathan Mitchell
@Vanhealen
May 16 2016 08:47
``````
function Destroyer(arr) {
var array = Array.from(arguments);
var filtered = arr.filter(function(elem) {
for (var i = 0; i < arguments.length; i++) {
return elem === arguments[i]
})
}  return filtered;
}

Destroyer([1,2,3,4,5],2,4)``````
tried that but it doesnt work
Keone Martin
@Athaman
May 16 2016 08:48
@AhmedNezar isNaN translates "2" into an int and calls it a number... not sure if that helps
also you can just use filter(Boolean) to go through an array and remove any false values
AhmedNezar
@AhmedNezar
May 16 2016 08:51
@Athaman so how scan I check for if the value is NaN
Keone Martin
@Athaman
May 16 2016 08:51
@Vanhealen inside your for loop you have a return statement, that will always return the first element vs arguments on the first iteration
@AhmedNezar you can try typeof === number;
what's the challenge @AhmedNezar ?
AhmedNezar
@AhmedNezar
May 16 2016 08:52
Everything Be True
``typeof collection[i][pre] === 1``
like that?
Keone Martin
@Athaman
May 16 2016 08:55
typeof collection[i][pre] will return "number" if it is a number
Jonathan Mitchell
@Vanhealen
May 16 2016 08:55
@Athaman wait how could I do it
Keone Martin
@Athaman
May 16 2016 08:55
but you don't have to test for all these things individually. all the values have an innate truthiness or falsiness that you can capitalise on here
Jonathan Mitchell
@Vanhealen
May 16 2016 08:55
????
i dont get what you mean
Keone Martin
@Athaman
May 16 2016 08:56
try just using else if(collection[i][pre]) @AhmedNezar
Jonathan Mitchell
@Vanhealen
May 16 2016 08:56
nah
how would you do it with .indexOf
AhmedNezar
@AhmedNezar
May 16 2016 08:57
`else if(collection[i][pre])` has passed the isNaN test and make 4 others fail :/
Keone Martin
@Athaman
May 16 2016 08:57
sorr @Vanhealen was talking to @AhmedNezar . for yours you'd need to set up a boolean outside the loop. say var isTrue = false; then instead of your return statement in the for loop have isFalse = elem === arguments[i]; or somthing to that effect
Arturo
@quake004
May 16 2016 08:58
``````var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
if (firstName === contacts[firstName])
if (prop === contacts[prop])
return contacts[prop];
else console.log("No such property");
else console.log("No such contact");
// Only change code above this line
}``````
How do I check if the property is a property of the contact?
Ovidiu Grigoras
@Oviduzz
May 16 2016 08:59
help Seek and Destroy
CamperBot
@camperbot
May 16 2016 08:59

# Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

Keone Martin
@Athaman
May 16 2016 08:59
@AhmedNezar that sounds pretty close, you probably just need to flip one of your return statements to true or something, can i grab the code again?
AhmedNezar
@AhmedNezar
May 16 2016 09:00
``````  for(var i = 0; i < collection.length; i++) {
if(!collection[i].hasOwnProperty(pre)) return false;
else if(collection[i][pre] === 0 || collection[i][pre]=== "" || collection[i][pre] === null || collection[i][pre] === undefined || collection[i][pre]) return false;
}``````
Keone Martin
@Athaman
May 16 2016 09:00

@Vanhealen ```js
function destroyer(arr) {
var args = Array.from(arguments);

return arr.filter(function(val){return args.indexOf(val) < 0;});

}
```

hmm, that didn't work. anyway the point is that indexOf() will return -1 if it doesn't find the thing you're looking for. so if indexOf(val) < 0 that means that that val is not contained anywhere inside args
Chris Wilson
@blockbeard
May 16 2016 09:02
help where art thou
CamperBot
@camperbot
May 16 2016 09:02

# Problem Explanation

Write an algorithm that will take an `array` for the first argument and return an `array` with all the `object`s that matches all the properties and values in the `Object` passed as second parameter.

Keone Martin
@Athaman
May 16 2016 09:03
@AhmedNezar
``````function truthCheck(collection, pre) {
// Is everyone being true?
for(var i = 0; i < collection.length; i++){
if(collection[i].hasOwnProperty(pre)){
if(!collection[i][pre]){
return false;
}
}else{
return false;
}
}
return true;
}``````
that's my solution to it if it helps
Chris Wilson
@blockbeard
May 16 2016 09:03
More frustarted than enraged, but thanks @camperbot
CamperBot
@camperbot
May 16 2016 09:03
blockbeard sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 1732 | @camperbot |http://www.freecodecamp.com/camperbot
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 09:04
can anyone explain that what i have to do in fahrenheit question
Keone Martin
@Athaman
May 16 2016 09:05
you need to convert one to the other @lokeshdewangan
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 09:06
can u tell me how @Athaman
AhmedNezar
@AhmedNezar
May 16 2016 09:06
@Vanhealen You can assign the destory args into an array and use filter on the main one, Inside the filter, use loop on destory array length and if val of the current array "filter(function(val)" == destroy[indexOfLoop] return false then return true
Keone Martin
@Athaman
May 16 2016 09:07
sure @lokeshdewangan so you need to declare the var farenheit in between the lines that say don't edit below/above.
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 09:08
ok then
Keone Martin
@Athaman
May 16 2016 09:08
then set farenheit to be whatever number it should be to represent the celsius input
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 09:08
like what
Keone Martin
@Athaman
May 16 2016 09:09
well all the conversion information is in the left, but simply it's (9/5) * celsius + 32
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 09:09
ok
this is the error, here i m unable to understand that what i have to do here
Keone Martin
@Athaman
May 16 2016 09:11
which part confuses you?
rphares
@rphares
May 16 2016 09:11
you just turn the formula they gave you into code, as @Athaman suggested, using the operators `=`, `*`, and `+` and the variables they gave, `fahrenheit` and `celsius` @lokeshdewangan
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 09:11
convertToF(0) should return a number
rphares
@rphares
May 16 2016 09:12
the temp in `fahrenheit` is the temp in `celsius` times 9/5 plus 32
can you paste what you tried when you received that error?
Markus Kiili
@Masd925
May 16 2016 09:13
@AhmedNezar You can test for variable value NaN by: `val!==val` or by `typeof val==="number" && isNaN(val)`
Darth Skywalker
May 16 2016 09:14
@Masd925 : Why not just `isNaN(val)` ?
Keone Martin
@Athaman
May 16 2016 09:14
which would be useful in some contexts but is less useful in others
Darth Skywalker
May 16 2016 09:15
@Athaman : and `typeof val === "number"` will be false if val is `"2"` :)
so, just `isNaN(val)` condition is enough
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 09:18
i didn't get that what i need to do exactly guys plz help me
Keone Martin
@Athaman
May 16 2016 09:19
hmm
rphares
@rphares
May 16 2016 09:19
can you paste what you are trying, @lokeshdewangan ? we can help a lot better if we know what you have tried :blush:
Keone Martin
@Athaman
May 16 2016 09:19
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 09:20

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

var fahrenheit;
fahrenheit = 9/5+32;

// Only change code above this line
return fahrenheit;

}

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

Keone Martin
@Athaman
May 16 2016 09:20
@adityaparab valid observation... but i think in the example we want to turn true for when it is a number... i think in this example typeof==="number" should be enough, but isNaN(val) will throw false info for strings containing numbers
@lokeshdewangan you need to have the celsius variable in the middle
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 09:21
ok then
Keone Martin
@Athaman
May 16 2016 09:21
(9/5) * celsius + 32;
this takes the value which is sent into the function (the degrees in celsius) and converts it into the fahrenheit which is then returned
Markus Kiili
@Masd925
May 16 2016 09:22
@adityaparab Because isNaN tests for NaN after coercing the value to type number. Therefore is returns true for many other values besides NaN.
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 09:23
thanks done it
Keone Martin
@Athaman
May 16 2016 09:23
@lokeshdewangan no problem, do you understand it?
rphares
@rphares
May 16 2016 09:23
Congrats and happy coding, @lokeshdewangan ~
Darth Skywalker
May 16 2016 09:23

@Athaman : `isNaN("2")` will return false. :)

isNaN returns `true` if it fails the `parseInt` or `parseFloat` internally. :)

rphares
@rphares
May 16 2016 09:23
( @Athaman , ty! :blush: )
CamperBot
@camperbot
May 16 2016 09:23
rphares sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
Darth Skywalker
May 16 2016 09:24
It is always advisable to use `isNaN` over string comparison like `something === "something else"` Because string operations are costly.
Keone Martin
@Athaman
May 16 2016 09:25
yeah but sometimes you actually want to use strict typing and not accept string numbers as numbers, so typeof is still pretty useful
for my arguments optional solution i needed to check whether the inputs were real numbers for the addTogether function... and isNaN kept sending me back "2" + 3 = 23;
Lokesh K Dewangan
@lokeshdewangan
May 16 2016 09:29
hey guys i m here with new problem
Declare String Variables

this is my code
// Example
var firstName = "Alan";
var lastName = "Turing";

// Only change code below this line
var myfirstName = "lokesh";
var mylastName = "dewangan";

Darth Skywalker
May 16 2016 09:30

@Athaman : that's not a problem with `isNaN`.

If you want to write correct code, you must cast your arguments to proper datatype.

like if the `typeof val === "number"` is false, your function will no longer work as expected.

what you should be doing is, parsing the inputs first.

like

``````var val = parseInt(args[0]);

//OR

var val = +args[0];``````

Then only you are writing the code that is correct, portable, standardized and well performant, obviously. :)

Lokesh K Dewangan
@lokeshdewangan
May 16 2016 09:30
this is the error
myFirstName should be a string with at least one character in it.
Arturo
@quake004
May 16 2016 09:30
help Profile Lookup
CamperBot
@camperbot
May 16 2016 09:30

# Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

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

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

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

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

Keone Martin
@Athaman
May 16 2016 09:31
@adityaparab but the tests want addTogether("2", 3); to return undefined, so if i parse it to an int first and send back 5 i'm still not matching the criteria
Darth Skywalker
May 16 2016 09:31
@lokeshdewangan : What you have is `myfirstName`. What you need is `myFirstName` NOTICE - F in myFirstName should be capital. Your's is small one. :)
Keone Martin
@Athaman
May 16 2016 09:32
@lokeshdewangan same goes for myLastName
Markus Kiili
@Masd925
May 16 2016 09:35
@Athaman You should just make two tests. One if for two valid arguments and the second for one valid argument. Let the function return undefined automatically if neither condition is met. Using typeof to check for validity is fine.
Arturo
@quake004
May 16 2016 09:39
``````function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
if (contacts[i].hasOwnProperty(firstName))
if (contacts[i].hasOwnProperty(prop))
return contacts[i][prop];
else return "No such property";
}
return "No such contact";
// Only change code above this line
}``````
what's the problem?
Markus Kiili
@Masd925
May 16 2016 09:39
@quake004 Missing if brackets.
Keone Martin
@Athaman
May 16 2016 09:40
@Masd925 yeah that's what i have. I was just telling @adityaparab that parsing the argument to an int before testing wasn't the purpose of the challenge.
Arturo
@quake004
May 16 2016 09:40
ok
thanks
Marko
@markobosnj
May 16 2016 09:47
Hi, can enyone help me
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr

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

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

why doesn't that work
Keone Martin
@Athaman
May 16 2016 09:48
the array is call arr not multiplyAll
so try
```js
for(i=0; i<arr.length; i++){
for(j=0; j<arr[i].length; j++){
product *= arr[i][j];
}
}
bah... forgot backticks on the bottom.
Marko
@markobosnj
May 16 2016 09:50
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(i=0;i<arr.length;i++){
for(j=0;j<arr[i].length;j++){
product+=arr[i][j];
}}
// Only change code above this line
return product;
Ujjwal Sharma
@ryzokuken
May 16 2016 09:50
where are the bonfire hints?
Marko
@markobosnj
May 16 2016 09:50
I tried this but nothing
rphares
@rphares
May 16 2016 09:50
you can say `help algorithimName` @ryzokuken
example: help smallest common
Markus Kiili
@Masd925
May 16 2016 09:51
@ryzokuken There are no bonfires nowadays I think.
Ujjwal Sharma
@ryzokuken
May 16 2016 09:51
thanks @rphares
CamperBot
@camperbot
May 16 2016 09:51
ryzokuken sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4611 | @rphares |http://www.freecodecamp.com/rphares
Ujjwal Sharma
@ryzokuken
May 16 2016 09:51
help Sum All Odd Fibonacci Numbers
CamperBot
@camperbot
May 16 2016 09:51

# Explanation:

You will need to gather all the Fibonacci numbers and then check for the odd ones. Once you get the odd ones then you will add them all. The last number should be the number given as a parameter if it actually happens to be an off Fibonacci number.

Marko
@markobosnj
May 16 2016 09:51
thanks @Athaman
CamperBot
@camperbot
May 16 2016 09:51
markobosnj sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
Ujjwal Sharma
@ryzokuken
May 16 2016 09:51
hint Sum All Odd Fibonacci Numbers
CamperBot
@camperbot
May 16 2016 09:51
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Marko
@markobosnj
May 16 2016 09:51
I did it
Keone Martin
@Athaman
May 16 2016 09:51
@markobosnj yeah it needs to be multiplied right?
so *= not +=
and no problems, glad i could help
rphares
@rphares
May 16 2016 09:53
ty again, @Athaman (may be too soon for me to give you brownies form someone else again... :pensive: )
CamperBot
@camperbot
May 16 2016 09:53
rphares sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:warning: rphares already gave athaman points
rphares
@rphares
May 16 2016 09:53
sigh
Keone Martin
@Athaman
May 16 2016 09:53
nooo my brownie points :D
rphares
@rphares
May 16 2016 09:54
i try when i see it... but can only feed once an hour, lol :blush:
Keone Martin
@Athaman
May 16 2016 09:54
i'm doing ok today anyway, feeding my addiction to a reasonable level. thanks for the thought though @rphares
CamperBot
@camperbot
May 16 2016 09:54
athaman sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4612 | @rphares |http://www.freecodecamp.com/rphares
rphares
@rphares
May 16 2016 09:55
lol, no need to ever thank me... i need the wealth redistributed a lil, embarrassingly fat :blush:
Keone Martin
@Athaman
May 16 2016 09:56
with great help comes great hordes of brownie points
rphares
@rphares
May 16 2016 09:57
lol, help, welcomes, and over-zealous e-friends, I'm afraid... be careful, when you get too many, people thank you for existing and it just gets exponential... :wink2:
Divyam Bhagchandani
@divyambhagchandani
May 16 2016 09:57

anyone help me with Stand in Line?

function nextInLine(arr, item) {
var a = arr[0];
arr.push(item);
arr.shift();

return a ; // Change this line
}

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

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

Stephen James
@sjames1958gm
May 16 2016 10:05
@divyambhag To pass the case where arr is empty, you have to return value after pushing. Check the docs on shift.
Claudio Restifo
@Marmiz
May 16 2016 10:05

Hello fellow coders :smile:
I have just finished the `pig latin` challenge with a huge effort.
I was lucky enough to find some resource on line about `regex` and the `match()` method (thanks Stackoverflow).

But at this point I am curious: did someone completed the challenge using the suggested methods? If so..... HOW?

Nuno Rocha
@nunogrocha
May 16 2016 10:09
Hi, can anyone help me with the Convert HTML Entities bonfire? For some reason my code matches the one requested but does not aprove it. I'm wondering what might be wrong. Here is my code:
``````function convertHTML(str) {
return str.replace(/&/g, "&amp;").replace(/</g, "&​lt;").replace(/>/g, "&​gt;").replace(/"/g, "&​quot;").replace(/'/g, "&​apos;");
}``````
the results in the console.log from that return match the requested :worried:
Stephen James
@sjames1958gm
May 16 2016 10:11
@nunogrocha Looks correct. Try copy the code, reset the challenge and paste back the code. Maybe a bug.
@Marmiz I used regex and match - seems it would be more complex to use the methods suggested.