These are chat archives for FreeCodeCamp/HelpJavaScript

11th
Jul 2017
NicholasGalarza
@NicholasGalarza
Jul 11 2017 00:04
If anyone wants to look at my disgusting Codepen of this problem, I'll post the link upon request because I don't want to inundate the chat more than I already have.
Stephen James
@sjames1958gm
Jul 11 2017 00:09
@NicholasGalarza You have a lot of elements with the same ID, which is frowned upon. 2x the number of followers. Maybe change that to class.
Also your success function is going to set them all the the last status returned. I would think that at least one status id would be set.
Can you link your codepen?
NicholasGalarza
@NicholasGalarza
Jul 11 2017 00:12
@sjames1958gm Absolutely, and for now, if all of the status elements are updated with the status of the user id, that's a success for me, I'll figure out how to asynchronously loop each user after.
Stephen James
@sjames1958gm
Jul 11 2017 00:13
@NicholasGalarza you could incorporate the channel name into the id and use that to set the status
NicholasGalarza
@NicholasGalarza
Jul 11 2017 00:15
@sjames1958gm Euuuuu, that's a really good idea! I never thought about that! Thank you for that one! lol. I was wondering how I would target each individual but that's a nice step in the right direction. So thank you for that tip!
CamperBot
@camperbot
Jul 11 2017 00:15
nicholasgalarza sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8038 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 11 2017 00:16
@NicholasGalarza I think that code you showed is setting the status id, but it is the one next to FCC, that is why you don't see it.
NicholasGalarza
@NicholasGalarza
Jul 11 2017 00:16
So just to point, if every row is updated with the status of septiness, which is the first user in the array, then my problem is solved lol.
@sjames1958gm So status is actually targetting the '#status' tag for FCC? So the question is this now, why is it not updating the other rows as well?
Since they also have the id of status
Stephen James
@sjames1958gm
Jul 11 2017 00:18
@NicholasGalarza Not sure, but maybe for IDs it stops at the first match.
@NicholasGalarza '<div id="' + name + '" class="col-xs-3 col-sm-1">' +
instead of status. then below do the same when you set the icon
NicholasGalarza
@NicholasGalarza
Jul 11 2017 00:21
@sjames1958gm So I just played around with the names, and I think you may be correct about ids. I had no clue it stops on first match but it seems that may be the case. I'm going to try out your code now as well.
Oh and I'm developing locally so you won't see my changed unfortunately. I don't like to use Codepen!
changes*
Stephen James
@sjames1958gm
Jul 11 2017 00:25
Good luck
NicholasGalarza
@NicholasGalarza
Jul 11 2017 00:27
Okay, so what yours did is it updated the status of the last element in the row. So progress! lol. Okay, so I updated the codepen to reflect that new change!
@sjames1958gm Thank you for the tips! And I definitely need it! xD
CamperBot
@camperbot
Jul 11 2017 00:27
nicholasgalarza sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: nicholasgalarza already gave sjames1958gm points
Stephen James
@sjames1958gm
Jul 11 2017 00:27
@NicholasGalarza :+1:
Sunny Wong
@swong194
Jul 11 2017 00:54
hi everyone im attempting the calculator challenge
any tips?
Stephen James
@sjames1958gm
Jul 11 2017 01:02
@swong194 Make some buttons without any styling and get the calculator part to work then style the buttons.
That way you don't get stuck in the styling.
Mai Thinh
@mthinh
Jul 11 2017 01:12
Please help, how i match all whitespace and character except the dash -
NicholasGalarza
@NicholasGalarza
Jul 11 2017 01:13
@mthinh With regex? I believe you would use /\s/g
oh and characters so /\s[A-Za-z]/g
Mai Thinh
@mthinh
Jul 11 2017 01:14
/\s/g just match all the white space?
every character except the dash ?
NicholasGalarza
@NicholasGalarza
Jul 11 2017 01:15
woops, I'm derping lol. uhh! regex hmm ...
I know that ^ will exclude
Mai Thinh
@mthinh
Jul 11 2017 01:15
okay :D
thank you @NicholasGalarza
CamperBot
@camperbot
Jul 11 2017 01:15
mthinh sends brownie points to @nicholasgalarza :sparkles: :thumbsup: :sparkles:
:cookie: 290 | @nicholasgalarza |http://www.freecodecamp.com/nicholasgalarza
NicholasGalarza
@NicholasGalarza
Jul 11 2017 01:17
@mthinh np, I'm half-awake right now so I was just misreading the question over and over again xD
NicholasGalarza
@NicholasGalarza
Jul 11 2017 01:20
@mthinh One more thing, ^ alone will mean to match if it starts with the specified character.
to use it for exclusion, you will have to use it within [] character set.
AlliBun
@AlliBun
Jul 11 2017 01:23
my javascript to get the user input on a search form does not seem to be working :c
https://codepen.io/Erynfi/pen/bRmXeL
Janelle deMent
@janelledement
Jul 11 2017 01:30

Hey , I'm working on Basic Algorithms and am stuck stuck on 'seek and destroy'. I know the problem is that I'm mis-using filter() somehow but at a loss. Can anyone point me the right direction? function destroyer(arr) {

var args = Array.prototype.slice.call(arguments);
var destroyedArr = [];

for(var i = 1; i < args.length; i++) {
destroyedArr += args.filter(function(val){
return val !== args[i];
});

return destroyedArr;

}

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Moisés Man
@moigithub
Jul 11 2017 01:53
@janelledement filter returns a new array...
if u wanna add elements to array u need to use array methods
NOT +
i always think on .. what VALUES this or that method returns.. based on X input
Nathaniel Suchy
@nsuchy
Jul 11 2017 01:57

https://gist.github.com/nsuchy/f397cb52ab6962e5a9da7b209f0ec4cf

It only shows the first user in the loop. Any ideas on why?

Moisés Man
@moigithub
Jul 11 2017 01:59
r u working locally ? or using codepen(some online tool) ? @nsuchy
Nathaniel Suchy
@nsuchy
Jul 11 2017 01:59
I work locally
John
@AnonymousLords
Jul 11 2017 02:00
Hi guys
Moisés Man
@moigithub
Jul 11 2017 02:01
easier tocheck/test if u put ur code on codepen or similar tool @nsuchy
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:01
@janelledement arr will be the array passed to the function, in this case [1,2,3,1,2,3] and args will be everything passed to the function. But you already have access to the array, so you can remove that array from args and you'll have two arrays. One with [1,2,3,1,2,3] and one with [2,3]. So now you can use the indexOf method to check if an item in one array is present in another. Together with filter you'll be able to filter out the unique values in arr.
Nathaniel Suchy
@nsuchy
Jul 11 2017 02:01
@moigithub Codepen has a ton of issues, I don’t want to deal with it
Also what happens when I’m in software dev job?
Opps I can only make it work on Codepen?
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:02
do you use git?
Nathaniel Suchy
@nsuchy
Jul 11 2017 02:02
I don’t think my boss would like to hear that
And yes I use git
a lot
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:02
cool then it's easy to share the code.
I think you're right about dev job and codepen!
Nathaniel Suchy
@nsuchy
Jul 11 2017 02:03
Thank you @alexanderkopke
CamperBot
@camperbot
Jul 11 2017 02:03
nsuchy sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1605 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Nathaniel Suchy
@nsuchy
Jul 11 2017 02:04
@alexanderkopke You can see my work on GitHub via https://github.com/nsuchy
Moisés Man
@moigithub
Jul 11 2017 02:04
@nsuchy well.. for me is easier to open link/click run
instead of copy all code /create some files
cuz im lazy :P
nsuchy @nsuchy Dies inside
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:04
we're all lazy :)
Nathaniel Suchy
@nsuchy
Jul 11 2017 02:04
I’m not
I take my time so it can get done right
I should avoid getting bad habits now rather than later
Moisés Man
@moigithub
Jul 11 2017 02:05
most probably ur problem is cuz async
Nathaniel Suchy
@nsuchy
Jul 11 2017 02:05
what is async?
Joseph
@revisualize
Jul 11 2017 02:05
Hi.
Long Nguyen
@longnt80
Jul 11 2017 02:05
@nsuchy you post on codepen so other can check it, not for you to check it
Nathaniel Suchy
@nsuchy
Jul 11 2017 02:06
@longnt80 Fine, keep in mind I work locally so it’s easier to package when pushing to my production server for project display
Long Nguyen
@longnt80
Jul 11 2017 02:07
@nsuchy this is simple project, won't make a big deal if it's on codepen or local
Moisés Man
@moigithub
Jul 11 2017 02:07
asynchronous code
enjoy
Last reason I develop locally, I like using atom on one monitor and having my browser on another
Guderian Raborg
@hypercuber
Jul 11 2017 02:11
What do they want in this problem: https://projecteuler.net/problem=13
I dont understand.
John
@AnonymousLords
Jul 11 2017 02:12
uhhhh
Long Nguyen
@longnt80
Jul 11 2017 02:12
@nsuchy you can develop wherever you want, but when asking for debugging, show some courtesy by giving others the easy way to test
John
@AnonymousLords
Jul 11 2017 02:12
Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.
all of those hundred and 150 digets, what is their sum?
Then what is teh first ten digest of that sum
im guessing
Nathaniel Suchy
@nsuchy
Jul 11 2017 02:14
@longnt80 Alright, well I’ve posted on codepen, I’ll package it later
for now let’s focus on debugging, pretty package will have to come later :/
Long Nguyen
@longnt80
Jul 11 2017 02:16
@nsuchy change to append
$("#usersrow").append("&nbsp; &nbsp; &nbsp; <strong>" + json["display_name"] + "</strong><br><br>");
Nathaniel Suchy
@nsuchy
Jul 11 2017 02:18
updated
though it looks like API failing to work at the moment
Long Nguyen
@longnt80
Jul 11 2017 02:18
what's the error?
Nathaniel Suchy
@nsuchy
Jul 11 2017 02:19
can you view my pen for a moment
It’s been updated with append
Long Nguyen
@longnt80
Jul 11 2017 02:20

@nsuchy error in console:
Uncaught ReferenceError: $ is not defined

you need to include jQuery

Nathaniel Suchy
@nsuchy
Jul 11 2017 02:20
that fixed it
Thank you
Long Nguyen
@longnt80
Jul 11 2017 02:20
np
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:21
@nsuchy use channels instead of users
Nathaniel Suchy
@nsuchy
Jul 11 2017 02:21
Good idea
Sunny Wong
@swong194
Jul 11 2017 02:22
can som1 help me understand why
Nathaniel Suchy
@nsuchy
Jul 11 2017 02:22
I’m developing locally now though
Sunny Wong
@swong194
Jul 11 2017 02:22
my display won't clear or show operators
Nathaniel Suchy
@nsuchy
Jul 11 2017 02:22
I’ll post an update once I’m finished coding
Mai Thinh
@mthinh
Jul 11 2017 02:30
function sumPrimes(num) {
  var i=1,arr=[];
  while(i<num){
    for(var j=1;j<i-1;j++){
      if(i%1===0 && i%i===0 && i%j!==0){
        arr.push(i);
        i++;
      }
    }


  }
  return arr;
}
sb explain me why this causes infinite loop
Bradley Sands
@sandsbe
Jul 11 2017 02:31
Are there other fCC chat rooms in Gitter? I only have HelpJavaScript, Help, and FreeCodeCamp.
Long Nguyen
@longnt80
Jul 11 2017 02:33
@swong194 change the function name of clear() to something else
I don't know why it doesn't accept clear
NicholasGalarza
@NicholasGalarza
Jul 11 2017 02:35
@mthinh Your value of i is equal to 1. entering thefor() loop, the condition is j < i-1 in other words, while j(1) < 0. This means your value of i is never going to be incremented hence you are stuck in the while loop.
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:35
hmm there seems to be a clear property on the Window object
Sunny Wong
@swong194
Jul 11 2017 02:35
@longnt80 thanks
CamperBot
@camperbot
Jul 11 2017 02:35
swong194 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 439 | @longnt80 |http://www.freecodecamp.com/longnt80
Sunny Wong
@swong194
Jul 11 2017 02:35
@alexanderkopke thanks as well
CamperBot
@camperbot
Jul 11 2017 02:35
swong194 sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1606 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:36
@swong194 thanks
Long Nguyen
@longnt80
Jul 11 2017 02:36
@alexanderkopke :+1:
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:36
why my thanks never work?
Sunny Wong
@swong194
Jul 11 2017 02:36
always thankful for insight
oh
u have to be sincere
hahaha
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:36
thank you, merci, gracias @swong194
Sunny Wong
@swong194
Jul 11 2017 02:36
that is weird though...
@alexanderkopke gracias
CamperBot
@camperbot
Jul 11 2017 02:36
swong194 sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:warning: swong194 already gave alexanderkopke points
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:37
@swong194 gracias
Long Nguyen
@longnt80
Jul 11 2017 02:37
@mthinh hello
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:37
???
Sunny Wong
@swong194
Jul 11 2017 02:37
haha
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:37
camperbot hates me :cry:
Sunny Wong
@swong194
Jul 11 2017 02:37
do you guys mind looking into why my operators won't display?
Mai Thinh
@mthinh
Jul 11 2017 02:37
@NicholasGalarza so how i have to change the value of i ?
@longnt80 hey : )) can you pls help my prob
Sunny Wong
@swong194
Jul 11 2017 02:38
actually im kinda iffy on my logic in terms of building the calculator ;/
Long Nguyen
@longnt80
Jul 11 2017 02:38
@mthinh let me see
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:38
@swong194 use single quotes to send the string <button onclick="show('+')" id="+">+</button>
Sunny Wong
@swong194
Jul 11 2017 02:39
i was thinking of displaying everything, and when "=" is pressed i take the input and pass it into a function to calculate
oh
NicholasGalarza
@NicholasGalarza
Jul 11 2017 02:39
@mthinh You just need to change the condition of your for loop is all. You can try starting from the value of num, then going down to 1 instead and summing primes from there. There are many ways to its up to you!
Sunny Wong
@swong194
Jul 11 2017 02:39
@alexanderkopke bless you
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:39
I hated doing the calculator challenge. Especially after it looking like it was made of playdoh and someone stepped on it
my pleasure :)
@sandsbe you can use the search feature to the left, write freecodecamp hit enter and more fcc rooms will appear
Sunny Wong
@swong194
Jul 11 2017 02:43
im sorry for asking so many questions, but is there a way for me to return whatever is currently in my html
NicholasGalarza
@NicholasGalarza
Jul 11 2017 02:43
@alexanderkopke Did you find the twitch api difficult to deal with at all? I'm currently struggling with callback hell lol. Someone did help me earlier and pointed me in the right direction, but my mind is just so dead right now, I cannot think clearly any longer lol.
fdemaa
@fdemaa
Jul 11 2017 02:46
Anyone know whats wrong with this : i can insert my html
var reference = document.getElementsByTagName("div");
var newHtml = reference.insertAdjacentHTML('beforebegin' ,'<div><p>Hola soy un nuevo texto</p><h5>Fua que bueno poder insertar todo de una si es que sale dale porfavor!</h5><p>Vainilla js</p></div>');
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:46
@NicholasGalarza yeah it was difficult for me for sure. But back then it was even more simple than it is now. Today they built in security stuff making it even harder
NicholasGalarza
@NicholasGalarza
Jul 11 2017 02:46
@alexanderkopke Haha, CORS and documentation changes. I've gotten passed that step fortunately xD
Alexander Køpke
@alexanderkopke
Jul 11 2017 02:47
@NicholasGalarza oh good!
NicholasGalarza
@NicholasGalarza
Jul 11 2017 02:48
:dancers:
Kane Mcgukin
@kanemcgukin
Jul 11 2017 02:59

I was working on the seek and destroy challenge and I'm confused about the following code. I orginally had function destroyer(arr) {
// Remove all the values

var args = Array.prototype.slice.call(arguments);
console.log(args);
return arr.filter(function(x){
return args.indexOf(x) < 0;
});
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

I'm confused why the function(args) part didn't worked
once I changed it to function(x) and indexOf(x) it worked
Janelle deMent
@janelledement
Jul 11 2017 03:07
@alexanderkopke That was a very helpful hint. I'm much less confused, thank you!
CamperBot
@camperbot
Jul 11 2017 03:07
janelledement sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1607 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Alexander Køpke
@alexanderkopke
Jul 11 2017 03:07
@janelledement my pleasure!
Joel Y.
@zapcannon99
Jul 11 2017 03:33

This question is about the twitch API example they provide.

Does anybody know why, when I click on a link that should bring me to the relevant streamer's twitch page, the page does not load. However when I right click and open the hyperlink in a new tab or window, it works.

I've observed that this problem occurs in both mozilla and chrome. In Safari, it works perfectly. Chrome says that the request is ERR_BLOCKED_BY_CLIENT and something about the request coming from a sandboxed origin. Mozilla says that it's an insecure request.

jorlee92
@jorlee92
Jul 11 2017 03:56
@zapcannon99 It has something to do with cross site scripting I think
I think json P fixes it, or having the right callback
I know I had the same issue with the weather project, adding an appropriate callback fixed it for me
John
@AnonymousLords
Jul 11 2017 03:58
Guys why doesnt this work
"Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed."
thsi is my code
function nextInLine(arr, item) {
  arr.unshift(5);
  arr.shift(item);
  return item;  
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:00
@John-freeCodeCamp you're to add item to the end of arr holding the array, what method will you use to add a value to the end of an array?
John
@AnonymousLords
Jul 11 2017 04:01
testArr.unshift(item); ?
ello?
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:03
@John-freeCodeCamp testArr is used for testing your code, don't use that, you have a parameter arr holding the array
@John-freeCodeCamp do you still remember what push does ?
John
@AnonymousLords
Jul 11 2017 04:05
push adds to back
shift removes first
ello?
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:07
@John-freeCodeCamp so now add item to the back of arr
John
@AnonymousLords
Jul 11 2017 04:08
okay did that
arr.push(item)
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:09
@John-freeCodeCamp cool
@John-freeCodeCamp how do you remove the first element in an array?
John
@AnonymousLords
Jul 11 2017 04:09
shift
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:10
@John-freeCodeCamp but you know shift removes and return the value from that array ?
John
@AnonymousLords
Jul 11 2017 04:10
okay
jorlee92
@jorlee92
Jul 11 2017 04:11
@John-freeCodeCamp Alright you only need to do two things altogether. 1) Insert num at the end of the array 2) Remove the first element of an array the same function that removes the first element will also return the value that was removed
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:11
@John-freeCodeCamp but the value is yet to be returned in the function so you have to return it too
jorlee92
@jorlee92
Jul 11 2017 04:11
So you can do it in 2 lines of code
John
@AnonymousLords
Jul 11 2017 04:11
@jorlee92 ?
@Lumexralph okay
return item;
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:11
@John-freeCodeCamp nope
jorlee92
@jorlee92
Jul 11 2017 04:12
@John-freeCodeCamp I might be out of the loop of where you currently are, but what will add the number to the end of the array
And what will remove the first element
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:12
@John-freeCodeCamp just give it a lil thought
John
@AnonymousLords
Jul 11 2017 04:12
hummm
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:12
@John-freeCodeCamp see shift has it's holding the value it removed but you have to return it in your function
John
@AnonymousLords
Jul 11 2017 04:13
how?
return __
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:13
@John-freeCodeCamp continue ......
John
@AnonymousLords
Jul 11 2017 04:13
return.shift()
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:14
@John-freeCodeCamp :joy: , almost
@John-freeCodeCamp shift is an array method, which parameter did you push item to?
jorlee92
@jorlee92
Jul 11 2017 04:14
@John-freeCodeCamp What object are you trying to shift the first element away from?
John
@AnonymousLords
Jul 11 2017 04:14
return arr
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:15
@John-freeCodeCamp join the 2 pieces together
John
@AnonymousLords
Jul 11 2017 04:15
return.shift(arr):
jorlee92
@jorlee92
Jul 11 2017 04:15
@John-freeCodeCamp Return arr will return the array as it currently is. arr.shift() will remove the first element and give you the value that was removed
John
@AnonymousLords
Jul 11 2017 04:15
;
jorlee92
@jorlee92
Jul 11 2017 04:15
@John-freeCodeCamp so if arr = [1,2,3]
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:15
@John-freeCodeCamp arr.shift(); this removes the value and returns it but you're to also return the value in your function
jorlee92
@jorlee92
Jul 11 2017 04:16
arr.shift() will make the array [2,3] and will give you the removed number
1
John
@AnonymousLords
Jul 11 2017 04:16
this is my code
Nathaniel Suchy
@nsuchy
Jul 11 2017 04:16
/*
  Twitch.tv API Example
  Description: This is the client side
*/

var users = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas", "tominationtime"];
var streamstatus;
var streamstatus2;


$(document).ready(function() {

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

    /*
    For each i in the array of users, get the json, log to console, add to page.
    */

    $.getJSON("https://wind-bow.glitch.me/twitch-api/users/" + users[i], function(json) {
      $("#usersrowleft").append("&nbsp; &nbsp; &nbsp; <strong>" + "<a href=\"" + "https://twitch.tv/" + json["name"] + "\">" + json["display_name"] + "</a>" + "</strong><br><br>");
    });

    $.getJSON("https://wind-bow.glitch.me/twitch-api/streams/" + users[i], function(json) {
      if (json["stream"] === null) {
        $streamstatus = "Offline";
      } else {
        $streamstatus = "Online";
      }
      $("#usersrowright").append("&nbsp; &nbsp; &nbsp; <strong>" + $streamstatus + "</strong><br><br>");
    });
  }


  $("#usernamelookupcheck").on("click", function() {
    $.getJSON("https://wind-bow.glitch.me/twitch-api/users/" + $("#usernamelookup").val(), function(json) {
      if (json["error"] == "Not Found") {
        $streamstatus2 = "User does not exist!";
        $("#lookupresult").html("User does not exist!");
      } else {
        $.getJSON("https://wind-bow.glitch.me/twitch-api/streams/" + $("#usernamelookup").val(), function(json) {
          $currentgame = json["game"];
          if (json["stream"] === null) {
            $streamstatus2 = "Offline";
          } else {
            $streamstatus2 = "Online" + "<br><br>";
            console.log(json);
          };
          $("#lookupresult").html("<br><br> &nbsp; &nbsp; &nbsp; <strong>Status: " + $streamstatus2 + "</strong><br><br>" + $currentgame);

        });

      };
    })
  });
});
I’m working on this javascript, everything works, but when you check a stream to see the current game, it always returns undefined even though the array defines it. Could someone help me fix the current game variable to work properly?
John
@AnonymousLords
Jul 11 2017 04:16

function nextInLine(arr, item) {
  arr.push(item);
  arr.shift();
  return arr.shift();
}
Its still wrong?
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:16
@John-freeCodeCamp cool, you're very close
John
@AnonymousLords
Jul 11 2017 04:17
what am i missing
jorlee92
@jorlee92
Jul 11 2017 04:17
@John-freeCodeCamp as it stands your code runs shift twice
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:17
@John-freeCodeCamp but there's something you're doing, you're to remove the first element only once but using shift twice, you're removing it twice
John
@AnonymousLords
Jul 11 2017 04:17
OHHH THANKS @Lumexralph @jorlee92
CamperBot
@camperbot
Jul 11 2017 04:17
john-freecodecamp sends brownie points to @lumexralph and @jorlee92 :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @jorlee92 |http://www.freecodecamp.com/jorlee92
:star2: 2030 | @lumexralph |http://www.freecodecamp.com/lumexralph
jorlee92
@jorlee92
Jul 11 2017 04:17
One of the two shifts can be removed, possibly the first one
John
@AnonymousLords
Jul 11 2017 04:18
I was doing shift twice, so i was giving me 2
jorlee92
@jorlee92
Jul 11 2017 04:18
@John-freeCodeCamp :+1:
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:18
@John-freeCodeCamp yeah..... you're welcome, finally landed safely :smile:
John
@AnonymousLords
Jul 11 2017 04:19
Your on a plane :airplane:
:D
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:20
@John-freeCodeCamp you're on a journey, we tried to help you get there
John
@AnonymousLords
Jul 11 2017 04:20
and we did
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:20
yeah :smile:
John
@AnonymousLords
Jul 11 2017 04:20
Ik a website where i can make a lego moasic of your profile picture
SHould i do it :P
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:21
@John-freeCodeCamp i'll love to see it so love to :smile:
John
@AnonymousLords
Jul 11 2017 04:21
Okay ill see hwo it comes out
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:22
@John-freeCodeCamp no problem, you can send a private message whenever you're done, will check anytime i'm online
John
@AnonymousLords
Jul 11 2017 04:22
almost done
almost
Nathaniel Suchy
@nsuchy
Jul 11 2017 04:23
John
@AnonymousLords
Jul 11 2017 04:23
some people get 404
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:24
i didn't, if I could read the server response 200 Ok should be in the header :smile: @John-freeCodeCamp thank you
CamperBot
@camperbot
Jul 11 2017 04:24
lumexralph sends brownie points to @john-freecodecamp :sparkles: :thumbsup: :sparkles:
:cookie: 224 | @john-freecodecamp |http://www.freecodecamp.com/john-freecodecamp
John
@AnonymousLords
Jul 11 2017 04:25
@Lumexralph i privated message dyou, didnt know if you had to go lol
How doe sit look :P i could only do 60 by 60 inch
Ogundele Olumide
@Lumexralph
Jul 11 2017 04:27
@John-freeCodeCamp the mosaic me looks good, :laughing: , thanks again, received the message
CamperBot
@camperbot
Jul 11 2017 04:27
lumexralph sends brownie points to @john-freecodecamp :sparkles: :thumbsup: :sparkles:
:warning: lumexralph already gave john-freecodecamp points
John
@AnonymousLords
Jul 11 2017 04:35
@Lumexralph :)
@Lumexralph thx
CamperBot
@camperbot
Jul 11 2017 04:35
john-freecodecamp sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: john-freecodecamp already gave lumexralph points
John
@AnonymousLords
Jul 11 2017 04:35
wasnt sure if i thanked you erailer
Long Nguyen
@longnt80
Jul 11 2017 04:42
@DennisEnt do you know how to use for loop?
Dennis
@denskiz
Jul 11 2017 04:43
@longnt80 Yes. This is what I have so far:
for (let i = 0; i < arr.length; i++) {
if (arr[i] === elem){
arr.splice( i, 1);
}
}
Long Nguyen
@longnt80
Jul 11 2017 04:44
@DennisEnt what do you think the value of arr[i] is?
Dennis
@denskiz
Jul 11 2017 04:44
@longnt80 The position in the array of elem
Long Nguyen
@longnt80
Jul 11 2017 04:45
@DennisEnt no, i is the position/index
take a look: https://repl.it/JBrK/8
hit Ctrl+Enter
I logged all the results of arr[i]
Nathaniel Suchy
@nsuchy
Jul 11 2017 04:47
I did it guys
my project meets all the user stories
:D
Long Nguyen
@longnt80
Jul 11 2017 04:48
@nsuchy good job
Thoughts?
anyways, it’s almost 1 am here, so I’m off to bed now that I got a ton of coding done :D
Dennis
@denskiz
Jul 11 2017 04:57

@longnt80

this is what I have
for (let i = 0; i < arr.length; i++) {
if (arr[i] == elem){
newArr.push(arr[i]);
}
}

Long Nguyen
@longnt80
Jul 11 2017 04:58
@DennisEnt did you take a look at the example above I gave you?
@DennisEnt ok, do you know how to check if a value exist in an array?
Dennis
@denskiz
Jul 11 2017 05:00
@longnt80 indexOf()?
Long Nguyen
@longnt80
Jul 11 2017 05:01
@DennisEnt ok now you need to loop through the inner arrays and remove any array that contain elem
so another loop inside the current loop
wonder
@wonder2991
Jul 11 2017 05:05
why beta though if you are starting out? it's still very beta.
Dennis
@denskiz
Jul 11 2017 05:06
@wonder2991 The original FCC doesnt have data structures
@longnt80 Still stuck
Long Nguyen
@longnt80
Jul 11 2017 05:07
@DennisEnt create another for loop inside that loop
@DennisEnt this is wrong: arr[i] == elem
what is arr[i]?
what is elem?
for example, with this test: filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3)
what is arr[i]??
what is elem?
wonder
@wonder2991
Jul 11 2017 05:13
@DennisEnt Ok. you need to compare the elements of the subarray.
with elem
Long Nguyen
@longnt80
Jul 11 2017 05:15
@wonder2991 he needs to know what is elem
in this test
wonder
@wonder2991
Jul 11 2017 05:16
alright
Long Nguyen
@longnt80
Jul 11 2017 05:22
@DennisEnt try console.log(arr.indexOf(elem) inside your loop to see what happens
like this https://repl.it/JBrK/14
@DennisEnt do you see the result in the console on the right?
arr.indexOf(elem) is always -1
again what is elem? Do you know?
you can insert console.log(elem) at the start of your function to see
Dennis
@denskiz
Jul 11 2017 05:26
yeah if 3 exists in the array why the -1?
Long Nguyen
@longnt80
Jul 11 2017 05:27
that's the inner array
arr is an array that has inner arrays
so you have to check with arr[0], and arr[1], and arr[2], and ...
use arr[i].indexOf(elem)
Mai Thinh
@mthinh
Jul 11 2017 06:24
function steamrollArray(arrs) {
  // I'm a steamroller, baby
var newArr= arrs.reduce(function(pre,cur){
  return pre.concat(cur);
},[]);

 newArr = newArr.reduce(function(pre,cur){
  return pre.concat(cur);
},[]);
  var newArr1=newArr.reduce(function(pre,cur){
  return pre.concat(cur);
},[]);
  return newArr1;
}
My solution is too handy, is there any solutions better? thank you
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 06:52
@mthinh Here is mine
function steamrollArray(arr) {
    var a=[];
    arr.map(n=>a=Array.isArray(n)?[...a,...steamrollArray(n)]:[...a, n]);
    return a;
}
Mai Thinh
@mthinh
Jul 11 2017 06:53
oh i havent known what is spread operator
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 06:54
it basically changes ...[ a, b, c ] to a, b, c
Mai Thinh
@mthinh
Jul 11 2017 06:55
ok thank you :D @saifsmailbox98
CamperBot
@camperbot
Jul 11 2017 06:55
mthinh sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 753 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 06:55
:+1:
Markus Kiili
@Masd925
Jul 11 2017 07:05
@mthinh That solution doesn't really fulfill the problem description. That only solves up to certain level of array nesting.
Mai Thinh
@mthinh
Jul 11 2017 07:06
@Masd925 yeah i know, im trying to find the way to meet all case
Markus Kiili
@Masd925
Jul 11 2017 07:07
@mthinh There are both recursive and non-recursive ways.
Mai Thinh
@mthinh
Jul 11 2017 07:08
you mean to create a function that call itself?
Markus Kiili
@Masd925
Jul 11 2017 07:11
@mthinh Yes, the easiest way is to use steamRollArray to flatten the inner arrays.
Just be sure not to create an infinite recursion.
Mai Thinh
@mthinh
Jul 11 2017 07:13
@Masd925 ok i got it, thank you :3
CamperBot
@camperbot
Jul 11 2017 07:13
mthinh sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4291 | @masd925 |http://www.freecodecamp.com/masd925
Ashan Mohammed
@AshanMohammed
Jul 11 2017 07:18
Hello! I have finished the wikipedia viewer challenge. Any comments on my code?
https://codepen.io/ashan_zeroxster/full/MoYMWL/
wonder
@wonder2991
Jul 11 2017 07:20
good job but it should also work on enter. @AshanMohammed
Ali
@ichbinali
Jul 11 2017 07:21

Hey guys, hope everything's well! I've a question to ask.
I finished Confirm The Ending in basic algorithms yesterday. I had a few times where I thought I was that close to figuring it out. Before I gave in and checked the hints.
The code that I thought was the solution is this.

return str.substring(str.length-1, str.length) === target.substring(target.length-1, target.length);

From my understanding, the code's wrong because I was checking for the last letter of the str and target, am I correct?

That's a clean design. Like what @wonder2991 said, it should also work on enter. @AshanMohammed
wonder
@wonder2991
Jul 11 2017 07:25
@ichbinali the code should also clear when the target is not a single letter
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 07:27
@wonder2991 even single characters have their wikipedia page, try -. @AshanMohammed It would be better if you show some error messages when there are no entries.
wonder
@wonder2991
Jul 11 2017 07:29
@saifsmailbox98 what you mean?
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 07:30
@wonder2991 what do you mean by "single" letter?
wonder
@wonder2991
Jul 11 2017 07:30
i was answering to @ichbinali
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 07:30
i know.
wonder
@wonder2991
Jul 11 2017 07:30
so
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 07:31
nothing :shipit:
wonder
@wonder2991
Jul 11 2017 07:31
str.substring(str.length-1, str.length) this return the last char
Ali
@ichbinali
Jul 11 2017 07:32
Hmm, testing my code again now, I can confirm the code only checks the last letter of both str and target. Both returns true but only the bottom should be doing so.
haha("Walking on water and developing software from a specification are easy if both are frozen", "factorization");
haha("Walking on water and developing software from a specification are easy if both are frozen", "frozen");
Thanks for trying to help. :smile:
makalohri
@makalohri
Jul 11 2017 07:49
@knrt10 thank you
CamperBot
@camperbot
Jul 11 2017 07:49
makalohri sends brownie points to @knrt10 :sparkles: :thumbsup: :sparkles:
:cookie: 454 | @knrt10 |http://www.freecodecamp.com/knrt10
Owais Ahmed
@owaisehmed
Jul 11 2017 08:05
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    }
guys how do i access firstName and its value?
wonder
@wonder2991
Jul 11 2017 08:08
contacts[0]["firstName"]
@owaisehmed
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 08:08
contacts[0].firstName; // "Akira"
contacts[0]["firstName"]; // "Akira"
@owaisehmed
Owais Ahmed
@owaisehmed
Jul 11 2017 08:11
@saifsmailbox98 not printing
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 08:12
@owaisehmed you need to console.log to print.
Owais Ahmed
@owaisehmed
Jul 11 2017 08:12
@saifsmailbox98 i know but still not printing
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 08:12
post your code.
Owais Ahmed
@owaisehmed
Jul 11 2017 08:13

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


function lookUpProfile(firstName, prop){
// Only change code below this line
  //if(this.firstName == contacts[0].firstName[0])
    console.log(contacts[0].this.firstName);
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 08:13
remove this
Thayyeb salim
@Thayyebsalim
Jul 11 2017 08:14
this
Owais Ahmed
@owaisehmed
Jul 11 2017 08:14
still not
i added this later on
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 08:14
try again
Owais Ahmed
@owaisehmed
Jul 11 2017 08:15
nope
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 08:15
@owaisehmed do you know where console in located?
Thayyeb salim
@Thayyebsalim
Jul 11 2017 08:16
ok i think you have to check the condition first, right?
Owais Ahmed
@owaisehmed
Jul 11 2017 08:17
@saifsmailbox98 what do u mean
Thayyeb salim
@Thayyebsalim
Jul 11 2017 08:18
which challenge is it
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 08:18
@owaisehmed are you checking in the black box present on the sidebar?
Owais Ahmed
@owaisehmed
Jul 11 2017 08:19
yeah ofcourse i am. Its blank
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 08:19
@owaisehmed that's not the console window.
Owais Ahmed
@owaisehmed
Jul 11 2017 08:19
where should i check then
@owaisehmed Ctrl+Shift+I on most browsers.
Long Nguyen
@longnt80
Jul 11 2017 08:22
@owaisehmed or you can use this,click Run and you'll see the error on the right (the console):
https://repl.it/JBrK/20
Owais Ahmed
@owaisehmed
Jul 11 2017 08:22
@saifsmailbox98 thanks!
CamperBot
@camperbot
Jul 11 2017 08:22
owaisehmed sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 754 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Cato Myhre
@Zalmez
Jul 11 2017 08:35
I'm having slight issues changing the background color with jquery
$("quoteBtn").click(function(){
    $("body").css("background-color", "blue !important");
});
Randy Goldsmith
@Dueldrawer8
Jul 11 2017 08:39
@Zalmez dont see that code insides your pen, also did you include jQuery on codepen?
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 08:39
@Zalmez you are not selecting are right thing?
Cato Myhre
@Zalmez
Jul 11 2017 08:39
ops
$("quoteBtn").click(function(){
$("body").css("background-color", "blue !important");
});
Randy Goldsmith
@Dueldrawer8
Jul 11 2017 08:39
@Zalmez ah nvm see it
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 08:40
@Zalmez $("#quoteBtn").
Cato Myhre
@Zalmez
Jul 11 2017 08:40
I'm trying to select the body since it's what controlls the color
Randy Goldsmith
@Dueldrawer8
Jul 11 2017 08:42
@Zalmez i havent used jQuery in ages but @saifsmailbox98 is right.. quotebtn is an ID not a class
Finn Pegler
@FinnPegler
Jul 11 2017 08:42

Codewars question, solution works but is too slow to pass. I'm guessing it's the middle section where I am iterating through 3 variables. Not sure how to fix. The solution tries to find the unique string in inputs such as:

([ 'Aa', 'aaa', 'aaaaa', 'BbBb', 'Aaaa', 'AaAaAa', 'a' ]) Ans = 'BbBb'
([ 'abc', 'acb', 'bac', 'foo', 'bca', 'cab', 'cba' ]) Ans = 'foo'
([ 'silvia', 'vasili', 'victor' ]) Ans =  'victor'

Code:

function findUniq(arr) {
noSpaces = [];
lengthArr = [];
for (var i in arr){ 
noSpaces[i] = arr[i].toLowerCase().replace(/ /g, "");
}

splitArr=[];
countArr=[];  
for (var k in noSpaces){
splitArr[k] = noSpaces[k].split("");
countArr[k] = 0;
for (var j = 0;j < splitArr[k].length;j++){
  for (var n in noSpaces){
    if (noSpaces[n].indexOf(splitArr[k][j]) >= 0){countArr[k] += 1}
}
}
}
max = 0;
index1 = 0;
for (var m in countArr){
  if (countArr[m] > max){
    max = countArr[m];
    index1 = m;
  }
}

min = countArr[0];
index2 = 0;
for (var p in countArr){
  if (countArr[p] < min){
    min = countArr[p];
    index2 = p;
  }
}
if (max == 1) {return arr[index1]} else return arr[index2];
}
Randy Goldsmith
@Dueldrawer8
Jul 11 2017 08:42
to select an ID in jQuery, you need to put the "#" sign before the name and a "." for classes
https://learn.jquery.com/using-jquery-core/selecting-elements/
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 08:43
@Zalmez
$("#quoteBtn").click(function(){
    $("body").css("background-color", "blue", "important");
});
Cato Myhre
@Zalmez
Jul 11 2017 08:43
@saifsmailbox98 thanks! works
CamperBot
@camperbot
Jul 11 2017 08:43
zalmez sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 755 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Bryan Reese
@breese8009
Jul 11 2017 08:49
@FinnPegler that is alot of code there...whats the objective here for this challenge?
@FinnPegler u can post the codewars link
Owais Ahmed
@owaisehmed
Jul 11 2017 08:58
The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.
what is meant by property in the following code:
```
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];
Nevermind
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 09:00
@owaisehmed iterate over the contact objects, and if any object's firtName matches, then check whether the property is present or not, if present, return the property's value, else return "No such property", after the end of the loop if there were no such contact return "No such contact".
Owais Ahmed
@owaisehmed
Jul 11 2017 09:02
Yeah i got it
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 09:02
@owaisehmed
{
property:value;
property:value;
}
Mai Thinh
@mthinh
Jul 11 2017 09:03
excuse me! how i match all the value except the first one
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 09:04
@mthinh values, from where?
Mai Thinh
@mthinh
Jul 11 2017 09:05
example -10-00-3
i want to match all the dash
except the first dash
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 09:06
@mthinh and what do you mean by match?
count the number of dashes?
Mai Thinh
@mthinh
Jul 11 2017 09:06
ah i mean i want to replace all the dash except the first one
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 09:07
@mthinh you tried anything?
Mai Thinh
@mthinh
Jul 11 2017 09:07
??
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 09:08
@mthinh regex?
Mai Thinh
@mthinh
Jul 11 2017 09:09
yeah i mean i want to use the regex , but i dont know how
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 09:14
@mthinh str.replace(/(.)(\-)/g, "$1A"); // replaces - with A
Cato Myhre
@Zalmez
Jul 11 2017 09:15
hmm, now that I do have random colors I need to fade them onChange. any suggestions? tried looking at the .fadeOut or .FadeIn didn't work for me so
Mai Thinh
@mthinh
Jul 11 2017 09:15
@saifsmailbox98 whhy does it contain ( . ) ?
what does "$1A" mean?
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 09:16
@mthinh so pick up a character before. $1 = (.) captured group
Mai Thinh
@mthinh
Jul 11 2017 09:17
oh im sr, but i didnt work
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 09:21
@Zalmez add this to the body css
transition: background-color 200ms;
Mai Thinh
@mthinh
Jul 11 2017 09:29
@saifsmailbox98 thank you :D
CamperBot
@camperbot
Jul 11 2017 09:29
mthinh sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 756 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 09:30
:+1:
Cato Myhre
@Zalmez
Jul 11 2017 09:36
@saifsmailbox98 only to the css or witht the JS?
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 09:36
@Zalmez only to the css
Cato Myhre
@Zalmez
Jul 11 2017 09:36
thanks o/ @saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 09:37
yw
Cato Myhre
@Zalmez
Jul 11 2017 09:46
using the webkit one might be better for mobile :thought_balloon:
Ashan Mohammed
@AshanMohammed
Jul 11 2017 09:52
@saifsmailbox98 @wonder2991 @ichbinali Thanks Guys! I do those changes you'll suggested.
CamperBot
@camperbot
Jul 11 2017 09:52
ashanmohammed sends brownie points to @saifsmailbox98 and @wonder2991 and @ichbinali :sparkles: :thumbsup: :sparkles:
:cookie: 757 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
:cookie: 396 | @wonder2991 |http://www.freecodecamp.com/wonder2991
:cookie: 246 | @ichbinali |http://www.freecodecamp.com/ichbinali
Sachin
@sachinmc
Jul 11 2017 09:56
hi folks, The below piece of regex is meant to identify alternating vowel pattern across a string. I don't quite understand how it works.
/[aeiou]{2,}|[^aeiou]{2,}/g
For example, this matches 'banana'. The character set should first match a vowel of size 2 or a consonant of size 2, but then it fails already.
can someone explain
Owais Ahmed
@owaisehmed
Jul 11 2017 10:00
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
How do i access the array keys?
heroiczero
@heroiczero
Jul 11 2017 10:00
@owaisehmed myPlants is your object and list is your property with the arrray
@owaisehmed so myPlants.list[0] would be the first item in the array
Finn Pegler
@FinnPegler
Jul 11 2017 10:01
Owais Ahmed
@owaisehmed
Jul 11 2017 10:01
no i mean to ask how do i access the key which is list or type
list[0] would return the value of rose
Finn Pegler
@FinnPegler
Jul 11 2017 10:01

Stuck on a kata, it works for all solutions but is too slow - https://www.codewars.com/kata/585d8c8a28bc7403ea0000c3

Codewars question, solution works but is too slow to pass. I'm guessing it's the middle section where I am iterating through 3 variables. Not sure how to fix. The solution tries to find the unique string in inputs such as:

([ 'Aa', 'aaa', 'aaaaa', 'BbBb', 'Aaaa', 'AaAaAa', 'a' ]) Ans = 'BbBb'
([ 'abc', 'acb', 'bac', 'foo', 'bca', 'cab', 'cba' ]) Ans = 'foo'
([ 'silvia', 'vasili', 'victor' ]) Ans =  'victor'

Code:

function findUniq(arr) {
noSpaces = [];
lengthArr = [];
for (var i in arr){ 
noSpaces[i] = arr[i].toLowerCase().replace(/ /g, "");
}

splitArr=[];
countArr=[];  
for (var k in noSpaces){
splitArr[k] = noSpaces[k].split("");
countArr[k] = 0;
for (var j = 0;j < splitArr[k].length;j++){
  for (var n in noSpaces){
    if (noSpaces[n].indexOf(splitArr[k][j]) >= 0){countArr[k] += 1}
}
}
}
max = 0;
index1 = 0;
for (var m in countArr){
  if (countArr[m] > max){
    max = countArr[m];
    index1 = m;
  }
}

min = countArr[0];
index2 = 0;
for (var p in countArr){
  if (countArr[p] < min){
    min = countArr[p];
    index2 = p;
  }
}
if (max == 1) {return arr[index1]} else return arr[index2];
}
Owais Ahmed
@owaisehmed
Jul 11 2017 10:02
i want to check just the "list"
heroiczero
@heroiczero
Jul 11 2017 10:02
@owaisehmed sorry didn't see myPlants is an arrray of objects
@owaisehmed it would be myPlants[0].lists
abraham anak agung
@padunk
Jul 11 2017 10:03
@owaisehmed you could use object.keys
Bryan Reese
@breese8009
Jul 11 2017 10:03
@FinnPegler ur thinkin too much into it
Frostbites
@Frostbites
Jul 11 2017 10:28
I am highly demotivated
What should be my thought process?
May Kittens Devour Your Soul
@diomed
Jul 11 2017 10:31
@Frostbites u are in wrong room. that kind of question belongs here: https://gitter.im/FreeCodeCamp/YouCanDoThis
heroiczero
@heroiczero
Jul 11 2017 10:34
@Frostbites Be positive. It takes time and effort, but coding is life. It takes time to adjust :)
May Kittens Devour Your Soul
@diomed
Jul 11 2017 10:34
@heroiczero your knowledge is needed in main Help room :yum:
Owais Ahmed
@owaisehmed
Jul 11 2017 10:40
Has anyone done the Profile Lookup Task?
Markus Kiili
@Masd925
Jul 11 2017 10:40
@owaisehmed Yes.
Owais Ahmed
@owaisehmed
Jul 11 2017 10:41

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


function lookUpProfile(firstName, prop){
// Only change code below this line
  var flag = 0;
  for(var i = 0; i < contacts.length; i++){
    if(firstName == contacts[i].firstName && contacts[i].prop == contacts[i].lastName){
        flag = 1;
        break;
      }
    else if(firstName == contacts[i].firstName || prop == contacts[i].likes){
      flag = 2;
      break;
    }
    else if(firstName == contacts[i].firstName || prop == contacts[i].number){
      flag = 3;
      break;
    }
  }

  if(flag == 1)
    return(contacts[i].lastName);
  else if(flag == 2)
    return(contacts[i].likes);
  else if (flag == 3)
    return("No such contact");

// Only change code above this line
}

// Change these values to test your function
  lookUpProfile("Bob", "number");
im not able to do it. Confused as hell
@Masd925 help needed
abraham anak agung
@padunk
Jul 11 2017 10:47
@owaisehmed you need to use .hasOwnProperty to check if the key has prop or not
Finn Pegler
@FinnPegler
Jul 11 2017 10:54
@breese8009 What do you mean?
Frostbites
@Frostbites
Jul 11 2017 10:55

function mutation(arr) {

    check = arr[1].toLowerCase();
    from = arr[0].toLowerCase();

  if (check.indexOf(from) >= 0) {
    return true;
  }

a
}

mutation(["hello", "hey"]);
Is this correct?
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 10:57
@Frostbites you have to check all the characters then return.
@Frostbites you can return only once.
@Frostbites from is a string, there is nothing like indexOf(from) on check
Frostbites
@Frostbites
Jul 11 2017 10:59
@saifsmailbox98
How should I correct it?
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 10:59
@Frostbites split the secondWord, then for each letter of the secondWord check the indexOf(thatLetter) on the firstWord, if it's -1, then return false, at the end of the loop return true
Stephen James
@sjames1958gm
Jul 11 2017 11:03
@saifsmailbox98 strings do have indexOf
Frostbites
@Frostbites
Jul 11 2017 11:03
@sjames1958gm yes
I am looking at that right now
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 11:03
@sjames1958gm yeah, but passing a string to it doesn't make sense.
Frostbites
@Frostbites
Jul 11 2017 11:04
@saifsmailbox98 why?
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 11:04
@Frostbites pass individual characters
Stephen James
@sjames1958gm
Jul 11 2017 11:04
@saifsmailbox98 The whole string doesn't make sense, but a string with a single character does
For this project you have to check each character of arr[1]
so you will do `from.indexOf(<something>) because you are checking if something is in the first string
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 11:06
@Frostbites
"hello".indexOf("h"); // 0
"hello".indexOf("e"); // 1
"hello".indexOf("l"); // 2
"hello".indexOf("y"); // -1
Frostbites
@Frostbites
Jul 11 2017 11:08
should I use two for loops?
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 11:08
@Frostbites one would be enough.
Frostbites
@Frostbites
Jul 11 2017 11:10

function mutation(arr) {

  secondWord = arr[1].toLowerCase().split('');
  firstWord = arr[0].toLowerCase();

  for (i = 0; secondWord[i] < secondWord.length; i++) {
    if (firstWord.indexOf(secondWord[i])) {
      return true;
    }
    }return false;

  }


mutation(["hello", "hey"]);
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 11:11
@Frostbites if (firstWord.indexOf(secondWord[i])===-1) return false
Markus Kiili
@Masd925
Jul 11 2017 11:12
@saifsmailbox98 You mean to return true after the loop.
Saif Ur Rahman
@saifsmailbox98
Jul 11 2017 11:12
@Masd925 yes
return true; after the loop ends
i<secondWord.length
Frostbites
@Frostbites
Jul 11 2017 11:12
@saifsmailbox98 Thank you buddy
CamperBot
@camperbot
Jul 11 2017 11:12
frostbites sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 758 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Frostbites
@Frostbites
Jul 11 2017 11:12
it worked
Owais Ahmed
@owaisehmed
Jul 11 2017 11:12
@padunk so i shouldn't use if else and flag? Right?
Stephen James
@sjames1958gm
Jul 11 2017 11:16
@Frostbites :+1:
Dovydas Stirpeika
@Giveback007
Jul 11 2017 11:17
@sjames1958gm can you rescue me
Stephen James
@sjames1958gm
Jul 11 2017 11:17
@Giveback007 Maybe.
Dovydas Stirpeika
@Giveback007
Jul 11 2017 11:17
I am having soooo much frustration with making things work on ios
Stephen James
@sjames1958gm
Jul 11 2017 11:17
I have a meeting in 10 minutes, but @Masd925 is a great resources as well
Dovydas Stirpeika
@Giveback007
Jul 11 2017 11:17
even position fixed isn't working
Stephen James
@sjames1958gm
Jul 11 2017 11:18
Oh, ios, I have no experience
Dovydas Stirpeika
@Giveback007
Jul 11 2017 11:18
well tnx anyways
I'm suprised that no one here so far has tested on ios, becouse a whole crap load of css brakes
and there's no proper support and solutions online, it's insane, it's such a big platform
Stephen James
@sjames1958gm
Jul 11 2017 11:21
We have one guy at work that does our IOS work and it is such a different environment
Dovydas Stirpeika
@Giveback007
Jul 11 2017 11:21
hmm
what if I want to do work for clients
(building a site for my mom)
and she owns an iphone
:angry:
Christopher
@bradley1492
Jul 11 2017 11:29
Hey guys, I am working on the "wherefore art thou" challenge. I managed to come up with half of the solution but it does not work with more than one key-value pair in the source object. Could someone give me hint in what direction to go to check the source object for more than one pair..
Here is my code:
function whatIsInAName(collection, source) {
  var arr = [];
  var sourceKey = Object.keys(source);
  var sourceValues = Object.values(source);
  for(var i=0; i<collection.length; i++){
    for(var j=0; j<sourceKey.length; j++){
      if(collection[i].hasOwnProperty(sourceKey[j])){    
      for(var k in collection[i]){
        if(collection[i][k] == sourceValues){
          arr.push(collection[i]);
        }//end if 2
      }//end for 3
    }//end if 1
    }//end for 2  
  }//end for 1
  return arr;
}//end function

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Markus Kiili
@Masd925
Jul 11 2017 11:33
@bradley1492 You only need two loops through collection and source's keys.
You keep those objects that have matching property values with source for all the source's keys.
Christopher
@bradley1492
Jul 11 2017 11:34
@Masd925 Hey thanks for the quick reply, I just looked through your advisory from a few weeks ago which i screenshotted. :)
CamperBot
@camperbot
Jul 11 2017 11:34
bradley1492 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4292 | @masd925 |http://www.freecodecamp.com/masd925
Christopher
@bradley1492
Jul 11 2017 11:38
@Masd925 So the for-in loop through each object of the collection array is completely unnessecary?
Markus Kiili
@Masd925
Jul 11 2017 11:39
@bradley1492 Yes, whatever keys the looped object might have are of no interest really.
Just looping the source's keys is enough.
KinderPreet Singh
@kindercappy
Jul 11 2017 11:41
Need help with exact change.
All the tests are passing except for 1.
checkCashRegister(19.50, 20.00, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1.00], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]])
This one should return "Insufficient Funds"
Should show the whole code here?
Christopher
@bradley1492
Jul 11 2017 11:47

@Masd925 But I loop the source keys with a for-in loop not with a for-loop right?
So this is right:

for(var j=0; j<sourceKey.length; j++){}

And this is right:

for(var k in source){
 if (objectk[k].hasOwnProperty(property)) {
        // do stuff
    }
}

Are those my two options here?

Markus Kiili
@Masd925
Jul 11 2017 11:48
@bradley1492 Either can be used.
For loop through Object.keys(source) avoids looking up the prototype chain for properties and for...in loop is a bit shorter to write. Both work.
RedJob
@RedJob
Jul 11 2017 11:51

function multiplyAll(arr) {
var product = 1;
// 请把你的代码写在这条注释以下
for(var i=0;i<arr.length;i++){
for(var j=0;j<arr[i].length;j++){
product=
}
}
// 请把你的代码写在这条注释以上
return product;
}

// 你可以修改这一行来测试你的代码
multiplyAll([[1,2],[3,4],[5,6,7]]);

Markus Kiili
@Masd925
Jul 11 2017 12:04
@bradley1492 Those are the options for looping through source's keys. You need to compare property values too.
abraham anak agung
@padunk
Jul 11 2017 12:06
@owaisehmed if statement for looking firstname is ok. Just dont harcode anything else
Marlon
@borgatajunky
Jul 11 2017 12:09

// Instructions
Create a function which answers the question "Are you playing Banjo?". If your name starts with the letter "R" or lower case "r", you are playing Banjo!
The function takes a name as its only argument, and returns one of the following strings:
name + "plays banjo"
name + "does not play banjo"
Names given are always valid strings.
// My function
function areYouPlayingBanjo(name) {
return /^\'r'/i.test(this) ? name + ' plays banjo' : name + ' does not play banjo';
}

//My test cases: ternary passes true case but the false does not. Can anyone help me figure out whats wrong with my false cases?

Test Passed: Value == 'Adam does not play banjo'
Test Passed: Value == 'Paul does not play banjo'
Expected: 'Ringo plays banjo', instead got: 'Ringo does not play banjo'
Test Passed: Value == 'bravo does not play banjo'
Expected: 'rolf plays banjo', instead got: 'rolf does not play banjo'

Christopher
@bradley1492
Jul 11 2017 12:42
@Masd925 Okay, now I came up with this solution, but there still is an error inside. First I loop through the collection and then through the sources keys. Inside the second loop I compare each object in the collection array against each property of the source object. But now only the second example turns right. From here I am sort of stuck..

function whatIsInAName(collection, source) {
  var arr = [];
  var sourceKey = Object.keys(source);
  var sourceValues = Object.values(source);
  for(var i=0; i<collection.length; i++){
    for(var j=0; j<sourceKey.length; j++){
      if(collection[i].hasOwnProperty(sourceKey[j])){
        arr.push(collection[i]);
      }  

    }//end for 2  
  }//end for 1
  return arr;
}//end function
Markus Kiili
@Masd925
Jul 11 2017 12:43
@bradley1492 You need some loop logic so you only keep the object if the property values match for all the source's keys. Just checking property key existence is not enough.
You need to compare source[sourceKey[j]] with collection[i][sourceKey[j]]
Christopher
@bradley1492
Jul 11 2017 12:45
@Masd925 Comparing objects in js usually happens through the hasOwnProperty method?
Markus Kiili
@Masd925
Jul 11 2017 12:46
@bradley1492 It only checks for property key existence. For comparing property values you need to access the objects with dot or bracket notation.
Christopher
@bradley1492
Jul 11 2017 12:48
@Masd925 I think i can grasp that. I have to leave know. I'll give the solution another try today with your last tips. Thanks for your wonderful help again :)
CamperBot
@camperbot
Jul 11 2017 12:48
bradley1492 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4293 | @masd925 |http://www.freecodecamp.com/masd925
Dhavalkumar Prajapati
@adhavalboy
Jul 11 2017 12:53
@/all what is nav class in boot strap ??
Tegan Ambrosa
@Spambrah
Jul 11 2017 13:06
@adhavalboy from my understanding, it is a class that has pre-set values that make it easier to make navigation menus using bootstrap. but i have not read the documentation in a while, so I could be wrong.
Definnitely go to the bootstrap website and skim through the documentation on how to use bootstrap.
@adhavalboy oops, I was wrong - it's used for tabular natigation...
Tegan Ambrosa
@Spambrah
Jul 11 2017 13:11
http://getbootstrap.com/components/#nav - they have an example of what the .nav class is...
Still could be used for a navigation menu I guess...
Diego Mayer
@Chrono79
Jul 11 2017 13:13
@borgatajunky remove the quotes and the backslash of your regular expression, what is this there? Use name instead of this
Valentin
@valentinlybmin
Jul 11 2017 13:28

So I have this

```

function onPositionReceived(position){
var lat = position.coords.latitude;
var long = position.coords.longitude;
}

navigator.geolocation.getCurrentPosition(onPositionReceived,locationNotReceived);
```

Can someone tell me how i can make lat and long public, so that I can use them outside of the function?

function onPositionReceived(position){ var lat = position.coords.latitude; var long = position.coords.longitude; } navigator.geolocation.getCurrentPosition(onPositionReceived,locationNotReceived);
function onPositionReceived(position){ var lat = position.coords.latitude; var long = position.coords.longitude; } navigator.geolocation.getCurrentPosition(onPositionReceived,locationNotReceived);
Ahh cant format it right, sorry
function onPositionReceived(position){ var lat = position.coords.latitude; var long = position.coords.longitude; } navigator.geolocation.getCurrentPosition(onPositionReceived,locationNotReceived);
function onPositionReceived(position){
var lat = position.coords.latitude;
var long = position.coords.longitude
}
navigator.geolocation.getCurrentPosition(onPositionReceived,locationNotReceived);
Ah there you go
Can someone tell me how i can make lat and long public, so that I can use them outside of the function?
Stephen James
@sjames1958gm
Jul 11 2017 13:31
@valentinlybmin You can define them outside the callback function - you just cannot use them until the callback function has executed.
Ragnorak
@Rrak
Jul 11 2017 13:31
1 You can declare them globally
or
Valentin
@valentinlybmin
Jul 11 2017 13:31
@sjames1958gm I tried this, but it gives me back undefined
Stephen James
@sjames1958gm
Jul 11 2017 13:32
@valentinlybmin then you are trying to use them before the callback runs
Valentin
@valentinlybmin
Jul 11 2017 13:32
@sjames1958gm How can I make sure to use them after
@Ragnorok-Gs I will read into this. To declare them globally , one just removes the "var" , right
Stephen James
@sjames1958gm
Jul 11 2017 13:33
@valentinlybmin Use them in the execution context of the callback.
If you need to use them in a subsequent ajax request, call a function from the callback.
I would specifically put a var lat; outside the function.
Ragnorak
@Rrak
Jul 11 2017 13:34
No you need var to declare a variable, just declare them outside the fun().
@valentinlybmin Is right!
Valentin
@valentinlybmin
Jul 11 2017 13:35
var lat;
var long;

function onPositionReceived(position){
   lat = position.coords.latitude;
   long = position.coords.longitude;
}

function locationNotReceived(positionError){
  console.log(positionError);
}

navigator.geolocation.getCurrentPosition(onPositionReceived,locationNotReceived);
I did this and it gives me back undifined
Am I failing to call the function ? I am a little confused my how navigator.geolocation.getCurrentPosition(onPositionReceived,locationNotReceived); works
by how*
Stephen James
@sjames1958gm
Jul 11 2017 13:37
@valentinlybmin Inside the onPositionReceived you could call another function that uses the lat/long, perhaps to get weather.
Valentin
@valentinlybmin
Jul 11 2017 13:38
@sjames1958gm yeah, I figured this, but I wanted to have the vars outside, it is more easy to follow, I think
Stephen James
@sjames1958gm
Jul 11 2017 13:39
It isn't a matter of where, but when.
Valentin
@valentinlybmin
Jul 11 2017 13:39

@sjames1958gm When I call navigator.geolocation.getCurrentPosition(onPositionReceived,locationNotReceived);

does it execute the function?

Stephen James
@sjames1958gm
Jul 11 2017 13:41

It executes the function, but not immediately, it is asynchronous.

var lat;
var long;

function onPositionReceived(position){
   lat = position.coords.latitude;
   long = position.coords.longitude;
  console.log("Inside ", lat, long);
}

function locationNotReceived(positionError){
  console.log(positionError);
}

navigator.geolocation.getCurrentPosition(onPositionReceived,locationNotReceived);
console.log("Outside ", lat, long);

You can see here the console.log after the getCurrentPosition runs before the one inside the function.

"Outside "
undefined
undefined
"Inside "
32.972426
-96.7012529
EpicTriffid
@EpicTriffid
Jul 11 2017 13:41
So i just created an iframe to go inside an element using javascript. I then want to remove it when i click a button. how do i reference a html element created in javascript?
if (but1 == "open") {
setTimeout(randFrame,1000)
function randFrame (){
$(".button1").html("<iframe src='demo_iframe.htm' height='100%' width='100%' style='border:none' name='randframe'></iframe>");
trying "randframe".name doesn't work
Stephen James
@sjames1958gm
Jul 11 2017 13:42
@EpicTriffid give it an id or class and reference that way
Ragnorak
@Rrak
Jul 11 2017 13:42
See by you image you have just initialized variable [var lat] you need to assign values or point it to another variable which holds the value. The reasong you are getting "Undefined" is this. Define a value to both of the variables.
EpicTriffid
@EpicTriffid
Jul 11 2017 13:43
@sjames1958gm can i do that in the same place i created it?
Valentin
@valentinlybmin
Jul 11 2017 13:43
@sjames1958gm So thats why it gives me undifined outsided? Because it runs before them being defined?
EpicTriffid
@EpicTriffid
Jul 11 2017 13:44
@sjames1958gm oh my god it works. I could frickin kiss you!
@sjames1958gm Thanks!
CamperBot
@camperbot
Jul 11 2017 13:44
epictriffid sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8040 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Valentin
@valentinlybmin
Jul 11 2017 13:44
@sjames1958gm anyway around this?
Stephen James
@sjames1958gm
Jul 11 2017 13:44
@EpicTriffid :)
@valentinlybmin
If you need to use the lat/long "immediately", use them in the context of the callback
Or if you have user interaction, then the user wouldn't interact until the data was retrieved.
Valentin
@valentinlybmin
Jul 11 2017 13:46
@sjames1958gm Right, I got it . Thanks man
CamperBot
@camperbot
Jul 11 2017 13:46
valentinlybmin sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8041 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 11 2017 13:46
@valentinlybmin :+1:
EpicTriffid
@EpicTriffid
Jul 11 2017 13:52
@sjames1958gm Got another question
$(".button1").on("click",function () {
var but = $(".button1");
var btext = $(".b1text");
var cross = $("#cross1");
but.animate({marginTop:"10%", width:"100%", height:"100vh"}, "fast");
btext.animate({opacity:0});
cross.delay(1000).fadeIn();
but1 = "open"
if (but1 == "open") {
setTimeout(randFrame,1000)
function randFrame (){
$(".button1").html("<iframe class='randframe' src='demo_iframe.htm' height='100%' width='100%' style='border:none'></iframe>");
$("#cross1").click(function() {
$('.button1').removeAttr('style');
$("#cross1").fadeOut('fast');
$('.randframe').remove();
$('.b1text').appendTo('.button1');
});
};
};
});
I fade out the btext at the top, then once i remove the iframe, i'm unable to bring it back
Any idea why?
Frostbites
@Frostbites
Jul 11 2017 14:01
function bouncer(arr) { 


  junk = [false, null, 0, "", undefined, NaN]; 

  var newArr = arr.filter(function(junkWord) { 
    return junkWord;


  }); 

  return newArr;

} 


bouncer([7, "ate", "", false, 9]);
How does this work without even mentioning the array junk ?
Diego Mayer
@Chrono79
Jul 11 2017 14:02
@Frostbites because filter evaluates its argument to true or false
Frostbites
@Frostbites
Jul 11 2017 14:02
@Chrono79 How does that happen?
Diego Mayer
@Chrono79
Jul 11 2017 14:03
@Frostbites exactly like if (myVar) evaluates myVar to true or false
Description
filter() calls a provided callback function once for each element in an array, and constructs a new array of all the values for which callback returns a value that coerces to true.
Frostbites
@Frostbites
Jul 11 2017 14:07
so I don't even need to create the array junk in the first place, right?
and that means 0 is by default a false calue
*value
Stephen James
@sjames1958gm
Jul 11 2017 14:08
@EpicTriffid does remove delete the element - maybe just hide it?
petros777
@petros777
Jul 11 2017 14:09
I need help with adding a space when concatenating two strings...
var myStr="This is the start." + "This is the end.";
What am i missing?
Frostbites
@Frostbites
Jul 11 2017 14:10
@petros777 ' ' is a string as well
EpicTriffid
@EpicTriffid
Jul 11 2017 14:10
@sjames1958gm if it hides it, is it possible its currently covering the text?
Frostbites
@Frostbites
Jul 11 2017 14:10
@petros777
var myStr="This is the start. " + "This is the end.";
petros777
@petros777
Jul 11 2017 14:11
That is the same as mycode...
Frostbites
@Frostbites
Jul 11 2017 14:11
@petros777 OR "This is the start." + " " + "This is the end."
petros777
@petros777
Jul 11 2017 14:11
@Frostbites THAT worked
Stephen James
@sjames1958gm
Jul 11 2017 14:11
@EpicTriffid I would think hiding wouldn't. But experimentation is the only way to know for sure.
petros777
@petros777
Jul 11 2017 14:11
thanks a bunch
Frostbites
@Frostbites
Jul 11 2017 14:11
You're welcome
EpicTriffid
@EpicTriffid
Jul 11 2017 14:12
@sjames1958gm Hmm, i've tried and no luck. It seems the text element is just being deleted
Diego Mayer
@Chrono79
Jul 11 2017 14:12
@Frostbites yes, you don't need it at all
Frostbites
@Frostbites
Jul 11 2017 14:12
@Chrono79 Thanks
CamperBot
@camperbot
Jul 11 2017 14:12
frostbites sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4478 | @chrono79 |http://www.freecodecamp.com/chrono79
Dovydas Stirpeika
@Giveback007
Jul 11 2017 14:13

@Giveback007
hey peeps, I finished up my react Camper Leader Board
https://codepen.io/giveback007/full/LLgPbd/

please let me know what I could have done better with my code
I'm still trying to grasp react so any mistakes you spot or suggestions will be appreciated

Stephen James
@sjames1958gm
Jul 11 2017 14:29
@Giveback007 Looks good - interesting choice that you Camper extends Component, but Header doesn't
Dovydas Stirpeika
@Giveback007
Jul 11 2017 14:31
@sjames1958gm yeah I'm not sure when it's better to use one than the other (i think for change of state) so maybe doing the reverse would be better?
Stephen James
@sjames1958gm
Jul 11 2017 14:32
@Giveback007 Since neither have state - both could just be functions. Not sure the overhead of extending React.Component
Dovydas Stirpeika
@Giveback007
Jul 11 2017 14:33
@sjames1958gm that makes sense. I do remember trying to revert it back to a functional component, but I was getting errors and gave up
Moisés Man
@moigithub
Jul 11 2017 14:34
setState causes ur component to re-render
soo if u have multiple states changes.. is better put all on same object and call setState only once @Giveback007
this.setState({
   key1: value1,
   key2: value2,
... 
   keyn: valuen
})
Dovydas Stirpeika
@Giveback007
Jul 11 2017 14:34
@sjames1958gm tnx for taking a look at it btw, had no idea you are the top dog here until I worked on this project :smile:
CamperBot
@camperbot
Jul 11 2017 14:34
giveback007 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8042 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 11 2017 14:34
@Giveback007 :)
@Giveback007 yw
Dovydas Stirpeika
@Giveback007
Jul 11 2017 14:35
@moigithub so that would be for only one major component in the whole app (most of the time?)
Moisés Man
@moigithub
Jul 11 2017 14:36
  } else {
    this.setState({
     data: this.state.data.sort(function(a, b) {
      if (a[2] > b[2]) {return -1}
      if (a[2] < b[2]) {return 1}
      return 0;
    }) 
   })
  }
  this.setState({ isRecentScore: !this.state.isRecentScore })
ie.. u can mix those 2 setState on 1
Marianissimus
@Marianissimus
Jul 11 2017 14:38
@moigithub does this ever gets to "return 0"? //except a[2] === b[2] ?
Dovydas Stirpeika
@Giveback007
Jul 11 2017 14:38
@moigithub you're right, I should have tried. I was paranoid that it would trigger the the !bool before executing the function so I thought it would be better
@moigithub also ty for taking a look
CamperBot
@camperbot
Jul 11 2017 14:39
giveback007 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3491 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jul 11 2017 14:39
@Marianissimus yep is they == it will return 0
Dovydas Stirpeika
@Giveback007
Jul 11 2017 14:40
theres actually a few 30 day scores that have ===
Harut
@harut-g
Jul 11 2017 14:40
How had solved the steamroller?
Diego Mayer
@Chrono79
Jul 11 2017 14:40
@harut-g most use recursion
Harut
@harut-g
Jul 11 2017 14:41
@Chrono79 yes, i know it's code what do you think ?
var q = [];
function steamrollArray(arr) {
if(Array.isArray(arr)) {
    for(var i =0;i<arr.length;i++){
        steamrollArray(arr[i]);
    }
}
    else{
        q.push(arr);
    }

    return q;

}

steamrollArray([[["a"]], [["b"]]]);
Diego Mayer
@Chrono79
Jul 11 2017 14:41
@harut-g don't use global vars
they keep their value between tests
you can use an inner recursive function for instance
and move the var q = []; inside the outer function
Moisés Man
@moigithub
Jul 11 2017 14:44
@Giveback007 also usually u use reactDOM.render only 1 time to set the app base (which contains multiple nested childs)
and pass data/state/props to ur childs component
when u change the state (using setState) react will rerender all components based on those state/props
soo no need to use reactDOM.render again (<-- this will create another instance of that component, is possible.. but not common )
Dovydas Stirpeika
@Giveback007
Jul 11 2017 14:45
@moigithub I thought I was using the DOM.render once no?
Harut
@harut-g
Jul 11 2017 14:46
@Chrono79 okay, but it will define the var on every function call
Diego Mayer
@Chrono79
Jul 11 2017 14:47
@harut-g
function outerFunction(arg1) {
  var myArray = [];
  var innerRecursiveFunction = function(arg2) {
  }
  ...
  return myArray;
}
Kelechi Chinaka
@ke1echi
Jul 11 2017 14:48
:wave: guys
Diego Mayer
@Chrono79
Jul 11 2017 14:48
:wave:
Kelechi Chinaka
@ke1echi
Jul 11 2017 14:48
how do i check if an input is an argument?
Moisés Man
@moigithub
Jul 11 2017 14:48
@Giveback007 yea..nvm then :P
though u were calling topByAllTime multiple times
Ayobami
@purpose50
Jul 11 2017 14:48

Hi Guys, so after five months i am back for FCC, completed my next challenge today..here is the link my pomodoro clock:
https://codepen.io/purpose/full/MoZgZe/

the design is not great i know, i will deal with that later, i just wanted it to work first..thanks in advance for checking it out

Dovydas Stirpeika
@Giveback007
Jul 11 2017 14:49
@moigithub well ty for bringing that up anyways :smile: keeping me on my toes!
Kelechi Chinaka
@ke1echi
Jul 11 2017 14:49
welcome back @purpose50
Diego Mayer
@Chrono79
Jul 11 2017 14:50
@purpose50 try disabling the length change buttons while the clock is running (click them and you'll see what it looks like)
Moisés Man
@moigithub
Jul 11 2017 14:51

@kelechy not sure what u mean

how do i check if an input is an argument?

Will White
@willnwhite
Jul 11 2017 14:51
@kelechy What challenge are you on?
Steven Nyeo
@limpingstone
Jul 11 2017 14:52
$('#body').on('click', 'div', function() {

        if ($(this).text() == "") {
            $(this).append(i % 2 == 0 ? 'X' : 'O');
            i++;
        }
});
Is it possible to get the id of what you clicked on? (Building a Tic Tac Toe game)
The id of this in specific
Moisés Man
@moigithub
Jul 11 2017 14:52
$(this).attr("id") ?? @limpingstone
or this.id
Kelechi Chinaka
@ke1echi
Jul 11 2017 14:53
function last(list) {
  return (Array.isArray(list) == true) ? list[list.length - 1] : (typeof(list) == 'string') ? list.split('')[list.length - 1] : //??
}
last( [1,2,3,4] ) // => 4
last( "xyz" ) // => z
last( 1,2,3,4 ) // => 4
@moigithub
CW @willnwhite
Harut
@harut-g
Jul 11 2017 14:53
@Chrono79 like this?
Ayobami
@purpose50
Jul 11 2017 14:54
@Chrono79 okay :+1: , nice one..will do something about that, thanks
CamperBot
@camperbot
Jul 11 2017 14:54
purpose50 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4479 | @chrono79 |http://www.freecodecamp.com/chrono79
Harut
@harut-g
Jul 11 2017 14:54
@Chrono79
function steamrollArray(arr) {
var q = [];

var qwe = function(arr) {

if(Array.isArray(arr)) {

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

}
    else{
        q.push(arr);
    }
 return q ;
};

qwe(arr);

}

steamrollArray([[["a"]], [["b"]]]);
Diego Mayer
@Chrono79
Jul 11 2017 14:55
@harut-g does that work?
Will White
@willnwhite
Jul 11 2017 14:55
@kelechy arguments.length > 1
Harut
@harut-g
Jul 11 2017 14:55
@Chrono79 no :D
Diego Mayer
@Chrono79
Jul 11 2017 14:55
your outer function should return too
Harut
@harut-g
Jul 11 2017 14:55
@Chrono79 ohhh.ok
@Chrono79 thank you very much ;)
CamperBot
@camperbot
Jul 11 2017 14:55
sorry harut-g, you can't send brownie points to yourself! :sparkles: :sparkles:
Will White
@willnwhite
Jul 11 2017 14:56
@kelechy arguments.length will be 1 for array and string, more if you give more than one input.
Will Hawks
@willfalcon
Jul 11 2017 14:56

Hey yall.. any wordpress ppl out there? I’ve got a question for you. I’m adding some jquery stuff to the functions.php file (of my child theme, of course) to move some stuff around on the page, in order to make it a little more mobile friendly.

Right now, I’ve got the jquery wrapped in an “if (wp_is_mobile() )” function. This works great for pulling it up on phones and tablets, but if I just scale my browswer down, it doesn’t trigger. Is there a better way to set this up than the wp_is_mobile function? And this could just be a js thing rather than a wp thing.

I JUST submitted my Random Quote Machine project, so I’m still pretty fresh in js. Sorry if this is something obvious.

Saahil Trivedi
@saahil777
Jul 11 2017 14:56
is it possible to feel like you have no idea how you're gonna code this when you start JS basics
Harut
@harut-g
Jul 11 2017 14:56
@Chrono79 thanks!
CamperBot
@camperbot
Jul 11 2017 14:56
harut-g sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4480 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 11 2017 14:57
:+1:
Kelechi Chinaka
@ke1echi
Jul 11 2017 14:57
not an array so does not have a length prop @willnwhite
Will White
@willnwhite
Jul 11 2017 14:57
@kelechy arguments is an object available in all functions.
@kelechy It's an array-like object of the inputs you give the function.
Kelechi Chinaka
@ke1echi
Jul 11 2017 14:58
i still dont get @willnwhite
Diego Mayer
@Chrono79
Jul 11 2017 14:59
@kelechy count the arguments first
Moisés Man
@moigithub
Jul 11 2017 15:00
"hello".slice(-1)
//"o"
"".slice(-1)
//""
[1,2,3].slice(-1)
//[3]
[].slice(-1)
//[]
extract last element test @kelechy
if ur function uses 1 argument (only) and its already defined on ur parameter list
no need to use the arguments object
probably some validation is needed.. like u doing.. check for array or strings only
Dovydas Stirpeika
@Giveback007
Jul 11 2017 15:01
should I start moving out of codepen? Is there a different resource?
Kelechi Chinaka
@ke1echi
Jul 11 2017 15:02
that doc is not clear to me @willnwhite
Will White
@willnwhite
Jul 11 2017 15:02
@kelechy
function x() {
  console.log(arguments.length);
}
x([45, 34]) // logs 1
x(1, 2, 3, 4) // logs 4 (4 arguments)
Kelechi Chinaka
@ke1echi
Jul 11 2017 15:02
if i have var arg = 1,"b",3,"d",5 so do i get 5 @Chrono79
Diego Mayer
@Chrono79
Jul 11 2017 15:03
@kelechy see @willnwhite post ^
Sweet Coding :)
@SweetCodingInc
Jul 11 2017 15:04
@kelechy yes
Kelechi Chinaka
@ke1echi
Jul 11 2017 15:09
am feeling daft this afternoon, still dont understand @Chrono79 @willnwhite
Diego Mayer
@Chrono79
Jul 11 2017 15:13
@kelechy check arguments length first, if it isn't 1, use what you had already, else get the last element of arguments
there are other ways of doing it
Scott Rhoades
@srhoades
Jul 11 2017 15:23
anyone available to help with my wikipedia pen? having an issue with api results.
Kelechi Chinaka
@ke1echi
Jul 11 2017 15:24
can u refer me to where i can understand it more @Chrono79
They tell you In javascript and CoffeeScript a list will be an array, a string or the list of arguments.
they won't give you invalid input, like numbers
Stephen James
@sjames1958gm
Jul 11 2017 15:26
@srhoades check your developer tools console - are you having cross origin issues.
wikipedia allows you to add origin=* to your URL to bypass cross origin issues
Steven Nyeo
@limpingstone
Jul 11 2017 15:27
@moigithub $(this).attr("id") ?? or this.id
I'll try. Thanks buddy
CamperBot
@camperbot
Jul 11 2017 15:27
limpingstone sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3492 | @moigithub |http://www.freecodecamp.com/moigithub
Joel Y.
@zapcannon99
Jul 11 2017 15:28

@jorlee92

It's not a problem with using/not using jsonp, it's just a hyperlink/anchor tag.

Kelechi Chinaka
@ke1echi
Jul 11 2017 15:28
this particular doc is not clear to me @Chrono79
how does the doc help me solve the problem
Diego Mayer
@Chrono79
Jul 11 2017 15:29
see what arguments is
it's an array-like object
Kelechi Chinaka
@ke1echi
Jul 11 2017 15:30
that i have args = 1,"b",3,"d",5 have i need to return 5 @Chrono79
Diego Mayer
@Chrono79
Jul 11 2017 15:30
to get the last argument you can do arguments[arguments.length - 1]
Kelechi Chinaka
@ke1echi
Jul 11 2017 15:31
when i do typeof args it gives number @Chrono79
Diego Mayer
@Chrono79
Jul 11 2017 15:32
args = 1,"b",3,"d",5 <- what is that?
Moisés Man
@moigithub
Jul 11 2017 15:32
@limpingstone on stackoverflow says last one is faster this.id
Diego Mayer
@Chrono79
Jul 11 2017 15:32
args = 1,"b",3,"d",5;
console.log(args); //1
Kelechi Chinaka
@ke1echi
Jul 11 2017 15:34
yea it returns 1 @Chrono79
Diego Mayer
@Chrono79
Jul 11 2017 15:34
@kelechy args is not arguments there, arguments object contains the arguments passed to your function
Kelechi Chinaka
@ke1echi
Jul 11 2017 15:37
function last(list) {
  return (Array.isArray(list) == true) ? list[list.length - 1] : (typeof(list) == 'string') ? list.split('')[list.length - 1] : //??
}
i didnt understand it and could not solve the last test case, pls take a look @Chrono79
https://www.codewars.com/kata/last/train/javascript
Diego Mayer
@Chrono79
Jul 11 2017 15:38
to get the last argument you can do arguments[arguments.length - 1]
list is only the first argument
if you have more than one argument, return the last one
you have to reorder your logic
Kelechi Chinaka
@ke1echi
Jul 11 2017 15:41
ok thanks @Chrono79 i would reorder
CamperBot
@camperbot
Jul 11 2017 15:41
kelechy sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4481 | @chrono79 |http://www.freecodecamp.com/chrono79
NicholasGalarza
@NicholasGalarza
Jul 11 2017 15:41
@Giveback007 You mean to develop your projects on? I personally use Atom and some add-ons to develop locally then I just copy & past my code onto Codepen. Since you are moving onto React/Sass, you should be moving onto use the CLI so you can start compiling code!
Innocent Tauzeni
@Telthem89
Jul 11 2017 15:42
how do you twitch tv guys am stack
how to use twitch tv api am stack

{

"status": 404,
"error": "not found"

}this error am getting if i use https://api.twitch.tv/Telthem2017

Jason Luboff
@JLuboff
Jul 11 2017 15:44
@Telthem89 You need a client id
If you click that link it tells you..
NicholasGalarza
@NicholasGalarza
Jul 11 2017 15:46
@Telthem89 You want to do https://api.twitch.tv/streams/Telthem2017
And the object that you are given back upon success(data) will be data.stream === nullif the person is offline.
Also, here is the link that tells you how to get a client-id for your twitch API:
https://blog.twitch.tv/client-id-required-for-kraken-api-calls-afbb8e95f843
@Telthem89 Woops, allow me to fix that endpoint: https://api.twitch.tv/kraken/streams/Telthem2017
Finn Pegler
@FinnPegler
Jul 11 2017 15:48
I am having trouble with efficiency of code. Some of my Kata answers in Codewars aren't executing quick enough. Are there any good resources to help with speeding up code?
Innocent Tauzeni
@Telthem89
Jul 11 2017 15:49
@alexanderkopke ok you may
NicholasGalarza
@NicholasGalarza
Jul 11 2017 15:51
@FinnPegler Haha, I'm doing codewars too! And chances are you are probably using too many nested loops in your solutions. For very general advice, I highly suggest you research some of the list transformation methods provided in JavaScript like forEach(), map(), reduce(), filter(). Here is a very good link for learning about them: http://eloquentjavascript.net/05_higher_order.html
Also, look up funfunfunction's YouTube channel because he talks more about them and he explains things well.
@FinnPegler Also, it could be useful to have good knowledge on data structures because using the correct one could make a difference between an O(n) and O(n^2) solution when comes to time-complexities. So Queues, Stacks, HashMaps, Linked-Lists. I apologize in advance if you already know about this stuff lol. I just don't know how well you know these things.
Lorena
@lore-code
Jul 11 2017 16:10

Any help with this one...I've tried it different ways and nothing yet
// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[16]; // Change this Line
var player = testObj[16]; // Change this Line

Joel Y.
@zapcannon99
Jul 11 2017 16:12
@lore-code What test do we need to hit true?
shivam gupta
@shivamg11000
Jul 11 2017 16:13
@lore-code try
var playerNumber = testObj["16"];
var player = testObj["16"];
Margaret
@Margaret2
Jul 11 2017 16:13
@lore-code the playerNumber variable is supposed to be an actual number, not a value from the object
Joel Y.
@zapcannon99
Jul 11 2017 16:13
^^^
@lore-code And then shove playerNumber in for the key for testObj
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:22
/*
  Local Weather App
*/

$(document).ready(function() {

  var apikey = "07f5408f2fe1a79cb5d9ae099b27bb28"; // API Key for OpenWeatherMap.org
  var userlocation;


  if ("geolocation" in navigator) {
    /* Use the HTML5 geolocation API to get the user's location */
    navigator.geolocation.getCurrentPosition(function(position) {
      userlocation = position.coords.latitude + ", " + position.coords.longitude;
      console.log(userlocation);
    });
  } else {
    /* The user either denied location access or their browser doesn't support it - fail over by detecting a location based on the user's IP Address! See: http://ip-api.com/json  */

    $.getJSON("http://ip-api.com/json", function(json) {
      userlocation = json["zip"];
      console.log(userlocation);
    });
  }

});
For my else statement, if I deny location, it doesn’t log the user location. Am I phrasing the json data wrong? It’s the failover to get a location if the user denies us access to their location
Greta Piliponytė
@gpiliponyte
Jul 11 2017 16:23
Hey guys.. Is there a way for me to only set the background color for a certain part (percentage) of the element?
Lorena
@lore-code
Jul 11 2017 16:24
Got it thanks @Margaret2 and @zapcannon99
CamperBot
@camperbot
Jul 11 2017 16:24
lore-code sends brownie points to @margaret2 and @zapcannon99 :sparkles: :thumbsup: :sparkles:
:cookie: 297 | @zapcannon99 |http://www.freecodecamp.com/zapcannon99
:star2: 2844 | @margaret2 |http://www.freecodecamp.com/margaret2
Joel Y.
@zapcannon99
Jul 11 2017 16:28

@gpiliponyte

I think you can apply a background image to a certain part of a div

something like this maybe? (unashamed advertising of my twitch pen which still needs work)
Joel Y.
@zapcannon99
Jul 11 2017 16:36

@nsuchy

Only thing I have to say is that if you're doing this over in codepen, http calls won't work I believe.

What's the console say?
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:37
developing locally
however jquery hates me and can’t do cross origin requests
So about to develop on codepen
even though I hate codepen
Joel Y.
@zapcannon99
Jul 11 2017 16:38
it won't work in codepen either
calls to http endpoints don't work on codepen.
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:38
that’s correct
you have to use https
Joel Y.
@zapcannon99
Jul 11 2017 16:38
Yeah, but I tried https for ip-api.com and it refused it
Hehehe
Bryan Reese
@breese8009
Jul 11 2017 16:39
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:39
does more than image
korzo
@korzo
Jul 11 2017 16:39
@zapcannon99 ip-api.com doesn't support https
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:39
@korzo Did you see my link above
Joel Y.
@zapcannon99
Jul 11 2017 16:39
Yeah, I know that
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:39
IT can proxy thru HTTPS
Joel Y.
@zapcannon99
Jul 11 2017 16:40
I guess if you are using a proxy, fine
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:40
yep
Proxies are great :D
Joel Y.
@zapcannon99
Jul 11 2017 16:40
lol
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:43
my proxy is buggy
so using the crossorigin.me one
It was written for images
Innocent Tauzeni
@Telthem89
Jul 11 2017 16:43
https://api.twitch.tv/kraken/users/163865837?client_id=lnxquv5eayasqk5xk1ayeh367iurom is this not my id client_id=lnxquv5eayasqk5xk1ayeh367iurom help
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:43
realistically anyone could abuse it for anything
Joel Y.
@zapcannon99
Jul 11 2017 16:43
So I think one problem I had with the json/jsonp stuff was that it would do the json/jsonp call, but unless you were very careful to put variables in some form of promise, you'd have the variable store an unknown/undefined value.
korzo
@korzo
Jul 11 2017 16:43
@nsuchy Yes. My point was that it didn't work, because it doesn't support https. Of course you can proxy ajax request as long as you don't need cookies
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:43
If someone abuses proxy, it’s OVHs problem, not mine :joy:
Innocent Tauzeni
@Telthem89
Jul 11 2017 16:43
i have tried things are not working
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:43
I have it working now though
So I can continue to develop locally
Joel Y.
@zapcannon99
Jul 11 2017 16:44
@Telthem89
Don't think so. I think you just use the name.
@Telthem89
So freecodecamp would be the id. At least, that's how I got it working for me.
If it was that hot I’d be dead
Joel Y.
@zapcannon99
Jul 11 2017 16:45
@nsuchy
Yeah, I believe so. How about you do something like on success: for the $.ajax {} syntax
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:45
why does it say 300+ degrees
Joel Y.
@zapcannon99
Jul 11 2017 16:45
@nsuchy Not if it was in kelvin, you'd freeze to death
Jason Luboff
@JLuboff
Jul 11 2017 16:46
@nsuchy Becuase it's in kelvin
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:46
OH
that makes more sense
Joel Y.
@zapcannon99
Jul 11 2017 16:46
My bad, you wouldn't freeze, smh forgot all my water kelvin points
Nathaniel Suchy
@nsuchy
Jul 11 2017 16:46
thanks
300degrees kelvin is 80degrees fahrenheit
Jason Luboff
@JLuboff
Jul 11 2017 16:50
If you're using the openweathermap api, you can specify what temp metric to use
Pedro Almeida
@pmqa
Jul 11 2017 16:51
A question regarding API’s, do you usually filter whatever the API returns into your own arrays or do you model your objects exactly like the API and render only what you need?
Jason Luboff
@JLuboff
Jul 11 2017 16:54
@pmqa Depends on the scenario really. Sometimes you can just grab exactly what you need from the returned results, other times you may get back something that has an array or additional objects inside it that you need to iterate over and grab only the necessary data
Pedro Almeida
@pmqa
Jul 11 2017 16:56
I see @JLuboff I’m doing a simple React app and I’m realising that it might be better to just model everything to the api and put most of the logic at render time
Jason Luboff
@JLuboff
Jul 11 2017 16:58
@pmqa I haven't messed with React at all, but ya it sounds like you have a scenario were using the returned data straight up isn't ideal :D
Joseph
@revisualize
Jul 11 2017 17:00
Hello.
Jason Luboff
@JLuboff
Jul 11 2017 17:01
Yo
Nathaniel Suchy
@nsuchy
Jul 11 2017 17:03
@JLuboff It’s best for me to just convert with javascript, trying to keep the amount of HTTP Requests down
Jason Luboff
@JLuboff
Jul 11 2017 17:04
@nsuchy It's in the same request...
Nathaniel Suchy
@nsuchy
Jul 11 2017 17:04
I didn’t see it
but it’s easier for me to convert
I already have the conversion written out
pahosler
@pahosler
Jul 11 2017 17:17
I made a simple module I hope someone might find useful... https://github.com/pahosler/MakeTimer
Kevin
@kevinwr
Jul 11 2017 17:25

Hey, all.

RIght now, I have a flexbox which has the initial direction of "column", and I'm trying to set the CSS through javascript to adjust the direction to "row" if the width of the flexbox is greater than 150px wide. Here is my code:

if(document.getElementById("#right-column .column-wrapper").width > 150px) {
    document.getElementById("#right-column .column-wrapper").style.flexDirection = "row";
}
Ogundele Olumide
@Lumexralph
Jul 11 2017 17:25
@JLuboff :wave:
Kevin
@kevinwr
Jul 11 2017 17:26
right now, it doesn't work, and actually causes my page to not load
Ogundele Olumide
@Lumexralph
Jul 11 2017 17:27
@kevinwr how will JS see 150px as number ?
Kevin
@kevinwr
Jul 11 2017 17:27
good question
don't know
lol
just figured it could
Jason Luboff
@JLuboff
Jul 11 2017 17:28
@Lumexralph Yo
Ogundele Olumide
@Lumexralph
Jul 11 2017 17:28
@kevinwr what is the type of the value returned by document.getElementById("#right-column .column-wrapper").width ?
@JLuboff how're you?
Kevin
@kevinwr
Jul 11 2017 17:28
not sure.
how do I find out?
Jason Luboff
@JLuboff
Jul 11 2017 17:28
@Lumexralph Not bad, yourself?
Kevin
@kevinwr
Jul 11 2017 17:28
typeof?
Ogundele Olumide
@Lumexralph
Jul 11 2017 17:29
@kevinwr 150 is okay, 150px makes it a string
@kevinwr you can use that to check ...nice move
@JLuboff not as stressful as yesterday, playing around with node though, building a site
Jason Luboff
@JLuboff
Jul 11 2017 17:30
@Lumexralph Cool. I'm still working on my voting app
Ogundele Olumide
@Lumexralph
Jul 11 2017 17:30
@JLuboff but should start my pomodoro and i'm using OOP for it
Jason Luboff
@JLuboff
Jul 11 2017 17:30
@Lumexralph Ya you gotta finish your frontend before beta becomes live
Kevin
@kevinwr
Jul 11 2017 17:30
@Lumexralph set it to 150, but it still isn't working. My page still won't load either
Ogundele Olumide
@Lumexralph
Jul 11 2017 17:31
@JLuboff really?
Jason Luboff
@JLuboff
Jul 11 2017 17:31
@Lumexralph The map changes I'm not sure if they'll keep the old path for people still working on it or not
Ogundele Olumide
@Lumexralph
Jul 11 2017 17:32
@kevinwr try this out of that blog to see what you're getting console.log(typeof document.getElementById("#right-column .column-wrapper").width) see what you get
@JLuboff but the points stays intact, right?
Jeremy
@JeremyAntonoff
Jul 11 2017 17:33
can anyone help me with simon game
Jason Luboff
@JLuboff
Jul 11 2017 17:33
@Lumexralph Ya I don't see why those would change
Kervtuza
@Kervtuza
Jul 11 2017 17:38
Hey guys, working on the Show Local Weather challenge in codepen. I just realized my layout with the city windspeed windgusy etc would look better by using bootstrap. For some reason when I go into my pen setting and link bootstrap, it instantly displays a giant white area covering up my background and I can't figure out why? If you remove the bootstrap links the white goes away and the white area goes away...any ideas?https://codepen.io/Kervtuza/pen/RgLzyP
Kevin
@kevinwr
Jul 11 2017 17:38
@Lumexralph I'm trying, but not sure where to see the output. I'm using brackets right now. Opened up "developer tools" and on a tab called "console," but not seeing any output from that
ok i tried to put it into the console by itself
Nathaniel Suchy
@nsuchy
Jul 11 2017 17:39
Could someone help me with this javascript? https://gist.github.com/nsuchy/1ce7551086ce948225ae7190df3b37e8
The buttons are not working properly
Kevin
@kevinwr
Jul 11 2017 17:40
and it came out with, "Uncaught TypeError: Cannot read property 'width' of null"
Nathaniel Suchy
@nsuchy
Jul 11 2017 17:40
It’s supposed to overwrite with a new button to change between the temperatures
Ogundele Olumide
@Lumexralph
Jul 11 2017 17:40
@kevinwr you checked the devTools console ?
@kevinwr cool, that should take you back to how to ge the DOM element you're targetting
@kevinwr can you copy just the html of that DOM let me see?
Kevin
@kevinwr
Jul 11 2017 17:41
so I'm not selecting the element correctly?
yeah
Ogundele Olumide
@Lumexralph
Jul 11 2017 17:41
@kevinwr probably
Saikat-Sinha
@Saikat-Sinha
Jul 11 2017 17:42

Hi Guys, please help me....In this CSS art https://codepen.io/AskSaikatSinha/pen/jwXNPJ?editors=1100

the overflow: hidden on the "semi-cir" class is not working. I want to create their logo http://www.commutatus.com/

Kevin
@kevinwr
Jul 11 2017 17:42
Also, forgive me for the horrible organization and naming of my code.
<!DOCTYPE HTML>
<html>





<head>
    <title>fCC Local Weather Report</title>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" />
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>
</head>


<body>
    <div id="wrapper" class="primary-font">
        <!--Start of the banner HTML -->
        <header id="banner-row" class="container-style">

            <div>

                <img src="https://kevinr.000webhostapp.com/Local%20Weather%20Report/images/banner.svg" id="banner" />

            </div>

        </header>

        <div id="main-weather-container">
            <div id="left-column" class="container-style">
                <div class="column-wrapper">
                    <!--aligns the following divs in the center of the column -->
                    <div id="weather-icon">
                        <img/>
                    </div>
                    <div id="weather-status"></div>
                </div>
            </div>

            <div id="center-column" class="container-style">
                <div class="column-wrapper">
                    <!--aligns the following divs in the center of the column -->
                    <div id="temp-extremes">
                        <img id="arrow-up-icon" class="icons" src="https://kevinr.000webhostapp.com/Local%20Weather%20Report/images/chevron-arrow-up.svg" />
                        <span id="todays-high"></span>
                        <img id="arrow-down-icon" class="icons" src="https://kevinr.000webhostapp.com/Local%20Weather%20Report/images/chevron-arrow-down.svg" />
                        <span id="todays-low"></span>
                    </div>
                    <div id="ctrow">
                        <div id="current-temp">
                        </div>
                        <div id="temp-toggle">
                            <button id="unit1" class="button">F</button>
                            <button id="unit2" class="button">C</button>
                        </div>
                    </div>
                    <div id="feels-like-temp">
                    </div>
                </div>
            </div>

            <div id="right-column" class="container-style">
                <div class="column-wrapper">
                    <!--aligns the following divs in the center of the column -->

                    <div>
                        <img id="rain-drop-icon" class="icons" src="https://kevinr.000webhostapp.com/Local%20Weather%20Report/icons/drop.svg" />
                        <span id="precip-prob"></span>
                    </div>
                    <div>
                        <img id="precip-amount-icon" class="icons" src="https://kevinr.000webhostapp.com/Local%20Weather%20Report/icons/drop-and-ruler.svg" />
                        <span id="precip-max"></span>
                    </div>

                    <div>
                        <img id="wind-icon" class="icons" src="https://kevinr.000webhostapp.com/Local%20Weather%20Report/icons/wind.svg" />
                        <span id="wind-speed"></span>
                    </div>

                </div>
            </div>
        </div>


        <footer id="footer">
            <a href="https://darksky.net/poweredby/">Powered by Dark Sky</a>
        </footer>
    </div>
</body>




<!--Put this at the end because I don't want it to run before everything else has preloaded -->
<script type="text/javascript" src="javascript/javascript.js"></script>



</html>
Ogundele Olumide
@Lumexralph
Jul 11 2017 17:43
@kevinwr who am I to judge..... i only said the html where the DOM is, not the whole thing :worried:
Kevin
@kevinwr
Jul 11 2017 17:44
oh not sure what you mean
Ogundele Olumide
@Lumexralph
Jul 11 2017 17:44
@kevinwr what element are you trying to get the width?
Kevin
@kevinwr
Jul 11 2017 17:44
a div element
these are the first two lines of the divs:
<div id="center-column" class="container-style">
                <div class="column-wrapper">
nested divs
oh crap
wrong one
haha
<div id="right-column" class="container-style">
                <div class="column-wrapper">
Ogundele Olumide
@Lumexralph
Jul 11 2017 17:49

@kevinwr

const div = document.querySelector("#right-column");
console.log(div);

let's see what that gives you

Dan Couper
@DanCouper
Jul 11 2017 17:54
getElementById does exactly what the name suggests, what you have currently couldn't work because you weren't selecting by ID @kevinwr
Kevin
@kevinwr
Jul 11 2017 17:55
image.png
@Lumexralph
@DanCouper Pretty sure I was
well...the first part was
NicholasGalarza
@NicholasGalarza
Jul 11 2017 17:56
Hello community. I'm currently doing a CodeWars problem and I think its pretty much the well known "two-sum" problem where you are given an array and you need to return the left most indice for the value that is returned. My solution is timing out and that confuses me because I think I may have an O(n) solution? To be specific, a O(2n) solution because I have two non-nested loops. The values in the array are not ordered so I cannot take the two-iterator approach. If you have any tips as to how to solve this problem more quickly, I'd love to hear it. And I would also like to know if my solution is indeed an O(n) solution because I'm not even sure anymore. It seems to be timing out unfortunately.
var sum_pairs = function (ints, s) {
    var sumMap = ints.reduce(function(obj, value, iter) {
      if (obj.hasOwnProperty(value)) {
           obj[value].push(iter);  
        } else {
           obj[value] = []; 
          obj[value].push(iter); 
        }
        return obj; 
     },  {} ); 

       var leftMostSum = ints.reduce (function(result, value, index) {
         let key = s - value; // check if the value in key exists in object.  
                // if key is available, 
                if (sumMap.hasOwnProperty(key)) {
                   // check if there is more than one indice available bc that is allowed. 
                   if (sumMap[key].length > 1) {
                   result.push([value, key]); 
                    }
            // check if the index is the same as the current index bc that isn't allowed. 
                   else if (sumMap[key][0] === index) {
                   return result;  
                   } else { // otherwise, the returned value from key is a suitable value so push to value and key_value to result.  
                   result.push([value, key]);  
                   } 
                   return result; 
                } else { // if key is unavailable, then the current value is not suitable for the sum, return result to continue. 
                  return result; 
               }
          }, []); 
   console.log(leftMostSum);  
   return leftMostSum[0]; 
}
Kevin
@kevinwr
Jul 11 2017 17:56
the second part is a class
I guess I'm just used to jQuery
Dan Couper
@DanCouper
Jul 11 2017 17:56
'#right-column .someclass' first part is not the name of an I'd
ID
Kevin
@kevinwr
Jul 11 2017 17:57
so how do I combine those?
Dan Couper
@DanCouper
Jul 11 2017 17:57
Use querySelector
Kevin
@kevinwr
Jul 11 2017 17:59
hmm never even heard of that. ugh this is why I shouldn't have started learning jQuery first
Dan Couper
@DanCouper
Jul 11 2017 17:59
getElementById('some-id') vs querySelector('#some-id .some-class')
Kevin
@kevinwr
Jul 11 2017 17:59
ok
let me try that
ahhh that worked
Dan Couper
@DanCouper
Jul 11 2017 18:00