16th
Aug 2016
Cage Echarte
@CageEcharte
Aug 16 2016 00:00
How do I write this??Concatenating Strings with the Plus Equals Operator
Lolaa Michele
@lolaamichele
Aug 16 2016 00:00
And that's exactly what the dag on thing says I am a string string 😣😣😣
llamatarianism
@llamatarianism
Aug 16 2016 00:00
@jennylu89 .replace(/\s+/g, ""); <- this bit's unnecessary
Stephen James
@sjames1958gm
Aug 16 2016 00:00
@jennylu89 You don't need the second replace (the \s+)
then instead of the second newStr line.
var newStr = str.split("").reverse().join("");
return str === newStr
llamatarianism
@llamatarianism
Aug 16 2016 00:00
your first regex (/[^a-z0-9]/g) will match \s+ too
and this:
if (str !== newStr) {
return false;
}
return true;
can just be changed to
return str === newStr;
Lolaa Michele
@lolaamichele
Aug 16 2016 00:01
Ok I did it . I don't like this 😏
Stephen James
@sjames1958gm
Aug 16 2016 00:01
@CageEcharte Some sort of variable += "string" ?
Margaret
@Margaret2
Aug 16 2016 00:01
@CageEcharte try to do it just like the provided example
Coy Sanders
@coymeetsworld
Aug 16 2016 00:01
lol it'll get easier with more practice @lolaamichele
Keith Alexander
@yojimbo256
Aug 16 2016 00:02
@coymeetsworld @sjames1958gm I just solved it. Thanks guys! I saw what you guys were telling me. I needed to search through all of the contacts before I decided what to do here is the new code. WARNING IF ANYONE IS WORKING ON THIS
function lookUpProfile(firstName, prop){
// Only change code below this line

for (var i = 0; i < contacts.length; i++){
if (firstName === contacts[i].firstName)
if (contacts[i].hasOwnProperty(prop) === true){
return contacts[i][prop];

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

}
// Only change code above this line
}
return "No such contact";
}
CamperBot
@camperbot
Aug 16 2016 00:02
yojimbo256 sends brownie points to @coymeetsworld and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2639 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:warning: yojimbo256 already gave coymeetsworld points
Coy Sanders
@coymeetsworld
Aug 16 2016 00:02
yep, nice work @yojimbo256
Stephen James
@sjames1958gm
Aug 16 2016 00:02
@yojimbo256 :checkered_flag:
llamatarianism
@llamatarianism
Aug 16 2016 00:02
@yojimbo256 you can simplify that a bit without changing the logic
I'll PM you a cleaner version
Keith Alexander
@yojimbo256
Aug 16 2016 00:03
@llamatarianism Ok cool, but right now I’m just happy I finally solved it lol!
llamatarianism
@llamatarianism
Aug 16 2016 00:03
:+1:
Jenny Lu
@jennylu89
Aug 16 2016 00:04
@llamatarianism @sjames1958gm
Its not working now :worried: (

function palindrome(str) {
// Good luck!
str = str.toLowerCase().replace(/[^a-z0-9]/g," ");
var newStr = str.split("").reverse().join("");
return str === newStr;
}

palindrome("race car");
llamatarianism
@llamatarianism
Aug 16 2016 00:04
Coy Sanders
@coymeetsworld
Aug 16 2016 00:04
@jennylu89 think you need to include capital letters too?
llamatarianism
@llamatarianism
Aug 16 2016 00:04
the problem is you're replacing them with spaces
you need to delete them
Jenny Lu
@jennylu89
Aug 16 2016 00:05
@llamatarianism got it! thank you so much!
CamperBot
@camperbot
Aug 16 2016 00:05
jennylu89 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
Aug 16 2016 00:05
also possibly underscore i forget
CamperBot
@camperbot
Aug 16 2016 00:05
:star2: 1195 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
Aug 16 2016 00:05
@camperbot [^a-z0-9] does match underscores
but you're right about capital letters
Coy Sanders
@coymeetsworld
Aug 16 2016 00:05
i thought maybe you had to keep underscores
llamatarianism
@llamatarianism
Aug 16 2016 00:06
nah
you have to remove them
Coy Sanders
@coymeetsworld
Aug 16 2016 00:06
oh ok
llamatarianism
@llamatarianism
Aug 16 2016 00:06
the problem for most people is that they try using \W
but if you use \W you won't match underscores
Coy Sanders
@coymeetsworld
Aug 16 2016 00:07
right
Cage Echarte
@CageEcharte
Aug 16 2016 00:07
@sjames1958gm This is what I have... var myStr += "This is the first sentence.";
"This is the second sentence.";
Stephen James
@sjames1958gm
Aug 16 2016 00:08
@jennylu89 Did you put a space in your replace?
llamatarianism
@llamatarianism
Aug 16 2016 00:08
@CageEcharte you can't use += when you're declaring a variable
if you're declaring a variable, you have to use =
you can only use += on variables that have already been declared
Margaret
@Margaret2
Aug 16 2016 00:09
@CageEcharte yeah, you have to declare myStr first and then use += in a second statement
Stephen James
@sjames1958gm
Aug 16 2016 00:09
@llamatarianism @coymeetsworld There is a toLowerCase() before the replace so A-Z is not needed
llamatarianism
@llamatarianism
Aug 16 2016 00:09
@sjames1958gm true, thanks
CamperBot
@camperbot
Aug 16 2016 00:09
llamatarianism sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2640 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
llamatarianism
@llamatarianism
Aug 16 2016 00:09
I just spent the past hour or so fixing the disgusting default theme on intelliJ, so my eyes are a little fried
Stephen James
@sjames1958gm
Aug 16 2016 00:10
@llamatarianism lol :roller_coaster:
@CageEcharte First you assign the first string to the variable then on the next line use += just like above
Cage Echarte
@CageEcharte
Aug 16 2016 00:11
Like this?var myStr = "This is the first sentence.";
+= "This is the second sentence.";
Yeyo Selso Poche
@Naxell
Aug 16 2016 00:11
"Selecting from many options with Switch Statements" i dont understan this section of javascript
Margaret
@Margaret2
Aug 16 2016 00:12
myStr needs to be at the beginning of the second statement also @CageEcharte
Coy Sanders
@coymeetsworld
Aug 16 2016 00:14
oh right too @sjames1958gm
Patrick Lippert
@mayhawstudios
Aug 16 2016 00:16
Having trouble with the record collection assignment. How do I assign the prop variable to the object?
Or pass, I think I mean.
Ken Aguilar
@piq9117
Aug 16 2016 00:17
@mayhawstudios Object.keys(collection) or collection.hasOwnProperty might helpt
Cage Echarte
@CageEcharte
Aug 16 2016 00:17
@Margaret2 It's not working.. this is what I have...var myStr = "This is the first sentence." ;
var myStr += "This is the second sentence.";
David Beczuk
@dbeczuk
Aug 16 2016 00:18
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

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

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
Hi, can this be done better than this?
Ken Aguilar
@piq9117
Aug 16 2016 00:18
@dbeczuk try filter and map
David Beczuk
@dbeczuk
Aug 16 2016 00:19
@piq9117 Thanks :)
CamperBot
@camperbot
Aug 16 2016 00:19
dbeczuk sends brownie points to @piq9117 :sparkles: :thumbsup: :sparkles:
Ken Aguilar
@piq9117
Aug 16 2016 00:19
:thumbsup:
Patrick Lippert
@mayhawstudios
Aug 16 2016 00:20
@piq9117 I mean the last part of the assignment, if the variables are complete and prop isn't "tracks", pass value to the appropriate record
Ken Aguilar
@piq9117
Aug 16 2016 00:23
const collection = [1,2,3,4,5,"this is a string", "another string", "not a number"]
funcition onlyNumber(col) {
return col. filter(c => typeof c === 'number')
}

const nums = onlyNumber(collection);
nums; // [1,2,3,4,5];
Margaret
@Margaret2
Aug 16 2016 00:27
@CageEcharte when you write Javascript, you only use var once for each variable - after that, you just use the name of the variable. So you should use var myStr on the first line and just myStr on the second line
David Beczuk
@dbeczuk
Aug 16 2016 00:28
@CageEcharte It is recomended to declare variable only by prefixing the variable with Var, otherwise the variable will be a global one, and this will cause problems. But once declared with Var you are setting it's scope. Global or local depending where you declare it.
Lolaa Michele
@lolaamichele
Aug 16 2016 00:29
Alrighty so I have come across another issue -- Finding a Remainder in JavaScript --
greg
@wearenotgroot
Aug 16 2016 00:30
@lolaamichele what you got so far?
Lolaa Michele
@lolaamichele
Aug 16 2016 00:30
Instructions
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator
I have ....
Cage Echarte
@CageEcharte
Aug 16 2016 00:30
@Margaret2 Now what? var myStr = "This is the first sentence. " ;
myStr += "This is the second sentence. ";
llamatarianism
@llamatarianism
Aug 16 2016 00:31
@lolaamichele % is the remainder operator
it works just like every other mathematical operator (+ - * /)
you shove it between 2 numbers
Zheng
@FireFalcon1155
Aug 16 2016 00:31
Hey, uh i'm stuck on Reverse a String in Basic Algorithm Programming. Anyone help?
Lolaa Michele
@lolaamichele
Aug 16 2016 00:31
Oops never mind lol
I got it !
greg
@wearenotgroot
Aug 16 2016 00:31
@lolaamichele :+1:
llamatarianism
@llamatarianism
Aug 16 2016 00:31
@CageEcharte probably the trailing space
@FireFalcon1155 arrays have a built in method for reversing them
var arr = [1, 2, 3];
console.log(arr.reverse()); // [3, 2, 1];
console.log(arr); // [3, 2, 1]
greg
@wearenotgroot
Aug 16 2016 00:32
llamatarianism
@llamatarianism
Aug 16 2016 00:32
if you can make a string into an array
Zheng
@FireFalcon1155
Aug 16 2016 00:32
@IAmAnubhavSaini I have to turn the string into an array though
llamatarianism
@llamatarianism
Aug 16 2016 00:32
then you can reverse it easily
Zheng
@FireFalcon1155
Aug 16 2016 00:32
@llamatarianism sorry
Cage Echarte
@CageEcharte
Aug 16 2016 00:32
@llamatarianism @Margaret2 Thank you
CamperBot
@camperbot
Aug 16 2016 00:32
cageecharte sends brownie points to @llamatarianism and @margaret2 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for margaret2
:star2: 1196 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Zheng
@FireFalcon1155
Aug 16 2016 00:32
@IlhamiD How do i turn it into an array?
llamatarianism
@llamatarianism
Aug 16 2016 00:32
you can use split to split a string on a substring
console.log("foo bar baz".split(" ")); // ["foo", "bar", "baz"]
llamatarianism
@llamatarianism
Aug 16 2016 00:33
if you leave that substring empty
Zheng
@FireFalcon1155
Aug 16 2016 00:33
@llamatarianism but it passes in "hello"
llamatarianism
@llamatarianism
Aug 16 2016 00:33
you get an array of all the characters in a string
console.log("foo".split("")); // ["f", "o", "o"]
Zheng
@FireFalcon1155
Aug 16 2016 00:33
oh ic....
llamatarianism
@llamatarianism
Aug 16 2016 00:33
then you can use String.prototype.join to join em back together
console.log(["a", "b", "c"].join("")); // "abc"
Zheng
@FireFalcon1155
Aug 16 2016 00:34
thanks @llamatarianism
CamperBot
@camperbot
Aug 16 2016 00:34
firefalcon1155 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1197 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Zheng
@FireFalcon1155
Aug 16 2016 00:35

@llamatarianism this is wat i did:
function reverseString(str) {
str.split("");
str.reverse();
str.join();

return arr;
}

reverseString("hello");

llamatarianism
@llamatarianism
Aug 16 2016 00:35
only reverse changes the variable in place
str.split("") doesn't change str
it just creates a new array
that you don't use.
Zheng
@FireFalcon1155
Aug 16 2016 00:36
so do i have to create a new var
wait. i split it first, then reversed it, then joined it back
it keeps saying str.reverse(); isn't a function
greg
@wearenotgroot
Aug 16 2016 00:37
@FireFalcon1155 str is a string
Zheng
@FireFalcon1155
Aug 16 2016 00:37
it's the parameter i passed in
Patrick Lippert
@mayhawstudios
Aug 16 2016 00:37
I've reviewed Accessing Nested Objects. It says that I should write the assignment collection[id].prop = value
greg
@wearenotgroot
Aug 16 2016 00:38
@FireFalcon1155 you need to store what the split give you as a return value
Zheng
@FireFalcon1155
Aug 16 2016 00:38
in a new var?
greg
@wearenotgroot
Aug 16 2016 00:38
@FireFalcon1155 yes (well you can use str if you want)
Liew Xun
@damakuno
Aug 16 2016 00:38
@FireFalcon1155 yep
Patrick Lippert
@mayhawstudios
Aug 16 2016 00:39
@mayhawstudios But prop won't be read as a variable. And you can't combine bracket and dot notation to pass the var to the nested array, can you? It doesn't seem to work.
Zheng
@FireFalcon1155
Aug 16 2016 00:39

@wearenotgroot
function reverseString(strn) {
var iasd=strn.split("");
iasd.reverse();
iasd.join(" ");

return iasd;
}

reverseString("hello");

llamatarianism
@llamatarianism
Aug 16 2016 00:39
join doesn't change it in place either.
like I said
llamatarianism
@llamatarianism
Aug 16 2016 00:39

out of those 3 methods,

only reverse changes the variable in place

also, you're trying to join the array using spaces
which will create something like "o l l e h"
Lorena
@lore-code
Aug 16 2016 00:40

I'm having some issues in the mutations challenge...don't understand why it is not returning the correct info...any advice...thought about maybe making everything lowercase...
function mutation(arr) {

if (arr[0].indexOf(arr1)!==-1)

 return true;

else if (arr[0].indexOf(arr1) ==-1)
return false;

}

mutation(["hello", "Hello"]);

Zheng
@FireFalcon1155
Aug 16 2016 00:40
but join is not changing anything
it stays as the join part is not working
greg
@wearenotgroot
Aug 16 2016 00:40
@FireFalcon1155 it will return a string made from the array
Zheng
@FireFalcon1155
Aug 16 2016 00:40
oops
it returns the reversed array
Alejandro Perez
@alejitopm90
Aug 16 2016 00:41
Hello
Iam having some troubles with the Counting Cards code
greg
@wearenotgroot
Aug 16 2016 00:43
@lore-code you need to make sure that every letter(character) in arr[1] is present in arr[0]
Alejandro Perez
@alejitopm90
Aug 16 2016 00:44
How can I use switch to set the cards value for the count?
Lorena
@lore-code
Aug 16 2016 00:44
@wearenotgroot guess I should use a for loop then
thanks
greg
@wearenotgroot
Aug 16 2016 00:44
@lore-code :+1:
@alejitopm90 review the previous lesson on switch(specially the one where multiple identical cases: Multiple Identical Options in Switch Statements)
Patrick Lippert
@mayhawstudios
Aug 16 2016 00:45
@alejitopm90 Look over Replacing If Else Chains With Switches
On the Record Collection assignment, how can I use variables to update a nested object? collection[id].prop = value doesn't work.
I think it reads prop as a value rather than a variable.
greg
@wearenotgroot
Aug 16 2016 00:50
@mayhawstudios use bracket notation since prop is a variable
Stephen James
@sjames1958gm
Aug 16 2016 00:50
@mayhawstudios Continue to use brackets as long as you have variables.
Patrick Lippert
@mayhawstudios
Aug 16 2016 00:50
Can I use a bracket in front of a dot like that? collection[id].[prop] = value; ?
Stephen James
@sjames1958gm
Aug 16 2016 00:51
@mayhawstudios No dot, just like with an array
Alejandro Perez
@alejitopm90
Aug 16 2016 00:51
I get the right code.
greg
@wearenotgroot
Aug 16 2016 00:51
@alejitopm90 ok, gratz?
Stephen James
@sjames1958gm
Aug 16 2016 00:51
@mayhawstudios Think about it left to right collection[id] is an object, so add [prop] to get to that objects property
Alejandro Perez
@alejitopm90
Aug 16 2016 00:51
This message was deleted
Lolaa Michele
@lolaamichele
Aug 16 2016 00:52
Alright I'm officially going crazy 😔
Convert Celsius to Fahrenheit
Patrick Lippert
@mayhawstudios
Aug 16 2016 00:53
collection[id , prop] = value; ?
greg
@wearenotgroot
Aug 16 2016 00:53
@lolaamichele first turn the instruction into an equation or look up the formula for converting celsius to fahrenheit
Stephen James
@sjames1958gm
Aug 16 2016 00:53
@mayhawstudios No [id][prop]
greg
@wearenotgroot
Aug 16 2016 00:53
:smile:
Patrick Lippert
@mayhawstudios
Aug 16 2016 00:54
@sjames1958gm Okay, that worked! Thanks
CamperBot
@camperbot
Aug 16 2016 00:54
mayhawstudios sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2641 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 16 2016 00:54
@mayhawstudios :+1:
Lolaa Michele
@lolaamichele
Aug 16 2016 00:54
Okay Greg ! @AeonBackflash
That's you right ?
pahosler
@pahosler
Aug 16 2016 00:55
just had some fun revisiting palindrome after learning lots of stuff :D .... spoiler ahead
function palindrome(str) {
var pal = [];
str.toLowerCase().split('').reduce((a,b)=>{
(b.match(/[a-z0-9]/)) ? pal.push(b) :  b
return b
},[])
return (pal.join('') == pal.reverse().join(''))
}

palindrome("eye");
greg
@wearenotgroot
Aug 16 2016 00:55
@lolaamichele after that substitute the variables/parameters then store the value you get into fahrenheit variable
Lolaa Michele
@lolaamichele
Aug 16 2016 00:56
But how should that look because I just wrote out var convertToF = 32 😩 for the first one
Stephen James
@sjames1958gm
Aug 16 2016 00:58
@lolaamichele Use the formula and inside the function use the fahrenheit variable for F and the celsius variable/parameter for C
greg
@wearenotgroot
Aug 16 2016 00:58
@lolaamichele turn this one into an equation ----->The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
written in another way
T(F) = T(C) * 9/5 + 32 //formula for converting celsius to fahrenheit where F is in fahrenheit and C is in celsius
Myles Chatman
@myleschatman
Aug 16 2016 00:59
@lolaamichele yup just used that algorithm greg mentioned
Lorena
@lore-code
Aug 16 2016 01:01
I have all the true working but false is not working...advice I'm thinking I should make everything lowercase, perhaps...
greg
@wearenotgroot
Aug 16 2016 01:01
@lore-code sure go for it
Lorena
@lore-code
Aug 16 2016 01:01
@pahosler I had been stuck on palindrome until I took a break and then it all came to my head lol
llamatarianism
@llamatarianism
Aug 16 2016 01:02
$T_F = T_C \times \frac{9}{5} + 32$
latex is pretty
Mike
@MikeJSchorah
Aug 16 2016 01:04
  // Don't show a false ID to this bouncer.
function bouncer(value) {
if (value === false) {
return false;
} else {
return true;
}
if (value === null) {
return false;
} else {
return true;
}
if (value === 0) {
return false;
} else {
return true;
}
if (value === "") {
return false;
} else {
return true;
}
if (value === undefined) {
return false;
} else {
return true;
}
if (value(isNaN)) {
return false;
} else {
return true;
}
}

[7, "ate", "", false, 9].filter(bouncer);
Could someone please give me a tip for Falsy Bouncer?
Gary Siu
@GarySiu
Aug 16 2016 01:05
What sort of tip would you like?
Lolaa Michele
@lolaamichele
Aug 16 2016 01:05
Omg ☺️😩
Gary Siu
@GarySiu
Aug 16 2016 01:06
@MikeJSchorah Consider what false, null, 0, '', NaN and undefined have in common
greg
@wearenotgroot
Aug 16 2016 01:07
@lolaamichele post you updated code so we can take a look
Young Mary-Claret Nnenna
@claretyoung20
Aug 16 2016 01:07
i really need help, am working on my show local weather project , but since yestersday the temperature of my current location has been the same. it is not corresponding with google ..

$(document).ready(function(){ var url1 = "http://ip-api.com/json"; var url; var ct,country; var getCity = function(data){ ct = data.city; country = data.country;$(".location").text(ct+", " + country);

    url = 'http://api.openweathermap.org/data/2.5/weather?'+'q='+ct+'&APPID=f7ec8f9583b86d92616709a348288dc3';
var getDescritn = function(data) {
var units = 'imperial';
var temp = Math.round((data.main.temp)/10);
var code = data.weather[0].icon;
var images = '<img src="http://openweathermap.org/img/w/' + code + '.png" alt="Weather Icon">' ;
var windUnit = units === 'metric' ? ' meters/s' : ' miles/h';
var wspeed = data.wind.speed;
var humidity = "Humidity "+data.main.humidity + "%";
var descrition =data.weather[].description ;

$(".description").text("Description: "+ descrition);$(".deg").html(temp+'&deg;');
$(".images").html(images);$(".wind").html(wspeed+windUnit);
$(".humidity").html(humidity);$(".celsiu").css("color", "red");
//-----------
$(".celsiu").click(function() {$(".deg").html(temp + '&deg;');
$(".frh").css("color", "white");$(".celsiu").css("color", "red");
});
//-----------------
$(".frh").click(function() { var freh = Math.round(1.8*temp+32);$(".deg").html(freh+'&deg;');
$(".frh").css("color", "red");$(".celsiu").css("color", "white");
});
//----------------------
var bgim = 'url("https://images.trvl-media.com/media/content/shared/images/travelguides/destination/178307/Kerry-Park-61617.jpg")';
if(descrition === "light rain"){
$('body').css('background-image',bg[0]); }else if(descrition === "mostly cloudy"){$('body').css('background-image',bg[1]);

}else if(descrition === "clear sky"){
$('body').css('background-image',bg[2]); } else if(descrition === "overcast clouds"){$('body').css('background-image',bg[3]);

}
else if(descrition === "cloudy"){
$('body').css('background-image',bg[4]); }else if(descrition === "sunny"){$('body').css('background-image',bg[5]);
}else if(descrition === "broken clouds"){
$('body').css('background-image',bg[7]); } else{$('body').css('background-image',bg[6]);
}
};

$(document).ready(function() {$.getJSON(url, getDescritn, 'jsonp');
});

};

$(document).ready(function() {$.getJSON(url1,getCity,'jsonp');
});

});

Liew Xun
@damakuno
Aug 16 2016 01:08
what weather api are you working on
open weather map?
greg
@wearenotgroot
Aug 16 2016 01:08
Young Mary-Claret Nnenna
@claretyoung20
Aug 16 2016 01:09
lettda
@lettda
Aug 16 2016 01:09
Can someone tell me why my rows aren't stackng? I'm sure it's a styling issue, but idk what's up
greg
@wearenotgroot
Aug 16 2016 01:13
@claretyoung20 remember if you dont specify the unit in the api url you'll get standard units(temp in kelvin)
Lorena
@lore-code
Aug 16 2016 01:13
@lettda I think it depends if you're using an inline or block element
llamatarianism
@llamatarianism
Aug 16 2016 01:14
This message was deleted
Lorena
@lore-code
Aug 16 2016 01:14
I believe block elements stack on top of each other
llamatarianism
@llamatarianism
Aug 16 2016 01:14
oh wait you've actually defined .row for yourself
nevermind
I instinctively go check if someone's got bootstrap or not if I see .row because it's a pretty common error
in this case it's unrelated
lettda
@lettda
Aug 16 2016 01:15
lol
all the div talk makes it seem like bootstrap would be involved
I tried changing the display to block for row but still nothing
llamatarianism
@llamatarianism
Aug 16 2016 01:16
if you remove the float: left;
and add display: block;
they take up an entire row
Young Mary-Claret Nnenna
@claretyoung20
Aug 16 2016 01:16
@wearenotgroot i got it thanks
CamperBot
@camperbot
Aug 16 2016 01:16
claretyoung20 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1357 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Lolaa Michele
@lolaamichele
Aug 16 2016 01:17
This is too much lol . HTML 5 and CSS was great , I felt something there but this JavaScript stuff has me on edge 😥😥
lettda
@lettda
Aug 16 2016 01:17
@llamatarianism yeah but now it spans the entire window
greg
@wearenotgroot
Aug 16 2016 01:17
Lolaa Michele
@lolaamichele
Aug 16 2016 01:17
Sighs.......
Myles Chatman
@myleschatman
Aug 16 2016 01:17
@lolaamichele lol i know what you mean
llamatarianism
@llamatarianism
Aug 16 2016 01:17
@lettda then give it a max-width or something
Lolaa Michele
@lolaamichele
Aug 16 2016 01:18
@myleschatman 😏
Ryan Guthrie
@DiogenestheDog
Aug 16 2016 01:19
@lolaamichele once it clicks it's so much fun! Keep throwing yourself at it :smile:
lettda
@lettda
Aug 16 2016 01:19
@llamatarianism what about doing something like $('.grid').width($('.row').width().val());
make it dynamic and equal to how ever wide the row width is since that'll be the width of squares within it
GeorgeMeehanDev
@georgemeehan
Aug 16 2016 01:22
@lolaamichele YouTube has been a BIG help to me with this JavaScript.
Lolaa Michele
@lolaamichele
Aug 16 2016 01:29
Thanks @ryan
CamperBot
@camperbot
Aug 16 2016 01:29
lolaamichele sends brownie points to @ryan :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for ryan
Lolaa Michele
@lolaamichele
Aug 16 2016 01:29
I'll look into it George !
Lolaa Michele
@lolaamichele
Aug 16 2016 01:35
Alrighty then this Convert Celsius to Fahrenheit is bugging me 😔😔😑😑
greg
@wearenotgroot
Aug 16 2016 01:35
@lolaamichele post what you have so far?
Myles Chatman
@myleschatman
Aug 16 2016 01:35
which part @lolaamichele
lettda
@lettda
Aug 16 2016 01:37
New dilemma I can't center the grid in the middle of the page
Moisés Man
@moigithub
Aug 16 2016 01:44
@lettda set a width on .grid
David Halls
@DavidHalls
Aug 16 2016 01:44
@lolaamichele what are you working on?
Santiago Gómez
@Sperkajugglite
Aug 16 2016 01:45
@lettda now... thats cool
lettda
@lettda
Aug 16 2016 01:45
got it!
thanks @moigithub
CamperBot
@camperbot
Aug 16 2016 01:46
lettda sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1907 | @moigithub |http://www.freecodecamp.com/moigithub
lettda
@lettda
Aug 16 2016 01:47
@Sperkajugglite it's an etch a sketch project, the square will be able to be set to a user inputed number and changed color in 3 different ways
Santiago Gómez
@Sperkajugglite
Aug 16 2016 01:48
@lettda naiz
Lolaa Michele
@lolaamichele
Aug 16 2016 01:49
I have nothing . I'm just staring at the screen ...
Santiago Gómez
@Sperkajugglite
Aug 16 2016 01:49
@lettda great man!!
good job :P
Lolaa Michele
@lolaamichele
Aug 16 2016 01:49
@AeonBackflash
@david I'm working on Convert Celsius to Fahrenheit
Boris
@Boris1011
Aug 16 2016 01:50
Can someone help please??? I'm on the 'Finding a Remainder in Javascript' and am so damn confused with the instructions!?
Myles Chatman
@myleschatman
Aug 16 2016 01:50
@lolaamichele what is confusing you?
David Halls
@DavidHalls
Aug 16 2016 01:50
@lolaamichele the challenge or the weather app?
Santiago Gómez
@Sperkajugglite
Aug 16 2016 01:50
oh ... school tomorrow :disappointed:
@Byzgig chalanee :P
greg
@wearenotgroot
Aug 16 2016 01:50
@lolaamichele well then research and read about js variable and js function concept? review previous lesson and come back to that challenge later?
Santiago Gómez
@Sperkajugglite
Aug 16 2016 01:50
chalanee*
challange*
idk whats wrong with my computer :joy:
Myles Chatman
@myleschatman
Aug 16 2016 01:51
@Boris1011 which part in the instructions?
Boris
@Boris1011
Aug 16 2016 01:51
the whole thing..... I was going ok, but.... @myleschatman
Santiago Gómez
@Sperkajugglite
Aug 16 2016 01:51
is anyone doing some weird project?
greg
@wearenotgroot
Aug 16 2016 01:51
@Boris1011 use % operator and store the result into the remainder variable
Boris
@Boris1011
Aug 16 2016 01:51
what am I meant to put for the code????
Santiago Gómez
@Sperkajugglite
Aug 16 2016 01:51
like @lettda :P
Ryan Guthrie
@DiogenestheDog
Aug 16 2016 01:52
@Boris1011 use % on remainder
Myles Chatman
@myleschatman
Aug 16 2016 01:52
ok think of remainder as what value is remaining after dividing two integers
Boris
@Boris1011
Aug 16 2016 01:53

yep... got that bit!? I only have this

// Only change code below this line

var remainder;

what must I add to get that remainder working????

Liew Xun
@damakuno
Aug 16 2016 01:53
use % as others have said
Myles Chatman
@myleschatman
Aug 16 2016 01:53
assign remainder to the values provided using the % operator
lettda
@lettda
Aug 16 2016 01:53
@Sperkajugglite Lol i actually got this from The Odin Project. i was tired of FCC algorithms so I'm trying this out, defintely doesn't hold your hand AT ALL
Liew Xun
@damakuno
Aug 16 2016 01:54
like 5%4 will return 1
Santiago Gómez
@Sperkajugglite
Aug 16 2016 01:54
@lettda nice man!! want to see more
:smile:
Ryan Apolinar
@ryanapolinar
Aug 16 2016 01:54
Trying to use jQuery to change text, but I can't seem to get it to work. This is what I have:
<script>
$(document).ready(function() {$("#quote").html("changed text");
});
</script>
<h3 id="quote">Text is not changed</h3>
Liew Xun
@damakuno
Aug 16 2016 01:54
@Boris1011 so you just need to put the expression into the variable
Myles Chatman
@myleschatman
Aug 16 2016 01:54
correct
Liew Xun
@damakuno
Aug 16 2016 01:55
something like x = num1 % num2 ?
Boris
@Boris1011
Aug 16 2016 01:55
@damakuno so like var remainder = 11 % 3;
Liew Xun
@damakuno
Aug 16 2016 01:55
something like that yeah
Santiago Gómez
@Sperkajugglite
Aug 16 2016 01:55
what is yelpCamp ? @lettda
Boris
@Boris1011
Aug 16 2016 01:55
ok, i'll see if that works!!!
Ty @damakuno
CamperBot
@camperbot
Aug 16 2016 01:56
boris1011 sends brownie points to @damakuno :sparkles: :thumbsup: :sparkles:
Liew Xun
@damakuno
Aug 16 2016 01:56
a fun way to use % operator is to determine whether a number is even or odd
greg
@wearenotgroot
Aug 16 2016 01:56
@Boris1011 now go test out what it does
Liew Xun
@damakuno
Aug 16 2016 01:56
you just pass anyNumber % 2 to determine it
if it returns 0 it is even
if not it is odd
lettda
@lettda
Aug 16 2016 01:56
@Sperkajugglite it's another project I'm doing for a Udemy course using the MEAN stack, I'm learning the MongoDB part of it now
Boris
@Boris1011
Aug 16 2016 01:56
@wearenotgroot I got it mate!!!!
@damakuno javascript freaking confuses me!!!
lettda
@lettda
Aug 16 2016 01:57
I can publish what I have of that too if you want to see it
h8rry
@h8rry
Aug 16 2016 01:57
@ryanapolinar any error messages?
Santiago Gómez
@Sperkajugglite
Aug 16 2016 01:57
@lettda thats great man
Liew Xun
@damakuno
Aug 16 2016 01:57
@Boris1011 it does? it shouldn't be
Santiago Gómez
@Sperkajugglite
Aug 16 2016 01:58
I'm watching shark tank :laughing:
Liew Xun
@damakuno
Aug 16 2016 01:58
well maybe it really does lol
Ryan Apolinar
@ryanapolinar
Aug 16 2016 01:58
@h8rry No error messages, trying to create the Random Quote Generator in Codepen so there's nothing I can really print to the console for debugging or any error messages
Santiago Gómez
@Sperkajugglite
Aug 16 2016 01:58
well, Im going to bed
have a good night guys :P
Boris
@Boris1011
Aug 16 2016 01:58
@damakuno it does....
@Sperkajugglite cya man!!
greg
@wearenotgroot
Aug 16 2016 01:58
h8rry
@h8rry
Aug 16 2016 01:58
@ryanapolinar Did you make sure jQuery has been injected into HTML correctly?
Santiago Gómez
@Sperkajugglite
Aug 16 2016 01:59
@Boris1011 bye!!!, thanks :)
CamperBot
@camperbot
Aug 16 2016 01:59
sperkajugglite sends brownie points to @boris1011 :sparkles: :thumbsup: :sparkles:
Liew Xun
@damakuno
Aug 16 2016 01:59
@Boris1011 it's okay, soon you'll get the hang of it
Ryan Apolinar
@ryanapolinar
Aug 16 2016 01:59
h8rry
@h8rry
Aug 16 2016 01:59
@ryanapolinar your jQuery code looks correct
Boris
@Boris1011
Aug 16 2016 01:59
@wearenotgroot thanks man!! will read that!!! Maybe it will lessen the confusion!!!
CamperBot
@camperbot
Aug 16 2016 01:59
boris1011 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1358 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Boris
@Boris1011
Aug 16 2016 01:59
@Sperkajugglite :smile:
Ryan Apolinar
@ryanapolinar
Aug 16 2016 01:59
I used the auto jQuery thing in the settings, should I also include it in the code?
greg
@wearenotgroot
Aug 16 2016 02:00
@ryanapolinar well first off put the js in the js section
Boris
@Boris1011
Aug 16 2016 02:00
@damakuno i certainly hope so!!
h8rry
@h8rry
Aug 16 2016 02:00
@ryanapolinar you should put your js code here
Lolaa Michele
@lolaamichele
Aug 16 2016 02:00
@myleschatman ALL OF IT . I don't even know how to begin
Ryan Apolinar
@ryanapolinar
Aug 16 2016 02:00
@wearenotgroot christ, thanks lol forgot to see that
CamperBot
@camperbot
Aug 16 2016 02:00
ryanapolinar sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1359 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Ryan Apolinar
@ryanapolinar
Aug 16 2016 02:01
@h8rry thanks
CamperBot
@camperbot
Aug 16 2016 02:01
ryanapolinar sends brownie points to @h8rry :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for h8rry
Lolaa Michele
@lolaamichele
Aug 16 2016 02:01
@david the challenge 😂
David Halls
@DavidHalls
Aug 16 2016 02:01
@lolaamichele how do you set the value of a variable?
Lolaa Michele
@lolaamichele
Aug 16 2016 02:02
Thanks @AeonBackflash sounds good
CamperBot
@camperbot
Aug 16 2016 02:02
lolaamichele sends brownie points to @aeonbackflash :sparkles: :thumbsup: :sparkles:
Lolaa Michele
@lolaamichele
Aug 16 2016 02:02
var = whatever
Myles Chatman
@myleschatman
Aug 16 2016 02:02
well the value 30 is being passed to the function convertToF so the parameter celsius is equal to 30.
lettda
@lettda
Aug 16 2016 02:02
@Sperkajugglite I published it but you can't see it without running mongodb and node on your computer...idk how to run a server for real yet :P
Myles Chatman
@myleschatman
Aug 16 2016 02:03
the functions purpose is to convert a temp. in celsius to fahrenheit
h8rry
@h8rry
Aug 16 2016 02:03
@ryanapolinar No problem! My friend @xiaopow and I built and run https://www.codeforx.com, which we aim to provide really quick Q&A like this group, but in a more organized manner. You can check it out and ask questions. We get notified instantly when you ask. :)
Lolaa Michele
@lolaamichele
Aug 16 2016 02:03
How do write it out
David Halls
@DavidHalls
Aug 16 2016 02:04
yes
Myles Chatman
@myleschatman
Aug 16 2016 02:05
variable1 = variable2 <insert algorithm here to convert>
greg
@wearenotgroot
Aug 16 2016 02:06
@ryanapolinar try and change the format to jsonp if you still got error(in the api url)
@ryanapolinar change the url into something like
"http://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&lang=en&jsonp=?"
Myles Chatman
@myleschatman
Aug 16 2016 02:11
cool idea @h8rry !
Mike
@MikeJSchorah
Aug 16 2016 02:12
function bouncer(value) {
if (value.includes(false)) {
return value -= false;
}
}
Could someone please give me a hint with Falsy Bouncer?
Chris Wu
@chriswudotnet
Aug 16 2016 02:12
Hello, can someone explain to me for the Profile Lookup challenge, why is contacts[i].firstName works but contacts[i][firstName] doesn't?
h8rry
@h8rry
Aug 16 2016 02:13
@myleschatman thanks! we are still building more features and the community around it. Let us know your thoughts and recommendations! We are up to build out requested features. :D
CamperBot
@camperbot
Aug 16 2016 02:13
h8rry sends brownie points to @myleschatman :sparkles: :thumbsup: :sparkles:
Mike
@MikeJSchorah
Aug 16 2016 02:13
@chriswudotnet That is just how the syntax works. Move along and when you see it like that later, it might click.
Chris Wu
@chriswudotnet
Aug 16 2016 02:14
@MikeJSchorah thanks
CamperBot
@camperbot
Aug 16 2016 02:14
chriswudotnet sends brownie points to @mikejschorah :sparkles: :thumbsup: :sparkles:
Myles Chatman
@myleschatman
Aug 16 2016 02:14
@h8rry cool i'll bookmark it
Mike
@MikeJSchorah
Aug 16 2016 02:16
Question...
Chris Lacaille
@ChrisL108
Aug 16 2016 02:16
@MikeJSchorah I would loop through all items in the provided array and make a new array with all true/false replacements (using push())
@MikeJSchorah and generally you can check for truthy'ness by just...
var item = true;

if (item) {
//this will run
}
greg
@wearenotgroot
Aug 16 2016 02:17
@ChrisL108 i think he is using filter
David Halls
@DavidHalls
Aug 16 2016 02:17
@MikeJSchorah look into Boolean Global Objects, i think it is a link in the challenge
Mike
@MikeJSchorah
Aug 16 2016 02:17
I'm somewhat new to this site. Is it more standard to give thanks right after the smallest morsel of information is given or when someone is actually able to complete the exercise? It just seems like brownie points are given out way too lavishly.
Aug 16 2016 02:19
Hello! I need some help with the Mutations JS challenge. I've managed to fulfill every requirement except for the first one "mutation(["hello", "hey"]) should return false." Could someone point to me where my code is wrong?
function mutation(arr) {

for (i = 0; i < arr[1].length; i++) {

if (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase()) === -1) {
return false;
}

return true;
}
}

mutation(["Hello", "hey"]);
Diego Mayer
@Chrono79
Aug 16 2016 02:19
@lucasbadu don't return true inside the loop, the loop only runs once that way
Chris Lacaille
@ChrisL108
Aug 16 2016 02:19
@MikeJSchorah I don't think there are any set rules for giving points (or prizes for points :p) but generally when someone solves your problem or sends you in the right direction.
Aug 16 2016 02:20
wow I can't believe it was that simple. Thanks a lot @Chrono79!
CamperBot
@camperbot
Aug 16 2016 02:20
lucasbadu sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1828 | @chrono79 |http://www.freecodecamp.com/chrono79
greg
@wearenotgroot
Aug 16 2016 02:21
@lucasbadu just remember what return does, next time
John Ngo
@johnngo
Aug 16 2016 02:21

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

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

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

llamatarianism
@llamatarianism
Aug 16 2016 02:21
gotos considered harmful
John Ngo
@johnngo
Aug 16 2016 02:21
anyone help solve this?
llamatarianism
@llamatarianism
Aug 16 2016 02:21
but apparently not break, continue or return
ho hum.
Diego Mayer
@Chrono79
Aug 16 2016 02:21
@johnngo use the formula
Chris Lacaille
@ChrisL108
Aug 16 2016 02:22
@johnngo Give it a go first
llamatarianism
@llamatarianism
Aug 16 2016 02:22
@johnngo the formula for converting them is $T_F = T_C \times \frac{9}{5} + 32$
should be easy enough to translate that into code
Mike
@MikeJSchorah
Aug 16 2016 02:22
@ChrisL108 I write down everything that everyone says on a sheet of paper. When the problem is finally solved, I go back and see who gave me the most relevant information and then send out brownie points. It helps me reward the people who actually know what they are talking about while reinforcing learning the material (since I write it down).
Just didn't know what the expectations are on this here site...
llamatarianism
@llamatarianism
Aug 16 2016 02:24
I doubt anyone cares that much @MikeJSchorah
Chris Lacaille
@ChrisL108
Aug 16 2016 02:24
@MikeJSchorah That sounds reasonable. Personally I couldn't attest to the expectations as I am not on here all that often.
@MikeJSchorah @llamatarianism Yeah I wouldn't pay it much mind honestly
Mike
@MikeJSchorah
Aug 16 2016 02:26
@llamatarianism Lol, really? Sounds like when a football player gets his record broken. He always says that it doesn't matter much on the outside, but you can see from the look in his face, that he secretly didn't want the record broken. LOL
llamatarianism
@llamatarianism
Aug 16 2016 02:26
lol
Joseph
@revisualize
Aug 16 2016 02:26
Funny stuff.
llamatarianism
@llamatarianism
Aug 16 2016 02:27
in my experience most people just thank everyone who gave them even the slightest tip
Mike
@MikeJSchorah
Aug 16 2016 02:27
@revisualize LOL. And here is the comedian of the group...
Joseph
@revisualize
Aug 16 2016 02:28
HEY! I know I'm funny. But come on man.. Looks aren't everything.
Mike
@MikeJSchorah
Aug 16 2016 02:28
Mr. Joseph "Dick" Tracy (That was a cartoon in the 80s, right?)
Joseph
@revisualize
Aug 16 2016 02:28
It was.
Mike
@MikeJSchorah
Aug 16 2016 02:28
lol
Stephen James
@sjames1958gm
Aug 16 2016 02:29
@MikeJSchorah 80s, try the 30s
@revisualize Its hard to tell you keep just looking out from the corner of that picture
Joseph
@revisualize
Aug 16 2016 02:31
That's why I only have part of my face showing. Because I'm funny looking.
Mike
@MikeJSchorah
Aug 16 2016 02:31
@sjames1958gm I was just thinking about that. Wonder why the picture of the emergency exit was taken...
And why is the emergency exit only for cats?

@Maggie9468
Aug 16 2016 02:33
"lol", what does it mean?
Stephen James
@sjames1958gm
Aug 16 2016 02:33
@Maggie9468 laugh out loud
llamatarianism
@llamatarianism
Aug 16 2016 02:33
@Maggie9468 laugh out loud
you know who else looks funny?
joe armstrong, guy who made erlang

@Maggie9468
Aug 16 2016 02:34
You look funny
llamatarianism
@llamatarianism
Aug 16 2016 02:34
true

@Maggie9468
Aug 16 2016 02:35
lol
Could you speak Chinese ?
llamatarianism
@llamatarianism
Aug 16 2016 02:37
a little bit. not much. probably not enough to have a fluent conversation about programming.
Yogesh Gupta
@yogesh-
Aug 16 2016 02:39
I am stuck here : Returning boolean values from function
can anybody help ?

@Maggie9468
Aug 16 2016 02:40
lol
Myles Chatman
@myleschatman
Aug 16 2016 02:41
@yogesh- looks like you need to change comparison operator

@Maggie9468
Aug 16 2016 02:41

greg
@wearenotgroot
Aug 16 2016 02:41
@yogesh- read function name it should tell you what it should do
function isLess(a,b)
Yogesh Gupta
@yogesh-
Aug 16 2016 02:41
@myleschatman ok ..
the script is fine
but returns error for 10,15
@wearenotgroot what is the fix for this error ?
greg
@wearenotgroot
Aug 16 2016 02:43
@yogesh- remember this === mean is equal(comparison), now change it to less than operator
Yogesh Gupta
@yogesh-
Aug 16 2016 02:43
yes done
thanks @wearenotgroot
CamperBot
@camperbot
Aug 16 2016 02:43
yogesh- sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1362 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Aug 16 2016 02:44
@yogesh- GJ :+1:
Yogesh Gupta
@yogesh-
Aug 16 2016 02:44
@wearenotgroot going to office..have a nice day
greg
@wearenotgroot
Aug 16 2016 02:44
@yogesh- ok have a good one
Michael
@davidfutch
Aug 16 2016 02:54
how does one compare a character ex. 8 < "A"
ahmed abouhay
@abohay
Aug 16 2016 02:54
function mutation(arr) {
var arrj = arr.toString();
var arrj1 = arrj.ToLowerCase();
var arrj2 = arrj1.split(" ");
var seg1 = arrj2[0].split("");
var seg2 = arrj2[1].split("");
if(seg1.indexOf(seg2) >= 0){
return true;
}
else{
return false;
}
}

mutation(["hello", "hey"]);
any one help me i'm too frustrated
Ryan Guthrie
@DiogenestheDog
Aug 16 2016 02:55
@davidfutch use === to see if the character is the same
TruongNDN
@NDNTruong
Aug 16 2016 02:56

switch(val){
case 1:
break;
case 2:
break;
case 3:
answer = "There is no #1";
break;
case 4:
answer = "Missed me by this much!";
break;
default:

}
// Only change code above this line
}

You should not use any else statements anywhere in the editor
You should not use any if statements anywhere in the editor
You should have at least four break statements
chainToSwitch("bob") should be "Marley"
chainToSwitch(1) should be "There is no #1"
chainToSwitch(99) should be "Missed me by this much!"
chainToSwitch(7) should be "Ate Nine"
chainToSwitch("John") should be "" (empty string)
chainToSwitch(156) should be "" (empty string)
Michael
@davidfutch
Aug 16 2016 02:57
how is a range checked? Example, cards with the J, Q, K, A
Mike R
@mikeinmiami
Aug 16 2016 02:58
Comparison with the Greater Than Operator i need help with this one ughh
llamatarianism
@llamatarianism
Aug 16 2016 02:58
you can either use || and an if statement @davidfutch
Mike R
@mikeinmiami
Aug 16 2016 02:58
plz
llamatarianism
@llamatarianism
Aug 16 2016 02:58
if (x === 1 || x === 2 || x === 3) {
// stuff
}
Ryan Guthrie
@DiogenestheDog
Aug 16 2016 02:58
@davidfutch you can use an associative array or object e.g. {J : 1, Q: 2, K: 3, A: 4}
llamatarianism
@llamatarianism
Aug 16 2016 02:59
or with a switch statement
switch (x) {
case 1:
case 2:
case 3:
// stuff
break;
}
because there's no break between the case 1: and the case 2: and the case 3:, it sort of cascades down
@mikeinmiami you can compare numbers using <, >, >= and <=
x < y (or x >= y, or whatever, it doesn't matter) will return true if it's true or false if it's false
so you can use them in if statements
if (10 > 20) {
// this never happens, because the above is false
console.log("bar");
}
if (10 <= 20) {
// this will happen because the above is true
console.log("foo");
}
Mike R
@mikeinmiami
Aug 16 2016 03:02
@llamatarianism yea but i got use greater than twice
llamatarianism
@llamatarianism
Aug 16 2016 03:02
the above code will only output "foo"
@mikeinmiami so?
Stephen James
@sjames1958gm
Aug 16 2016 03:02
@NDNTruong You need case 7 for the Ate Nine your default should return ""
Mike R
@mikeinmiami
Aug 16 2016 03:03

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

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

return "10 or Under";
}

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

llamatarianism
@llamatarianism
Aug 16 2016 03:04
so just compare it 100
then compare it to 10
I don't see the issue
Mike R
@mikeinmiami
Aug 16 2016 03:04
how would i be able to get 10 or under and over 10 at the same time
llamatarianism
@llamatarianism
Aug 16 2016 03:04
you don't
that's not possible
keep in mind that return ends the execution of a function
function foo(x) {
if (x === 6) {
return "bar";
}
// this part will never be reached if x is equal to 6, because the return will make cause the function to be exited.
return "baz";
}
console.log(foo(6)); // baz
console.log(foo(5)); // bar
Mike R
@mikeinmiami
Aug 16 2016 03:07
@llamatarianism I still don't get what they ask for. I keep checking 1 of the tasks off and then the other becomes an x
It's getting me confused
llamatarianism
@llamatarianism
Aug 16 2016 03:08
@mikeinmiami in the first if statement
Myles Chatman
@myleschatman
Aug 16 2016 03:08
@mikeinmiami add the values in the if statements
llamatarianism
@llamatarianism
Aug 16 2016 03:08
you have to check if val is greater than 100
in the second one, you have to check if it's greater than 10
Mike R
@mikeinmiami
Aug 16 2016 03:09
if the first if statement doesn't return it goes past the next if statement to the last return correct?
Myles Chatman
@myleschatman
Aug 16 2016 03:10
more like if the if statement isn't true
but you have the right idea.
Mike R
@mikeinmiami
Aug 16 2016 03:11

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

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

return "10 or Under";
}

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

If you add val > 11 on the first if it should return 10 or under correct?
if you add val > 9 on the second if statement it should be over 10?
Myles Chatman
@myleschatman
Aug 16 2016 03:14
no it won't return 10 because 10 > 11 is false so it will move on to the next if statment
Bri
@brishirley
Aug 16 2016 03:14
Hi there! So I am running into a Uncaught ReferenceError: todoList is not defined in my code for a ToDoList project I want to add to my portfolio. I am not sure what is causing it in the console... What's odd is I ran into the issue in Brackets, but when I put it into Codepen it seems to at least give me values now. var todoList = {
todos: ['item 1', 'item 2', 'item 3'],
displayTodos: function() {
console.log('My Todos:', this.todos);
},
this.todos.push(todo);
this.displayTodos();
},
changeTodo: function(position, newValue) {
this.todos[position] = newValue;
this.displayTodos();
},
deleteTodo: function(position) {
this.todos.splice(positon, 1);
this.displayTodos();
}
};
Myles Chatman
@myleschatman
Aug 16 2016 03:14
same thing for the second if statement 9 > 10 is false so the program will return "10 or Under"
Mike R
@mikeinmiami
Aug 16 2016 03:16
@myleschatman Yeah and I get that but I still can't pass the darn tasks
testGreaterThan(0) should return "10 or Under"
testGreaterThan(10) should return "10 or Under"
testGreaterThan(11) should return "Over 10"
testGreaterThan(99) should return "Over 10"
testGreaterThan(100) should return "Over 10"
testGreaterThan(101) should return "Over 100"
testGreaterThan(150) should return "Over 100"
You should use the > operator at least twice
I can check mark every single 1 of those but I can't check mark all of them together lol
It's either or
unless I add a return line to the first if statement which I doubt it will let me do
Myles Chatman
@myleschatman
Aug 16 2016 03:18
no worries! so the string being returned in the first if statement is "100" and for the second is "10"
so use those values in your if statements
Mike R
@mikeinmiami
Aug 16 2016 03:20
@myleschatman What? that didn't make any sense. Why did it work? wth
Ryan
@RyanLongVA
Aug 16 2016 03:21
help on disabling notifications on just this chatroom?
CamperBot
@camperbot
Aug 16 2016 03:21
no wiki entry for: on disabling notifications on just this chatroom
Ryan Guthrie
@DiogenestheDog
Aug 16 2016 03:22
@brishirely where are you calling it
Ryan
@RyanLongVA
Aug 16 2016 03:22
someone tell me how to disable notifications for a single room please xD
Bri
@brishirley
Aug 16 2016 03:22
in the console, i'm writing todoList.displayTodos();
Mike R
@mikeinmiami
Aug 16 2016 03:23
settings
Bri
@brishirley
Aug 16 2016 03:23
@DiogenestheDog
Mike R
@mikeinmiami
Aug 16 2016 03:23
@myleschatman could you please explain why that worked?
Ryan
@RyanLongVA
Aug 16 2016 03:23
thanks @mikeinmiami
CamperBot
@camperbot
Aug 16 2016 03:23
ryantlong sends brownie points to @mikeinmiami :sparkles: :thumbsup: :sparkles:
Ryan
@RyanLongVA
Aug 16 2016 03:24
Myles Chatman
@myleschatman
Aug 16 2016 03:24
@mikeinmiami yeah sure
the value 10 is being passed in to the function testGreaterThan(val)
so val = 10
Jaren Escueta
@jarenescueta731
Aug 16 2016 03:26
@brishirely which value are you getting as undefined? this is what i get:
http://jsbin.com/gupecujefi/edit?js,console
Myles Chatman
@myleschatman
Aug 16 2016 03:26
if (10 > 100), 10 is not greater than 100 so we pass over that if statement, if (10 > 10), well 10 isn't greater than itself, it is equal to itself so we also pass over that, so the program returns "10 or under" does that make sense?
Jaren Escueta
@jarenescueta731
Aug 16 2016 03:26
@brishirely "My Todos:"
["item 1", "item 2", "item 3"]
zacharydylan
@zacharydylan
Aug 16 2016 03:28
@abohay I think a loop is in order for this challenge. And no need to turn the strings in to arrays, you can loop through them as is. Have you tried logging any of your variables to the console? They will show that you end up with one string compare against, which would always return true were you looping through as opposed to comparing the first and second value of your new string each time your function is called.
Bri
@brishirley
Aug 16 2016 03:29
in codepen.io it works. it's in brackets that I was getting the error. I was trying to run todoList.displayTodos(); and was getting "Uncaught referenceerror: todoList is not defined. at <anonymous>:2:1 @jarenescueta731
Mike R
@mikeinmiami
Aug 16 2016 03:29
@myleschatman Aww man, so by using val = 10 all I had to do is get all of the if statements to be 10 or under? Man! I'm very upset at my self right now lol
@myleschatman But you know what, how come other integers don't work?
it has to be 100 and 10
@cjpowellaz
Aug 16 2016 03:31
Help Return Largest Numbers in Arrays
CamperBot
@camperbot
Aug 16 2016 03:31

# Algorithm Return largest Numbers in Arrays

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

### :checkered_flag: Problem Explanation:

You will get an array that contains sub arrays of numbers and you need to return an array with the largest number from each of the sub arrays.

Myles Chatman
@myleschatman
Aug 16 2016 03:32
@mikeinmiami it doesn't pass in freecodecamp because i their test is looking for you to actually use the values 100 and 10 to pass the test. the challenge is greater than 100 or 10 so use have to use those values to pass.
believe*
Jaren Escueta
@jarenescueta731
Aug 16 2016 03:33
@cjpowellaz try out using Math.max.apply(Math, array);
it's part of a js math library and it returns the largest number in array
Mike R
@mikeinmiami
Aug 16 2016 03:33
@myleschatman Got it, thanks man
CamperBot
@camperbot
Aug 16 2016 03:33
mikeinmiami sends brownie points to @myleschatman :sparkles: :thumbsup: :sparkles:
Mike R
@mikeinmiami
Aug 16 2016 03:33
appreciate it
Myles Chatman
@myleschatman
Aug 16 2016 03:33
np!
@cjpowellaz
Aug 16 2016 03:33
thank you @jarenescueta731
CamperBot
@camperbot
Aug 16 2016 03:33
cjpowellaz sends brownie points to @jarenescueta731 :sparkles: :thumbsup: :sparkles:
llamatarianism
@llamatarianism
Aug 16 2016 03:34
@jarenescueta731 Math.max.apply isn't a special feature of the Math object
it's a method of all functions
function foo(x, y, z) {
return x * y / z;
}

console.log(foo.apply(this, [2, 3, 4]));
// => 1.5
ahmed abouhay
@abohay
Aug 16 2016 03:36
@zacharydylan thanks
CamperBot
@camperbot
Aug 16 2016 03:36
abohay sends brownie points to @zacharydylan :sparkles: :thumbsup: :sparkles:
Sekharan Natarajan
@mnsekh111
Aug 16 2016 03:37

document.getElementById("hfimage").src = "servlet/ValServlet1?"

The image from the servlet (Response content type : image/png) is getting loaded into the image tag. Is there any way I can capture the response? as I want to analyse the headers.

zacharydylan
@zacharydylan
Aug 16 2016 03:37
@abohay No problem. You got the algorithm solved?
Jaren Escueta
@jarenescueta731
Aug 16 2016 03:40
@llamatarianism i don't think i said apply is exclusive to the Math object
fyi
llamatarianism
@llamatarianism
Aug 16 2016 03:40
it's part of a js math library and it returns the largest number in array
of course you didn't literally state it
but it was implied
Jaren Escueta
@jarenescueta731
Aug 16 2016 03:41
@llamatarianism sure
luis4flames
@luis4flames
Aug 16 2016 03:50

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

var fName = "firstName";
var lName = "lastName";
var numb = "number";
var like = "likes";
for ( var i =0; i < contacts.length; i++) {
if ( firstName == contacts[i][fName]) {
if (prop == contacts[i].lName) {
return contacts[i].lName;
} else if ( prop == contacts[i].numb) {
return contacts[i].num;
} else if (prop == contacts[i][like]) {

  }
else {
return "No such property";
}
}
else {
return "No such contact";
}

}

}
will the return within my if statements make the for loop terminate after the first loop?

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

var fName = "firstName";
var lName = "lastName";
var numb = "number";
var like = "likes";
for ( var i =0; i < contacts.length; i++) {
if ( firstName == contacts[i][fName]) {
if (prop == contacts[i].lName) {
return contacts[i].lName;
} else if ( prop == contacts[i].numb) {
return contacts[i].num;
} else if (prop == contacts[i][like]) {

  }
else {
return "No such property";
}
}
else {
return "No such contact";
}

}

// Only change code above this line
}

sorry for the junk not sure why it only does that part
llamatarianism
@llamatarianism
Aug 16 2016 03:52
it highlights that bit because it's indented 4 spaces or more
it doesn't indent the rest because you need newlines around your backticks

like so

Gyeognphil Choi
@creativeworkers10
Aug 16 2016 03:53
hi guys! I am at the challenge: Record Collection,

function updateRecords(id, prop, value) {
if (id === 5439){
var a4 = 5439;
collection[a4].artist = "ABBA";
collection[a4].tracks = ["Lay all your love on me","Gimme Gimme Gimme","Take a Chance on Me"];
} else if (id ===2548){
var a3 = 2548;
delete collection[a3].artist;
delete collection[a3].tracks;
} else if (id === 1245){
var a2 = 1245;
collection[a2].tracks = ["something","you","I love you", "Addicted to Love"];
}

return collection;
}

I did this and it worked, but I don't think this is the good answer. any suggestions?
js
function updateRecords(id, prop, value) {
if (id === 5439){
var a4 = 5439;
collection[a4].artist = "ABBA";
collection[a4].tracks = ["Lay all your love on me","Gimme Gimme Gimme","Take a Chance on Me"];
} else if (id ===2548){
var a3 = 2548;
delete collection[a3].artist;
delete collection[a3].tracks;
} else if (id === 1245){
var a2 = 1245;
collection[a2].tracks = ["something","you","I love you", "Addicted to Love"];
}

return collection;
}
I did this and it worked, but I don't think this is the good answer. any suggestions?**
llamatarianism
@llamatarianism
Aug 16 2016 03:56
yeah you hardcoded a bunch of stuff
that's not what you're supposed to do
what if I did
luis4flames
@luis4flames
Aug 16 2016 03:56
function lookUpProfile(firstName, prop){
// Only change code below this line

var fName = "firstName";
var lName = "lastName";
var numb = "number";
var like = "likes";
for ( var i =0; i < contacts.length; i++) {
if ( firstName == contacts[i][fName]) {
if (prop == contacts[i].lName) {
return contacts[i].lName;
} else if ( prop == contacts[i].numb) {
return contacts[i].num;
} else if (prop == contacts[i][like]) {

}
else {
return "No such property";
}
}
else {
return "No such contact";
}
}

// Only change code above this line
}
llamatarianism
@llamatarianism
Aug 16 2016 03:57
updateRecords(5439, "tracks", "Dancing Queen");
luis4flames
@luis4flames
Aug 16 2016 03:57
will the return in my if statements stop the loop?
llamatarianism
@llamatarianism
Aug 16 2016 03:57
you wouldn't end up actually adding "Dancing Queen" to the array
@luis4flames yes
@creativeworkers10 don't hardcode stuff like that
Gyeognphil Choi
@creativeworkers10
Aug 16 2016 03:57
@llamatarianism Okay. Thanks for the advice!
CamperBot
@camperbot
Aug 16 2016 03:57
:star2: 1200 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
luis4flames
@luis4flames
Aug 16 2016 03:57
how would I return something then without it terminating?
CamperBot
@camperbot
Aug 16 2016 03:57
creativeworkers10 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
llamatarianism
@llamatarianism
Aug 16 2016 03:58
@luis4flames you can't
Joseph
@revisualize
Aug 16 2016 03:58
@llamatarianism 1200! Congrats!
luis4flames
@luis4flames
Aug 16 2016 04:01
@revisualize makes sense, Thanks again!
CamperBot
@camperbot
Aug 16 2016 04:01
luis4flames sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1640 | @revisualize |http://www.freecodecamp.com/revisualize
Michael
@davidfutch
Aug 16 2016 04:01

Looking to see how I could have written the code better with the javascript blackjack exercisevar count = 0;

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

switch(true) {
case card < 7:
++count;
break;

case (card > 6 && card < 10):
count = count;
break;

}

switch (card) {
case 10:
--count;
break;

case 'J':
--count;
break;

case 'Q':
--count;
break;

case 'K':
--count;
break;

case 'A':
--count;
break;

}

switch (count){
case -5:
exit = "-5 Hold";
break;

case -1:
exit = "-1 Hold";
break;

case 0:
exit = "0 Hold";
break;

case 1:
exit = "1 Bet";
break;

case 5:
exit = "5 Bet";
break;

}

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

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Reyner
@ReynerAL
Aug 16 2016 04:07
@davidfutch Hello, I just did this excersice,
I do think that you can just write something like this?
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
Toyco
@Toyco
Aug 16 2016 04:09
I'm confused on how this works..

var myVar = 87;

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

why does myVar++1; come up with a syntaax error
Michael
@davidfutch
Aug 16 2016 04:10
toyco, only need the myVar++ to increment by 1
Myles Chatman
@myleschatman
Aug 16 2016 04:10
@toyco that is incorrect syntax
Reyner
@ReynerAL
Aug 16 2016 04:10
@Toyco you don't need to add 1 behind to increment the number
Myles Chatman
@myleschatman
Aug 16 2016 04:10
myVar++;
Reyner
@ReynerAL
Aug 16 2016 04:10

@davidfutch
well here is my code..

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 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
break;
}

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

// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Toyco
@Toyco
Aug 16 2016 04:11
oh so ++ is only for x + 1?
and can't be changed in value from 1?
Myles Chatman
@myleschatman
Aug 16 2016 04:11
++ is like x = x + 1
Toyco
@Toyco
Aug 16 2016 04:11
how would I change it to a different value other than 1 using ++?
would I go myVar++13048?
or does it only work for the value 1
Myles Chatman
@myleschatman
Aug 16 2016 04:12
myVar+=2
Toyco
@Toyco
Aug 16 2016 04:12
ok thanks
Michael
@davidfutch
Aug 16 2016 04:12
myVar = myVar + num;
luis4flames
@luis4flames
Aug 16 2016 04:15
so im a little confused as to when I should use the dot method over the bracket method to access data within a JSON Object. From what I can read the bracket method is basiclly when its a string with a space youre accessing? Can anyone clarify
Lokendra Puri
@lokenpuri
Aug 16 2016 04:18
hello
anyone there
zacharydylan
@zacharydylan
Aug 16 2016 04:23
@luis4flames you also use bracket notation when you want to access properties with variables (such as accessing properties with a loop).
Aug 16 2016 04:24
guys can someone help me with profile lookup challenge ?
pls
i need some hints
yes @lokenpuri
@luis4flames u use the bracket method when
1- your property has spaces in it
2- it is a number
3- ur passing property as another variable
Brandon
@Brandons42
Aug 16 2016 04:27
function convertHTML(str) {
// &colon;&rpar;
//Can someone help me with
//what I'm doing wrong here?
//The challenge name is
//Convert HTML Entities.
var arr = str.split("");
for (q = 0; q < arr.length; q++) {
if (arr[q] == "&") {
arr[q] = "&amp;";
} else if (arr[q] == "<") {
arr[q] = "&lt";
} else if (arr[q] == ">") {
arr[q] = "&gt";
} else if (arr[q] == "\"") {
arr[q] = "&quot";
} else if (arr[q] == "'") {
arr[q] = "&apos";
}
}
arr.join("");
return str;
}
Sorin Ruse
@sorinr
Aug 16 2016 04:28
@Brandons42 if you want to split the str by a space then: str.split(" ") not str.split("")
Ryan
@RyanLongVA
Aug 16 2016 04:29
that point in the night when you're coding and can't remember basic english
Brandon
@Brandons42
Aug 16 2016 04:29
I don't want to split it by a space, but thanks anyways @sorinr
CamperBot
@camperbot
Aug 16 2016 04:29
brandons42 sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
NixonRichard
@NixonRichard
Aug 16 2016 04:30
i feel the stuck
codepen.io/Ayanami_Rei/pen/pbGxKk
any one know why this pen doesnt work ?
pahosler
@pahosler
Aug 16 2016 04:32
@Brandons42 you'll want to use regex and replace for that exercise
Zach4531
@Zach4531
Aug 16 2016 04:33
can any one help me?
@cjpowellaz
Aug 16 2016 04:33
Working on "Return Largest Numbers in Arrays", so far am I on the right track to iterate through the arrays?

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

for (var x = 0; x < arr.length; x++) {
for (var y = 0; y < arr[x].length; y++)
}
}
return newArray;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

Aug 16 2016 04:34
guys anyone here can please give me some tips of the problem of profile-lookUP from javascript?
@cjpowellaz
Aug 16 2016 04:34
I know this will only return 0, I just want to know if I am started correctly
luis4flames
@luis4flames
Aug 16 2016 04:36
@cjpowellaz not sure about the entire thing, but you're missing an opening bracket after the second for statement
pahosler
@pahosler
Aug 16 2016 04:36
@cjpowellaz foreach and Math.max will make this challenge much easier to solve...
Brandon
@Brandons42
Aug 16 2016 04:37
@pahosler I actually just finished it without regex and replace, but thanks anyways
CamperBot
@camperbot
Aug 16 2016 04:37
brandons42 sends brownie points to @pahosler :sparkles: :thumbsup: :sparkles:
@cjpowellaz
Aug 16 2016 04:37
ok, will look those up, thanks @pahosler
CamperBot
@camperbot
Aug 16 2016 04:37
cjpowellaz sends brownie points to @pahosler :sparkles: :thumbsup: :sparkles:
@cjpowellaz
Aug 16 2016 04:38
is the "for" loop still necessary if using foreach and math.max?
pahosler
@pahosler
Aug 16 2016 04:39
@Brandons42 you can do it in three lines of code only one foreach...
@cjpowellaz
llamatarianism
@llamatarianism
Aug 16 2016 04:40
you can do it in one loc if you're a wizard
pahosler
@pahosler
Aug 16 2016 04:40
probably
but still an apprentice myself :D
llamatarianism
@llamatarianism
Aug 16 2016 04:40
although I suppose technically
foo(); bar(); baz = qux;
is all one line
pahosler
@pahosler
Aug 16 2016 04:41
LOL true...
llamatarianism
@llamatarianism
Aug 16 2016 04:41
so really your entire program could be one line :D
Aug 16 2016 04:41
luis4flames
@luis4flames
Aug 16 2016 04:41
function lookUpProfile(firstName, prop){
// Only change code below this line

var fName = "firstName";
var lName = "lastName";
var numb = "number";
var like = "likes";
var restult;
for ( var i =0; i < contacts.length; i++) {
if ( firstName == contacts[i][fName] ) {
if (prop == contacts[i][lName]) {
result = contacts[i][lName];
} else if ( prop == contacts[i][numb]) {
result = contacts[i][numb];
} else if (prop === contacts[i][like]) {
result = contacts[i][like];
}
else {
result = "No such property";
}
}
else {
result = "No such contact";
}
}

return result;
// Only change code above this line
}
Can anyone see why this wouldnt work when function is looking up from a json object with multiple arrays within
NixonRichard
@NixonRichard
Aug 16 2016 04:42
okay
pahosler
@pahosler
Aug 16 2016 04:42
Brandon
@Brandons42
Aug 16 2016 04:42
Restult
luis4flames
@luis4flames
Aug 16 2016 04:43
ahh still didnt work out. got excited for a second
pahosler
@pahosler
Aug 16 2016 04:43
This message was deleted
Heemama
@heemama
Aug 16 2016 04:45
Hi!
Brandon
@Brandons42
Aug 16 2016 04:45
Which cases are checked and exed out? @luis4flames
Hi, @heemama
Heemama
@heemama
Aug 16 2016 04:45
I have a dumb question .. I'm not a native speaker so I think I don't understand this question :) ..
var ourDecimal = 5.7;
Brandon
@Brandons42
Aug 16 2016 04:45
Heemama
@heemama
Aug 16 2016 04:45
Create a variable myDecimal and give it a decimal value with a fractional part (e.g. 5.7).
luis4flames
@luis4flames
Aug 16 2016 04:46
the only one working out is when it reaches "no such contact" all other dont execute correctly.
pahosler
@pahosler
Aug 16 2016 04:46
the if / else if/ else should look like this...
if ( condition) {
do stuff;
} else if (some other condition) {
do this stuff;
} else {
}
luis4flames
@luis4flames
Aug 16 2016 04:46
it goes through matching the name okay, but not the property
Chris Cullen
@123xylem
Aug 16 2016 04:46

@123xylem

for(j=1;j<arr.length;j++){
arr[j]+=arr[j-1];
if(arr[j]==arg){
indAr.push(j);
console.log(arr[j], arr[j-1]);
}
else return "nope";

Hi
Why doesnt this return arr[j]? if i console.log it arr[j] does at some point = arg so at that ponit it should do what i wanted, or is it that the for loop keeps going until completion then says it failed?

Heemama
@heemama
Aug 16 2016 04:46
Thanks @Brandons42 ! My native language is Korean and also Japanese :)
CamperBot
@camperbot
Aug 16 2016 04:46
heemama sends brownie points to @brandons42 :sparkles: :thumbsup: :sparkles:
Heemama
@heemama
Aug 16 2016 04:47
But anyways.. the question is about "Create a variable myDecimal and give it a decimal value with a fractional part (e.g. 5.7)."

var ourDecimal = 5.7;

ourDecimal = 5.3;

and this failed
ShaneBenj317
@ShaneBenj317
Aug 16 2016 04:47
Hey guys! I'm stumped on "Iterate Through an Array with a For Loop". Here is my code:
Brandon
@Brandons42
Aug 16 2016 04:47
What's the challenge name? @heemama
ShaneBenj317
@ShaneBenj317
Aug 16 2016 04:47

var myArr = [ 2, 3, 4, 5, 6];
var myTotal = 0;
// Only change code below this line

for (var i = 0; i < myArr.length; i++){
total += myArr[i];
}

Any help would be greatly appricated!
pahosler
@pahosler
Aug 16 2016 04:48
@luis4flames it may almost work, but it doesn't, it will help if you organize your code and give it some coherent structure, it will make your issue easy to fix
Heemama
@heemama
Aug 16 2016 04:48
@Brandons42 : Create Decimal Numbers with JavaScript
llamatarianism
@llamatarianism
Aug 16 2016 04:48
@heemama you reassigned to ourDecimal
luis4flames
@luis4flames
Aug 16 2016 04:48
@pahosler it is? checks a different property in every else if and sets result to a certain value every time.
llamatarianism
@llamatarianism
Aug 16 2016 04:48
Create a variable myDecimal
do that ^
Aug 16 2016 04:48
'<div class="content" onclick = "location.href = \'http://en.wikipedia.org/?curid=\' + temp[i]" style="cursor:pointer">' ->>> I need to put the value of temp[i] inside that div string thing... can anyone help? Please.
Aug 16 2016 04:49
@ShaneBenj317
Heemama
@heemama
Aug 16 2016 04:49
Yes it already existed >>>> var ourDecimal = 5.7;
luis4flames
@luis4flames
Aug 16 2016 04:49
@pahosler How should I go about cleaning it up? dont want to get use to bad habits
Aug 16 2016 04:49
its myTotal and not total
total += myArr[i];
luis4flames
@luis4flames
Aug 16 2016 04:49
@pahosler Thanks by the way!
CamperBot
@camperbot
Aug 16 2016 04:49
luis4flames sends brownie points to @pahosler :sparkles: :thumbsup: :sparkles:
Brandon
@Brandons42
Aug 16 2016 04:49
@heemama Your English is fine, I didn't understantd it at first either, all it's say is, as @llamatarianism said, creat a variable called myDecimal whose value is 5.7.
Aug 16 2016 04:49
change this to myTotal+=myArr[i];
@ShaneBenj317
pahosler
@pahosler
Aug 16 2016 04:49
:point_up:
Heemama
@heemama
Aug 16 2016 04:51
Thanks @Brandons42 :) but the black board on the right side of the tutorial already has the declaration and initialized the number (5.7) and THEN the instruction is asking " Create a variable myDecimal and give it a decimal value with a fractional part (e.g. 5.7)."
CamperBot
@camperbot
Aug 16 2016 04:51
heemama sends brownie points to @brandons42 :sparkles: :thumbsup: :sparkles:
:warning: heemama already gave brandons42 points
ShaneBenj317
@ShaneBenj317
Aug 16 2016 04:52
Just tried that. It's still coming up with the error "total should equal 20"
@cjpowellaz
Aug 16 2016 04:52
I can't find anything that makes sense on how to use foreach and Math.max, any good references?
Chris Cullen
@123xylem
Aug 16 2016 04:52
for(j=1;j<arr.length;j++){
arr[j]+=arr[j-1];        console.log(arr[j], arr[j-1]);
}if(arr[j]==7){return "done";}
else return 'd';
The console.log shows 7 but it still doesnt execute the if statement! How come??!
pahosler
@pahosler
Aug 16 2016 04:52
@luis4flames I'm trying to find a good example for you, but I don't always write pretty code either LOL
luis4flames
@luis4flames
Aug 16 2016 04:53
Haha no worries any sort of general tips will be fine. Im over here thinking i was pretty organized lol @pahosler
pahosler
@pahosler
Aug 16 2016 04:57
@cjpowellaz that exercise came right after a using while challenge, it's a little easier to solve it with while....
ooops I meant @luis4flames sorry @cjpowellaz
@luis4flames partial example...
function lookUpProfile(firstName, prop){
// Only change code below this line
var i = 0;
while (i < contacts.length) {
if (contacts[i].firstName !== firstName) {
++i;
} else {
// check property
if(! contacts[i].hasOwnProperty(prop)) {
return "No such property";
and I could probably write it MUCH better now
Mostafa Syam
@pro-mos
Aug 16 2016 05:01
@123xylem post the whole code
pahosler
@pahosler
Aug 16 2016 05:02
@cjpowellaz mdn has the info you are looking for...
so does my github ;)
Mostafa Syam
@pro-mos
Aug 16 2016 05:03
@123xylem your if statement should be inside the loop;
Chris Cullen
@123xylem
Aug 16 2016 05:04
@pro-mos
function pairwise(arr, arg) {

var    indices=[];
for(i=0;i<arr.length;i++){//Here we have array of indices to use
indices.push(i);
}

var indAr=[];
var count= 0;
for(j=1;j<arr.length;j++){
arr[j]+=arr[j-1];
if(arr[j]==arg){
indAr.push(j);
console.log(arr[j], arr[j-1]);
return "d";
}
else return "nope";}}

pairwise([1,4,2,3,0,5], 7);
pahosler
@pahosler
Aug 16 2016 05:04
@123xylem why? because of scope...
luis4flames
@luis4flames
Aug 16 2016 05:04
ohh nice! Didnt think of it that way. I just need one more if statement to match the property right? @pahosler
Chris Cullen
@123xylem
Aug 16 2016 05:04
@pahosler @pro-mos it still doesnt work with if in the {}
pahosler
@pahosler
Aug 16 2016 05:05
@luis4flames hmmm...
Joseph
@revisualize
Aug 16 2016 05:05
39 lines total. They're really helpful.
pahosler
@pahosler
Aug 16 2016 05:06
@123xylem I just finished pairwise today, that was a tuffy
Mostafa Syam
@pro-mos
Aug 16 2016 05:06
@123xylem try to place it before the arr[j] += .... because arr[j] would never be 7 if it's gettin changed before tested
pahosler
@pahosler
Aug 16 2016 05:06
I used reduce for my solution...
reduce is the shizzzz
@123xylem let me know when you've solved it and I'll share my code...
luis4flames
@luis4flames
Aug 16 2016 05:07
@revisualize defnitely huge help! Thanks. I followed that structure Just my code isnt matching with the property for some reason, but it will for matching the name.
CamperBot
@camperbot
Aug 16 2016 05:07
luis4flames sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1643 | @revisualize |http://www.freecodecamp.com/revisualize
luis4flames
@luis4flames
Aug 16 2016 05:08
function lookUpProfile(firstName, prop){
// Only change code below this line

var fName = "firstName";
var lName = "lastName";
var numb = "number";
var like = "likes";
var result;
for ( var i =0; i < contacts.length; i++) {
if ( firstName == contacts[i][fName] ) {
if (prop == contacts[i][lName]) {
result = contacts[i][lName];
} else if ( prop == contacts[i][numb]) {
result = contacts[i][numb];
} else if (prop == contacts[i][like]) {
result = contacts[i][like];
}
else {
result = "No such property";
}
}
else {
result = "No such contact";
}
}

return contacts[3][lName];
// Only change code above this line
}
ignore that last return I was just testing the format of how I was reaching the values
should be return result;
Chris Cullen
@123xylem
Aug 16 2016 05:09
@pro-mos hmmok il try that
Joseph
@revisualize
Aug 16 2016 05:09

@luis4flames This:

  var fName = "firstName";
var lName = "lastName";
var numb = "number";
var like = "likes";
var result;

is all junk

@luis4flames Look at my Gist again. There are comments as well.
luis4flames
@luis4flames
Aug 16 2016 05:09
yea noticed that after reading it
i could just use .lastName etc
Joseph
@revisualize
Aug 16 2016 05:10
anyhow, I need to get to bed.
@luis4flames You need to use .hasOwnProperty()
Chris Cullen
@123xylem
Aug 16 2016 05:14
for(j=1;j<arr.length;j++){
if(arr[j]==arg){
indAr.push(j);
console.log(arr[j], arr[j-1]);
arr[j]+=arr[j-1];

return "d";
}
else return "nope";}}
Still nope
@pro-mos
Im kind of lost what to do . really dont want to look at the answer but I cant figure out this easy for loop nevermind the whole task
Mostafa Syam
@pro-mos
Aug 16 2016 05:15
@123xylem do you know you have unclosed curly braces else {}
pahosler
@pahosler
Aug 16 2016 05:16
help pairwise
CamperBot
@camperbot
Aug 16 2016 05:16

# Algorithm Pairwise

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

### :checkered_flag: Problem Explanation:

The program should look for pairs of numbers in the array whose sum equal the second argument arg. Then instead of adding those numbers up, their indices are to be added.

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.

Rey Winters
@reywinters03
Aug 16 2016 05:16
hi all .. could i bother anyone for javascript testing advice
pahosler
@pahosler
Aug 16 2016 05:16
@123xylem don't look at the spoiler but there is awesome help!
Chris Cullen
@123xylem
Aug 16 2016 05:17
@pahosler ive read the comments on the help answers.. but they use forloops... Im trying something similar but cant get them to work
@pro-mos yea still no change
NixonRichard
@NixonRichard
Aug 16 2016 05:17
Mostafa Syam
@pro-mos
Aug 16 2016 05:17
@123xylem well i can't do much help as i didn't reach pairwise yet, i was commenting at (if arrJ = 7) thing.
NixonRichard
@NixonRichard
Aug 16 2016 05:17
hi all i got this returns data in json format
how to fix thatr
Mostafa Syam
@pro-mos
Aug 16 2016 05:17
btw what is the value of arg?
NixonRichard
@NixonRichard
Aug 16 2016 05:17
pahosler
@pahosler
Aug 16 2016 05:18
 I didn't use any for loops
Chris Cullen
@123xylem
Aug 16 2016 05:18

var indAr=[];
var count= 0;
for(j=1;j<arr.length;j++){
arr[j]+=arr[j-1];}
console.log(arr[j]);
while(arr[j]<arg){
indAr.push(i);
}

}
This also doesnt work
pahosler
@pahosler
Aug 16 2016 05:18
weird
Chris Cullen
@123xylem
Aug 16 2016 05:18
@pahosler Yea I tried reduce but Couldnt think of how to use it
pahosler
@pahosler
Aug 16 2016 05:18
I did nest two reduce(s)
help reduce
CamperBot
@camperbot
Aug 16 2016 05:18

# Challenge Condense Arrays with Reduce

Reduce can be useful for condensing an array of numbers into one value.

var array = [4,5,6,7,8];
var singleVal = 0;
// Only change code below this line.

var singleVal = array.reduce(function(previousVal, currentVal){

return previousVal+currentVal;

});
pahosler
@pahosler
Aug 16 2016 05:19
Mostafa Syam
@pro-mos
Aug 16 2016 05:19
@NixonRichard you need to make html elements for each entry in the returned json data and display on page
pahosler
@pahosler
Aug 16 2016 05:19
I was struggling heroically trying to figure it out
after readin for about 10 mins it freaking clicked like a bolt of lightning
:point_up: that is not the right article though
@123xylem let me see if I can track it down again
Chris Cullen
@123xylem
Aug 16 2016 05:23
@pahosler thanks
CamperBot
@camperbot
Aug 16 2016 05:23
123xylem sends brownie points to @pahosler :sparkles: :thumbsup: :sparkles:
@cjpowellaz
Aug 16 2016 05:24
am I any closer with the Return Largest Number in Arrays?

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

for (var x = 0; x < arr.length; x++) {

newArray = Math.max.apply(Math, arr[x]);
}

return newArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

I know I keep assigning the highest number in each array to newArray, but I don't know how to get it out. Tries using Push but I can't seem to get it right.
Rey Winters
@reywinters03
Aug 16 2016 05:26
can i just paste random code in here and ask for help?
not sure of the protocol ...
or just ignore me ... it's okay ... i'll cry in the corner
it is rather early anyways
Daniel Garcia
@Atl151
Aug 16 2016 05:28
Hi, guys. I'm trying to complete the Seek and Destroy challenge, but I'm not sure how to use the filter funtion with the arguments objet. Any help?
Dan Couper
@DanCouper
Aug 16 2016 05:29
@123xylem been a while since I did this, but recursion makes it a lot easier, though what you're trying to do should work the same way. This is going from memory, but I added two arguments to the function - a counter and an accumulator , same as you have. Then go through the array. Each recursion checks the start (head) value. Push the indices if a pair is found in the rest of the array. Then run the function again with the rest of the array, and keep doing that until there are only two values. Check those, return the accumulator. The key thing is that values cannot be reused, so if a pair is found, replace the match with the value + 1, which means it can never match again.
pahosler
@pahosler
Aug 16 2016 05:29
friscodisco
@friscodisco
Aug 16 2016 05:29
@reywinters03 just paste and ask we all cry
Rey Winters
@reywinters03
Aug 16 2016 05:29
was wondering how to test this thing
friscodisco
@friscodisco
Aug 16 2016 05:30
@reywinters03 what challenge is this from
Rey Winters
@reywinters03
Aug 16 2016 05:30
nothing :( ... was talking to a friend and he said that i shouldn't use internal variables for testing purposes
i disagreed ... we came up with this code
pahosler
@pahosler
Aug 16 2016 05:31
@123xylem I have an index[] that I push the index pairs to, then I check to make sure I haven't already pushed them to the index array
@reywinters03 you need commas after one and two instead of ;
Rey Winters
@reywinters03
Aug 16 2016 05:33
i told him we can call X.A('tsetse') and assert that result to X.one which should be equaled to {"testme" : "bar"}
This message was deleted
Jaren Escueta
@jarenescueta731
Aug 16 2016 05:33
@cjpowellaz try using push again, and post your code
pahosler
@pahosler
Aug 16 2016 05:34
X.one will return object
Rey Winters
@reywinters03
Aug 16 2016 05:35
updated with ,
Chris Cullen
@123xylem
Aug 16 2016 05:36
@pahosler thanks ive read that already but il give it another go
CamperBot
@camperbot
Aug 16 2016 05:36
123xylem sends brownie points to @pahosler :sparkles: :thumbsup: :sparkles:
:warning: 123xylem already gave pahosler points
pahosler
@pahosler
Aug 16 2016 05:36
yeah, it should be... @reywinters03 if I'm reading it correctly
Rey Winters
@reywinters03
Aug 16 2016 05:37
edited so the sentence reads a bit better
(i hope)
pahosler
@pahosler
Aug 16 2016 05:37
yup
friscodisco
@friscodisco
Aug 16 2016 05:38
@reywinters03 I played with it but can't seem to make it work seems like a mix of a few languages...if your friend is a cat like me you can check this out http://jsforcats.com
Rey Winters
@reywinters03
Aug 16 2016 05:38
i'm wondering if that's a good test or not. my friend said it was useless. said just test that it doesn't have an error and return undefined
@cjpowellaz
Aug 16 2016 05:38
I am not sure how to use it, but here is bad attempt:

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

for (var x = 0; x < arr.length; x++) {
newArray = Math.max.apply(Math, arr[x]);
newArray.push(arr[x]);

  }

return newArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

Rey Winters
@reywinters03
Aug 16 2016 05:38
thanks @friscodisco
CamperBot
@camperbot
Aug 16 2016 05:38
reywinters03 sends brownie points to @friscodisco :sparkles: :thumbsup: :sparkles:
Rey Winters
@reywinters03
Aug 16 2016 05:39
thanks for listening too @pahosler
CamperBot
@camperbot
Aug 16 2016 05:39
reywinters03 sends brownie points to @pahosler :sparkles: :thumbsup: :sparkles:
Dan Couper
@DanCouper
Aug 16 2016 05:39
@Atl151 the arguments object is a bit like an array, but not quite. filter works on arrays. So you need to turn arguments into an array. const myArgs = Array.from(arguments) will work. Also, altering the function arguments to something like myFunction(...args) {} or myFunction(arg1, arg2, ...moreArgs) {} - the ...args basically means " how my
Oops
Jaren Escueta
@jarenescueta731
Aug 16 2016 05:40
@cjpowellaz you want newArray to be an array of the four max numbers right? so don't save the max in newArray. create a new variable and set it to that, then push that variable into newArray.
Dan Couper
@DanCouper
Aug 16 2016 05:40
Basically means " pass any number of arguments, and collect them as an array", and it's already an array.
Jaren Escueta
@jarenescueta731
Aug 16 2016 05:41
@cjpowellaz or else newArray gets overwritten in each loop, like you said before
Ryan Apolinar
@ryanapolinar
Aug 16 2016 05:42
I'm trying to use getJSON in order to get random quotes for my webpage, but I can't seem to access the JSON and at least print it out on my webpage like one of the challenges did. Here's what I have right now, am I missing anything?
$.getJSON("http://quotes.stormconsultancy.co.uk/random.json", function(json){$("#quote").html(JSON.stringify(json));
});
Here's the codepen to put it into context
http://codepen.io/ryanapolinar/pen/KrEPPq
Dan Couper
@DanCouper
Aug 16 2016 05:44
@Atl151 there is also the call/slice thing which you used to need to do, but if you go to the arguments wiki page on MSN, there's still I think a big red warning saying don't do this because no existing JS engine can optimise it
@cjpowellaz
Aug 16 2016 05:46
closer? I keep getting the largestNum.push is not a function.

function largestOfFour(arr) {
// You can do this!
var largestNum;
var newArray;

for (var x = 0; x < arr.length; x++) {
largestNum = Math.max.apply(Math, arr[x]);
newArray = largestNum.push(arr[x]);

  }

return newArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

Daniel Garcia
@Atl151
Aug 16 2016 05:46
@DanCouper Ok, so the arguments object create an array with the data that is given in the function?
Mateusz Szymański
@matszym
Aug 16 2016 05:47
@cjpowellaz number doesnt have push method on prototype. Only arrays do
@cjpowellaz
Aug 16 2016 05:48
so I am trying to create a new array as the loop goes through the arrays, I don't know how to get the numbers out into a new array
Jaren Escueta
@jarenescueta731
Aug 16 2016 05:48
@cjpowellaz you don't want to assign (=) to newArray, you push largestNum to it.
largestNum is the max in the current loop, push that to newArray.
newArray.push(largestNum);
you don't want to create a new array for each loop, ending up with 4 different arrays.
pahosler
@pahosler
Aug 16 2016 05:49
@reywinters03 for code that kinda looks like that you can look here https://github.com/pahosler/freecodecamp/blob/master/www/twitch/js/twitch.js
Rey Winters
@reywinters03
Aug 16 2016 05:50
@pahosler thanks!
CamperBot
@camperbot
Aug 16 2016 05:50
reywinters03 sends brownie points to @pahosler :sparkles: :thumbsup: :sparkles:
:warning: reywinters03 already gave pahosler points
Rey Winters
@reywinters03
Aug 16 2016 05:50
also i need to get my vocabulary correct lol ... in that example is init a prototype of twitch?
luis4flames
@luis4flames
Aug 16 2016 05:51
function lookUpProfile(firstName, prop){
// Only change code below this line

var result;
var i = 0;
while ( i < contacts.length) {
if ( contacts[i].firstName !== firstName) {
result = "No such contact";
i++;
} else {
if ( contacts[i].hasOwnProperty(prop) === false ){
result = "No such property";
}
else {
result = contacts[i][prop];
}
i++;
}
}

return result;
// Only change code above this line
}
Anyone see why this would find one name but not another if spelling isnt an error
Rey Winters
@reywinters03
Aug 16 2016 05:52
caps? is it case-sensitive?
Sorin Ruse
@sorinr
Aug 16 2016 05:52
@ryanapolinar make your getjson like: \$.getJSON("http://quotes.stormconsultancy.co.uk/random.json?callback=?", function(json){
Ryan Apolinar
@ryanapolinar
Aug 16 2016 05:53
@sorinr thanks sorin! can you explain real quick why adding callback=? makes it work, or is it too complicated
CamperBot
@camperbot
Aug 16 2016 05:53
ryanapolinar sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
luis4flames
@luis4flames
Aug 16 2016 05:54
spelling is excactly the same. Ill enter one name and a property and itll give me his last name, for example. Then i entire a different name, but it wont find the contact. i = 0 when that specific contact should be found. I dont see why this wouldnt start the loop with i = 0
Jaren Escueta
@jarenescueta731
Aug 16 2016 05:54
@cjpowellaz by the way, you also need to declare newArray as an array, like so:
var newArray = [];
Timur Uzel
@timurtu
Aug 16 2016 05:54
@reywinters03 what is your testing question @luis4flames is contacts defined?
@cjpowellaz
Aug 16 2016 05:55
you read my mind! Can you see my screen? :-)
Jaren Escueta
@jarenescueta731
Aug 16 2016 05:55
@cjpowellaz im actually outside your window....
luis4flames
@luis4flames
Aug 16 2016 05:55

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

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

var result;
var i = 0;
while ( i < contacts.length) {
if ( contacts[i].firstName !== firstName) {
result = "No such contact";
i++;
} else {
if ( contacts[i].hasOwnProperty(prop) === false ){
result = "No such property";
}
else {
result = contacts[i][prop];
}
i++;
}
}

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

// Change these values to test your function
lookUpProfile("Akira", "address");
Mateusz Szymański
@matszym
Aug 16 2016 05:55
@ryanapolinar its a hack to get around same origin policy https://en.wikipedia.org/wiki/JSONP
luis4flames
@luis4flames
Aug 16 2016 05:55
this is the entire question, contacts json was defined for me
Rey Winters
@reywinters03
Aug 16 2016 05:56
@timurtu Q1. should i use internal variables to unit test
@cjpowellaz
Aug 16 2016 05:56
I kept getting "undefined" so I was looking on how to define newArray. Thank you! @jarenescueta731
CamperBot
@camperbot
Aug 16 2016 05:56
cjpowellaz sends brownie points to @jarenescueta731 :sparkles: :thumbsup: :sparkles:
Jaren Escueta
@jarenescueta731
Aug 16 2016 05:56
@cjpowellaz good luck :D
@cjpowellaz
Aug 16 2016 05:57
I am so happy that worked. Thanks again fro the help
friscodisco
@friscodisco
Aug 16 2016 05:57
@luis4flames what challenge name/number is that
luis4flames
@luis4flames
Aug 16 2016 05:57
Akira is the only contact that isnt found for any property
Rey Winters
@reywinters03
Aug 16 2016 05:57
@timurtu Q2. in this code is bar a prototype of foo?
var foo = {
bar: function(hello){
console.log("hello world");
}
};
luis4flames
@luis4flames
Aug 16 2016 05:57
its profile lookup in basic javascript
Mateusz Szymański
@matszym
Aug 16 2016 05:57
@reywinters03 no
Sorin Ruse
@sorinr
Aug 16 2016 05:57
@ryanapolinar to solve the cross origin problem you should use a callback function to get jsonp instead of json: http://quotes.stormconsultancy.co.uk/api
Rey Winters
@reywinters03
Aug 16 2016 05:58
what is bar then?
ShaneBenj317
@ShaneBenj317
Aug 16 2016 05:58

Hey guys! I'm struggling with "Generate Random Whole Numbers with Javascript." Here is my code:
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line.
function myFunction(){
return Math.floor(Math.random()*10);
}
return Math.random();
}

Use this technique to generate and return a random whole number between 0 and 9
luis4flames
@luis4flames
Aug 16 2016 05:58
@friscodisco profile lookup in basic java script. not sure where to find number
Rey Winters
@reywinters03
Aug 16 2016 05:58
@matszym no meaning bar is not a prototype or i shouldn't use internal variables to test ..?
Mateusz Szymański
@matszym
Aug 16 2016 05:58
@reywinters03
this is how you make it a prototype:
var fooProto = {
bar: function(hello){
console.log("hello world");
}
};
var foo = Object.create(fooProto)
Rey Winters
@reywinters03
Aug 16 2016 05:59
ah! thank you @matszym
CamperBot
@camperbot
Aug 16 2016 05:59
reywinters03 sends brownie points to @matszym :sparkles: :thumbsup: :sparkles:
Mateusz Szymański
@matszym
Aug 16 2016 05:59
@reywinters03 no meaning in your example bar is not a prototype of foo
Rey Winters
@reywinters03
Aug 16 2016 05:59
what would you call bar?
if you were to talk to someone about what you're doing
Mateusz Szymański
@matszym
Aug 16 2016 06:00
@reywinters03 method on object foo
Rey Winters
@reywinters03
Aug 16 2016 06:00
ah
Jaren Escueta
@jarenescueta731
Aug 16 2016 06:00
@ShaneBenj317 im confused, do you have to return a number between 1 and 19 or 1 and 9?
Rey Winters
@reywinters03
Aug 16 2016 06:00
thank you
ShaneBenj317
@ShaneBenj317
Aug 16 2016 06:01
@jarenescueta731 We have to return a number between 1 and 19.
1 and 9 *
Timur Uzel
@timurtu
Aug 16 2016 06:02
@luis4flames I’m confused. should lookup profile return the property name for every property value in the array of objects? you can do that with
const firstNames = contacts.filter(contact => contact.firstName !== firstName)
I mean
luis4flames
@luis4flames
Aug 16 2016 06:03
@timurtu no it should only return the property the function searches
Timur Uzel
@timurtu
Aug 16 2016 06:03
const firstNames = contacts.filter(contact => contact.firstName === firstName)
Jaren Escueta
@jarenescueta731
Aug 16 2016 06:03
@ShaneBenj317 ok then you don't need that var randomNumberBetween0and19 right?
i think your myFunction() does exactly what you need.
Sorin Ruse
@sorinr
Aug 16 2016 06:04
@ShaneBenj317 here is the formula to get a random number between two min and max: https://www.codecademy.com/en/forum_questions/5198adbdbbeddf9726000700
Timur Uzel
@timurtu
Aug 16 2016 06:05
const getProps = (contacts, prop) => contacts.filter(contact => prop === contact.prop)
this is a function
Jaren Escueta
@jarenescueta731
Aug 16 2016 06:05
@ShaneBenj317 oh i see that came with the exercise, looking at it now. all you need is the return statement inside myFunction()
Timur Uzel
@timurtu
Aug 16 2016 06:05
the one you call at the bottom
@luis4flames
luis4flames
@luis4flames
Aug 16 2016 06:06
I think the exercise wants me to use loops though lol Havent learned how to use .filter
@timurtu
friscodisco
@friscodisco
Aug 16 2016 06:07
@luis4flames I think it is your iteration...try using this for (var x = 0; x < contacts.length; x++){
Daniel Garcia
@Atl151
Aug 16 2016 06:08
CamperBot
@camperbot
Aug 16 2016 06:08
atl151 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
ShaneBenj317
@ShaneBenj317
Aug 16 2016 06:08
@jarenescueta731 Thanks a lot!
CamperBot
@camperbot
Aug 16 2016 06:08
shanebenj317 sends brownie points to @jarenescueta731 :sparkles: :thumbsup: :sparkles:
Dan Couper
@DanCouper
Aug 16 2016 06:09
@Atl151 sorry late reply - yes, you make it into an array - generally, have the first thing inside the function be something like var args = Array.from(args)`. Which challenge are you doing?
luis4flames
@luis4flames
Aug 16 2016 06:10
@friscodisco still no luck. its not finding that first contact for some reason
I return i just to make sure it goes through the iterations and it does
"i"
Timur Uzel
@timurtu
Aug 16 2016 06:11
@luis4flames filter exists on the Array object less code less bugs
luis4flames
@luis4flames
Aug 16 2016 06:11
also how would i return an entire array from within the json
@timurtu yea it sure looks like it lol, but id just be cheating myself if i divert from the purpose of this exercise, which is to learn to manipulate it using a loop
Timur Uzel
@timurtu
Aug 16 2016 06:14
yeah this approach is similar but instead you’re creating a new object instead of mutating one
Daniel Garcia
@Atl151
Aug 16 2016 06:15
@DanCouper I was doing Seek and Destroy

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

}

<