11th
Aug 2017
Johnny Meza
@XLpacman805
Aug 11 2017 00:01
else if(!isNaN(parseInt(time))){ //time is number
var time_unix = parseInt(time);
var dx = new Date(time_unix);
console.log(time_unix);
res.end(JSON.stringify(
{
unix: dx.getTime(),
natural: (dx.toUTCString() === "Invalid Date") ? null : dx.toDateString()
}));
}
I keep getting Jan 13, 1970 for natural. I'm not sure why.
kumquatfelafel
@kumquatfelafel
Aug 11 2017 00:01

More generally speaking, strings are immutable (i.e. can't be changed). That is, with an array, for example you could change an element at i to 7 by saying arr[i] = 7. Something like this is just not possible with a string. No character in a string can be changed to a different character. The only way to "change" a string is to create an entirely new string. Functions that "modify" a string actually work not by modifying the original string, but by using the original string to create a new string with the desired changes. It is this new string that is returned. This new string, which has not yet been stored anywhere.

If you do not store this string in a variable, or "use" it immediately to perform further operations(in the same statement), then this string will be lost.

@dyon3334
@XLpacman805 What, exactly, is output by console.log(time_unix)?
dyon3334
@dyon3334
Aug 11 2017 00:05
@kumquatfelafel thanksalot !!! im gonna research
more
Johnny Meza
@XLpacman805
Aug 11 2017 00:05
1078963200
time is a unix time but as a string, so i need to convert it to an int.
Stephen James
@sjames1958gm
Aug 11 2017 00:06
@XLpacman805 What does dx output with console.log
Johnny Meza
@XLpacman805
Aug 11 2017 00:06
wait one
1970-01-13T11:42:43.200Z
it's strange because dx.getTime() returns the correct unix time.
kumquatfelafel
@kumquatfelafel
Aug 11 2017 00:09
Stephen James
@sjames1958gm
Aug 11 2017 00:10
@hypercuber Your first if check in draw has two this.length when checking x and y
@XLpacman805 That number is milliseconds not seconds ?
Greg Duncan
@GregatGit
Aug 11 2017 00:10
@hypercuber your code is a littlte hard to read (tho overall well written) - I would group all your variables togeather (and possibly put them in an object later) and console.log the sqArr every time you click to see if there are any changes
kumquatfelafel
@kumquatfelafel
Aug 11 2017 00:11

I don't see anything that indicates this is operating incorrectly. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

new Date(value);
value
Integer value representing the number of milliseconds since 1 January 1970 00:00:00 UTC, with leap seconds ignored (Unix Epoch; but consider that most Unix time stamp functions count in seconds).

Johnny Meza
@XLpacman805
Aug 11 2017 00:12
wow
@sjames1958gm you're right
i multiplied unix_time by 1000 and it worked
smh
@sjames1958gm thank you
CamperBot
@camperbot
Aug 11 2017 00:12
xlpacman805 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8289 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 11 2017 00:12
@XLpacman805 :+1:
Greg Duncan
@GregatGit
Aug 11 2017 00:14
@hypercuber also - use const for obj and arr and function - while properties in the arrays and obj may change it still constantly points to it - use let for numbers, strings and only use for an obj or array if you are going to change it from an array to a string - not it you are going to add or push a value to it
insouciantone
@insouciantone
Aug 11 2017 01:01
Hey all, I'm doing the weather API challenge and I don't know how to access the weather data in the JSON object.

https://fcc-weather-api.glitch.me/api/current?lat=35&lon=139

for something like the temperature I'd do var.main.temp but there is another layer to the weather data that I don't understand

Johnny Meza
@XLpacman805
Aug 11 2017 01:03
I used DarkSky API. I had to get data using JSONP, perhaps that it the problem.
insouciantone
@insouciantone
Aug 11 2017 01:04
I'm just using what they provided on the FCC website.
insouciantone
@insouciantone
Aug 11 2017 01:12
Nevermind I figured it out.
techhamster
@techhamster
Aug 11 2017 01:30
Hi guys. Is there something wrong with my ajax call? I'm working on my wiki viewer and I double checked that the link+search term url is correct, but it still gives me the error message... https://codepen.io/techhamster/pen/JyEMZG
Karan Nandha
@karann7
Aug 11 2017 01:37

hey guys feel free to follow me and code along on twitch or just hangout and talk with me.

I code everyday 5-9PM Pacific on there things such as React, React Native, Mongodb, Es6, Redux, Node, Expo XDE. I mostly am focused on react native development at the moment.

Join me here

Greg Duncan
@GregatGit
Aug 11 2017 01:40
@techhamster is it a codepen issue - try using this
var myUrl = 'http://en.wikipedia.org/w/api.php?format=json';
myUrl += '&action=query&generator=search&gsrnamespace=0&gsrlimit=10';
myUrl += '&prop=pageimages|extracts&pilimit=max&exintro&explaintext';
myUrl += '&exsentences=1&exlimit=max&gsrsearch=' + myItem + '&callback=?';
techhamster
@techhamster
Aug 11 2017 01:43
@GregatGit wow..that's a lot of code. I saw a few examples with https://en.wikipedia.org/w/api.php?action=opensearch&format=jsonfm&search=[searchTerm] and i though that was it
Greg Duncan
@GregatGit
Aug 11 2017 01:45
@techhamster if you look through it, its just one line with different params
insouciantone
@insouciantone
Aug 11 2017 01:47
What is it about codepen that forces you to build the URL like that?
techhamster
@techhamster
Aug 11 2017 01:47
@GregatGit I see that now. Thanks I'll try this one now. I was stuck trying to use the simple one for awhile now...
CamperBot
@camperbot
Aug 11 2017 01:47
techhamster sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
insouciantone
@insouciantone
Aug 11 2017 01:48
I always like building my applications locally before I try and smoosh them onto codepen.
Greg Duncan
@GregatGit
Aug 11 2017 01:48
@techhamster why don't you try
  $.getJSON(myUrl, function(json) { console.log(myUrl) // do you thing here }); } @techhamster I would also consider moving to gitHub to do your projects. techhamster @techhamster Aug 11 2017 01:51 @GregatGit Ok I'll try that then. and yeah I do other stuff on brackets but I figured I should just use codepen for fcc stuff haha Ccs99817 @ccs99817 Aug 11 2017 01:53 I need help with the Wherefore art thou  function whatIsInAName(collection, source) { // What's in a name? var firstRoundArr = []; var secondRoundArr = []; // Only change code below this line //************************************/ // generate a set of keys var keysSet = Object.keys(source); //generate a set of values var valuesSet = Object.values(source); //test for object in collectionthat has all the key required 1-round-filter for (var i=0; i<collection.length; i++){ var match = false; for (var j=0; j<keysSet; j++){ match = collection[i].hasOwnProperty(keysSet[j]); } if(match){ firstRoundArr.push(collection[i]); } } //test the passed object if the values matches //************************************/ // Only change code above this line return firstRoundArr; } whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 }); I found a bug in line 15 to line 24. I try to change the value of the boolean "match" by the return value in line 18; But, I dunno why it didn't work. Greg Duncan @GregatGit Aug 11 2017 01:53 @techhamster I highly recommend doing all fcc projects on gitHub. Using git is a key skill. In time people will see your progression on gitHub. techhamster @techhamster Aug 11 2017 01:56 @GregatGit Seems like its super valuable for this industry. I tried creating my first one like 2 weeks ago, but I couldn't figure out how to get an embedded flash game to work with my page. Ah well, more to Google later! Gulsvi @gulsvi Aug 11 2017 01:56 @techhamster For a counter argument, I'd say wait until you have your front end development certificate and get comfortable with issue like CORS before attempting to deploy web applications to GitHub You'll just end up re-doing everything in the end, and it can be a lot of extra re-work if you start deploying to github now Your wikipedia issue would also happen with Github-pages, it is not specific to codepen  var wikiUrl = "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&origin=*&search="; //call ajax$.ajax({
url: wikiUrl+searchTopic,
success: function(data) {
console.log(data);
},
error: function(errormsg) {
console.log("ERROR!");
}
});
Main changes are to use &format=json&origin=* in your URL instead of format=jsonfm and to simplify your ajax to use the default settings
insouciantone
@insouciantone
Aug 11 2017 02:00
@SkyC0der I agree, it's better to start cataloging progression on git after you're more comfortable with the development process. Your progression can be seen well enough on codepen initially.
techhamster
@techhamster
Aug 11 2017 02:00
@SkyC0der oh is using jsonfm bad? it looked nice...
Gulsvi
@gulsvi
Aug 11 2017 02:01
It's hard to parse @techhamster but it does look nice if you want it all embedded in HTML
techhamster
@techhamster
Aug 11 2017 02:01
@SkyC0der oh okay I learned something today! Thanks for the help!
CamperBot
@camperbot
Aug 11 2017 02:01
techhamster sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2359 | @skyc0der |http://www.freecodecamp.com/skyc0der
Gulsvi
@gulsvi
Aug 11 2017 02:02
Just another opinion :)
Happy to help though
techhamster
@techhamster
Aug 11 2017 02:04
@SkyC0der oh and that origin=* thing that you added. Does it have something to do with CORS?
Gulsvi
@gulsvi
Aug 11 2017 02:05
@techhamster Yeah, it makes it so you can request data from wikipedia.org from a remote server like github.com or codepen.io
origin = domain like freecodecamp.com, github.com, etc..
techhamster
@techhamster
Aug 11 2017 02:06
@SkyC0der thanks I just wanted to make sure. I got a lot to learn still :P
CamperBot
@camperbot
Aug 11 2017 02:06
techhamster sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:warning: techhamster already gave skyc0der points
kumquatfelafel
@kumquatfelafel
Aug 11 2017 02:12
@ccs99817 What is keysSet? Is it a number?
If not, then what is this... for (var j=0;:point_right: j<keysSet; :point_left: j++){ ... going to do?
kumquatfelafel
@kumquatfelafel
Aug 11 2017 02:21
@ccs99817 there are other issues that will arise due to how you change the value of match(this isn't a properly implemented flag variable), but I'll give you a chance to work that out on your own. ;)
Bryan Reese
@breese8009
Aug 11 2017 03:08
hey guys, my images are local so their not working on code pen, but im gettin an error ---> "Cannot read property 'appendChild' of null
at createBoard"
i think my issue is in the flipCard function, lemme know if u see an issue https://codepen.io/brJitsu85/pen/mMwjMG?editors=1111
kumquatfelafel
@kumquatfelafel
Aug 11 2017 03:19
Saying this.getAttribute is not a function @breese8009
In my console anyway.
Aug 11 2017 03:23
@breese8009 - it looks like the this in the this.getAttribute is the window object, not an HTML element?
Stuhl
@Stuhl
Aug 11 2017 03:26
Guys I just understood prototypes
I feel like god
Aug 11 2017 03:33

@breese8009 - I made a few changes and got part of your app working. First, I changed the place where the event handler is being added to this: cardElement.addEventListener('click', flipCard); - assigning it to the element that was just created. Then in the flipCard function - I made this change:

const flipCard = (event)=>{
let element = event.currentTarget;
let cardID = element.getAttribute('data-id');

And it is getting the card ID that was clicked. I know that there is more to do, but it's late for me here, and I"m going to just put this out there for you... good luck!

Guderian Raborg
@hypercuber
Aug 11 2017 03:43
@GregatGit @sjames1958gm thanks for feedback
CamperBot
@camperbot
Aug 11 2017 03:43
hypercuber sends brownie points to @gregatgit and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8290 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
ZhiyuLiu
@BarryLiu1995
Aug 11 2017 03:45
@Stuhl me too!!!
DavyDrei
@dj4919
Aug 11 2017 03:49
can someone help me figure out why my timer is increasing rather than resetting ?
Gersho
@Gersho
Aug 11 2017 03:50
Stuhl
@Stuhl
Aug 11 2017 03:50
@BarryLiu1995 If you get, u then realise how cool prototypes are lol
Gersho
@Gersho
Aug 11 2017 03:50
ok so the timer is supposed to reset each time i clic ?
DavyDrei
@dj4919
Aug 11 2017 03:50
I cant find an error in the console
Stuhl
@Stuhl
Aug 11 2017 03:50
Though I needed it to get a better grasp on design patterns
DavyDrei
@dj4919
Aug 11 2017 03:50
yes
its supposed to
namethatisnottaken
@namethatisnottaken
Aug 11 2017 03:51
var a=document.getElementById("#idName").innerHTML;
a=random text //this is how i supposed to change html with javascript right ?
can anyone help ?
DavyDrei
@dj4919
Aug 11 2017 03:52
yes @namethatisnottaken
Gersho
@Gersho
Aug 11 2017 03:52
@dj4919
var start = new Date().getTime();
at the start of your js, you should redo that everytime a cycle is completed, otherwise cycle 2 will still be using the first start time
namethatisnottaken
@namethatisnottaken
Aug 11 2017 03:52
but it did not work T_T
Gersho
@Gersho
Aug 11 2017 03:52
@namethatisnottaken remove the #
DavyDrei
@dj4919
Aug 11 2017 03:52
@Gersho thanks
CamperBot
@camperbot
Aug 11 2017 03:52
dj4919 sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
namethatisnottaken
@namethatisnottaken
Aug 11 2017 03:53
oh my God thanks
thanks @Gersho
CamperBot
@camperbot
Aug 11 2017 03:53
namethatisnottaken sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
kumquatfelafel
@kumquatfelafel
Aug 11 2017 03:53
@dj4919 the var start in makeShapeAppear is not the same as the var start at very top. It is the latter start that is getting used in var timeTaken = (end - start) / 1000; in spite of this value never changing.
namethatisnottaken
@namethatisnottaken
Aug 11 2017 03:55
 else if(parseInt($("#numberField").text()) == 0 && parseInt($("#operationField").text())>0){
let temp = document.getElementById('operationField').innerHTML;
let tempText = temp.slice(0,temp.length-2);
temp=tempText + " - ";
}
can anyone tell why this does not work ?
the slice one
DavyDrei
@dj4919
Aug 11 2017 03:55
i fixed it
Gersho
@Gersho
Aug 11 2017 03:56
\o/
DavyDrei
@dj4919
Aug 11 2017 03:56
i removed the 'var' from in front of the start under the function makeShapeAppear
namethatisnottaken
@namethatisnottaken
Aug 11 2017 03:59
can anyone help tell how to change html element with javascript and slice it as well if possible ?
Gersho
@Gersho
Aug 11 2017 04:00
change the element ? it's content ?
$("#id").html.(whatever); ? oh sorry that's jquery namethatisnottaken @namethatisnottaken Aug 11 2017 04:02 yes i was thinking of slicing two last string from the html but failed to do it  else if(parseInt($("#numberField").text()) == 0 && parseInt($("#operationField").text())>0){$("#operationField").html("does work")//this works
let temp = document.getElementById('operationField').innerHTML;
let tempText = temp.slice(0,temp.length-2);
temp = it does not work
}
kumquatfelafel
@kumquatfelafel
Aug 11 2017 04:03
@namethatisnottaken I'm not entirely sure what you're asking to do here. Could you provide an actual example of... "here's what it starts as, and here's what it is in the end"?
namethatisnottaken
@namethatisnottaken
Aug 11 2017 04:03
not sure where i did it wrong
here is the project
Joel Y.
@zapcannon99
Aug 11 2017 04:05
You times doesn't work @namethatisnottaken
multiplication*
namethatisnottaken
@namethatisnottaken
Aug 11 2017 04:05
yes i am still figuring out how to change the sign if we want to change it midway
thinking of slicing the operation field but did not work out yet :sob:
kumquatfelafel
@kumquatfelafel
Aug 11 2017 04:08
@namethatisnottaken I can't find the above snippet in your code.
namethatisnottaken
@namethatisnottaken
Aug 11 2017 04:09
above snippet ?
kumquatfelafel
@kumquatfelafel
Aug 11 2017 04:09
Sorry, snippet, as in small piece of code.
namethatisnottaken
@namethatisnottaken
Aug 11 2017 04:10
$("#plus").click(function() { if (parseInt($("#numberField").html()) != 0) {
$("#numberField").html(0);$("#operationField").append(" + ");
$("#operationField").show(); } else if(parseInt($("#numberField").html()) == 0 && parseInt($("#operationField").html())> 0){$("#operationField").slice(0, ($("#operationField").html().length - 2));$("#operationField").append(" + ");
}
})
$("#minus").click(function() { if (parseInt($("#numberField").html()) != 0) {
$("#numberField").html(0);$("#operationField").append(" - ");
$("#operationField").show(); } else if(parseInt($("#numberField").text()) == 0 && parseInt($("#operationField").text())>0){ let temp =$("#operationField").html()//this works
let tempText = temp.slice(0,temp.length-2);

}
i want to actually work in this part, removing 2 last part of operation field if - is clicked after +
supposed the user change its mind mid way
but the slice did not work :sob: not sure why
kumquatfelafel
@kumquatfelafel
Aug 11 2017 04:13
@namethatisnottaken slice doesn't modify existing string. It returns a new one. Where are you putting this new string back into operation field?
namethatisnottaken
@namethatisnottaken
Aug 11 2017 04:17
oh my God it works
not sure why i did not get it haha thanks @kumquatfelafel
CamperBot
@camperbot
Aug 11 2017 04:18
namethatisnottaken sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
namethatisnottaken
@namethatisnottaken
Aug 11 2017 04:18
by the way how exactly am i supposed to set the html with javascript mate ?
else if(parseInt($("#numberField").text()) == 0 && parseInt($("#operationField").text())>0){
let temp = document.getElementById("operationField").innerHTML;//this works
let correctHTML = temp.slice(0,temp.length-2);
temp=correctHTML;//this one does not work
$("#operationField").html(correctHTML); }//this one work Joel Y. @zapcannon99 Aug 11 2017 04:20 @namethatisnottaken Good point. Good Luck. namethatisnottaken @namethatisnottaken Aug 11 2017 04:20 sorry it works @_@ too much crazy thinking haha kumquatfelafel @kumquatfelafel Aug 11 2017 04:21 after let temp = blahblahblah, temp just holds a value. Doing = again will reassign the variable a different value, but the original value won't change??? I'm... not entirely sure what you're asking haha What I just said was also very poorly worded, but mind only semi-functional :p Kaeleb Rocha @Kralleb Aug 11 2017 04:39 Hello everyone I'm confused as to why when I join() an empty object it returns [object Object] Joseph @revisualize Aug 11 2017 04:39 Node.js Design Patterns - Second Edition https://www.packtpub.com/packt/offers/free-learning That looks liek a good subject to learn. Kaeleb Rocha @Kralleb Aug 11 2017 04:40 Does anyone have a solution for this? Joseph @revisualize Aug 11 2017 04:41 @Kralleb What? @Kralleb Do you have some code to show/ Kaeleb Rocha @Kralleb Aug 11 2017 04:43 Sure """ var myArr = []; arr = arr.join(); for(var element in arr) { if(arr[element] !== ",") { if(parseInt(arr[element])) { myArr.push(parseInt(arr[element])); } else { myArr.push(arr[element]); } } } return myArr; """ i forget how to send code properly 'var myArr = []; arr = arr.join(); for(var element in arr) { if(arr[element] !== ",") { if(parseInt(arr[element])) { myArr.push(parseInt(arr[element])); } else { myArr.push(arr[element]); } } } return myArr;' @revisualize i'm just going to quit while i'm behind. Also the challenge is steamroller Gersho @Gersho Aug 11 2017 04:48 oh i remember that one i hated it when i found what i was missing to do it xD Joseph @revisualize Aug 11 2017 04:50 @Kralleb This: arr.join(); Isn't correct. Kaeleb Rocha @Kralleb Aug 11 2017 04:50 but it works for everything but the object. Joseph @revisualize Aug 11 2017 04:50 @Kralleb The .join() method needs an argument. Kaeleb Rocha @Kralleb Aug 11 2017 04:50 @revisualize Joseph @revisualize Aug 11 2017 04:51 @Kralleb The .join() method is for taking an array and turning it into a string. @Kralleb If you're going to post code.. Can you post code that I can run? Kaeleb Rocha @Kralleb Aug 11 2017 04:51 sorry. ''' function steamrollArray(arr) { // I'm a steamroller, baby var myArr = []; arr = arr.join(); for(var element in arr) { if(arr[element] !== ",") { if(parseInt(arr[element])) { myArr.push(parseInt(arr[element])); } else { myArr.push(arr[element]); } } } return myArr; } steamrollArray([1, {}, [3, [[4]]]]);''' CamperBot @camperbot Aug 11 2017 04:52 :bulb: to format code use backticks!  more info Joseph @revisualize Aug 11 2017 04:52 @Kralleb But, you're still not using the .join() method correctly. Kaeleb Rocha @Kralleb Aug 11 2017 04:52 I mean... it works So how can you use it incorrectly if it works Joseph @revisualize Aug 11 2017 04:53 @Kralleb you're supposed to supply an argument. Gersho @Gersho Aug 11 2017 04:53 what are you expecting it to do ? Joseph @revisualize Aug 11 2017 04:53 When you turn an Object into a string it becomes [object Object] Gersho @Gersho Aug 11 2017 04:54 also join CAN be used without arguments fdemaa @fdemaa Aug 11 2017 04:54 anyone can help me with my weather project? Kaeleb Rocha @Kralleb Aug 11 2017 04:54 join() is a separator Gersho @Gersho Aug 11 2017 04:54 DavyDrei @dj4919 Aug 11 2017 04:55 where can i go for help with CSS? Joseph @revisualize Aug 11 2017 04:55 @Kralleb Because strings can be coursed into Arrays. You're going to get a bunch of elements for your loop. Gersho @Gersho Aug 11 2017 04:55 @dj4919 try the help chat Joseph @revisualize Aug 11 2017 04:55 @Kralleb Look: https://goo.gl/p9uLe9 @Kralleb Why are you turning arr into a string at all? Kaeleb Rocha @Kralleb Aug 11 2017 04:56 Because i need to get rid of the extra arr s.. Joseph @revisualize Aug 11 2017 04:56 @Kralleb Array.isArray() kumquatfelafel @kumquatfelafel Aug 11 2017 04:57 @Kralleb For future: if you write it in a code block, it makes it easier to read and allows you to do some formatting. To write it in a code block... for one line :point_right:  code goes here  or for multiple lines :point_down: js code goes here (important: keep code on a separate line from back ticks if want multiline)  Also, note that is not the same as ' You can also edit your post if you make a mistake by clicking the … that appears when you hover your mouse over your comment Kaeleb Rocha @Kralleb Aug 11 2017 04:57 Sigh... yes i'm suppose to work under the parameter of Array.isArray() if true do some stuff Joseph @revisualize Aug 11 2017 04:58 @Kralleb Look, I know that I'm supposed to let you drive when assisting you with trying solve your challenge. @Kralleb But, I've solved that challenge 4 different ways. Kaeleb Rocha @Kralleb Aug 11 2017 04:58 But i thought this approach would be easier since some of it is already a string anyhow Joseph @revisualize Aug 11 2017 04:59 @Kralleb You're the first that I've seen turn the arr into a string. Kaeleb Rocha @Kralleb Aug 11 2017 05:00 mmhmm. Well when you join it, it will return the values. Convert the Ints into Ints and bingo But i didn't take into account the object Joseph @revisualize Aug 11 2017 05:00 @Kralleb You're also having a problem with your for...in loop because of array coercion for Strings Kaeleb Rocha @Kralleb Aug 11 2017 05:00 I have zero problems with anything other then the object becoming a string... Joseph @revisualize Aug 11 2017 05:00 Gersho @Gersho Aug 11 2017 05:01 @Kralleb because that's the limite of the string method, expect if you plan to code a lot of exeption as regular expressions kumquatfelafel @kumquatfelafel Aug 11 2017 05:01 @Kralleb nah. More difficult using join. And solution using join is really sketchy. Kaeleb Rocha @Kralleb Aug 11 2017 05:03 lol I can't say that i understand what the problem is when turning the values into a string if it works But of course it probably won't work if the object is involved so i guess that's that Joseph @revisualize Aug 11 2017 05:04 @Kralleb What is [{}].join() ? "[object Object]" Then when you do string coercion and do a for in ... Kaeleb Rocha @Kralleb Aug 11 2017 05:06 So my understanding of the .join() which i didn't realize is that it would join the elements and not turn them into strings when i realized they turn into strings i said "Well... Maybe i can just turn the ints back" Joseph @revisualize Aug 11 2017 05:07 for (var element in [{}].join()) { } You're iterating across Gersho @Gersho Aug 11 2017 05:07 i have a navigator.geolocation.getCurrentPosition that works fine on vivaldi, but not on firefox, any ideas ? (in both case i have the notice to allow/refuse localisation, but on ff it fails) Kaeleb Rocha @Kralleb Aug 11 2017 05:07 But still not quite understanding that they were fully strings since when return "arr[0]" after i joined it it returned an int and not a string Joseph @revisualize Aug 11 2017 05:08 ["[", "o", "b", "j", "e", "c", "t", " ", "O", "b", "j", "e", "c", "t", "]"] Gersho @Gersho Aug 11 2017 05:08 @Kralleb try putting a lot a console.log to have a look how your variables evolve, it'll help you find how/where it went ba Joseph @revisualize Aug 11 2017 05:09 @Kralleb or you could just use: https://goo.gl/vnB5Za Gulsvi @gulsvi Aug 11 2017 05:10 @Gersho You can troubleshoot navigator.geolocation failures with an error function: if ("geolocation" in navigator) { navigator.geolocation.getCurrentPosition(success, fail); } else { fail("navigator.geolocation is not supported in your browser"); } function success(position) { console.log(position); } function fail(err) { console.error(err); } Kaeleb Rocha @Kralleb Aug 11 2017 05:10 @revisualize @Gersho Thanks for the infor CamperBot @camperbot Aug 11 2017 05:10 kralleb sends brownie points to @revisualize and @gersho :sparkles: :thumbsup: :sparkles: :cookie: 320 | @gersho |http://www.freecodecamp.com/gersho :star2: 4427 | @revisualize |http://www.freecodecamp.com/revisualize Kaeleb Rocha @Kralleb Aug 11 2017 05:11 info. Gersho @Gersho Aug 11 2017 05:11 function fail(err) { console.err(error); } it triggers that part (the call starts, but fails) @SkyC0der Gulsvi @gulsvi Aug 11 2017 05:12 that should be console.error(err) (whoops), but what failure message do you get? You should see something like: [object PositionError] { code: 1, message: "User denied Geolocation", PERMISSION_DENIED: 1, POSITION_UNAVAILABLE: 2, TIMEOUT: 3 } @Gersho (if they deny location, or a different code for other errors) Bryan Reese @breese8009 Aug 11 2017 05:15 @khaduch i tried this but no luck :( Kaeleb Rocha @Kralleb Aug 11 2017 05:15 function steamrollArray(arr) { // I'm a steamroller, baby var myArr = []; arr = arr.join(); for(var i = 0; i < arr.length; i++) { if(arr[i] === "[" && arr[i+1] === "o") { myArr.push({}); i += 15; } if(arr[i] !== ",") { if(parseInt(arr[i])) { myArr.push(parseInt(arr[i])); } else { myArr.push(arr[i]); } } } return myArr; } steamrollArray([1, {}, [3, [[4]]]]); There fixed it lol The ugliest piece of code you guys may ever see Markus Kiili @Masd925 Aug 11 2017 05:16 @Kralleb Yeah, and the inventor of arrays turns in his/hers grave. ;) Kaeleb Rocha @Kralleb Aug 11 2017 05:16 hahaha I'm dying i actually solved it with join() I should probably make that check for object more finite Markus Kiili @Masd925 Aug 11 2017 05:20 @Kralleb The problem description doesn't say what the array elements can be, and that code fails for example with steamrollArray([1, "cat", [3, [[4]]]]); Gersho @Gersho Aug 11 2017 05:20 @SkyC0der sorry for the delay, had to fix some stuff first ^^ PositionError { code: 2, message: "Unknown error acquiring position" } not that helpfull D: Gulsvi @gulsvi Aug 11 2017 05:23 @Gersho Hmmm, a few stack overflow articles with nothing definitive, but all pointing fingers at firefox Abhishek Tiwari @fillopfy Aug 11 2017 05:23 @Kralleb use reduce method and recursion to solve it Kaeleb Rocha @Kralleb Aug 11 2017 05:23 @Masd925 Right, I mean I could create a parameter to check that Gersho @Gersho Aug 11 2017 05:24 @SkyC0der since it worked fine on vivaldi, i kinda figure, i'll put it on codepen and see if it works for the ppl here Kaeleb Rocha @Kralleb Aug 11 2017 05:25 But this is getting out of hand. It was my understanding that the join method just joined elements and now i realized it turns them into strings so i can't truly use it, But I just thought it would be funny if i could actually solve it that way Markus Kiili @Masd925 Aug 11 2017 05:26 @Kralleb Those array elements can be any JS values, so I don't think you can actually make it work that way. Kaeleb Rocha @Kralleb Aug 11 2017 05:27 @Masd925 Yeah. I realized i couldn't when it turned it into strings. But I just thought of a way that i could pass the test so I did. @fillopfy i have no idea what recursion is i will have to look it up Gersho @Gersho Aug 11 2017 05:29 https://codepen.io/Gersho/pen/YQKYGo let me know if you get correct city/country data Markus Kiili @Masd925 Aug 11 2017 05:29 @Kralleb Yeah. If the arrays had only number elements, that way would have the merit of avoiding recursion. Bad that there are also elegant non-recursive solutions too. Good practice for you though. Kaeleb Rocha @Kralleb Aug 11 2017 05:31 @Masd925 I wonder why they never put documentation on recursion. I feel like you can't actually solve the problem without it Gersho @Gersho Aug 11 2017 05:31 there's also the problem of not knowing how deep the array can be, and some limitations (like if a value in the array is a string that contains a comma) @Kralleb @Kralleb lol that was my exact impresion too like "how was i supposed to google that " Markus Kiili @Masd925 Aug 11 2017 05:32 @Kralleb You can, but using recursion is easier. Kaeleb Rocha @Kralleb Aug 11 2017 05:32 @Gersho That's true, i know it's crap. It's not a real solution. Gersho @Gersho Aug 11 2017 05:32 Bad that there are also elegant non-recursive solutions too. i'd like to see some if you have some, really curious @Kralleb well it is, and recursion is elegent, but it feels like using gamefaqs to solve zelda Kaeleb Rocha @Kralleb Aug 11 2017 05:33 Lol Abhishek Kumar Pandey @abhishekpandeykr Aug 11 2017 05:34 how to get rid of Use of getPreventDefault() is deprecated while submitting the form Gersho @Gersho Aug 11 2017 05:34 don't use a form ? Kaeleb Rocha @Kralleb Aug 11 2017 05:34 Alright well I gotta go learn this stuff, It's been fun goofin. Thanks for the tips about recursion @Gersho Thanks @Masd925 thanks CamperBot @camperbot Aug 11 2017 05:34 kralleb sends brownie points to @gersho and @masd925 :sparkles: :thumbsup: :sparkles: :warning: kralleb already gave gersho points :star2: 4402 | @masd925 |http://www.freecodecamp.com/masd925 Markus Kiili @Masd925 Aug 11 2017 05:34 @Gersho I can post them on https://gitter.im/FreeCodeCamp/CodeReview so we don't spoil anyone's work here. Gersho @Gersho Aug 11 2017 05:34 actually 2 hours ago i was wondering if i should tell you about recursion D: kumquatfelafel @kumquatfelafel Aug 11 2017 05:34 @Kralleb you can, technically, trick FCC by doing something like this. return (arr.join(' ')).replace("$object Object$", '{}', 'g').split(/ |,/).filter(val => val).map(val => Number(val)? Number(val): val === "{}"? {}: val); But I think this is a very questionable solution. :p Kaeleb Rocha @Kralleb Aug 11 2017 05:35 Lol Oh i should of just used replace totally Markus Kiili @Masd925 Aug 11 2017 05:35 @kumquatfelafel True test-driven development ;) Gersho @Gersho Aug 11 2017 05:36 @Masd925 ok @kumquatfelafel that's kinda what i was saying when talking about exeptions and regular expressions xD kumquatfelafel @kumquatfelafel Aug 11 2017 05:39 of course, the above example doesn't, e.g., distinguish between possible string in original array (after all, we want this to work for strings as well), "[object Object]", and the post-join "[object Object]" that has resulted from coercion. Markus Kiili @Masd925 Aug 11 2017 05:43 @kumquatfelafel Yeah, and all object elements are turned into "[object Object]", which spoils it. Gersho @Gersho Aug 11 2017 05:44 that's some wake up call challenge ^^ kumquatfelafel @kumquatfelafel Aug 11 2017 05:45 assuming some object with actual properties, absolutely! ( :point_left: @Masd925 you meant in this context?) Markus Kiili @Masd925 Aug 11 2017 05:46 @kumquatfelafel Yes, the description doesn't limit what the elements can be. kumquatfelafel @kumquatfelafel Aug 11 2017 05:46 aye Gersho @Gersho Aug 11 2017 05:48 kumquatfelafel @kumquatfelafel Aug 11 2017 05:48 though yeah, I think you'd have to do a bunch of work on the array before .join() to change potentially coerced elements into something else that won't be coerced to even really hope for join to work. Don't really want to think about what's involved there :laughing: Joseph @revisualize Aug 11 2017 05:53 Note: I had an ex-coworker suggest https://www.gitbook.com/book/frontendmasters/front-end-handbook-2017/details to me for using to learn web development kumquatfelafel @kumquatfelafel Aug 11 2017 05:53 @Gersho board is so large that I can't get it fully visible in codepen. Markus Kiili @Masd925 Aug 11 2017 05:53 @kumquatfelafel If we assume that the result array should hold the same object references as the initial array (that is how typical solutions work), then stringifying the array cannot work. kumquatfelafel @kumquatfelafel Aug 11 2017 05:54 true. Could only work then in a deep copy context. At best... Gersho @Gersho Aug 11 2017 05:55 @kumquatfelafel oh...i kinda forgot my second screen has a better resolution than my main one >.> @kumquatfelafel and since i've done it all in fixed position...this is gonna be fun D: kumquatfelafel @kumquatfelafel Aug 11 2017 05:56 @Gersho My screen is also a bit small, to be fair... :laughing: Gersho @Gersho Aug 11 2017 05:57 i'm using a 12801024and a 19201080(laptop original screen) is there some way to get the user's resolution ? to adapt display well guess i'll see that tomorrow, going to sleep bye kumquatfelafel @kumquatfelafel Aug 11 2017 06:00 night Gulsvi @gulsvi Aug 11 2017 06:00 console.log(window.screen.availHeight) console.log(window.screen.availWidth) @Gersho Gersho @Gersho Aug 11 2017 06:00 @SkyC0der thanks, i'll copy that somewhere for tomorrow ;) CamperBot @camperbot Aug 11 2017 06:00 gersho sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles: :star2: 2362 | @skyc0der |http://www.freecodecamp.com/skyc0der Gulsvi @gulsvi Aug 11 2017 06:00 g'night :) Markus Kiili @Masd925 Aug 11 2017 06:01 @Gersho You can also use CSS media queries. kumquatfelafel @kumquatfelafel Aug 11 2017 06:06 @Gersho though yeah, it's pushing it a little, but can manage to get entire thing when switch to full page view. kumquatfelafel @kumquatfelafel Aug 11 2017 06:17 So I'm writing a kata at moment on codewars, but want to make sure that solution isn't too much of a stretch (requires a little bit of an educated guess). Basically, suppose you are told to uppercase a string without using [, ], or split, and when you call "Hello World".toUpperCase(), e.g., results in hello world instead of HELLO WORLD... If one were to make an educated guess a sort of... "What can I test next", if you will... what would you, inhabitants of FCC, test next in order to try and figure out what is going on/find a potential solution? kumquatfelafel @kumquatfelafel Aug 11 2017 06:24 (I feel like it's pretty straightforward what one would check immediately after determining the above, but I also have the benefit of knowing what I did, so... kinda looking for a few more eyes on this one) kumquatfelafel @kumquatfelafel Aug 11 2017 06:36 hmm... on second thought, I think I have to squash charAt as well. Kelechi Chinaka @ke1echi Aug 11 2017 06:37 i am trying to read meaning into your future kata...what exactly do u want warriors to do? @kumquatfelafel TJ Hardin @AndroidNinjaX Aug 11 2017 06:37 Hey everyone. Could any help me with this Algorithm Challenge "Arguments Optional" addTogether(2)(3) confuses me like crazy. kumquatfelafel @kumquatfelafel Aug 11 2017 06:39 @kelechy Your task is to upper case a string. No loops allowed, no split, charAt, etc. Basically, you're forced to call preexisting methods as opposed to writing your own. The only problem is, calling toUpperCase returns a word that is lower case. Kelechi Chinaka @ke1echi Aug 11 2017 06:41 ok Manish Giri @Manish-Giri Aug 11 2017 06:41 why would .toUpperCase() return lowercase? @kumquatfelafel Markus Kiili @Masd925 Aug 11 2017 06:41 @AndroidNinjaX In the case of one valid argument passed, the addTogether needs to return a function. @AndroidNinjaX So addTogether(2) returns a function and (3) calls it. kumquatfelafel @kumquatfelafel Aug 11 2017 06:42 @Manish-Giri In the case of this particular kata, toUpperCase will return a lower case string. Manish Giri @Manish-Giri Aug 11 2017 06:42 yes but why? @kumquatfelafel Claudio Restifo @Marmiz Aug 11 2017 06:44 @AndroidNinjaX It uses a curry: a function that returns a function: // a function that returns a function const curry = (greeting) => { return (name) => { console.log(${greeting}, ${name}); }; }; // then I can assign the first function a value and pass the second value after const hello = curry('Hello'); hello('Marmiz'); // "Hello, Marmiz" hello('Manish'); // "Hello, Manish" // or directly pass the two arguments curry('Hi')('chat') // "Hi, chat " prakash chandra yadav @prakashyadav008 Aug 11 2017 06:44 @Masd925 so we can use closures like this addTogether(2)(3) kumquatfelafel @kumquatfelafel Aug 11 2017 06:44 Because I modified it prakash chandra yadav @prakashyadav008 Aug 11 2017 06:44 addTogether(2)(3) Markus Kiili @Masd925 Aug 11 2017 06:45 @prakashyadav008 That just means that the return value of first call is a function. Closures are usually involved here, yes. Manish Giri @Manish-Giri Aug 11 2017 06:46 @kumquatfelafel I'd just use .toLocaleUpperCase() kumquatfelafel @kumquatfelafel Aug 11 2017 06:46 @Manish-Giri Assume that doesn't work either. Manish Giri @Manish-Giri Aug 11 2017 06:46 yeah then I'm not doing such a kata. kumquatfelafel @kumquatfelafel Aug 11 2017 06:47 Hmm. Kelechi Chinaka @ke1echi Aug 11 2017 06:47 sounds weird already @kumquatfelafel TJ Hardin @AndroidNinjaX Aug 11 2017 06:48 @Masd925 @Marmiz thanks for the response guys...... scratching my head trying to understand the craziness that just took place :smile: CamperBot @camperbot Aug 11 2017 06:48 androidninjax sends brownie points to @masd925 and @marmiz :sparkles: :thumbsup: :sparkles: :star2: 1019 | @marmiz |http://www.freecodecamp.com/marmiz :star2: 4403 | @masd925 |http://www.freecodecamp.com/masd925 TJ Hardin @AndroidNinjaX Aug 11 2017 06:48 @Marmiz I haven't got that far so what is const prakash chandra yadav @prakashyadav008 Aug 11 2017 06:50 @Masd925 so this means its two function calls right the first returns a function addTogether(2)(3) Markus Kiili @Masd925 Aug 11 2017 06:50 @prakashyadav008 Yes. TJ Hardin @AndroidNinjaX Aug 11 2017 06:53 @Masd925 So am I correct for thinking about it kinda like this? function addTogether() { function(){ stuff; } } Markus Kiili @Masd925 Aug 11 2017 06:53 @AndroidNinjaX In the case of one valid argument, you can construct and return such a function, yes. Claudio Restifo @Marmiz Aug 11 2017 06:53 @AndroidNinjaX It's a common pattern in many other programming languages: Imagine a program that let you select a product to buy, then ask you for how much money you have to pay before returning it your change. It will go like this: select product --> : user select product: ask for the payment --> : user insert payment : return the change To do so you need a function that wait for a product to be selected, and then wait for a payement to be inserted before giving the change. So myPaymentFunction('new smartphone')('1000$')

Will call the function saying that I want the new smartphone, and I will pay with 1000$. Make sense? :) (const is just constant a "new" kind of var in newer more fancy syntax. Ignore it and treat it like var) Markus Kiili @Masd925 Aug 11 2017 06:55 @AndroidNinjaX const declares a block-scope variable that cannot be assigned into or redeclared later. TJ Hardin @AndroidNinjaX Aug 11 2017 06:55 @Marmiz HOLY CRAP THAT JUST MADE SO MUCH MORE SENSE! kumquatfelafel @kumquatfelafel Aug 11 2017 06:56 yeah then I'm not doing such a kata. @Manish-Giri Though yeah. That's pretty much why I'm asking. Figuring it out requires, in part, making an educated guess based on seeing what happens when you call toUpperCase. But as said above, I'd rather modify to not include this part if it's too obscure. Basically though, it's one of those challenges where you'd have to test a few things and see what shakes loose, so a little uncertainty would be acceptable. Just... not too much. :p Claudio Restifo @Marmiz Aug 11 2017 06:58 @AndroidNinjaX tbh that's not a common pattern in JS at all. But in the good 'ole C writing a program like that is one of the first thing you learn to do (basic Input/Output) ;) TJ Hardin @AndroidNinjaX Aug 11 2017 07:00 @Masd925 so I'm guessing const stands for "constant" then? Probably getting ahead of myself Markus Kiili @Masd925 Aug 11 2017 07:00 @AndroidNinjaX Yes. Or it stands after some famous programmer like Constantin something. I don't guess anymore after finding out there is a guy named Haskell Curry. TJ Hardin @AndroidNinjaX Aug 11 2017 07:04 @Masd925 haha alright ill take it one step at a time. @Masd925 @Marmiz So am I on the right track or not even close? function addTogether() { var a = function check(value) { if (typeof(value) === "number") { return value; } }; if (arguments[0] === "number") { return arguments[0] + a; } } addTogether(2)(3); @Masd925 @Marmiz However I'm not cause I get this TypeError: addTogether(...) is not a function Markus Kiili @Masd925 Aug 11 2017 07:07 @AndroidNinjaX You need to check arguments.length so you know if one or two arguments were passed (combined with a typeof check for validity). alpox @alpox Aug 11 2017 07:08 @AndroidNinjaX Also, you are trying to add together a value with a function (arguments[0] + a) TJ Hardin @AndroidNinjaX Aug 11 2017 07:20 @Masd925 closer? function addTogether() { var a = function check(value) { if (arguments.length === 1) { if (typeof(value) === "number") { return value; } } }; return a; } addTogether(2)(3); gives me 3 now yes I know I could combined the 'if' statements, but i needed to split it up to be able to go through this Markus Kiili @Masd925 Aug 11 2017 07:22 @AndroidNinjaX arguments.length check should be outside function a so it checks addTogether's arguments. You need two positive test cases. One valid argument passed, and two valid arguments passed. TJ Hardin @AndroidNinjaX Aug 11 2017 07:29 @Masd925 unfortunately not following. I am really trying to. What is really confusing me, is when you check arguments.length outside of function a it yells at me and says TypeError: addTogether(...) is not a function Markus Kiili @Masd925 Aug 11 2017 07:30 @AndroidNinjaX The logic is then changed. First you need to make those two tests inside addTogether. TJ Hardin @AndroidNinjaX Aug 11 2017 07:31 @Masd925 both functions? @Masd925 sorry as in both test are functions themselves Markus Kiili @Masd925 Aug 11 2017 07:31 @AndroidNinjaX Two if's that test arguments passed into addTogether. Not talking about the returned function yet. prakash chandra yadav @prakashyadav008 Aug 11 2017 07:40 @AndroidNinjaX  function addTogether(args1,args2) { //start if(args2 === undefined){ console.log("one argument"); if(Number.isInteger(args1) === false){ return undefined; }else{ return function(arg){ console.log("arg="+arg); return addTogether(args1,arg); }; } }else{ console.log("two arguments"); if(Number.isInteger(args1) === false || Number.isInteger(args2) === false){ return undefined; }else{ return args1+args2; } } return false; } addTogether(2)(3); function addTogether(args1,args2) { //start if(args2 === undefined){ console.log("one argument"); if(Number.isInteger(args1) === false){ return undefined; }else{ return function(arg){ console.log("arg="+arg); return addTogether(args1,arg); }; } }else{ console.log("two arguments"); if(Number.isInteger(args1) === false || Number.isInteger(args2) === false){ return undefined; }else{ return args1+args2; } } return false; } addTogether(2)(3); Markus Kiili @Masd925 Aug 11 2017 07:42 @prakashyadav008 Checking against undefined is not a good way to check number of passed arguments, because one could pass undefined as an argument. So for checking the number of arguments, you should use arguments.length check. Works on this challenge with these limited test cases, but in general is not the proper tool to use. Also modifying the parameters of challenge functions is CHEATING ;) TJ Hardin @AndroidNinjaX Aug 11 2017 07:45 ya I was wondering about that Markus Kiili @Masd925 Aug 11 2017 07:46 @AndroidNinjaX Remember also that JS functions return undefined by default, so you can concentrate on positive tests. prakash chandra yadav @prakashyadav008 Aug 11 2017 07:46 its a hack .... @markus @Masd925 Claudio Restifo @Marmiz Aug 11 2017 07:47 Rejoice people... Bootstrap 4 is now on beta :sparkles: Vision ir @visionir Aug 11 2017 07:48 Word Blanks 填词造句 现在，我们来用字符串的相关知识实现一个造句函数。 How to solve? TJ Hardin @AndroidNinjaX Aug 11 2017 07:48 I'm really struggling with how to get any argument besides 3. I def get what you are saying now, with arguments.length. I know I have to test it somehow, but I dont even know how to return it in the first place. Markus Kiili @Masd925 Aug 11 2017 07:52 @AndroidNinjaX One test could be if(arguments.length===1 && typeof arguments[0] ==='number') You can figure out proper test for two valid arguments. Long Nguyen @longnt80 Aug 11 2017 08:05 @Marmiz :+1: Idowu Wasiu @Hoxtygen Aug 11 2017 08:11 Mayday! Mayday!! Mayday!!! i need help pls, dunno what i'm doing wrong anybody home? Tiago Correia @tiagocorreiaalmeida Aug 11 2017 08:12 in what can we help? kumquatfelafel @kumquatfelafel Aug 11 2017 08:12 post code Idowu Wasiu @Hoxtygen Aug 11 2017 08:13  var alphabets = [ ['A', 1], ['B', 2], ['C', 3], ['D', 4], ['E', 5], ['F', 6], ['G', 7], ['H', 8], ['I', 9], ['J', 10], ['K', 11], ['L', 12], ['M', 13], ['N', 14], ['O', 15], ['P', 16], ['Q', 17], ['R', 18], ['S', 19], ['T', 20], ['U', 21], ['V', 22], ['W', 23], ['X', 24], ['Y', 25], ['Z', 26] ]; function alphabetPosition(text) { var newText = text.toUpperCase().split(""); for (var i = 0; i < newText.length; i++) { for (var j = 0; j < alphabets.length; j++) { if (newText[i] === alphabets[j][0]) { return alphabets[j][1]; } } } } console.log(alphabetPosition("How on earth does one code without having a headache and banging your head on an imaginary wall"));  dammit is it 3 ? kumquatfelafel @kumquatfelafel Aug 11 2017 08:14 yeah you can just edit by clicking ... that pops up when you hover mouse over comment Idowu Wasiu @Hoxtygen Aug 11 2017 08:14  var alphabets = [ ['A', 1], ['B', 2], ['C', 3], ['D', 4], ['E', 5], ['F', 6], ['G', 7], ['H', 8], ['I', 9], ['J', 10], ['K', 11], ['L', 12], ['M', 13], ['N', 14], ['O', 15], ['P', 16], ['Q', 17], ['R', 18], ['S', 19], ['T', 20], ['U', 21], ['V', 22], ['W', 23], ['X', 24], ['Y', 25], ['Z', 26] ]; function alphabetPosition(text) { var newText = text.toUpperCase().split(""); for (var i = 0; i < newText.length; i++) { for (var j = 0; j < alphabets.length; j++) { if (newText[i] === alphabets[j][0]) { return alphabets[j][1]; } } } } console.log(alphabetPosition("How on earth does one code without having a headache and banging your head on an imaginary wall")); the code only returns the value of the first alphabet............I want it to return all kumquatfelafel @kumquatfelafel Aug 11 2017 08:16 return statements halt the entire function and return the specified value. So if you want to return them all, you'll have to think of a way to store all the values, then return said values. Kelechi Chinaka @ke1echi Aug 11 2017 08:17 you are returning in your last loop @Hoxtygen Idowu Wasiu @Hoxtygen Aug 11 2017 08:17 @kumquatfelafel so the return value is in the wrong position ? Kelechi Chinaka @ke1echi Aug 11 2017 08:17 wrong position TJ Hardin @AndroidNinjaX Aug 11 2017 08:17 @Masd925 still working at this, sorry for not responding in a while Blauelf @Blauelf Aug 11 2017 10:15 @Hoxtygen So you want it to return an array of the positions? Oh, that was two hours ago. Two hours of no message? What happened? Idowu Wasiu @Hoxtygen Aug 11 2017 10:17 @Blauelf i waited too to see if more help will come, none came and i tried harder and finally got it...... below is the code @Blauelf var alphabets = [ ['A', 1], ['B', 2], ['C', 3], ['D', 4], ['E', 5], ['F', 6], ['G', 7], ['H', 8], ['I', 9], ['J', 10], ['K', 11], ['L', 12], ['M', 13], ['N', 14], ['O', 15], ['P', 16], ['Q', 17], ['R', 18], ['S', 19], ['T', 20], ['U', 21], ['V', 22], ['W', 23], ['X', 24], ['Y', 25], ['Z', 26] ]; function alphabetPosition(text) { //remove the spaces text = text.split(" ").join("").toUpperCase(); //create an array variable to store the resulting values var textValue = []; //loop through the text for (var i = 0; i < text.length; i++) { //loop through the alphabets array for (var j = 0; j < alphabets.length; j++) { //compare the text and alphabets, see if they match if (alphabets[j][0] === text[i]) { //if they match return the integer equivalent textValue.push(alphabets[j][1]); //console.log(textValue); } } //return textValue; } return textValue.join(" "); } console.log(alphabetPosition("The sunset sets at twelve o' clock.")); that gives 20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11 heroiczero @heroiczero Aug 11 2017 10:21 nice job :+1: LydaTech @lydatech Aug 11 2017 10:23 anyone do any wp development? iso @iso1048 Aug 11 2017 10:23 does anyone know if there is an easy way to set multiple keys to the same value in an object? Blauelf @Blauelf Aug 11 2017 10:24 @Hoxtygen Do you have to use that alphabets array, or would it be ok to hard-code the latin alphabet? I mean, for that result, you could have easily done something like function alphabetPosition(text) { var textValue = []; var upperText = text.toUpperCase(); for (var i = 0; i < text.length; i++) { if ("A" <= upperText[i] && upperText[i] <= "Z") { textValue.push(upperText.charCodeAt(i) - 64); // 64 is "A".charCodeAt()-1 } } return textValue.join(" "); } Idowu Wasiu @Hoxtygen Aug 11 2017 10:25 @gothamknight no idea from my end. how about you try stackoverflow and some googling? @Blauelf A newbie here, so you should expect pretty basic things............. No i don't have to hardcode, i did it the way i could @Blauelf whats gist about the 64 in the code? Blauelf @Blauelf Aug 11 2017 10:27 @gothamknight If the keys are numeric, you might be able to use Array.prototype.fill iso @iso1048 Aug 11 2017 10:28 @Blauelf nah the keys are string. Idowu Wasiu @Hoxtygen Aug 11 2017 10:28 @Blauelf and its a challenge on code wars iso @iso1048 Aug 11 2017 10:28 @Blauelf @Hoxtygen thanks CamperBot @camperbot Aug 11 2017 10:28 gothamknight sends brownie points to @blauelf and @hoxtygen :sparkles: :thumbsup: :sparkles: :cookie: 333 | @hoxtygen |http://www.freecodecamp.com/hoxtygen :star2: 4561 | @blauelf |http://www.freecodecamp.com/blauelf Blauelf @Blauelf Aug 11 2017 10:28 @Hoxtygen From each uppercase character, I first subtract the ASCII code of 'A' (which is 65), resulting in a value in range 0..25, and then add one to get a range of 1..26. @gothamknight The usual suspects like lodash or underscore might have such a function, but if I had to do that repeatedly, I would do my own. Markus Kiili @Masd925 Aug 11 2017 10:30 @Blauelf I just registered to Codewars. What is the main idea there? Explained in 10 words. Blauelf @Blauelf Aug 11 2017 10:30 Solve puzzles in an elegant style, and write your own. Idowu Wasiu @Hoxtygen Aug 11 2017 10:30 @Blauelf oh thanks, always nice to have a better and cleaner code... CamperBot @camperbot Aug 11 2017 10:30 hoxtygen sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles: :star2: 4562 | @blauelf |http://www.freecodecamp.com/blauelf Idowu Wasiu @Hoxtygen Aug 11 2017 10:31 @Masd925 registered three days ago, not been easy.... goodluck..... @Blauelf mind if i make a proposition? Markus Kiili @Masd925 Aug 11 2017 10:32 @Blauelf So you try write clean solutions. Maybe some code gold challenges later? Are there any recruiters looking for programmers there or something like that? Blauelf @Blauelf Aug 11 2017 10:33 @Masd925 The katas differ from each other. Some try to explain some programming style, or a pattern, others require code golfing. Some are best solved by using maths before writing any code. There's voting on solutions in two categories. @Masd925 I have no idea where recruiters are. Markus Kiili @Masd925 Aug 11 2017 10:37 @Blauelf ok, thanks. CamperBot @camperbot Aug 11 2017 10:37 masd925 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles: :star2: 4563 | @blauelf |http://www.freecodecamp.com/blauelf IggySmith @IggySmith Aug 11 2017 10:39 help.. my solution only works if the 'target' is a word and not part of a word heroiczero @heroiczero Aug 11 2017 10:41 @IggySmith because you are dividing it into words for your array. spliting it with a "space" Stephen James @sjames1958gm Aug 11 2017 10:41 @IggySmith This is not a word challenge but a letter challenge, rethink your split kumquatfelafel @kumquatfelafel Aug 11 2017 10:47 @IggySmith There are links on the left at bottom of the instructions that offer some functions that may be helpful. I would familiarize yourself with those. Stephen James @sjames1958gm Aug 11 2017 10:51 @IggySmith Think about how to chop off the correct amount of the end of str to match target kumquatfelafel @kumquatfelafel Aug 11 2017 10:51 In any case, what you'd need to do in order to compare the ends of an array or a string (without using any other functions) is pretty much the same, so there's little point in using split here heroiczero @heroiczero Aug 11 2017 10:54 @IggySmith try manipulate the "length of the target" and the "length of the str" so you get the last letters of the sentence or word using https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring or substr kumquatfelafel @kumquatfelafel Aug 11 2017 10:55 IggySmith @IggySmith Aug 11 2017 11:00 @heroiczero @sjames1958gm @kumquatfelafel thanks CamperBot @camperbot Aug 11 2017 11:00 iggysmith sends brownie points to @heroiczero and @sjames1958gm and @kumquatfelafel :sparkles: :thumbsup: :sparkles: :star2: 1599 | @heroiczero |http://www.freecodecamp.com/heroiczero :cookie: 596 | @kumquatfelafel |http://www.freecodecamp.com/kumquatfelafel :star2: 8291 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm IggySmith @IggySmith Aug 11 2017 11:00 i'll be back lol Thayyeb salim @Thayyebsalim Aug 11 2017 11:26 https://codepen.io/Thayyeb_Itachi/pen/rzxKPg The input search works once only Is there any way I can recycle it? Stephen James @sjames1958gm Aug 11 2017 11:36 @Thayyebsalim Why are you re-appending the input element? Thayyeb salim @Thayyebsalim Aug 11 2017 11:36 is there any other way to let only the input box stay? Stephen James @sjames1958gm Aug 11 2017 11:37 @Thayyebsalim Put another div under the input and then add your streamers there - then you can clear that div only You'll have to rework your styling Thayyeb salim @Thayyebsalim Aug 11 2017 11:40 Yeah @sjames1958gm Stephen James @sjames1958gm Aug 11 2017 11:41 @Thayyebsalim Another option is instead of clearing streamers HTML do $(".user").remove();
And remove the adding back of the input
bilaal-s
@bilaal-s
Aug 11 2017 11:43
hello guys! my calculator so far: https://codepen.io/bilaal-s/pen/QMjVKK
Thayyeb salim
@Thayyebsalim
Aug 11 2017 11:43
YEah i'm looking that up @sjames1958gm
bilaal-s
@bilaal-s
Aug 11 2017 11:43
the plus minus and multiplication functions work
i need advice as to wether i should proceed with my current methods for handling the javascript
having a quick look (not cheating!) at other code has made me feel my approach is downright silly
Markus Kiili
@Masd925
Aug 11 2017 11:44
@bilaal-s Should AC clear the screen?
bilaal-s
@bilaal-s
Aug 11 2017 11:45
it will
not at the moment xD
just rerun
Markus Kiili
@Masd925
Aug 11 2017 11:45
:+1:
Stephen James
@sjames1958gm
Aug 11 2017 11:46
@bilaal-s Why are you rebinding click handler to plus /minus inside the click handler?
Looking at the console you are getting extra calls to your handler (adding a new one each time)
Markus Kiili
@Masd925
Aug 11 2017 11:46
@bilaal-s If I start with a negative number, it is not shown as negative.
bilaal-s
@bilaal-s
Aug 11 2017 11:47
@Masd925 loool didnt even think of that
Thayyeb salim
@Thayyebsalim
Aug 11 2017 11:47
Thanks man @sjames1958gm
CamperBot
@camperbot
Aug 11 2017 11:47
thayyebsalim sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8292 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 11 2017 11:47
@Thayyebsalim :+1:
bilaal-s
@bilaal-s
Aug 11 2017 11:47
@sjames1958gm to account for a second click?
@sjames1958gm wrong i know
Stephen James
@sjames1958gm
Aug 11 2017 11:49
If you do that you need to unbind the previous. or both get called on each click.
Thayyeb salim
@Thayyebsalim
Aug 11 2017 11:50
I'm dancing like a mad man
atlast I finished it
I've been on it for 3-4 days
Happy to say the least
Stephen James
@sjames1958gm
Aug 11 2017 11:51
@Thayyebsalim Congrats - looks great!
Thayyeb salim
@Thayyebsalim
Aug 11 2017 11:51
Thanks dude wouldn't be possible without you people
I have a bit more patching up to do
Stephen James
@sjames1958gm
Aug 11 2017 11:51
lol
Ronique Ricketts
@RoniqueRicketts
Aug 11 2017 11:52
@Thayyebsalim I thought I was the only one who does crazy dance when I solve things
Thayyeb salim
@Thayyebsalim
Aug 11 2017 11:53
:hand: @RoniqueRicketts @sjames1958gm
bilaal-s
@bilaal-s
Aug 11 2017 12:06
@sjames1958gm was thinking that
Ronique Ricketts
@RoniqueRicketts
Aug 11 2017 12:14
I can't log on to fcc anyone else has that problem
Thayyeb salim
@Thayyebsalim
Aug 11 2017 12:15
@RoniqueRicketts try clearing the browser cache
No problems on my end
either network or chache
Ronique Ricketts
@RoniqueRicketts
Aug 11 2017 12:18
@Thayyebsalim my co outer broke so I am borrowing I'd have to get permissions to do so
Same issue, connection refused.
namethatisnottaken
@namethatisnottaken
Aug 11 2017 12:33
hello
anyone knows why my code does not work on codepen but works fine on fiddle ?
same script but did not work on the code pen
Markus Kiili
@Masd925
Aug 11 2017 12:36
@namethatisnottaken Look at the errors on developer tools console.
namethatisnottaken
@namethatisnottaken
Aug 11 2017 12:37
i am sorry markus wrong fiddle
it works fine on the fiddle
Markus Kiili
@Masd925
Aug 11 2017 12:38
@namethatisnottaken Errors on codepen might tell the reason.
namethatisnottaken
@namethatisnottaken
Aug 11 2017 12:39
i see i think i got it
where can i see this developer console ?
Markus Kiili
@Masd925
Aug 11 2017 12:39
@namethatisnottaken F12 on some browsers.
namethatisnottaken
@namethatisnottaken
Aug 11 2017 12:40
i see thanks @Masd925
bilaal-s
@bilaal-s
Aug 11 2017 13:11
im thinking of displaying an error if plus and minus operator are combined rather than forcing it to work
at what point do i cap the functionality of this calculator? xD
the best person i have seen handle it is mr stephen james himelf
it works as you would expect a calculator should, when combining operations, it completes the previous before proceeding with the next
i guess i have to push my limits and make it work!
moshe18
@moshe18
Aug 11 2017 13:31
-+
Thayyeb salim
@Thayyebsalim
Aug 11 2017 13:31
same thing but different responses
what is happeneing
Now it works perfect did not change anything
Man API's sure are a pain
alpox
@alpox
Aug 11 2017 13:38
@Thayyebsalim He probably just came online :D
Thayyeb salim
@Thayyebsalim
Aug 11 2017 13:42
No, he has been online for some time now @alpox
and the screen shots were taken at the same time
Stephen James
@sjames1958gm
Aug 11 2017 13:58
@Thayyebsalim wind-bow might cache the responses which twitch doesn't or vice verse
Thayyeb salim
@Thayyebsalim
Aug 11 2017 14:11
aah that makes sense
Thayyeb salim
@Thayyebsalim
Aug 11 2017 14:19
@sjames1958gm any idea why the links dont work?
Chris Juchtmans
@kjuchtmans
Aug 11 2017 14:21
good afternoon to you all, the flower of coders :wave:
Thayyeb salim
@Thayyebsalim
Aug 11 2017 14:27
afternoon :wave:
bilaal-s
@bilaal-s
Aug 11 2017 14:27
is the calculator supposed to incorperate negative numbers?
Klaus Mana
@KlausMana
Aug 11 2017 14:33
i need halp
it's doing this weird thing
where it changes cn_name only to like the last value of the array for some reason
Thayyeb salim
@Thayyebsalim
Aug 11 2017 14:36
Hi @KlausMana
Klaus Mana
@KlausMana
Aug 11 2017 14:36
hey
kumquatfelafel
@kumquatfelafel
Aug 11 2017 14:37

@bilaal-s on fcc example calculator has negative numbers can get as result I suppose, but has no way to actually specify that a given number to add/multiply/etc. should be negative (apart from subtracting said number from 0, then multiplying/adding/etc. using that result ).

Though there's nothing to say that you couldn't try incorporate negative numbers more fully if you wanted to.

bilaal-s
@bilaal-s
Aug 11 2017 14:38
@kumquatfelafel cool thanks!
CamperBot
@camperbot
Aug 11 2017 14:38
bilaal-s sends brownie points to @kumquatfelafel :sparkles: :thumbsup: :sparkles:
kumquatfelafel
@kumquatfelafel
Aug 11 2017 14:40
there's also nothing in the user stories about being able to input negative numbers. But yeah, I would still make sure that the result of a set of operations can be negative. So that 2 - 5, e.g., would correctly be calculated as -3
Chris Juchtmans
@kjuchtmans
Aug 11 2017 14:41

'Exact Change' lesson :

How can I round the balance number to 2 decimal points?
I have implemented Math.round() in this repl.it link but when all my if statements are finished it's still returning a terrible number of dp's, 0.009999999999994874

cheers! chris

kumquatfelafel
@kumquatfelafel
Aug 11 2017 14:45
@KlausMana looking at. No guarantees though.
Klaus Mana
@KlausMana
Aug 11 2017 14:45
thanks
Tai Jones
@taiJones00
Aug 11 2017 14:53
$("#location").html(json.name + ", " + json.country); Stephen James @sjames1958gm Aug 11 2017 14:53 @kjuchtmans I converted everything to integer pennies, then converted back at the end Tai Jones @taiJones00 Aug 11 2017 14:53 Is this valid? Stephen James @sjames1958gm Aug 11 2017 14:54 @taiJones00 look valid Tai Jones @taiJones00 Aug 11 2017 14:54 it's saying undefined instead of the country from the json Klaus Mana @KlausMana Aug 11 2017 14:55 what API are you using? Tai Jones @taiJones00 Aug 11 2017 14:55 Stephen James @sjames1958gm Aug 11 2017 14:55 @kjuchtmans return Math.round(balance * 100) / 100; @taiJones00 My bad country is in json.sys.country Tai Jones @taiJones00 Aug 11 2017 14:56 yeah it's just saying undefined instead of the country name Stephen James @sjames1958gm Aug 11 2017 14:57 @taiJones00 My bad country is in json.sys.country Tai Jones @taiJones00 Aug 11 2017 14:57 ohhh arigato @sjames1958gm CamperBot @camperbot Aug 11 2017 14:57 taijones00 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 8294 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Stephen James @sjames1958gm Aug 11 2017 14:57 @taiJones00 de nada Chris Juchtmans @kjuchtmans Aug 11 2017 15:12 @sjames1958gm thanks for taking a look, but I'm still getting return balance 0.009999999999994874 Isn't it correct that one should round down to 2 decimal points, in order to close the cash register, i.e. arrive at zero finally? CamperBot @camperbot Aug 11 2017 15:12 kjuchtmans sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 8295 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Chris Juchtmans @kjuchtmans Aug 11 2017 15:15 @sjames1958gm oh wait. I've done it the other way around: rounding in every if statement, but you're saying: just round at the final return? Stephen James @sjames1958gm Aug 11 2017 15:15 @kjuchtmans Yes. Blauelf @Blauelf Aug 11 2017 15:16 @kjuchtmans When dealing with integers of reasonable size only (rounding after multiplying value-in-dollars by 100), you don't have rounding errors. I chose that route, and divided by 100 only in the last step. Or you could round in each step (multiply, round, divide), depending on how your algorithm works. kumquatfelafel @kumquatfelafel Aug 11 2017 15:19 @KlausMana look at what happens when you put console.log(i) inside of getJSON. Blauelf @Blauelf Aug 11 2017 15:20 Banks use integers for their balances. I think they use multiples of a $\frac{1}{10000}$Euro here, final balance rounded to cents. Chris Juchtmans @kjuchtmans Aug 11 2017 15:20 @sjames1958gm @Blauelf ok thanks that makes sense. However, when rounding at the final return like so, I'm left with 0.01, for which my present algorithm apparently isn't calculating change anymore, viz hand back 1 extra penny. Where is my error? CamperBot @camperbot Aug 11 2017 15:20 kjuchtmans sends brownie points to @sjames1958gm and @blauelf :sparkles: :thumbsup: :sparkles: :warning: kjuchtmans already gave sjames1958gm points :star2: 4564 | @blauelf |http://www.freecodecamp.com/blauelf Thayyeb salim @Thayyebsalim Aug 11 2017 15:20 @sjames1958gm Chelsea fan? kumquatfelafel @kumquatfelafel Aug 11 2017 15:25 @kjuchtmans post code Blauelf @Blauelf Aug 11 2017 15:25 @kjuchtmans You calculated with floating point. There are ways to deal with that, like var pennies = 0; var cash_in_dollars = 0.07; while (cash_in_dollars >= 0.01) { pennies++; cash_in_dollars -= 0.01; cash_in_dollars = Math.round(100 * cash_in_dollars) / 100; } or var pennies = 0; var cash_in_dollars = 0.07; var cash_in_pennies = Math.round(100 * cash_in_dollars); // From here on, integers only. No rounding issues. while (cash_in_pennies >= 1) { pennies++; cash_in_pennies -= 1; } Both would give you the same number in pennies, but the first version has to compensate for rounding errors. kumquatfelafel @kumquatfelafel Aug 11 2017 15:27 oh, wait... you did post it. nvm :laughing: Chris Juchtmans @kjuchtmans Aug 11 2017 15:39 @Blauelf Vielen Dank, so by cash_in_dollars you understand the fraction of the change due, left over after returning higher value bills & coins? In other words: Math.round(100 * cash_in_dollars) should be used once the algorithm gets down to calculating change in quarters, dimes, nickels and pennies, viz fractions of 1 dollar? Thayyeb salim @Thayyebsalim Aug 11 2017 15:49 Atlast I completed the last API project https://codepen.io/Thayyeb_Itachi/full/rzxKPg/ I would love to get some comment,reviews or critiques. Thanks to all those who helped when I was stuck Stephen James @sjames1958gm Aug 11 2017 15:51 @Thayyebsalim Yes Best weekend of the year - start of the new season!!! Thayyeb salim @Thayyebsalim Aug 11 2017 15:51 me too @sjames1958gm zeustamil @zeustamil Aug 11 2017 15:51 @zeustamil what is the difference between calling the function by using parantheses and without parantheses like this ,,,,foo() and foo Datikzz @Datikzz Aug 11 2017 15:55 how to create element inside fieldset? Xzanos @Xzanos Aug 11 2017 16:04 Bradley Sands @sandsbe Aug 11 2017 16:04 @Thayyebsalim :clap: :clap: :clap: Xzanos @Xzanos Aug 11 2017 16:04 ops sorry about that lol Gulsvi @gulsvi Aug 11 2017 16:05 Xzanos @Xzanos Aug 11 2017 16:05 hello all im trying to inject a style into an html element, currently i am having to get the element id using var elID = document.querySelector('[id^="slide-bg-"]').id' i have used console.log to confirm that elID has the value that i am wanting and it does. At this point i am a bit confused, i have tried using elID.setAttribute("style", "fill-opacity = 0"); but this gives me an error "actionator::exeJavaScript - elID.setAttribute is not a function" any ideas? Bradley Sands @sandsbe Aug 11 2017 16:05 @Thayyebsalim However, when I click the link, it takes you to the page URL but doesn't load. I think there is a workaround for that. Thayyeb salim @Thayyebsalim Aug 11 2017 16:05 thanks @sandsbe CamperBot @camperbot Aug 11 2017 16:05 thayyebsalim sends brownie points to @sandsbe :sparkles: :thumbsup: :sparkles: :cookie: 314 | @sandsbe |http://www.freecodecamp.com/sandsbe Thayyeb salim @Thayyebsalim Aug 11 2017 16:05 Yeah i saw that Is there any work around? Gulsvi @gulsvi Aug 11 2017 16:06 The only workaround is to open your page in Debug View Every single twitch.tv app on codepen does that Bradley Sands @sandsbe Aug 11 2017 16:07 @SkyC0der @Thayyebsalim just checked mine. Same "error". See stones and glass houses... Thayyeb salim @Thayyebsalim Aug 11 2017 16:08 @SkyC0der thanks CamperBot @camperbot Aug 11 2017 16:08 thayyebsalim sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles: :warning: thayyebsalim already gave skyc0der points Thayyeb salim @Thayyebsalim Aug 11 2017 16:08 as usual on point Gulsvi @gulsvi Aug 11 2017 16:08 @Xzanos I think you want this: var elID = document.querySelector('[id^="slide-bg-"]'); (remove the .id) from the end console.log(elID) will help you debug further Idowu Wasiu @Hoxtygen Aug 11 2017 16:11 hi guys Datikzz @Datikzz Aug 11 2017 16:11 guys, how to appendchild element inside fieldset? Xzanos @Xzanos Aug 11 2017 16:11 @SkyC0der thanks for the reply i will check it out, however i have console.log(elID) which returned "slide-bg-62ebmbib1j0" this is what i was expecting. CamperBot @camperbot Aug 11 2017 16:11 xzanos sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles: :star2: 2365 | @skyc0der |http://www.freecodecamp.com/skyc0der Gulsvi @gulsvi Aug 11 2017 16:11 @Xzanos Yeah, but you can't do slide-bg-62ebmbib1j0.setAttribute("style", "fill-opacity = 0") setAttribute needs to be used with an object representing the element, not an id name Chris Juchtmans @kjuchtmans Aug 11 2017 16:12 "Exact Change" : How can I add strings denoting currency e.g."TWENTY" to my array of amounts called changeArray in this code here ? At the start of my algorithm I am accessing only the values inside the thirds arguments, the array-like object. Eventually I need the currency back in. Any suggestions? cheers Idowu Wasiu @Hoxtygen Aug 11 2017 16:12 I have an array i need to filter out the min and max value. Is there a way to do this at a go? Gulsvi @gulsvi Aug 11 2017 16:15 @Xzanos You could also do this: var elID = document.querySelector('[id^="slide-bg-"]').id; document.getElementById(elID).setAttribute("style", "fill-opacity = 0"); Chris Juchtmans @kjuchtmans Aug 11 2017 16:15 @Hoxtygen I think this Stackoverflow post is offering a solution to your problem Xzanos @Xzanos Aug 11 2017 16:15 @SkyC0der so i would need to get the element based on the elID var first? @SkyC0der ok yeah thats what i was thinking you ment Gulsvi @gulsvi Aug 11 2017 16:16 Yeah, either that way, or get a collection of all the elements with the id starting with slide-bg- Xzanos @Xzanos Aug 11 2017 16:16 @SkyC0der thanks a bunch! i shall head forth into the great unknown! hopefully i can run with this for a while CamperBot @camperbot Aug 11 2017 16:16 xzanos sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles: :warning: xzanos already gave skyc0der points Gulsvi @gulsvi Aug 11 2017 16:16 @Hoxtygen Math.min() and Math.max() can be used to get the min or max value from an array. Lots of other options here: https://stackoverflow.com/questions/1669190/find-the-min-max-element-of-an-array-in-javascript @Xzanos Happy travels :) Idowu Wasiu @Hoxtygen Aug 11 2017 16:22 @SkyC0der i know how to use the Math.min() and Math.max() separately, I'm looking for a function that do both at the same time............................... Gulsvi @gulsvi Aug 11 2017 16:23 @Hoxtygen If you know how to use those, then writing that function would be one line of code............................ Kelechi Chinaka @ke1echi Aug 11 2017 16:24 u can sort them and return elements that are not min and max @Hoxtygen Gulsvi @gulsvi Aug 11 2017 16:25 ^^ That's also a good solution. Sort, then get the first and last elements. Maybe only 2 lines of code for that one ;) Idowu Wasiu @Hoxtygen Aug 11 2017 16:31 @SkyC0der @kelechy I put something together while you guys were suggesting, albeit less elegant and clean that what you're saying.............. It does the job anyway................... @kelechy @SkyC0der here it is function sumArray(array) { var midRange = []; var low = Math.min.apply(Math, array); var highest = Math.max.apply(Math, array); for (var i = 0; i < array.length; i++) { if (array[i] > low && array[i] < highest) { midRange.push(array[i]); var midRangeSum = midRange.reduce(function (x, y) { /* body... */ return x + y; }, 0); } } return midRangeSum; } Gulsvi @gulsvi Aug 11 2017 16:36 @Hoxtygen Rather than looping, just reduce the array and then subtract the max and min values function sumArray(array) { return array.reduce((a,b) => a + b) - Math.min(...array) - Math.max(...array); } Thayyeb salim @Thayyebsalim Aug 11 2017 16:37 Anyone using Emmet? Idowu Wasiu @Hoxtygen Aug 11 2017 16:38 @SkyC0der would've done that if i know how to do it............... i'm just learning bro Gulsvi @gulsvi Aug 11 2017 16:39 @Hoxtygen You have all of that code in your function. You reduce the array and you get the max and min. Idowu Wasiu @Hoxtygen Aug 11 2017 16:40 @SkyC0der and oh the looping isnt to determine the min and max, i'm comparing values to the min and max and getting the values between them and adding them up.................................................................. addition without min and max Gulsvi @gulsvi Aug 11 2017 16:40 Maybe this way it looks more familiar: function sumArray(array) { var sum = array.reduce(function(a, b) { return a + b; }); return sum - Math.min.apply(Math, array) - Math.max.apply(Math, array); } Jason Luboff @JLuboff Aug 11 2017 16:41 :angry: Nothing like antivirus to hog all your memory! Was holding up ~6GB of ram Idowu Wasiu @Hoxtygen Aug 11 2017 16:42 Maybe this way it looks more familiar: js function sumArray(array) { var sum = array.reduce(function(a,b) { return a + b }); return sum - Math.min.apply(Math, array) - Math.max.apply(Math, array); }  this is way cooler and applied to what i'm tryna do @JLuboff what? 6GB? Gulsvi @gulsvi Aug 11 2017 16:43 @Hoxtygen Both those code examples are the same. One is ES5 javascript, the other is ES6 reduce and subtract Idowu Wasiu @Hoxtygen Aug 11 2017 16:43 @SkyC0der thanks ..... havent got a grip on ES6 CamperBot @camperbot Aug 11 2017 16:43 hoxtygen sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles: :star2: 2366 | @skyc0der |http://www.freecodecamp.com/skyc0der Kelechi Chinaka @ke1echi Aug 11 2017 16:44 :smile: @JLuboff Markus Kiili @Masd925 Aug 11 2017 16:44 @JLuboff Sounds like a couple of 1GB viruses on the loose. Kelechi Chinaka @ke1echi Aug 11 2017 16:44 if it does the job why bother? :smile: @Hoxtygen James Patrick Kerrane @jamesjpk123 Aug 11 2017 16:44 On my website, https://chingu-coders.github.io/owl-24/, I am trying to mimic this jsfiddle that I made: http://jsfiddle.net/f4PV4/1220/. However, it is not working for me. Here is the repo's relevant files: https://github.com/chingu-coders/owl-24/blob/master/index.html, https://github.com/chingu-coders/owl-24/blob/master/index.js. Can someone help me? Jason Luboff @JLuboff Aug 11 2017 16:45 @Hoxtygen Yup. I had noticed a week or two back that my memory usuage was really high (13-14 gb of 16 in use). Closed all my applications and was still using 8-9 GB. Rebooted. Same thing even before opening any applications. Didn't worry about it, but it was getting on my nerves as Atom was hanging. Looked in Resource Mon, nothing out of the ordinary, even added everything up didn't make sense. Decided to close my antivirus, and sure enough drops 6GB! So now everything is running well (even with reopening it). Personally I would do without, but its my work computer Idowu Wasiu @Hoxtygen Aug 11 2017 16:45 @kelechy optimization bro Jason Luboff @JLuboff Aug 11 2017 16:45 @Masd925 You know me, always downloading those viruses ;) Idowu Wasiu @Hoxtygen Aug 11 2017 16:46 @JLuboff glad you got rid of those... can't imagine the number of WTC that must have been built in there :smile: kumquatfelafel @kumquatfelafel Aug 11 2017 16:47 @JLuboff speaking of viruses and downloading... anyone take the bait yet? Jason Luboff @JLuboff Aug 11 2017 16:47 @kumquatfelafel Nope. Everybody passed. So I'm sure we'll wait a few months to test again kumquatfelafel @kumquatfelafel Aug 11 2017 16:51 I'm... I guess that's good. Jason Luboff @JLuboff Aug 11 2017 16:51 It is good...they're learning finally Kelechi Chinaka @ke1echi Aug 11 2017 16:52 how do you raise to the power without math function? Jason Luboff @JLuboff Aug 11 2017 16:52 @kelechy You could use a loop i guess. kumquatfelafel @kumquatfelafel Aug 11 2017 16:52 Or the prince of saudi arabia just hasn't offered them enough money to get them to budge. ;) Jason Luboff @JLuboff Aug 11 2017 16:52 Keep multiplying by itself Kelechi Chinaka @ke1echi Aug 11 2017 16:52 a**b ? such tasks sounds weird to me :smile: kumquatfelafel @kumquatfelafel Aug 11 2017 16:53 @kelechy for babel, a**b will work, yes Not sure about newest ES's Markus Kiili @Masd925 Aug 11 2017 16:55 @kelechy ES7 I think. Jason Luboff @JLuboff Aug 11 2017 16:55 let num = 5; let power = 4; let result = 1; for (let i = 1; i <= power; i++){ result *= num; } return result; There's shorter ways to do that I'm sure....but technically that works James Patrick Kerrane @jamesjpk123 Aug 11 2017 16:56 :point_up: August 11, 2017 10:44 AM Can anyone help with this? Kelechi Chinaka @ke1echi Aug 11 2017 17:07 that code did not look like an optimized one @Hoxtygen Idowu Wasiu @Hoxtygen Aug 11 2017 17:09 @kelechy not talking about mine.......................... my code works but not the best, hence the need to not just sit back and say job done Xzanos @Xzanos Aug 11 2017 17:13 darn, and i was sure that this would work var elID = document.querySelector([id^="slide-bg-"]) console.log(elID); document.getElementByID(elID).setAttribute("style,"fill-opacity: 0;"); the console log has what i expect but after that i get an error saying that (elID).setAttribute is not a function if needed i can past a snipit of the HTML maybe i am not understanding something about the element Gulsvi @gulsvi Aug 11 2017 17:26 @Xzanos I'm not great with SVG, but isn't fill-opacity the attribute you want to set? var elID = document.querySelector('[id^="slide-bg-"]').id; document.getElementById(elID).setAttribute("fill-opacity", "0"); (edited to add all code ^^) Kelechi Chinaka @ke1echi Aug 11 2017 17:32 :+1: @Hoxtygen Xzanos @Xzanos Aug 11 2017 17:34 @SkyC0der maybe so, the reason i thought i needed to use style is that when i add the rule manually in the browser it adds style="fill-opacity: 0;" I will try to work with your suggestion and see whats what Gulsvi @gulsvi Aug 11 2017 17:37 @Xzanos Your code above was missing the .id at the end of the query selector, and you were using getElementByID instead getElementById, so try this out too and see if it works better: var elID = document.querySelector('[id^="slide-bg-"]').id; document.getElementById(elID).setAttribute("style", "fill-opacity: 0;"); Xzanos @Xzanos Aug 11 2017 17:42 just so I can understand a bit better, what is the difference between having the .id and not, and the difference between document.querySelector([id^="slide-bg-"]) and document.querySelector('[id^="slide-bg-"]')what are the extra quotes inside the () for only reason i ask is that the console.log returns the same value regardless Gulsvi @gulsvi Aug 11 2017 17:45 @Xzanos the CSS selector needs to be a string, without the quotes, you're passing an array to .querySelector() instead and then 'id' is seen as a variable and everything fails. the .id at the end gets the ID of the element you've matched with that CSS selector without the .id, you are setting elID equal to an object representing the elements matched Pieter Stokkink @forkerino Aug 11 2017 18:01 Hello! Jason Luboff @JLuboff Aug 11 2017 18:01 Hello Christopher McCormack @cmccormack Aug 11 2017 18:01 @forkerino hiya! Pieter Stokkink @forkerino Aug 11 2017 18:04 How's everything? Jason Luboff @JLuboff Aug 11 2017 18:05 Its going... you? Pieter Stokkink @forkerino Aug 11 2017 18:07 Things here are good. Got excellent new headphones, so I'm listening to high quality music. Jason Luboff @JLuboff Aug 11 2017 18:08 :musical_note: :musical_note: Addison @addisonday Aug 11 2017 18:09 I'm having fun putting to use all these array methods in the basic algorithm scripting challenges Christopher McCormack @cmccormack Aug 11 2017 18:10 @forkerino which headphones? @addisonday don't they just make everything much easier :) Pieter Stokkink @forkerino Aug 11 2017 18:11 @cmccormack Sony MDR-XB950AP. The bass is very full. Jason Luboff @JLuboff Aug 11 2017 18:12 All about dat bass? Pieter Stokkink @forkerino Aug 11 2017 18:12 Indeed Christopher McCormack @cmccormack Aug 11 2017 18:12 Nice! Do they make your head hot? that's always been my problem with over the ear headphones Addison @addisonday Aug 11 2017 18:12 @cmccormack Yes, they are super powerful. Pieter Stokkink @forkerino Aug 11 2017 18:13 @cmccormack Ah, yeah, I forgot about that. Let's see. The sound is delicious, though. Christopher McCormack @cmccormack Aug 11 2017 18:13 @addisonday check out lodash, that is pretty awesome as well, and not just for arrays Pieter Stokkink @forkerino Aug 11 2017 18:14 have had in ear-s for the past couple years Christopher McCormack @cmccormack Aug 11 2017 18:14 @forkerino if it's good enough, a little warmth won't matter haha i'm more of a podcast/audiobook guy and have been pretty happy with my LG HBS900, although the music sound quality is crap Pieter Stokkink @forkerino Aug 11 2017 18:15 :laughing: I love podcasts, but when I'm working I want something without words Christopher McCormack @cmccormack Aug 11 2017 18:15 Audiobooks for mundane tasks, podcasts for boring tasks, music for deep thinking tasks Jason Luboff @JLuboff Aug 11 2017 18:15 I don't listen to much music... used to..but got tired of it when I used to have to drive a lot for commuting. Now I listen to talk-radio in the car :joy: Christopher McCormack @cmccormack Aug 11 2017 18:15 and music with no words for studying @JLuboff same with me, I used to run a lot and you can only listen to so much music on a 2-hour run before you get really bored Pieter Stokkink @forkerino Aug 11 2017 18:16 podcasts all the way for commuting Addison @addisonday Aug 11 2017 18:17 @cmccormack highlights word, right clicks > Search Google for "lodash" Christopher McCormack @cmccormack Aug 11 2017 18:17 I don't have enough time in the day to listen to all the great podcasts out there, good problem to have I guess @addisonday :D it's pretty nice. all things you can implement yourself but eventually won't feel like Pieter Stokkink @forkerino Aug 11 2017 18:19 yay for lodash o/ Jason Luboff @JLuboff Aug 11 2017 18:20 Wooo lodash! (I've only ever used it once I think lol) Xzanos @Xzanos Aug 11 2017 18:21 well shoot, this is frustrating. @SkyC0der still no dice thanks for the help though CamperBot @camperbot Aug 11 2017 18:21 xzanos sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles: :star2: 2368 | @skyc0der |http://www.freecodecamp.com/skyc0der Jason Luboff @JLuboff Aug 11 2017 18:21 @cmccormack I'm going through some practice Windows exam questions...and I forgot how much the questions go over subject matter that is not in the official microsoft press books Christopher McCormack @cmccormack Aug 11 2017 18:22 @JLuboff I feel like many of these industry exams almost require you to look at the brain dumps to pass Jason Luboff @JLuboff Aug 11 2017 18:23 Yup. I did the practice exams that came with the book... scored 80, 90, 82, 100. Now going through a brain dump (may or may not be current, not sure) and I'm averaging 74% thus far :( Christopher McCormack @cmccormack Aug 11 2017 18:23 @forkerino you guys use React at work? @JLuboff well at least you'll have something to study up on :D Jason Luboff @JLuboff Aug 11 2017 18:24 @cmccormack Ya... thats what my plan is...finishing going through the dump then go back and assess what I need to study a bit more. The ones that are getting me mostly are the "Choose all that apply" bullshit questions Christopher McCormack @cmccormack Aug 11 2017 18:25 Those should be banned. Everything seems like it might be an ok option given different contexts right? Jason Luboff @JLuboff Aug 11 2017 18:26 For the most part, usually one answer is for sure not it but then theres always at least one that kind of falls in between Christopher McCormack @cmccormack Aug 11 2017 18:27 Work is paying for the exam though right? Jason Luboff @JLuboff Aug 11 2017 18:27 Yup Christopher McCormack @cmccormack Aug 11 2017 18:27 that's nice :) Jason Luboff @JLuboff Aug 11 2017 18:27 Most definitely. But I'd still like to make sure I pass Christopher McCormack @cmccormack Aug 11 2017 18:28 yeah my work pays for mine as well but if I fail it the next test is out of pocket Jason Luboff @JLuboff Aug 11 2017 18:29 I didn't ask what happens if I fail.. lol Damn it. I keep missing one on this damn multiple answer ones Pieter Stokkink @forkerino Aug 11 2017 18:37 @cmccormack No React, unfortunately, but AngularJS + Redux I dislike Angular a bit, but Redux is cool Christopher McCormack @cmccormack Aug 11 2017 18:39 Do you guys have custom webpack and build tools? Pieter Stokkink @forkerino Aug 11 2017 18:39 Yes Christopher McCormack @cmccormack Aug 11 2017 18:39 I tried setting up my environment without create-react-app and it's so much more tedious Pieter Stokkink @forkerino Aug 11 2017 18:39 hahaha yes It's a good idea to make your own starterkit once Christopher McCormack @cmccormack Aug 11 2017 18:39 I still don't know how to package everything to a build folder and use custom variables that get autofilled I agree but it's a lot to learn that's for sure Pieter Stokkink @forkerino Aug 11 2017 18:42 I did a course on pluralsight on building a starter kit a while ago. That was helpful. But it's one of those things you often do once and then forget. Joseph @revisualize Aug 11 2017 18:43 Hi. Pieter Stokkink @forkerino Aug 11 2017 18:44 Hey! Jason Luboff @JLuboff Aug 11 2017 18:46 I love password recovery where they send you you're password in an email in plain text Christopher McCormack @cmccormack Aug 11 2017 18:46 @revisualize hi! @JLuboff it's crazy that with all the security issues over the past several years there are still companies that don't give a rip about security Jason Luboff @JLuboff Aug 11 2017 18:47 Yup. Given...its from exam collections...so..how much do they really care about security? lol Christopher McCormack @cmccormack Aug 11 2017 18:48 But the problem is you might use the same username/password combo somewhere else (your fault, but still...) and them ignoring security can have effects elsewhere Jason Luboff @JLuboff Aug 11 2017 18:48 Definitely. Luckily its a password that I haven't used in a very very long time Jason Luboff @JLuboff Aug 11 2017 18:56 @cmccormack @revisualize Either you know an alternative to Visual Cert Exam? Joseph @revisualize Aug 11 2017 19:05 @JLuboff nope Christopher McCormack @cmccormack Aug 11 2017 19:14 I don't even know what that is :D Blauelf @Blauelf Aug 11 2017 19:18 @kjuchtmans What I meant is, store all values as multiples of the smallest value instead of their dollar value. That way, you can operate on integers, which don't have rounding issues. You only have to convert input to your integer representation, and later integers back to output. But in between, try to avoid floating point. Xzanos @Xzanos Aug 11 2017 19:19 Jason Luboff @JLuboff Aug 11 2017 19:20 @cmccormack Software to run .vce files. Essentially for running brain dumps in a faux-testing enviornment Christopher McCormack @cmccormack Aug 11 2017 19:22 ah ok Jason Luboff @JLuboff Aug 11 2017 19:22 I had a cracked version long ago, but it doesn't run new vce files Diego Mayer @Chrono79 Aug 11 2017 19:23 :wave: Christopher McCormack @cmccormack Aug 11 2017 19:24 @Chrono79 hiya! Jason Luboff @JLuboff Aug 11 2017 19:24 :wave: Diego Mayer @Chrono79 Aug 11 2017 19:24 How are you doing? Christopher McCormack @cmccormack Aug 11 2017 19:24 Counting down the hours until the weekend :D Jason Luboff @JLuboff Aug 11 2017 19:25 Yup...lunch right now Christopher McCormack @cmccormack Aug 11 2017 19:26 I just started the data vis stuff with d3 and having a lot of fun, probably going to waste my weekend working on that Jason Luboff @JLuboff Aug 11 2017 19:28 I might work on my sotck chart app over the weekend..otherwise...need to rest.. Christopher McCormack @cmccormack Aug 11 2017 19:28 working coding and studying all week isn't restful enough? Jason Luboff @JLuboff Aug 11 2017 19:30 working, coding, studying, pregnant wife, injured dog (as of today), sick grandma, my own illness (whatever it is)...ya...not restful enough :P Christopher McCormack @cmccormack Aug 11 2017 19:33 Yeah I take it back, get some rest in fact, everyone get some rest! Jason Luboff @JLuboff Aug 11 2017 19:34 :D BrianWilliams28 @BrianWilliams28 Aug 11 2017 19:56 hey guys, working on the missing letters algorithm and I'm looking for a tip on how to tackle this. Here is what I have so far... /* Find the missing letter in the passed letter range and return it. If all letters are present in the range, return undefined. */ function fearNotLetter(str) { var missingLetter = ''; for (var i = 0; i < str.length; i++) { var index = str.charCodeAt(i); console.log(index); } return str; } fearNotLetter("abce"); // needs to return "d" Coy Sanders @coymeetsworld Aug 11 2017 19:57 the character codes for each letter are sequential @BrianWilliams28 Diego Mayer @Chrono79 Aug 11 2017 19:58 or should be in your string when no one is missing BrianWilliams28 @BrianWilliams28 Aug 11 2017 19:58 @coymeetsworld yup i know that Coy Sanders @coymeetsworld Aug 11 2017 19:58 then if a is 97, what should the code be for the next character? BrianWilliams28 @BrianWilliams28 Aug 11 2017 19:59 @coymeetsworld in this case I know d is supposed to = 100 Coy Sanders @coymeetsworld Aug 11 2017 19:59 thats not what I asked though but yes it should be 100 when its not, you know something is missing in the range BrianWilliams28 @BrianWilliams28 Aug 11 2017 20:00 if a is 97 then b is 98...? what do you mean Coy Sanders @coymeetsworld Aug 11 2017 20:00 yes BrianWilliams28 @BrianWilliams28 Aug 11 2017 20:00 a is equal to 65 here Diego Mayer @Chrono79 Aug 11 2017 20:00 65 is capital A BrianWilliams28 @BrianWilliams28 Aug 11 2017 20:00 ah yeah i mean i know what im supposed to get just figuring out how to make that happen Diego Mayer @Chrono79 Aug 11 2017 20:01 each following letter should have a code greater than the previous one in 1 BrianWilliams28 @BrianWilliams28 Aug 11 2017 20:03 so i could use a conditional statement to compare str[i] to something Diego Mayer @Chrono79 Aug 11 2017 20:04 yes BrianWilliams28 @BrianWilliams28 Aug 11 2017 20:08 im stumped lol funny thing is i figured out the last 3 without much issues Angel J Piscola @Redmega Aug 11 2017 20:10 @BrianWilliams28 What I would do is make a string of the alphabet, var alphabet = 'abcdefghijklmnopqrstuvwxyz'; BrianWilliams28 @BrianWilliams28 Aug 11 2017 20:10 mm yeah i was thinking of doing something like that Angel J Piscola @Redmega Aug 11 2017 20:11 Get the first letter and last letter of the string, find their indices to determine what length it should be, and then compare that to the length of the string BrianWilliams28 @BrianWilliams28 Aug 11 2017 20:11 compare that to the length of the alphabet variable you mean? Angel J Piscola @Redmega Aug 11 2017 20:11 Nope :) str.length === alpha.substr(alpha.indexOf(str[0]), alpha.indexOf(str[str.length-1])) Something like that If we know the first and last letters of the range, we can find the real range by getting the substring of the alphabet abcdefg.length === 7 abc efg.length === 6 Oh wait You need to return the missing letter Angel J Piscola @Redmega Aug 11 2017 20:17 in that case I would use regex Though I'm sure there's a better solution ;) Coy Sanders @coymeetsworld Aug 11 2017 20:24 you don't need regex checking the character code of each letter and verifying it's sequential is the best option when its not you know there's a missing letter Diego Mayer @Chrono79 Aug 11 2017 20:30 @coymeetsworld +1 Angel J Piscola @Redmega Aug 11 2017 20:37 Never said you need regex, Coy ;) Diego Mayer @Chrono79 Aug 11 2017 20:39 easiest way would be checking each letter code is its index plus the first letter char code when that check fails return the missing letter Angel J Piscola @Redmega Aug 11 2017 20:44 Definitely easiest BrianWilliams28 @BrianWilliams28 Aug 11 2017 20:44 i'm going to take a break from this and come back later to try again, thanks for the suggestions @Chrono79 @Redmega @coymeetsworld CamperBot @camperbot Aug 11 2017 20:44 brianwilliams28 sends brownie points to @chrono79 and @redmega and @coymeetsworld :sparkles: :thumbsup: :sparkles: :cookie: 157 | @redmega |http://www.freecodecamp.com/redmega :star2: 2990 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld :star2: 4519 | @chrono79 |http://www.freecodecamp.com/chrono79 Tai Jones @taiJones00 Aug 11 2017 20:57 Do I have to combine the freeCodeCamp weather API with the navigator API from the couple lessons before to finish the weather project Jason Luboff @JLuboff Aug 11 2017 20:59 @taiJones00 Yes, or use another method for getting the users location such as IP address Tai Jones @taiJones00 Aug 11 2017 20:59 Oh okay. Are multiple apis in one project common Jason Luboff @JLuboff Aug 11 2017 21:00 It all depends on the project and what you're accomplishing Christopher McCormack @cmccormack Aug 11 2017 21:01 APIs usually serve a single purpose, so if you want to do multiple things you may need multiple APIs Gersho @Gersho Aug 11 2017 21:02 or multiple calls to the same one Tai Jones @taiJones00 Aug 11 2017 21:04 okay well i'm trying this and something doesn't seem right $.getJSON("https://fcc-weather-api.glitch.me/api/current?position.coords.latitude=35&lon=139", function(json) {
can I just invoke the built in navigator from the browser by putting it in the url?
Jason Luboff
@JLuboff
Aug 11 2017 21:05
No
Christopher McCormack
@cmccormack
Aug 11 2017 21:06
@taiJones00 make sure you do your weather api call within the scope of the geolocation response, as both are asynchronous
Gersho
@Gersho
Aug 11 2017 21:06
i don't know what you mean by "invoke the built"
Tai Jones
@taiJones00
Aug 11 2017 21:07
like to call it
Christopher McCormack
@cmccormack
Aug 11 2017 21:07
@taiJones00 also you if you wanted to use the geolocation response, why would you assign something to it?
Gersho
@Gersho
Aug 11 2017 21:08
well if you just want a look at the json, put the url in your browser, but the response object is already provided on the api page, and if you want to use that data in your code, that's what the callback is for
Tai Jones
@taiJones00
Aug 11 2017 21:09
So I can find the location of the user and get the weather for that location. Here it's just 35 and 139 but I want those values to change depending on what the geolaction returns
Christopher McCormack
@cmccormack
Aug 11 2017 21:09

you could do something like

 https://fcc-weather-api.glitch.me/api/current?lat=${lat}&lon=${lon}

which, assuming you stored lat and lon in variables, would use template literals to fill in the lat and lon positions in your url

sorry for the poor formatting :D
Gersho
@Gersho
Aug 11 2017 21:10
there's various way to get a user's position, but you need an answer in long/lat
Tai Jones
@taiJones00
Aug 11 2017 21:10
how'd you know that this ${var} format works Jason Luboff @JLuboff Aug 11 2017 21:11 That Template Literals(strings) Christopher McCormack @cmccormack Aug 11 2017 21:11 Gersho @Gersho Aug 11 2017 21:11 i haven't tried it myself but it looks like it calls for the object (in js, almost everything is an object) Christopher McCormack @cmccormack Aug 11 2017 21:11 They're awesome Jason Luboff @JLuboff Aug 11 2017 21:11 Instead of using '' or "" you use  Gersho @Gersho Aug 11 2017 21:12 i use += and build it over multiple lines D; Jason Luboff @JLuboff Aug 11 2017 21:12 And then you can use variables/parameters in the string using ${variableName}
Gersho
@Gersho
Aug 11 2017 21:13
will it use current value or update it before executing ? like var = foo()
Jason Luboff
@JLuboff
Aug 11 2017 21:14
I guess it would depend on your structure..
Christopher McCormack
@cmccormack
Aug 11 2017 21:14
you can invoke any expression in the ${...} which is awesome you can take something that would normally be several lines and do it in one: .style("background-color", (t)=>hsl(${scaleColor(t[1])}, 50%, 50%))
Gersho
@Gersho
Aug 11 2017 21:16
well i have to recheck almost all my projects because i was using <center>, so i guess i'll try to add some ${..} while i'm at it Christopher McCormack @cmccormack Aug 11 2017 21:16 ? Gersho @Gersho Aug 11 2017 21:17 i don't know that operator => what is it called so i can google it ? Christopher McCormack @cmccormack Aug 11 2017 21:17 arrow function Jason Luboff @JLuboff Aug 11 2017 21:17 es6 arrow syntax Christopher McCormack @cmccormack Aug 11 2017 21:17 or fat arrow to some :D Gersho @Gersho Aug 11 2017 21:17 thanks @cmccormack @JLuboff CamperBot @camperbot Aug 11 2017 21:17 gersho sends brownie points to @cmccormack and @jluboff :sparkles: :thumbsup: :sparkles: :star2: 1123 | @cmccormack |http://www.freecodecamp.com/cmccormack :star2: 2145 | @jluboff |http://www.freecodecamp.com/jluboff Christopher McCormack @cmccormack Aug 11 2017 21:18 basically var foo=(t)=>t[0] would be the equivalent to function foo(t){ return t[0]; } Gersho @Gersho Aug 11 2017 21:18 had the same issue when i stumbled upon the if/then/else in the a?b:c form, kinda hard to google until you know what it is Christopher McCormack @cmccormack Aug 11 2017 21:19 ternary Jason Luboff @JLuboff Aug 11 2017 21:20 ternary. Very confusing until you understand it too lol Christopher McCormack @cmccormack Aug 11 2017 21:20 Oh I didn't know for ternary - You can also do more than one single operation per case, separating them with a comma Jason Luboff @JLuboff Aug 11 2017 21:20 Yup return a < b ? true : b< c? true : false Christopher McCormack @cmccormack Aug 11 2017 21:20 ternarys are great because they can be used inline where an if statement cannot well not easily anyway Gersho @Gersho Aug 11 2017 21:21 @cmccormack i had that issue using concat (or reduce, can't remember) Christopher McCormack @cmccormack Aug 11 2017 21:21 concat usually wouldn't require a ternary Gersho @Gersho Aug 11 2017 21:22 just rechecked my code, it was a concat nested in a reduce Christopher McCormack @cmccormack Aug 11 2017 21:24 I"m guessing the nested array problem? Gersho @Gersho Aug 11 2017 21:25 don't really remember (i kinda don't want to remember that challenge xD) but it didn't work as an if/then/else but did as a if?then:else Nathan Vu @NathanVu Aug 11 2017 21:51 var oldArray = [1, 2, 3]; var timesFour = oldArray.map(function(val){ return val * 4; }); console.log(timesFour); // returns [4, 8, 12] console.log(oldArray); // returns [1, 2, 3] hey guys i don't understand this code what is function(val) used for ? Jason Luboff @JLuboff Aug 11 2017 21:53 It's the callback for your map Essentially you have to pass in a function to map, where val is the parameter that you can manipulate inside the map Diego Mayer @Chrono79 Aug 11 2017 21:55 val is each element of your array Jason Luboff @JLuboff Aug 11 2017 21:56 I guess I should have said that Diego Mayer @Chrono79 Aug 11 2017 22:00 I don't know if they even say what is a callback function in the current map Jason Luboff @JLuboff Aug 11 2017 22:00 Probably not Diego Mayer @Chrono79 Aug 11 2017 22:02 later :wave: Jason Luboff @JLuboff Aug 11 2017 22:02 See ya Nathan Vu @NathanVu Aug 11 2017 22:15 free codecamp do a poor job at explaining instructions. What is a callback function? Coy Sanders @coymeetsworld Aug 11 2017 22:32 its a function thats passed into another function, FCC does a good job at explaining most things it covers but its not all inclusive nothing is really Christopher McCormack @cmccormack Aug 11 2017 22:33 Callbacks are basically a function that is passed by reference to another function. When the called function is ready, it will call the callback function with its own arguments Christopher McCormack @cmccormack Aug 11 2017 22:39 here's a crappy example I just made: https://codepen.io/cmccormack/pen/YxxpXX Jason Luboff @JLuboff Aug 11 2017 22:45 Man that is crappy...couldn't even write it to the DOM? :P Christopher McCormack @cmccormack Aug 11 2017 22:47 hello haha it would be out of context in the dom Nathan Vu @NathanVu Aug 11 2017 22:49 @cmccormack can you explain your codepen? it's a bit confusing... Jason Luboff @JLuboff Aug 11 2017 22:49 You need to look at the console to see the output Nathan Vu @NathanVu Aug 11 2017 22:50 its returning Received 40 malt balls. Christopher McCormack @cmccormack Aug 11 2017 22:52 I updated with a few more descriptions Nathan Vu @NathanVu Aug 11 2017 22:54 Thanks @cmccormack CamperBot @camperbot Aug 11 2017 22:54 nathanvu sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles: :star2: 1124 | @cmccormack |http://www.freecodecamp.com/cmccormack Christopher McCormack @cmccormack Aug 11 2017 22:55 np Guderian Raborg @hypercuber Aug 11 2017 23:05 event listener for left and right click? Jason Luboff @JLuboff Aug 11 2017 23:10 Woo. Web sockets is working Tai Jones @taiJones00 Aug 11 2017 23:15  if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var lat = position.coords.latitude; var lon = position.coords.longitude; //Get the weather API$.getJSON("https://fcc-weather-api.glitch.me/api/current?lat=${lat}&lon=${lon}", function(json) {
Did I set this up right? I'm trying to put the lat I got from the geolocation in the API url for the weather
Jason Luboff
@JLuboff
Aug 11 2017 23:16
@taiJones00 You need to use  instead of " for your string if oyu're going to use template literals