These are chat archives for FreeCodeCamp/HelpFrontEnd

5th
Sep 2017
Tom
@moT01
Sep 05 2017 00:01
@Androbat you want some project ideas?
a place to practice?
codepen.io is a place to start coding if you're kinda new
Roxroy
@roxroy
Sep 05 2017 00:02
@Androbat , I know what you are saying. I have tried these, www.codewars.com, www.codechef.com. However, Codewar is my favourite., it will definitely flex those javascript muscles.
Tom
@moT01
Sep 05 2017 00:02
you can bring up some tutorials on youtube and follow along
Marc Graci
@MarcGraci
Sep 05 2017 00:10
Hi. I hope that someone can help me with my Weather App. I have almost the entire thing done, but my problem is accessing some of the API information. I have the location and the weather showing up fine, but I don't know how to accurately pull the description. Could someone look?
I want to get the description, and have tried "data.weather.description" but that's not right.
Tom
@moT01
Sep 05 2017 00:12
weather is an array
Marc Graci
@MarcGraci
Sep 05 2017 00:14
@moT01 , thanks. I see that. I'm still having trouble. "main.weather[description]" does not work. How should I call for this?
Tom
@moT01
Sep 05 2017 00:14
how do you get something from an array?
CamperBot
@camperbot
Sep 05 2017 00:14
marcgraci sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
Tom
@moT01
Sep 05 2017 00:16
var arr = [a,b,c,d]; how do i get c?
Marc Graci
@MarcGraci
Sep 05 2017 00:18
arr[2]
Tom
@moT01
Sep 05 2017 00:18
yup
Marc Graci
@MarcGraci
Sep 05 2017 00:19
Going from that, it should be "data.weather[2]". But that does not work.
Because the description I want is the second element of the array.
Tom
@moT01
Sep 05 2017 00:20
var arr = [a, b, {description: cloudy, temp: 56} ,d]
so how do i get temp
Marc Graci
@MarcGraci
Sep 05 2017 00:21
Oooh. That's trickier. I really don't know.
arr[3,2] ?
Tom
@moT01
Sep 05 2017 00:22
kinda close
Marc Graci
@MarcGraci
Sep 05 2017 00:22
arr[3,1]. I forgot to start at 0.
Tom
@moT01
Sep 05 2017 00:22
in that case arr[2] = {description: cloudy, temp: 56}
Marc Graci
@MarcGraci
Sep 05 2017 00:22
I follow that.
Tom
@moT01
Sep 05 2017 00:22
and thats an object
so you gotta go back to dot or brackets
Marc Graci
@MarcGraci
Sep 05 2017 00:24
So if I want the temp from your example, would I put arr[2].1 ?
arr[2][1]?
Tom
@moT01
Sep 05 2017 00:24
no
i know you know this
Marc Graci
@MarcGraci
Sep 05 2017 00:25
I think you give me too much credit.
Tom
@moT01
Sep 05 2017 00:25
arr[2].temp
you used it to get the location and temp in your pen
so if your weather = [{description: tornado}]
Marc Graci
@MarcGraci
Sep 05 2017 00:27
I tried data.weather[0].description and this worked.
It looks like the weather array only has one item?
Tom
@moT01
Sep 05 2017 00:28
right
Marc Graci
@MarcGraci
Sep 05 2017 00:29
So it's always going to be data.weather[0]. and then "id" or "main" or "description"?
Thanks for your help. My trouble, I think, is viewing the API info. It's a jumbled mess.
Tom
@moT01
Sep 05 2017 00:29
yup
for all the things in that object, yes
Marc Graci
@MarcGraci
Sep 05 2017 00:29
Tom
@moT01
Sep 05 2017 00:30
what browser
Marc Graci
@MarcGraci
Sep 05 2017 00:30
Is there a easier way to view it? Chrome.
Is there a better browser for this purpose?
Tom
@moT01
Sep 05 2017 00:30
is there options at the top?
one says JSON maybe and the other says RAW
Marc Graci
@MarcGraci
Sep 05 2017 00:31
Options on the page itself? No. Is there a viewing option in the Chrome settings?
Tom
@moT01
Sep 05 2017 00:31
i assume chrome has that option but maybe not, ...firefox does. another way would be to console.log(data) and view it in the dev tools
it might be in there not sure
Marc Graci
@MarcGraci
Sep 05 2017 00:32
Well, thanks a bunch, Tom. And I actually appreciate how you walked me through it and asked questions instead of giving me it.
Tom
@moT01
Sep 05 2017 00:34
that's what you're supposed to do
not gonna learn if i just paste the answer
aRtoo
@artoodeeto
Sep 05 2017 00:36

yow fam on my repl.it i am returning the right objects but when i paste everything on fcc theres a incorrect return value. heres my code:


// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold",

    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

  if(prop !== 'tracks' && value !== '') {
      collection[id][prop] = value;
  } 
   else if(prop === 'tracks' && !collection[id].hasOwnProperty('tracks') ) {
    collection.tracks = [value];
   }    

    else if(prop === 'tracks' && value !== '') {
      collection[id].tracks.push(value);
    } 

    else if(value === '') {
      delete collection[id][prop];
    }

  return collection;
}

updateRecords(5439, "tracks", "Take a Chance on Me");//tracks should have "Take a Chance on Me" as the last element.

this is the culprit. but i think its a bug.

updateRecords(5439, "tracks", "Take a Chance on Me");//tracks should have "Take a Chance on Me" as the last element.
Tom
@moT01
Sep 05 2017 00:39
i think you're missing the [id] in the else that one would fall in to
i also don't think you need the bracket on value
Johnny
@jtan3
Sep 05 2017 00:44
@MarcGraci you can download an extension called json viewer in chrome to see json objects easier
Manuel Reyes
@Androbat
Sep 05 2017 01:09
@roxroy OMG thank you so much for sharing.
CamperBot
@camperbot
Sep 05 2017 01:09
androbat sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:star2: 1136 | @roxroy |http://www.freecodecamp.com/roxroy
Manuel Reyes
@Androbat
Sep 05 2017 01:10
@moT01 Yes. I have projects ideas.
Ismail Hozain
@ismailhozain
Sep 05 2017 01:14
hey guys i need to address a js variable in css -how do i do that
Tom
@moT01
Sep 05 2017 01:27
can't
Ismail Hozain
@ismailhozain
Sep 05 2017 01:29
so what do i have to do
Tom
@moT01
Sep 05 2017 01:30
what are you trying to do
Ismail Hozain
@ismailhozain
Sep 05 2017 01:31
i am trying to neaten up the output from my wikipedia viewer
here is the link
Tom
@moT01
Sep 05 2017 01:32
can you be more specific
Ismail Hozain
@ismailhozain
Sep 05 2017 01:34
well so after the search results are shown they are like one big blob that you cant do anything with so i want them to be like multiple entries(like a proper search engine
)
i have been trying to work things out from my console and have not gotten anywhere
Tom
@moT01
Sep 05 2017 01:36
you can append to you html with jquery
Ismail Hozain
@ismailhozain
Sep 05 2017 01:36
?
Tom
@moT01
Sep 05 2017 01:37
$('#output').append('<div>'+variable+'</div>');
that will put a single div in the output
Ismail Hozain
@ismailhozain
Sep 05 2017 01:37
where would i use that like on which part of the output
Tom
@moT01
Sep 05 2017 01:37
you can make a loop to cycle through the arrays you're getting
that's in the js
so something like ...
Ismail Hozain
@ismailhozain
Sep 05 2017 01:38
this?
for(var i = 0; i < info[1].length; i++) { console.log(info[1][0]) }
except i have no clue how to proceed
Mercy Manrique
@mers89
Sep 05 2017 01:39
I have a similar question as @moT01. Trying to line up items side by side using .append .prepend on a different project. Any reccomendations on a good tutorial?
Tom
@moT01
Sep 05 2017 01:39
for (var i=0; i<info[0].length; i++){
  #ouput.append('div'+info[0][i]+'/div')
Ismail Hozain
@ismailhozain
Sep 05 2017 01:40
so what will that do
?
Tom
@moT01
Sep 05 2017 01:40
that will put 10 divs in your #output
cause you get 10 things back
and each will have different info
not exactly like that, but the right idea
Ismail Hozain
@ismailhozain
Sep 05 2017 01:41
oh
Tom
@moT01
Sep 05 2017 01:42
and you could add a class to style it up a bit
Ismail Hozain
@ismailhozain
Sep 05 2017 01:42
so can i give those elements ids and style them like that
Tom
@moT01
Sep 05 2017 01:42
@mers89 like a css tutorial on how to line things up?
Mercy Manrique
@mers89
Sep 05 2017 01:44
@moT01 using Javascript. Using api and wanted the info its pulling to display next to each other horizontal on three divs, instead info is being displayed in one column vertically
Tom
@moT01
Sep 05 2017 01:45
try display: inline or display: inline-block
or are you using bootstrap
Mercy Manrique
@mers89
Sep 05 2017 01:47
@moT01 $.getJSON(url2).done(function(data3) {
if (data3.error == undefined) {
$("#followerinfo")
      .prepend("<img src='"+ data3.logo + "'>")
      .prepend("<div>" + data3.name+ "</div>")
      .prepend("<div>" + data3.status + "</div>");
  } else {
    var logo= "http://res.cloudinary.com/mers/image/upload/c_scale,w_400/v1504573315/ui-day033-404error_u37kee.png";
     $("#followerinfo")
      .prepend("<img src='"+ logo + "'>")
      .prepend("<div>" + data3.message+ "</div>")
      .prepend("<div>" + data3.error + "</div>");
  }});
Ismail Hozain
@ismailhozain
Sep 05 2017 01:47
can you link your pen
@mers89
I am assuming because I only used prepend
Ismail Hozain
@ismailhozain
Sep 05 2017 01:49
so you are trying to center the images
?
Tom
@moT01
Sep 05 2017 01:50
looks like prepend is putting all the info you want in there, just maybe not in the order you want
Mercy Manrique
@mers89
Sep 05 2017 01:50
@ismailhozain so I wanted the logo to display next to the user's name and then then there status all in one row. Instead all the info is vertically align
Ismail Hozain
@ismailhozain
Sep 05 2017 01:50
oh
Mercy Manrique
@mers89
Sep 05 2017 01:51
@ismailhozain @moT01 I tried changing some of it to append to move it to the end of the row but no luck.
Tom
@moT01
Sep 05 2017 01:51
so here's a structure you may want to try and build with your js ...
<div> //make this block
 <logo> //inline
 <title> //inline
</div>
logo and title aren't actual tags
Mercy Manrique
@mers89
Sep 05 2017 01:54
@moT01 so should I format them under css?
Tom
@moT01
Sep 05 2017 01:54
does that make any sense? if you open your dev tools you can see that the title is taking the whole width of the page
that's block
any block element will take the whole width
you will need to format them in css
probly should anyway
lemme try and write something up how i would do it real quick a little closer to what you actually need
Mercy Manrique
@mers89
Sep 05 2017 01:56
@moT01 ok great! Ill try that and see if that works
Tom
@moT01
Sep 05 2017 01:59
 $("#followerinfo").append('<div class="block">
                                <img src="'+imgHere+'" class="inline">
                                <div class="inline">' + data3.status + '</div>
                             </div>');
name the class whatever you want, but then style them in the css like that
that's closer to how i would do it anyway
Mercy Manrique
@mers89
Sep 05 2017 02:03
@moT01 awesome! Let me try to do it that way. :)
Tom
@moT01
Sep 05 2017 02:03
you could actually maybe just take what you have, add some classes in there, and style it up
Kira
@nxdl
Sep 05 2017 02:04
Simons Game starting questions. How did you guys do colored fields to click on? Table, buttons or something else?
Tom
@moT01
Sep 05 2017 02:05
fyi, im pretty sure prepend adds things to immediately after your target(the first child), and append adds them sequentially
to the end
Mercy Manrique
@mers89
Sep 05 2017 02:08
@moT01 yeah I remember the before and after. It was just the correct way to apply it I guess. But thanks so much you gave me so much info.
CamperBot
@camperbot
Sep 05 2017 02:08
mers89 sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 840 | @mot01 |http://www.freecodecamp.com/mot01
Tom
@moT01
Sep 05 2017 02:08
i just used some <div>'s and css @nxdl
Kira
@nxdl
Sep 05 2017 02:08
Thanks Tom
that's how i did mine
iso
@iso1048
Sep 05 2017 02:11
@moT01 have you got your front-end certificate?
Kira
@nxdl
Sep 05 2017 02:12
@gothamknight Nice! This is a perfect example. Thank you bunch
CamperBot
@camperbot
Sep 05 2017 02:12
nxdl sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 419 | @gothamknight |http://www.freecodecamp.com/gothamknight
iso
@iso1048
Sep 05 2017 02:15
@nxdl wrong person
Tom
@moT01
Sep 05 2017 02:15
thieves
Kira
@nxdl
Sep 05 2017 02:16
@gothamknight Pfffff.....
@moT01 Thank you, man
CamperBot
@camperbot
Sep 05 2017 02:16
nxdl sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 841 | @mot01 |http://www.freecodecamp.com/mot01
Tom
@moT01
Sep 05 2017 02:16
@gothamknight yea
3 projects left on the back-end
iso
@iso1048
Sep 05 2017 02:18
@moT01 Cool. i feel like i have asked you before...
Tom
@moT01
Sep 05 2017 02:18
perhaps
just finished my stock market
iso
@iso1048
Sep 05 2017 02:23
that is great
Tom
@moT01
Sep 05 2017 02:26
i went through the same process as everyone here
Rafael Monroy
@rafaelmonroy
Sep 05 2017 02:44
whats up guys! hope everyone had a good weekend, I just finised about 90%(or so i think) of my wiki search engine, the only thing i am having trouble with is getting my program to print out each title as it irerates through the array, it only prints out the last result, I tried a for loop and while loop but same results, im so close I KNOW IT lol maybe not, can anyone look into my code and see what i am doing wrong? thanks! https://codepen.io/rafaelmonroy/pen/BdEBXB
@rafaelmonroy
acutally, you need that and a .append
Roxroy
@roxroy
Sep 05 2017 02:55
@rafaelmonroy , you are almost there. You are overwriting the #results with each loop iteration. Instead append the new li to the list. Use the jQuery .append() function. See http://api.jquery.com/append/ to see how it works
Tom
@moT01
Sep 05 2017 02:56
your using .html which just changes the whole content of #results each time
so you end up with the last thing returned
and you actually dont need the first thing
Rafael Monroy
@rafaelmonroy
Sep 05 2017 03:01
@moT01 @roxroy ah man! i knew it was going to be something silly lol well kinda of, that fixed it. thanks guys!
CamperBot
@camperbot
Sep 05 2017 03:01
rafaelmonroy sends brownie points to @mot01 and @roxroy :sparkles: :thumbsup: :sparkles:
:star2: 1137 | @roxroy |http://www.freecodecamp.com/roxroy
:cookie: 842 | @mot01 |http://www.freecodecamp.com/mot01
Rafael Monroy
@rafaelmonroy
Sep 05 2017 03:02
@moT01 do I still need to add the forEach() ?
Tom
@moT01
Sep 05 2017 03:02
no you dont
keep it in mind for the twitch project
i dont think you do anyway, it seems to be working without it
Rafael Monroy
@rafaelmonroy
Sep 05 2017 03:03
@moT01 oh cool, ill keep that in mind for sure! thanks man!
CamperBot
@camperbot
Sep 05 2017 03:03
rafaelmonroy sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:warning: rafaelmonroy already gave mot01 points
Rafael Monroy
@rafaelmonroy
Sep 05 2017 03:03
first project i only had to ask one question in here… woooo
Tom
@moT01
Sep 05 2017 03:06
first project? jumped right into the wiki, nice
Rafael Monroy
@rafaelmonroy
Sep 05 2017 03:07
@moT01 yeah man, it was different, had to do more reading lol but felt better finishing it without so much help.
hopefully I can say the same about the next project
lfvpCO
@lfvpCO
Sep 05 2017 03:28
new JS for newbies
hillsie
@Hillsie
Sep 05 2017 03:33
does anyone have some good reference videos on the DOM ?
Found something that looks great. But I was hoping for some video tutorials. http://domenlightenment.com/
Long Nguyen
@longnt80
Sep 05 2017 03:53
@Hillsie you can search for "dom javascript" on youtube
hillsie
@Hillsie
Sep 05 2017 03:55
thanks @longnt80 , I found one and I’m downloading to my grey matter ssd
CamperBot
@camperbot
Sep 05 2017 03:55
hillsie sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 547 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
Sep 05 2017 03:56
@Hillsie also, you can read: http://eloquentjavascript.net/13_dom.html
hillsie
@Hillsie
Sep 05 2017 03:56
Ta
Markus Kiili
@Masd925
Sep 05 2017 06:38
@Hillsie DOM manipulation is maybe the hardest part of learning JS. Complex stuff and you have to learn it from several resources and by trial and error too.
Browser compatibility problems are also present etc.
LiciniusRex
@hashtagyolo1
Sep 05 2017 06:48
Having trouble getting .append to work. I know I must have missed something really obvious, but with no errors I can't work it out
Jan Shah
@JanShah
Sep 05 2017 06:51
@hashtagyolo1 you're mixing object types. check your console log
LiciniusRex
@hashtagyolo1
Sep 05 2017 06:52
my console doesn't say anything
Jan Shah
@JanShah
Sep 05 2017 06:53
@hashtagyolo1
 let circ =  document.getElementById("circle")

 let circle= document.createElement('circle')
circle.setAttribute('cx', 100)
circle.setAttribute('cy', 100)
circle.setAttribute('r', 20)

circ.appendChild(circle)
@hashtagyolo1 not the codepen console :)
LiciniusRex
@hashtagyolo1
Sep 05 2017 06:54
the dev console. I know :D. Not a thing in it on my screen
Jan Shah
@JanShah
Sep 05 2017 06:54
@hashtagyolo1 Idk mate, it was there for me, one sec
sorry I must have changed something to coerce the error myself. @hashtagyolo1
LiciniusRex
@hashtagyolo1
Sep 05 2017 06:55
haha @JanShah , no worries
Jan Shah
@JanShah
Sep 05 2017 06:55
but in any case, the above code will generate a circle for you :)
inside your circle
LiciniusRex
@hashtagyolo1
Sep 05 2017 06:56
is there a particular reason my code does't work?
Jan Shah
@JanShah
Sep 05 2017 06:56
VM290 pen.js:6 Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
    at createCircle (VM290 pen.js:6)
    at HTMLButtonElement.onclick (index.html?editors=0011:9)
that's the error I got
the same thing applies, you can append dom objects but I'm not sure about appending raw html
LiciniusRex
@hashtagyolo1
Sep 05 2017 06:57
weird
Jan Shah
@JanShah
Sep 05 2017 06:58
if you want content, you would set innerHTML or innerText, if you want to append, you create the object (circle) and appendChild usually, or prepend, I think, if you want it as the first child element
LiciniusRex
@hashtagyolo1
Sep 05 2017 06:58
kk. Thanks @JanShah
CamperBot
@camperbot
Sep 05 2017 06:58
hashtagyolo1 sends brownie points to @janshah :sparkles: :thumbsup: :sparkles:
:cookie: 511 | @janshah |http://www.freecodecamp.com/janshah
Markus Kiili
@Masd925
Sep 05 2017 06:58
@hashtagyolo1 JS has Node.appendChild(). I think .append() is a jQuery method.
as @JanShah already said...
Jan Shah
@JanShah
Sep 05 2017 07:02
i didn't bro :( @Masd925
I remember now but it doesn't pop into my head automatically, I usually have to refer back to my own code :(
Trello Whoomer
@Trellowhoomer
Sep 05 2017 08:16
var age=Number(prompt("your age"));

if (age<0) {
    console.log("error" );
}

else if(age===21) {
    console.log("happy 21st birthday");
}

else if (age%2==1) {
    console.log("your age is odd");
}

else(age % Math.sqrt(age) === 0) {
    console.log("your age is perfect square");
}
There is an error in the last else statement
it shows unexpected {
"Uncaught SyntaxError: Unexpected token { "
iso
@iso1048
Sep 05 2017 08:19
@Trellowhoomer try removing the conditional expression for the else statement. else is like a default output so you do not need a conditional for it. I never have anyway (although that is not saying much)
@Trellowhoomer try removing (age % Math.sqrt(age) === 0) that
Trello Whoomer
@Trellowhoomer
Sep 05 2017 08:20
yeah, got it thanx @gothamknight
CamperBot
@camperbot
Sep 05 2017 08:20
trellowhoomer sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 420 | @gothamknight |http://www.freecodecamp.com/gothamknight
LiciniusRex
@hashtagyolo1
Sep 05 2017 08:23
still not getting any errors when I do this, but still not amking any circles either
making*
Hmm, when I use the test append, it's putting the text below my SVG box. I wonder if 't calling the circles below my screen? SHouldn't I be able to croll own to see them then?
LydaTech
@lydatech
Sep 05 2017 08:31
@Trellowhoomer
var age = prompt("What is your age?");

if (age < 0) { 
  console.log("error" ); 
} else if (age === 21) { 
  console.log("happy 21st birthday"); 
} else if (age % 2 == 1) { 
    console.log("your age is odd"); 
} else (age % Math.sqrt(age) === 0)  
      console.log("your age is perfect square");
LiciniusRex
@hashtagyolo1
Sep 05 2017 08:49
function createCircle(){
  var cx1 = Math.floor(Math.random() * (50 - 5));
  var cy1 = Math.floor(Math.random() * (50 - 5));
  var r1 = Math.floor(Math.random() * (10 - 2));
  //$("#circle").append("<p>test</>");
  $("#circle").append("<svg viewBox="0 0 200 200"><circle cx='" + cx1 + "' cy='" + cy1 + "' r='" + r1 + "' /></svg>");
}
Getting an unexpected number error, but I can't work why
double quote and single quotes. Bingo :D
Trello Whoomer
@Trellowhoomer
Sep 05 2017 09:06
@lydatech the code you have provided is not working correctly
LydaTech
@lydatech
Sep 05 2017 09:13
@Trellowhoomer what do you mean not working?
LydaTech
@lydatech
Sep 05 2017 09:20
@Trellowhoomer I was focusing on the format not the logic
else (age % Math.sqrt(age) === 0) 
console.log("your age is perfect square");
in its current place is wrong logic
Nicol
@NicolNonga
Sep 05 2017 09:34
hi help me please
what iam doing wrong help
LiciniusRex
@hashtagyolo1
Sep 05 2017 09:42
Having trouble reading your code @NicolNonga. Why do you have jquery script call in your html box? You can select it by using the cog in the js box. Much easier and tidie
I alos can't see you actual api call
Trello Whoomer
@Trellowhoomer
Sep 05 2017 09:46
@lydatech sir, i meant to say that, this statement "your age is perfect square" is printing everytime on console irregardless of the number user enters
Markus Kiili
@Masd925
Sep 05 2017 09:47
@Trellowhoomer I think the last else should be else if. Or just if.
LiciniusRex
@hashtagyolo1
Sep 05 2017 09:47
to get the information from wikipedia you'll need to get the JSON data and then arrange it nicely on the screen.
LydaTech
@lydatech
Sep 05 2017 09:47
@Trellowhoomer yes because of the logic. You want to test for age. choose what message to display THEN check if its a square
the way you have it in the else statement says if everything else fails in all the ifs then print the square message
Nicol
@NicolNonga
Sep 05 2017 09:52

@hashtagyolo1 ´$('.input').autocomplete({

  source: function(query, result){
$.ajax({
        url: "http://en.wikipedia.org/w/api.php",
        dataType: "jsonp",
        data: {
            'action': "opensearch",
            'format': "json",
            'search': query.term
        },

        success: function (data) {
             console.log(data)
        }
    });

  }
});

´ CONSOLE.LOG(data ) is not responde Iam try to get data from the Weakipedia API

LiciniusRex
@hashtagyolo1
Sep 05 2017 09:55
This is the call I used, where searchBox is the value of the search box: "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&redirects=return&search=" + searchBox + "&callback=?" @NicolNonga
I think you'll need to put a ? at the end of your url
iso
@iso1048
Sep 05 2017 09:58
@NicolNonga make sure the url is https not http
Nicol
@NicolNonga
Sep 05 2017 10:09
@gothamknight @hashtagyolo1 it is returning an empty array ["query.term", [], [], []]
Trello Whoomer
@Trellowhoomer
Sep 05 2017 10:10
@lydatech yeah, but when i enter -ve number, 21 and an Odd number(true conditions), "your age is perfect square" prints too with the other true statement...why it is so?
Nicol
@NicolNonga
Sep 05 2017 10:11
I got it thanks @hashtagyolo1 @gothamknight
CamperBot
@camperbot
Sep 05 2017 10:11
nicolnonga sends brownie points to @hashtagyolo1 and @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 421 | @gothamknight |http://www.freecodecamp.com/gothamknight
:cookie: 272 | @hashtagyolo1 |http://www.freecodecamp.com/hashtagyolo1
LydaTech
@lydatech
Sep 05 2017 10:11
@Trellowhoomer because of the last statement position
@Trellowhoomer I would do checkSqr() or a single checkAge() function
Trello Whoomer
@Trellowhoomer
Sep 05 2017 10:16
thanks @lydatech sir
CamperBot
@camperbot
Sep 05 2017 10:16
trellowhoomer sends brownie points to @lydatech :sparkles: :thumbsup: :sparkles:
:star2: 2406 | @lydatech |http://www.freecodecamp.com/lydatech
LiciniusRex
@hashtagyolo1
Sep 05 2017 10:40
@NicolNonga no worries. Glad to be able to give something back
Nicol
@NicolNonga
Sep 05 2017 10:44
@hashtagyolo1 iam try to understand how to display the data
any hint please
LiciniusRex
@hashtagyolo1
Sep 05 2017 10:48
@NicolNonga how do you mean?
So that it all separates out?
Nicol
@NicolNonga
Sep 05 2017 10:49
now iam able to get data from wikipedia, but i want to show it well formated
LiciniusRex
@hashtagyolo1
Sep 05 2017 10:53
@NicolNonga you'll need to get it into a html element. I created my elements on the fly as part of the call with jquery.
append is your friend
:)
Fredrik Strand Oseberg
@FredrikOseberg
Sep 05 2017 11:01
Anyone used webpack to generate responsive images? If so which module did you use?
SUOERLIU
@SUOERLIU
Sep 05 2017 11:09
how to display the result?
LiciniusRex
@hashtagyolo1
Sep 05 2017 11:11
Sorry @FredrikOseberg , not used it.
@SUOERLIU What are you trying to display?
Fredrik Strand Oseberg
@FredrikOseberg
Sep 05 2017 11:13
@hashtagyolo1 I’m following this: https://www.udacity.com/course/responsive-images--ud882 udacity course. They are using grunt and ImageMagick to create several different versions of an image to use on your website to load the most effective picture depending on screen size in regards to performance. My build tools are generally based on webpack, so I’m trying to find a way to reverse engineer this process using webpack.
SUOERLIU
@SUOERLIU
Sep 05 2017 11:14
Thank you I got it
LiciniusRex
@hashtagyolo1
Sep 05 2017 11:23
no idea man, sorry
krckyboy
@krckyboy
Sep 05 2017 11:43
Does anyone know a good tutorial for Bootstrap grid system? Only grid. Thanks.
krckyboy
@krckyboy
Sep 05 2017 11:55
@just1witness Thanks!
CamperBot
@camperbot
Sep 05 2017 11:55
krckyboy sends brownie points to @just1witness :sparkles: :thumbsup: :sparkles:
:cookie: 325 | @just1witness |http://www.freecodecamp.com/just1witness
LiciniusRex
@hashtagyolo1
Sep 05 2017 12:32
@krckyboy I'm doing this one at the moment: https://www.youtube.com/watch?v=HgwCeNVPlo0
krckyboy
@krckyboy
Sep 05 2017 13:11
@VRamazing Thank you very much!
CamperBot
@camperbot
Sep 05 2017 13:11
krckyboy sends brownie points to @vramazing :sparkles: :thumbsup: :sparkles:
:cookie: 121 | @vramazing |http://www.freecodecamp.com/vramazing
PierreProgramer
@PierreProgramer
Sep 05 2017 13:31
How do I make the buttons appear at the center of the word and how do I make the go button go at the bottom
Rajat
@rajataudichya
Sep 05 2017 13:40
can someone share me a wordpress help group
or anyone here that can help me for in js
Morchid Chellali
@Morched23MJ
Sep 05 2017 13:41
What's the matter?
Tom
@moT01
Sep 05 2017 13:41
@PierreProgramer the <center> tag is deprecated
and you probly dont need any <form>'s if you're not sending info to a server
you should probly also properly indent your code if you want people to help
you can use text-align: center; in your css to center things - one way anyway
Mike
@MikeJSchorah
Sep 05 2017 13:50
How many web designers buy child themes already done opposed to customizing their own child theme?
Johnny
@JohnnyBizzel
Sep 05 2017 13:51
@rajataudichya Wordpress.org has a forum
@MikeJSchorah Is that a rhetorical question?
Johnny
@JohnnyBizzel
Sep 05 2017 13:58
@MikeJSchorah Completely different question
Mike
@MikeJSchorah
Sep 05 2017 13:58
There surely can't be that many $200 website guys out there, but when I do a Google search for "website designer", 5/6 of the ads lead me to a landing page of a "web design" company from anywhere in the United States with a contact form and shitty design. Organic search results seem to be legit, though
Johnny
@JohnnyBizzel
Sep 05 2017 14:00
@MikeJSchorah If you can't find a free theme that suits, you can always go to a freelancing website and ask for a theme designing.
Mike
@MikeJSchorah
Sep 05 2017 14:00
@JohnnyBizzel Is Wordpress.org as good as this chat or do you have to wait a couple of days for an answer?
@JohnnyBizzel I've been using the Divi theme and Avada theme, but I haven't been using child themes. I was going to start doing that today, but the first search result for a YouTube instructional video suggested that I buy a already done child theme and I was like "wait, what?"
Johnny
@JohnnyBizzel
Sep 05 2017 14:02
@MikeJSchorah Not been on it for a while. Stackoverflow also has a Wordpress forum. Maybe ask a question that will get an answer. "How many web designers?" is such a vague question.
Jay
@jatacid
Sep 05 2017 14:02
Oh wow there is activity on here! Hello all. I've just found codecamp
Johnny
@JohnnyBizzel
Sep 05 2017 14:03
@MikeJSchorah I don't even know what a child theme is. A theme for kids? Age <7?
Tom
@moT01
Sep 05 2017 14:03
@jatacid welcome
Johnny
@JohnnyBizzel
Sep 05 2017 14:03
@jatacid Afternoon
Jay
@jatacid
Sep 05 2017 14:03
I've changed my html/css junior job to part time so that I can study. I'm going to try to improve to become a front end developer :) wish me luck!
Mike
@MikeJSchorah
Sep 05 2017 14:03
@JohnnyBizzel I tried Stackoverflow before for JavaScript questions. Seems like they want you to have a little bit of experience or they won't give you points. When I first started coding, they actually gave me negative points until I started asking better questions.
@JohnnyBizzel But I guess my answer should be "Only fly-by-night web designers buy already done child themes"
@jatacid Welcome. It's a long journey, but it's worth it
Jay
@jatacid
Sep 05 2017 14:05
What are people's thoughts on codecamp? any parts I should skip/focus on IYO?
Mike
@MikeJSchorah
Sep 05 2017 14:05
@JohnnyBizzel Oh, you don't know much about WordPress?
Tom
@moT01
Sep 05 2017 14:06
@jatacid the things required for the certs are marked on the map with a *, but i would go through it all
Jay
@jatacid
Sep 05 2017 14:06
Does the cert count for anything?
Mike
@MikeJSchorah
Sep 05 2017 14:06
@jatacid Depends. What are you trying to do exactly? This site seems to be more geared towards software development opposed to web development, especially the back-end section
Tom
@moT01
Sep 05 2017 14:06
its something you can say you achieved
self satisfaction
Johnny
@JohnnyBizzel
Sep 05 2017 14:07
@MikeJSchorah apart from hosting 3-4 sites and building a plugin, no.
@MikeJSchorah Things change quickly in this industry; that was a while ago.
Jay
@jatacid
Sep 05 2017 14:08
Sometimes that's enough :P
I'm more interested in foundation logic. Like I know some html/css/javascript but need OOC and understanding of fundamentals. Is this course going to be good for that do you think? or is it more technically focussed?
Johnny
@JohnnyBizzel
Sep 05 2017 14:08
@jatacid You reap what you sow.
Mike
@MikeJSchorah
Sep 05 2017 14:09
@JohnnyBizzel You're saying you used to do WordPress, but you wouldn't touch it if your life depended on it now?
Tom
@moT01
Sep 05 2017 14:10
@jatacid not sure what you mean by fundamentals, if you know some stuff already you should fly through the first few sections
Johnny
@JohnnyBizzel
Sep 05 2017 14:11
@MikeJSchorah No
Tom
@moT01
Sep 05 2017 14:11
they give you enough to have a decent enough understanding of the language/technology to use it, but they push you to figure out stuff on your own
Jay
@jatacid
Sep 05 2017 14:12
@moT01 Yeah hoping so :)
For example I had a phone interview the other day and as a screening question they asked like "Do you know what's the difference between a static, dynamic and persistent variable" and "what are the benefits of using a closure?" I was stumped lol.
Mike
@MikeJSchorah
Sep 05 2017 14:13
@JohnnyBizzel Someone on Quora answered my question perfectly
Jay
@jatacid
Sep 05 2017 14:13
I know them, probably even used them all - but don't know the theory. Any ideas on how to fill the knowledge holes?
Tom
@moT01
Sep 05 2017 14:16
yea, that won't be covered here. You might be looking for some books or video tutorials. But i would say you should definitely do this as well.
Jay
@jatacid
Sep 05 2017 14:17
@moT01 yeah, having a look through the map and a lot will be quite useful to solidify my technical knowledge & fix up my dorky syntax. OOC stuff too which I'm most interested in
not sure where to go for a book though! There are so many!
Tom
@moT01
Sep 05 2017 14:19
@jatacid there is a few videos here that have a little of that, if you scroll down the map
Jay
@jatacid
Sep 05 2017 14:21
Yeah saw them :) Thanks.
I love 1 minute video summarys - sometimes that's all you need. Not a whole hr lecture at uni lol.
If anyone else wants to chime in and recommend a good book that'd be great! (one that covers what a closure might be or whats the difference between a persistent, static and dynamic variable or information about 'float' vs 'integers' and some core CS info)
Tom
@moT01
Sep 05 2017 14:25
im sure if you do a you tube search you can come across some stuff
floats are usually numbers with decimals, or least have the ability to store decimals, integers are whole numbers
data types
i will assume that dynamic variables have changing values based something else. static probly dont change at all, and im not sure on persistent, maybe they dont change but its passed around or available throughout the code, ...like a global variable - not sure
korzo
@korzo
Sep 05 2017 14:44

@jatacid
those questions are javascript related?

"Do you know what's the difference between a static, dynamic and persistent variable" and "what are the benefits of using a closure?"

Marat
@Marat89bluolyu
Sep 05 2017 14:45
Hi all, i stacked on creating function, then return all objects from array
var pointK = {
    "Moscow":1,
    "Samara":1.1
}

var deliveryStore = [];

function registerDelivery(obj){
  var cash;
    if(Array.isArray(obj)) {
        obj.map(function(x) {
        obj = x;
    });
    }

    var delivery = Math.floor (obj.price*0.015*pointK[obj.destination]+175);

deliveryStore.push(obj, delivery);
}

registerDelivery([{
   product: 'Canon EOS 1500D Kit 18-55mm DC black',
   price: 22999,
   destination: 'Moscow',
   count: 1
},

{
   product: 'Canon EOS 1200D Kit 18-55mm DC black',
   price: 15000,
   destination: 'Samara',
   count: 1
}]);

console.log(deliveryStore);
now after map returned only second object
dinesh
@1532j0004kg
Sep 05 2017 14:47
obj refers what?
Marat
@Marat89bluolyu
Sep 05 2017 14:48
registerDelivery
dinesh
@1532j0004kg
Sep 05 2017 14:48
then delivery?
Marat
@Marat89bluolyu
Sep 05 2017 14:49
yes delivery makes operation, for next functions
i need get obj from array if argument the array and after use other operation delivery
if my argument is object - its ok
korzo
@korzo
Sep 05 2017 14:51
@Marat89bluolyu
then use for of forEach and push to deliveryStore inside after get delivery price
@Marat89bluolyu What are you trying to achieve here?
        obj.map(function(x) {
        obj = x;
    });
Marat
@Marat89bluolyu
Sep 05 2017 14:53
@korzo trying get obj from array :D
korzo
@korzo
Sep 05 2017 14:53
@Marat89bluolyu It overwrites value of obj with first element of array
Marat
@Marat89bluolyu
Sep 05 2017 14:53
@korzo yea, i dont know what to do
@korzo using forEach instead map?
korzo
@korzo
Sep 05 2017 14:55
@Marat89bluolyu
for(var i = 0; i < obj.length; i++) {
    deliveryStore.push(obj[i], Math.floor (obj[i].price*0.015*pointK[obj[i].destination]+175);
}
Marat
@Marat89bluolyu
Sep 05 2017 14:55
@korzo or declare delivery in condition?
korzo
@korzo
Sep 05 2017 14:56
@Marat89bluolyu but thats wrong.
What shoul be element in deliveryStore? array or object?
Marat
@Marat89bluolyu
Sep 05 2017 14:57
@korzo array
@korzo cause is store deliveries
korzo
@korzo
Sep 05 2017 14:57
@Marat89bluolyu then
for(var i = 0; i < obj.length; i++) {
    deliveryStore.push([obj[i], Math.floor (obj[i].price*0.015*pointK[obj[i].destination]+175]);
}
LiciniusRex
@hashtagyolo1
Sep 05 2017 14:57
Anyone who has some CSS grid experience can help me work out why my grid doesn't reorder when I change the screen size?
korzo
@korzo
Sep 05 2017 14:58
inside Array.isArray condition
Marat
@Marat89bluolyu
Sep 05 2017 14:58
@korzo thank you:)
CamperBot
@camperbot
Sep 05 2017 14:58
marat89bluolyu sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 451 | @korzo |http://www.freecodecamp.com/korzo
LiciniusRex
@hashtagyolo1
Sep 05 2017 15:04
werdi, works when I move the actual screen, but not the response in dev tools
Jorge
@OrangeKulture
Sep 05 2017 15:21
hey whats up guys
dinesh
@1532j0004kg
Sep 05 2017 15:21
5n...hru?
Jorge
@OrangeKulture
Sep 05 2017 15:22
all good thanks .. trying to tackle this unit tests in angular :S
dinesh
@1532j0004kg
Sep 05 2017 15:22
R u well known in js
Jorge
@OrangeKulture
Sep 05 2017 15:25
i dont think so ... i mean i know JS, im no master at it tho .. not yet
dinesh
@1532j0004kg
Sep 05 2017 15:26
How u finished the weathor api any tips?
Jorge
@OrangeKulture
Sep 05 2017 15:27
sure .. i would use darksky api, it's pretty good. What i did was display the location info with google maps api and handled all other logic with the API call
dinesh
@1532j0004kg
Sep 05 2017 15:28
I am not good at js
i know bit..
Jorge
@OrangeKulture
Sep 05 2017 15:30
where are you in the project so far?
dinesh
@1532j0004kg
Sep 05 2017 15:30
i finished the portfolio
and random quote generator but by refering others...
html and css i know...
how to learn api ?
Jorge
@OrangeKulture
Sep 05 2017 15:32
did you complete the challenges ? it's kinda daunting at first, if you've never worked with APIs, but once you get it, it's pretty easy
dinesh
@1532j0004kg
Sep 05 2017 15:33
i finished the tasks...
Jorge
@OrangeKulture
Sep 05 2017 15:33
search on youtube for something like 'working with apis' or api tutorials or something along those lines, you should get some info
dinesh
@1532j0004kg
Sep 05 2017 15:33
ok
krckyboy
@krckyboy
Sep 05 2017 15:33
@hashtagyolo1 That's CSS grid, which isn't Bootstrap grid. Bootstrap has all cross-browser support while CSS grid doesn't. Keep that in mind. :)
dinesh
@1532j0004kg
Sep 05 2017 15:33
but how to work to handle the functions tips?
i have dought in using the parameters...
In the tasks the where given the function references and values
but in the projects they where not working with values..
like data is the parameter used but i dont know why it is used...
this data parameter is refer the api?
Jorge
@OrangeKulture
Sep 05 2017 15:36
basically u need to make a call to the server, the url is know as an endpoint .. you pass a URL to the ajax call, or getJSON, whatever method you are using, and pass the url with some values .. then, if the request(the url you sent) is valid, you will get a response from the server, you can then use this data to manipulate your app
dinesh
@1532j0004kg
Sep 05 2017 15:37
the parameter names are in any name?
are only with particular name ?
if we using the multiple parameters like(resp,req) . how the resp and req will get the proper vaues from the server...
without the values collapse or interchange
Jorge
@OrangeKulture
Sep 05 2017 15:40
because it already knows ... req parameter is the request you pass in , res is the response from the server
that's usually done on the backend tho .. u dont need that much
dinesh
@1532j0004kg
Sep 05 2017 15:41
thats my question ... that resp and req how u know...
Jorge
@OrangeKulture
Sep 05 2017 15:41
for example, this is my API call to the darksky endpoint:
 var url =
        "https://api.darksky.net/forecast/8bfe73adbee0a652190e6c9ccd1e1d21/" +
        lat +
        "," +
        long +
        "?exclude=minutely,hourly,daily,alerts,flags&units=si&callback=?";

      $.ajax({
        url: url,
        type: "GET",
        async: false,
        dataType: "json",
        success: function(data, status) {
           // do some magic with data
       }
dinesh
@1532j0004kg
Sep 05 2017 15:42
what is data and status actually means
Jorge
@OrangeKulture
Sep 05 2017 15:42
data is the data you get back from the server .. its an object
status is the status send by the server, used for error handling and stuff like that
dinesh
@1532j0004kg
Sep 05 2017 15:43
these names are found where...
in api?
Jorge
@OrangeKulture
Sep 05 2017 15:43
what names?
dinesh
@1532j0004kg
Sep 05 2017 15:43
data and status
Jorge
@OrangeKulture
Sep 05 2017 15:43
data is just a variable name .. you can use any name you want
dinesh
@1532j0004kg
Sep 05 2017 15:44
status?
Jorge
@OrangeKulture
Sep 05 2017 15:44
it's like naming a parameter for a function, you can use any name you want when getting the info in a function, u just have to use the same name within the function
dinesh
@1532j0004kg
Sep 05 2017 15:45
ok thanks @OrangeKulture
CamperBot
@camperbot
Sep 05 2017 15:45
1532j0004kg sends brownie points to @orangekulture :sparkles: :thumbsup: :sparkles:
:cookie: 460 | @orangekulture |http://www.freecodecamp.com/orangekulture
dinesh
@1532j0004kg
Sep 05 2017 15:45
i understood some thing ...
thanks for spending time for me...
Jorge
@OrangeKulture
Sep 05 2017 15:46

```
function logMe(name){
console.log(name)
}

function logMe(car){
console.log(car)
}

logMe(mercedes);
``

woops
ohh well .. you get it
basically those two are the same
dinesh
@1532j0004kg
Sep 05 2017 15:47
function logMe(name){
console.log(name)
}
function logMe(car){
console.log(car)
}
logMe(mercedes);
this is the code right?
name and car vakue is mercedes right?
value
Jorge
@OrangeKulture
Sep 05 2017 15:48
yeah .. i mean it doesnt make sense to have that, but it's just to illustrate the the variable name you pass in, doesnt matter
Tom
@moT01
Sep 05 2017 15:48
there's an edit button on the right @OrangeKulture
Jorge
@OrangeKulture
Sep 05 2017 15:48
exactly .. it's just a placeholder
yeah i did try to edit, but would go for it .. this p#$^@
:joy:
wouldnt ** even
dinesh
@1532j0004kg
Sep 05 2017 15:49
@OrangeKulture what lang u learning now?
Jorge
@OrangeKulture
Sep 05 2017 15:50
not learning languages, im developing a small project in angular, sort of like a test to see if i get a job
it's proven to be a tad difficult :S
dinesh
@1532j0004kg
Sep 05 2017 15:51
what project
in what resource u doing project...
from tomorrw i am also doing project insteadof learning theratical , it helpful for me?
Jorge
@OrangeKulture
Sep 05 2017 15:53
It's a test they give you .. if you pass, u probably get the job. We'll see
yeah it's definitely helpful to do projects .. that's why FCC's curriculum is project based. Go through the projects and google what u don't know. There's a lot of good info online
dinesh
@1532j0004kg
Sep 05 2017 15:54
ok...
where u doing projects...
in angular js
Jorge
@OrangeKulture
Sep 05 2017 16:01
angular 2 yeah ...
angular is really fun .. but it's also kinda hard to grasp to a full extent
dinesh
@1532j0004kg
Sep 05 2017 16:02
In ide or like codepen...
Jorge
@OrangeKulture
Sep 05 2017 16:03
oh no .. independently. I have express in the backend with nodeJS runtime. i use visual studio code as the code editor
dinesh
@1532j0004kg
Sep 05 2017 16:03
In visual studio u doing project right?
Jorge
@OrangeKulture
Sep 05 2017 16:04
yeah thats the code editor
i use node to run the code
dinesh
@1532j0004kg
Sep 05 2017 16:04
backend will create automatically?
or u need to create a code?
Jorge
@OrangeKulture
Sep 05 2017 16:05
nope .. i mean u can have a server running on the frontend only, if the project is small. I do need server side logic, so im using express and mongo
dinesh
@1532j0004kg
Sep 05 2017 16:06
Oh ur great ... I didn't know the js ...
lol...
Jorge
@OrangeKulture
Sep 05 2017 16:06
haha it's all good, we all have to start somewhere .. im still an angular newbie
dinesh
@1532j0004kg
Sep 05 2017 16:07
but u know the node and express and mongo..
Jorge
@OrangeKulture
Sep 05 2017 16:11
yeah.. express not as much as id like . it's really awesome
be back in a few
dinesh
@1532j0004kg
Sep 05 2017 16:12
ok...bye gn..
krckyboy
@krckyboy
Sep 05 2017 16:30
Is there a way to apply Bootstrap grid system through your main CSS file, without tweaking in HTML? It feels messy to touch HTML.
piteto
@piteto
Sep 05 2017 16:31
@krckyboy No. To apply the grid system, you have to use their css class names in your html
krckyboy
@krckyboy
Sep 05 2017 16:32
@piteto Alrighty, thank you.
CamperBot
@camperbot
Sep 05 2017 16:32
krckyboy sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 56 | @piteto |http://www.freecodecamp.com/piteto
Amit Patel
@AmitP88
Sep 05 2017 16:35

hey guys, quick question, for img.src, is it possible to turn this into an array? http://www.williammalone.com/briefs/how-to-draw-image-html5-canvas/

for example, would the following code be valid?

img.src = [
    'images/image1.png',
    'images/image2.png',
    'images/image3.png'
];
just1witness
@just1witness
Sep 05 2017 16:38
Yes, if you used .html() you could change your html images with that. At least I'm pretty sure.
.
@AmitP88
krckyboy
@krckyboy
Sep 05 2017 16:39
Can someone tell me how to get only the Bootstrap v4 Grid, not the full Boostrap?
Amit Patel
@AmitP88
Sep 05 2017 16:39
@just1witness hmmm, well, I'm actually using it to see if I can generate random images in canvas using the drawImage method
just1witness
@just1witness
Sep 05 2017 16:39
I would try it, I bet you could get it to work
Amit Patel
@AmitP88
Sep 05 2017 16:41
@just1witness I'll give it a shot. thanks
CamperBot
@camperbot
Sep 05 2017 16:41
amitp88 sends brownie points to @just1witness :sparkles: :thumbsup: :sparkles:
:cookie: 326 | @just1witness |http://www.freecodecamp.com/just1witness
just1witness
@just1witness
Sep 05 2017 16:42
No problem. I'm an opamist who try all sorts of crazy things, I've discovered a lot of them work!
Lol
Opamist... I mean optimist
Amit Patel
@AmitP88
Sep 05 2017 16:43
@just1witness it didn't work, but maybe I can sort of cheat by making multiple img.src's and nest those in an array lol
Tom
@moT01
Sep 05 2017 16:44
im not sure if you can use . in variables
maybe you want
img {
   src: [img1, img2...]
}
just1witness
@just1witness
Sep 05 2017 16:45
I actually thought that was what you meant, lol. I figured the code you posted was a placeholder example.
Tom
@moT01
Sep 05 2017 16:45
then img.src[0] gives you the first img
Amit Patel
@AmitP88
Sep 05 2017 16:46
ah ok, I'll try that. thanks @moT01 @just1witness !
CamperBot
@camperbot
Sep 05 2017 16:46
amitp88 sends brownie points to @mot01 and @just1witness :sparkles: :thumbsup: :sparkles:
:warning: amitp88 already gave just1witness points
:cookie: 843 | @mot01 |http://www.freecodecamp.com/mot01
just1witness
@just1witness
Sep 05 2017 16:46
I'm on my phone rn and have to go or I would want to see your whole code, this sounds very interesting. I hope someone can help you! 😊
Amit Patel
@AmitP88
Sep 05 2017 16:47
@just1witness thanks bro. I'm actually working on a demo for a mobile game idea that I have. once I get the basic functionality going I'll post it on here :)
CamperBot
@camperbot
Sep 05 2017 16:47
amitp88 sends brownie points to @just1witness :sparkles: :thumbsup: :sparkles:
:warning: amitp88 already gave just1witness points
just1witness
@just1witness
Sep 05 2017 16:49
Nice!
Mike
@MikeJSchorah
Sep 05 2017 16:59
What do you do about HTML regarding WordPress updates?
gexuewei20130126
@gexuewei20130126
Sep 05 2017 17:01
?
Mike
@MikeJSchorah
Sep 05 2017 17:01
@gexuewei20130126 Do you use WordPress?
Christopher McCormack
@cmccormack
Sep 05 2017 17:02
@AmitP88 you could probably do something like the following if you're trying to add multiple images. You'll still need to do something with the drawImage options though:
let images = [
    'images/image1.png',
    'images/image2.png',
    'images/image3.png'
];
images.forEach( function(image){
   let img = new Image();
   img.onload = function () {
       context.drawImage(img, 100, 100, 150, 110, 0, 0, 300, 220);
   }
   img.src = image;
}
Amit Patel
@AmitP88
Sep 05 2017 17:05

@cmccormack I was brainstorming possible workarounds and I came up with this:

    var tileImg = [
        'images/tiles/orbs/physical.png',
        'images/tiles/orbs/thunder.png',
        'images/tiles/orbs/fire.png',
        'images/tiles/orbs/earth.png',
        'images/tiles/orbs/light.png',
        'images/tiles/orbs/water.png',
        'images/tiles/orbs/dark.png',
    ];

    img.src = function () {
        tileImg[Math.floor(Math.random() * 7) + 0];
        };    


    var img = new Image();

    img.onload = function () {

        ctx.drawImage(img, 0, 0);
    }

However, no matter how I set img.src, it seems like if it's anything but an image URL I'll get 'Cannot set property 'src' of undefined'

Mike
@MikeJSchorah
Sep 05 2017 17:05
Does anyone here use WordPress?
Christopher McCormack
@cmccormack
Sep 05 2017 17:07
@AmitP88 img.src is a function in your code
Amit Patel
@AmitP88
Sep 05 2017 17:08
@cmccormack yeah, I know. I also tried setting img.src = tileImg[Math.floor(Math.random() * 7) + 0];
@cmccormack but that didn't work either
Christopher McCormack
@cmccormack
Sep 05 2017 17:08
@AmitP88 one thing that can help is to seperate your logic a bit. Make your random function a unique function just for getting random values:
function randRangeInt(m, n){
  return Math.floor((Math.random() * (n+1-m)) + m)
}

then you can call

tileImg[randRangeInt(0, tileImg.length)]

or however you want to do it

Amit Patel
@AmitP88
Sep 05 2017 17:09
@cmccormack ah I see
Christopher McCormack
@cmccormack
Sep 05 2017 17:10
you can even add that as a method to the prototype of Array if you wanted, even cleaner as you can use this
@AmitP88 img.src should be a string right?
Amit Patel
@AmitP88
Sep 05 2017 17:11
@cmccormack yeah, it should
Christopher McCormack
@cmccormack
Sep 05 2017 17:11
in your code above, make sure you set src after you declare the variable
Amit Patel
@AmitP88
Sep 05 2017 17:15
stuck.png
@cmccormack here's my code so far
Mike
@MikeJSchorah
Sep 05 2017 17:15
I built 5 sites, 3 with Divi. I'm learning how to modify the style.css file for a child theme of the Divi theme.
Christopher McCormack
@cmccormack
Sep 05 2017 17:18
@AmitP88 you're still pointing img.src to a function, so img.src is a function. Don't do that.
Amit Patel
@AmitP88
Sep 05 2017 17:18
@cmccormack oh sorry about that. hang on a sec, let me fix it
Amit Patel
@AmitP88
Sep 05 2017 17:24
stuck.png
@cmccormack ugh, I'm confused.
Christopher McCormack
@cmccormack
Sep 05 2017 17:25

Correction btw:

tileImg[randRangeInt(0, tileImg.length)]

should be

tileImg[randRangeInt(0, tileImg.length-1)]
Mike
@MikeJSchorah
Sep 05 2017 17:25
Amit Patel
@AmitP88
Sep 05 2017 17:26
@cmccormack still getting the same error
@cmccormack I think we overcomplicated this
Christopher McCormack
@cmccormack
Sep 05 2017 17:27
@AmitP88 I don't think we added anything more complicated... what's your code now?
Amit Patel
@AmitP88
Sep 05 2017 17:28
@cmccormack my goal is to be able to use multiple images in img.src somehow when using this code:
var img = new Image();

img.onload = function() {
   ctx.drawImage(img, 0, 0 )
}

img.src = 'images/image.png';
Christopher McCormack
@cmccormack
Sep 05 2017 17:29
@AmitP88 that shouldn't be your goal, your goal should be to draw multiple images, as I said earlier
so add the new image and drawing to a loop over your images
Amit Patel
@AmitP88
Sep 05 2017 17:30
@cmccormack yes, but I want to draw one single random image first to make sure that it's working first, before looping over for the rest of the cells on the grid
Mike
@MikeJSchorah
Sep 05 2017 17:30
I understand that, ok, so if you have custom CSS in this child theme, then updates won't erase changes to CSS, but what about HTML? I just pasted a CSS file from a website that I did from scratch and everything changed to my CSS (menu... see paragraph below, background color). But, there is no content on the page. How do I create content/structure if there is no HTML?
Christopher McCormack
@cmccormack
Sep 05 2017 17:30
@AmitP88 Here - I made you an example for drawing random images while we've been talking:
https://codepen.io/cmccormack/pen/ZJZxJJ
Amit Patel
@AmitP88
Sep 05 2017 17:31
@cmccormack thanks. this makes things a lot clearer. let me see if I can implement this in my code
CamperBot
@camperbot
Sep 05 2017 17:31
amitp88 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1185 | @cmccormack |http://www.freecodecamp.com/cmccormack
Amit Patel
@AmitP88
Sep 05 2017 17:32
@cmccormack I feel like I was hovering around this solution, but I just couldn't get it
Christopher McCormack
@cmccormack
Sep 05 2017 17:33
@AmitP88 Just make sure you look at each line of the example code to see now only what they did but WHY they did it.
Mike
@MikeJSchorah
Sep 05 2017 17:33
Does anyone here know anything about WordPress?
Amit Patel
@AmitP88
Sep 05 2017 17:34
@cmccormack for sure, the logic makes more sense now. my main obstacle was being able to use multiple images using img.src (was having a hard time coming up with a workaround that would work)
Christopher McCormack
@cmccormack
Sep 05 2017 17:34
@MikeJSchorah sorry never touched it
@AmitP88 but you shouldn't even be considering using multiple images with img.src
Instead, consider pushing all the logic for a new image into a function that you can then call from a loop over all your images
Mike
@MikeJSchorah
Sep 05 2017 17:35
@lydatech ?
Christopher McCormack
@cmccormack
Sep 05 2017 17:35
It's var img = new Image(); not var img = new Images(); :)
Amit Patel
@AmitP88
Sep 05 2017 17:35
@cmccormack the thing is, i'm trying to make a 3 match puzzle game using canvas and JS.
Christopher McCormack
@cmccormack
Sep 05 2017 17:36
@AmitP88 yup I remember discussing this weekend - look at my code and see how you can use that to fill your board
Notice how all of the Image code is wrapped in function that can then be reused for whatever you need
Amit Patel
@AmitP88
Sep 05 2017 17:38
@cmccormack for sure. If i'm gonna use this to loop over the entire grid, I'll need to keep things organized into one function when it comes to the images
Christopher McCormack
@cmccormack
Sep 05 2017 17:39
@AmitP88 sure. I updated it a bit more to separate the functionality a bit more, so you can have a pure drawImage function that may or may not use a random image function
Daniel
@Feldbot
Sep 05 2017 17:41
Hi, I'm working on the Random Quote Machine challenge and stuck on trying to figure out the Twitter web intent API. I'm not sure how to pre-populate my tweet with quote text my API is generating. Can anyone help me troubleshoot this? I have a pen here.
Christopher McCormack
@cmccormack
Sep 05 2017 17:44
@Feldbot you should probably be using the &text= parameter
Daniel
@Feldbot
Sep 05 2017 17:44
@MikeJSchorah I have used WordPress a little... What are you wondering about?
@cmccormack Do you mean to build my URL with that parameter hard-coded in there? I'm not sure how to pass whatever URL I build back to the Twitter intent so it can see what I've constructed.
Christopher McCormack
@cmccormack
Sep 05 2017 17:46
@Feldbot I think you may be making it more difficult than you need, something like the following is plenty:
$("#btn-tweet").attr("href", twitter_url + quote + ... ), convert to vanilla as necessary
Parameters are usually built as object, are you sure you're following the docs properly?
Daniel
@Feldbot
Sep 05 2017 17:49
@cmccormack Yes, I'm sure I am making it more difficult, lol. No, I'm not sure exactly where I need to start with the docs. I got sucked in to all these Twitter docs that I don't quite understand and it does seem I've made a plate of code spaghetti.
Jorge
@OrangeKulture
Sep 05 2017 17:49
@MikeJSchorah wordpress kinda sucks for that very same reason
Mike
@MikeJSchorah
Sep 05 2017 17:49
@Feldbot I built 5 sites, 3 with Divi. I'm learning how to modify the style.css file for a child theme of the Divi theme.
@OrangeKulture Which reason?
Jorge
@OrangeKulture
Sep 05 2017 17:50
that you can have conflicting css rules, depending on the theme
Christopher McCormack
@cmccormack
Sep 05 2017 17:50

@Feldbot https://dev.twitter.com/web/intents

<script type="text/javascript" async src="https://platform.twitter.com/widgets.js"></script>
<a href="https://twitter.com/intent/tweet?in_reply_to=463440424141459456">Reply</a>
<a href="https://twitter.com/intent/retweet?tweet_id=463440424141459456">Retweet</a>
<a href="https://twitter.com/intent/like?tweet_id=463440424141459456">Like</a>

This part of the documentation is really all you need to complete the web intent. I only used the first two lines in my project

More specifically, I just used the following URL and concatenated the quote:
"https://twitter.com/intent/tweet?related=freecodecamp&text="
Daniel
@Feldbot
Sep 05 2017 17:52
@cmccormack With those snippets, don't I still need to build a new URL to pass in to the intent somehow?
Mike
@MikeJSchorah
Sep 05 2017 17:53
@OrangeKulture I'm only using 2 themes... Divi and Avada. I've been using Divi exclusively since I found out it would be cheaper for me
Christopher McCormack
@cmccormack
Sep 05 2017 17:53
@Feldbot not unless you want to make it harder on yourself
@Feldbot the widget.js will take care of making the new window with all the chrome, just create an href with the text above and your quote appended and it should work fine
Daniel
@Feldbot
Sep 05 2017 17:55
@cmccormack So is this one the way to go: $("#btn-tweet").attr("href", twitter_url + quote + ... )
but I'd still need to create variables for twitter_url and quote?
Jorge
@OrangeKulture
Sep 05 2017 17:55
@MikeJSchorah when i worked with WP i always tried to find which rules where affecting which element with chrome dev tools
Christopher McCormack
@cmccormack
Sep 05 2017 17:56
@Feldbot yeah if you want, mine is posted up above if you want to use it
you can inline the url if you like as well
I don't recommend doing that though, better to declare URLs at the top where it's easy to see and change
Daniel
@Feldbot
Sep 05 2017 17:56
@cmccormack Okay, thanks Chris. I'll try that, back in a bit...
CamperBot
@camperbot
Sep 05 2017 17:56
feldbot sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1186 | @cmccormack |http://www.freecodecamp.com/cmccormack
Mike
@MikeJSchorah
Sep 05 2017 17:57
@OrangeKulture I understand that, ok, so if you have custom CSS in this child theme, then updates won't erase changes to CSS, but what about HTML? I just pasted a CSS file from a website that I did from scratch and everything changed to my CSS (menu... see paragraph below, background color). But, there is no content on the page. How do I create content/structure if there is no HTML?
Christopher McCormack
@cmccormack
Sep 05 2017 17:57
@Feldbot np gl
piteto
@piteto
Sep 05 2017 17:57

@Feldbot If you want to use the official twitter button you just need a div in your HTML:

<div id="tweet"></div>

And this line in your JS:

twttr.widgets.createShareButton("/", document.getElementById('tweet'), {size: "large", text: $('#quote-content').text()});
I hadn't seen that URL before when I did this, so maybe it's a slightly easier route since you already have that twitter icon set up in an <a> tag
Christopher McCormack
@cmccormack
Sep 05 2017 17:58
@piteto :thumbsup: that's cool
piteto
@piteto
Sep 05 2017 17:58
I'm kicking myself for not seeing that URL @cmccormack took me an hour to figure that code out!
Jorge
@OrangeKulture
Sep 05 2017 17:59
@MikeJSchorah u have to create a new page and add the html .. im not exactly sure what you are trying to do. Are you trying to set new CSS rules for an existing page?
Daniel
@Feldbot
Sep 05 2017 17:59
@piteto I thought the text: key would only accept actual text, I didn't know you could put more javascript in there.
piteto
@piteto
Sep 05 2017 18:00
Yeah, it will take JS code! You could combine the quote + author in a variable @Feldbot and use that instead - probably a little better
Mike
@MikeJSchorah
Sep 05 2017 18:01
@OrangeKulture
So the HTML (content/structure) will/could change upon theme update if I don't know PHP?
Or will just adding menus, adding Favicon, making the Home Page my front page, etc, etc. (PHP stuff) change upon theme update?
Christopher McCormack
@cmccormack
Sep 05 2017 18:01
@Feldbot that's an expression, it returns actual text
Jorge
@OrangeKulture
Sep 05 2017 18:10
@MikeJSchorah that depends a lot on the theme .. but the html should not change. Updates on wordpress are usually targeted to add-ons and plugins
you can have a site look completely custom, even if you have wordpress .. you just need to know the file structure and where to find each piece of code
Mike
@MikeJSchorah
Sep 05 2017 18:12
@OrangeKulture I'm a little confused as to why you need a child theme for CSS/PHP... why doesn't HTML get affected?
Daniel
@Feldbot
Sep 05 2017 18:13
@piteto It doesn't seem to render the Twitter button for some reason...
Amit Patel
@AmitP88
Sep 05 2017 18:14
@cmccormack hey Chris, I was able to successfully implement your solution into my project (although I didn't separate functionality as much - I wanted to keep it short). However, I'm facing some problems getting my for loop to work in order to generate random images in each cell of the grid, rather than just one.
piteto
@piteto
Sep 05 2017 18:14
@Feldbot Put the code inside your success callback - that way it runs after you get the quote text in your HTML
Amit Patel
@AmitP88
Sep 05 2017 18:14
populate.png
Christopher McCormack
@cmccormack
Sep 05 2017 18:14
@AmitP88 keeping it short is usually much less of a priority than making it functional
@AmitP88 randomTile should not be declared every time within the loop, move that block to the global scope
Jorge
@OrangeKulture
Sep 05 2017 18:16
@MikeJSchorah wordpress themes are a pain in the ass, if u ask me .. specially if u dont know much php. Unfortunately, it's hard to help out with the exact issue, i would either contact the theme developers (it it's a paid theme) or try to google it out
Christopher McCormack
@cmccormack
Sep 05 2017 18:16
@AmitP88 tileImgs should also not be declared within your loop
Amit Patel
@AmitP88
Sep 05 2017 18:17
@cmccormack I don't know why this isn't working, as I'm using i and j for the coordinates for the drawImage method (since i is used in my for loop for canvas.width and j is used in the loop for canvas.height.
Daniel
@Feldbot
Sep 05 2017 18:18
@piteto Aha! That works... Do you know a way that I can use this on the font awesome icon rather than having it generate the button?
piteto
@piteto
Sep 05 2017 18:18
@Feldbot Use the method that @cmccormack recommended if you don't want to use the official tweet button
That twitter widget code is for the official tweet button
Christopher McCormack
@cmccormack
Sep 05 2017 18:19
@AmitP88 put some console.log statements in there, make sure you log what your values are for i, j, canvas.width, img.src, etc...
Ivan Ngundela
@ingundela
Sep 05 2017 18:19
hello everyone...may you please advice on the best way to have my project tested on my Mac? like having local Webserver to the my website before I hand it ove to the client?
Amit Patel
@AmitP88
Sep 05 2017 18:20
@cmccormack ah ok, will do. thanks
CamperBot
@camperbot
Sep 05 2017 18:20
amitp88 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: amitp88 already gave cmccormack points
Christopher McCormack
@cmccormack
Sep 05 2017 18:20
@AmitP88 it's bad practice to not declare your variables in the for loop as well, I would recommend using let i=0... and let j=0;... in your loops
Daniel
@Feldbot
Sep 05 2017 18:20
@pieto Okay, I'll give @cmccormack's solution a try too. Thanks much for the help!
CamperBot
@camperbot
Sep 05 2017 18:20
feldbot sends brownie points to @pieto and @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: @pieto's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
:warning: feldbot already gave cmccormack points
Christopher McCormack
@cmccormack
Sep 05 2017 18:20
@AmitP88 also make sure your files are actually in the right directory :D
Amit Patel
@AmitP88
Sep 05 2017 18:21
@cmccormack I see. I always used to see for loops just using i=0 or w/e without declaration with var or let. guess I'll have to get into that habit
Christopher McCormack
@cmccormack
Sep 05 2017 18:22
Where do you see that? In the FCC exercises I'm pretty sure they stated you should definitely do that, and in most code it's declared
Amit Patel
@AmitP88
Sep 05 2017 18:22
@cmccormack I think I've seen it in code examples on stackoverflow or something
Mike
@MikeJSchorah
Sep 05 2017 18:23
@OrangeKulture So if I don't know PHP, then my HTML is f'ked?
Jorge
@OrangeKulture
Sep 05 2017 18:24
no .. not at all
Mike
@MikeJSchorah
Sep 05 2017 18:27
@OrangeKulture No no no, haha. I'm not saying that I updated a theme and it was modified. I'm saying IF IF I update a theme, will the HTML (structure/content) be modified? In other words, I'm a little confused as to why you need a child theme for CSS/PHP... why doesn't HTML get affected?
Trommelochse
@Trommelochse
Sep 05 2017 18:28
@AmitP88 with "use strict" the code wouldn't even run, to my knowledge
Amit Patel
@AmitP88
Sep 05 2017 18:28
@Trommelochse oh yeah, I forgot about use strict
@Trommelochse I'll have to implement that. thanks
CamperBot
@camperbot
Sep 05 2017 18:28
amitp88 sends brownie points to @trommelochse :sparkles: :thumbsup: :sparkles:
:cookie: 327 | @trommelochse |http://www.freecodecamp.com/trommelochse
Trommelochse
@Trommelochse
Sep 05 2017 18:30
@AmitP88 since I started using Lint, I would never want to write code without anymore
gives you warnings about stuff, that's just a bit 'incorrect', and after you fixed your mistake for the 3rd time, you will never do it again, because now you've learned it
Amit Patel
@AmitP88
Sep 05 2017 18:36
@Trommelochse good to know, I'll have to implement it in my project :)
@Trommelochse thanks
CamperBot
@camperbot
Sep 05 2017 18:36
amitp88 sends brownie points to @trommelochse :sparkles: :thumbsup: :sparkles:
:warning: amitp88 already gave trommelochse points
Christopher McCormack
@cmccormack
Sep 05 2017 18:38
@Feldbot https://codepen.io/cmccormack/pen/LjvmKZ I was meaning to make a sample for this anyway, hope it helps
Marat
@Marat89bluolyu
Sep 05 2017 18:44
hi all, how to comapre object values in arr? whats wrong in my code:
var test = [{
   product: 'Canon EOS 1300D Kit 18-55mm DC',
   price: 22999,
   destination: 'Samara',
   count: 1
},

{
   product: 'Canon EOS 1200D Kit 18-55mm DC',
   price: 15000,
   destination: 'Moscow',
   count: 1
},

{
   product: 'Canon EOS 1300D Kit 18-55mm DC',
   price: 22999,
   destination: 'Samara',
   count: 2
}
]

function getObjReport(test) {
         for (var i = 0; i < test.length; i++) {
             for (var j = 1; j < test.length; j++) {
                     if (test[j].destination != test[i].destination){
                         console.log(test[i].destination);
                         console.log(test[j].destination);
                     } else {
                         console.log(test[i].destination)
                     }
                 }
             }
        }

getObjReport(test);
Christopher McCormack
@cmccormack
Sep 05 2017 18:46
@Marat89bluolyu you probably want to use var j = i + 1 in your second loop
and you may need to do test.length-1 in the first loop as well
Marat
@Marat89bluolyu
Sep 05 2017 18:48
need to get output
```
// Moscow:
// Canon EOS 1300D Kit 18-55mm DC ', 22999 , 1 . = delivery 519 .
// Samara:
//
Canon EOS 1200D Kit 18-55mm DC ', 22999 , 2 . = delivery 1108 .
// Canon EOS 1200D Kit 18-55mm DC ', 22999 , 2 . = delivery 1108.
//
Canon EOS 1200D Kit 18-55mm DC ', 22999 , 2 . = delivery 1108.
// Total: 3843 .
Daniel
@Feldbot
Sep 05 2017 18:49
@cmccormack That is a nice example Chris, thanks. I'm still trying to understand your previous mention of using$("#btn-tweet").attr("href", twitter_url + quote + ... )
I tried reconstructing this but am not having any luck.
CamperBot
@camperbot
Sep 05 2017 18:49
feldbot sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: feldbot already gave cmccormack points
Marat
@Marat89bluolyu
Sep 05 2017 18:50
@cmccormack test.lenght-1 for j?
Christopher McCormack
@cmccormack
Sep 05 2017 18:50
@Feldbot that's with jQuery, have you used it? I intentionally avoided it in my example but the code you posted was from my original quote api
@Marat89bluolyu for i - you don't want to compare the last element with anything outside of your array :)
or with anything at all as it's already been one by the previous iterations

@Feldbot

$("#btn-tweet").attr("href", twitter_url + quote + ... )

is equivalent to

document.getElementById('btn-tweet').href = 'https://twitter.com/intent/tweet?text=' + quote + ...

where ... is anything else you want to add like author or whatever.

Marat
@Marat89bluolyu
Sep 05 2017 18:57
@cmccormack yeah but how to filter it?
I need output test.detination 1 time if i have several identical values
Christopher McCormack
@cmccormack
Sep 05 2017 18:58
@Marat89bluolyu Can you describe what your function is supposed to do?
Marat
@Marat89bluolyu
Sep 05 2017 19:02
@cmccormack this app must output deliveries reports. Function receive some array with objects and after processing makes report:
// Moscow:
// Canon EOS 1300D Kit 18-55mm DC ',price= 22999 , quantity=1 . = delivery 519 .
// Samara:
// Canon EOS 1200D Kit 18-55mm DC ', price=22999 ,quantity=1 2 . = delivery 1108 .
// Canon EOS 1200D Kit 18-55mm DC ', price=22999 ,quantity=1 2 . = delivery 1108.
// Canon EOS 1200D Kit 18-55mm DC ',price= 22999 , quantity=12 . = delivery 1108.
// Total: 3843 .
Christopher McCormack
@cmccormack
Sep 05 2017 19:06

@Marat89bluolyu ah. So what you can do is create a new object that you store these product objects in. As you iterate your array, you can do something like

newObj[test[i].destination].push(test[i])

You should check if the destination exists prior to this by doing something like

if (!newObj.hasOwnProperty(test[i].destination){ 
   newObj[test[i].destination] = [ test[i] ]
} else {
   newObj[test[i].destination].push(test[i])
}

This way you don't even have to compare objects - if your new object doesn't have a property for that destination

Then you can return and parse the newObj as needed to display the results
The code above may have bugs, you'll have to play with it
Marat
@Marat89bluolyu
Sep 05 2017 19:10
@cmccormack Thank you very much, I did not even imagine it
Christopher McCormack
@cmccormack
Sep 05 2017 19:11
@Marat89bluolyu :thumbsup:
Marat
@Marat89bluolyu
Sep 05 2017 19:11
@cmccormack thanks)
CamperBot
@camperbot
Sep 05 2017 19:11
marat89bluolyu sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1187 | @cmccormack |http://www.freecodecamp.com/cmccormack
Daniel
@Feldbot
Sep 05 2017 19:15
@cmccormack Yeah, I'm using jQuery with my modified URL. Can you check out my pen again? I'm still not sure what I am doing.
Christopher McCormack
@cmccormack
Sep 05 2017 19:26
@Feldbot you're adding the href to your icon, not the anchor tag
Ross Nelson
@rdnelson2010
Sep 05 2017 19:36
hello everyone! is the freecodecamp website down today?
Andrew Knox
@iamknox
Sep 05 2017 19:37
Looks like it is @rdnelson2010
Ross Nelson
@rdnelson2010
Sep 05 2017 19:38
@iamknox yeah cause is tried logging in on two separate computers and it keeps saying the same thing.
just1witness
@just1witness
Sep 05 2017 19:47
Down for me
Daniel
@Feldbot
Sep 05 2017 19:49
@cmccormack Ha ha! Silly me. Thank you Chris, you are the man :-)
CamperBot
@camperbot
Sep 05 2017 19:49
feldbot sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:star2: 1189 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Sep 05 2017 19:51
@Feldbot np
Ross Scarborough
@SourceHorse
Sep 05 2017 20:11
Finished the twitch app for FCC. Critique is welcome.
Trommelochse
@Trommelochse
Sep 05 2017 20:30
@SourceHorse very nice visually, I am surprised you wrote the whole thing in Vanilla JS - but very nice, man really like it :)
Mike
@MikeJSchorah
Sep 05 2017 20:38
@OrangeKulture So the content/structure is all done in the child theme and it comes with CSS and PHP files that can be edited?
So when I activate a child theme, I'm actually using the child theme?
A child theme isn't the CSS/PHP files only. It is EVERYTHING that I'm looking at on my dashboard?
Jorge
@OrangeKulture
Sep 05 2017 21:24
@MikeJSchorah yes.. basically the whole theme is php code. you can build on top of that or you can modify it, if u know how to and if the theme permits, i guess ..
im not really sure tho, like i said, i havent worked all that much with wordpress .. dont really like it that much
Mike
@MikeJSchorah
Sep 05 2017 21:25
No one does. But, I guess it's a way to get experience working with clients
Sue
@coding-sue-true
Sep 05 2017 21:47
Hi everyone
does anyone knows the best room to ask about some git bash queries?
Mike
@MikeJSchorah
Sep 05 2017 21:48
What would you like to know?
It seems best to ask the FreeCodeCamp room for alot of stuff. They're always active
Sue
@coding-sue-true
Sep 05 2017 21:49
I'm currently taking a coursera specialization, and I'm now on one exercise where I have to write some scripts on my package.json
using the git bash, but it's giving me error
okay, will try my luck there
thanks!
Mike
@MikeJSchorah
Sep 05 2017 21:50
What's the error? @coding-sue-true
Eric Hasegawa
@EricHasegawa
Sep 05 2017 22:22
I'm currently trying to center the text portion of the logos for the social media links I have on this page. Can anyone help? Here's my code https://codepen.io/erichasegawa/pen/YxMJOa
korzo
@korzo
Sep 05 2017 22:26
@EricHasegawa put <i> for icon inside <a> and add text-align: center to <a>
Eric Hasegawa
@EricHasegawa
Sep 05 2017 22:29
@korzo I tried that like this but it didn't work
korzo
@korzo
Sep 05 2017 22:34
@EricHasegawa https://codepen.io/korzo/pen/brJmXX?editors=1100
I added changes at the end of CSS
Eric Hasegawa
@EricHasegawa
Sep 05 2017 22:36
@korzo Could you explain the thought process behind the changes?
@korzo Also if you have time, I'm trying to make the colored boxes that act as a background for the icons less tall and I'm having trouble targeting them
korzo
@korzo
Sep 05 2017 22:38
before has position: absolute, so it doesn't depend on document flow.
Put it in the middle (left: 50%) and shift it back for half of the width of element (translateX(-50%))
you can see how I'm targeting them .socialMedias a . No need for duplicate code
Eric Hasegawa
@EricHasegawa
Sep 05 2017 22:40
@korzo Yeah that makes sense, do you have time for the other question? If not no worries
korzo
@korzo
Sep 05 2017 22:41
@EricHasegawa Sure
Eric Hasegawa
@EricHasegawa
Sep 05 2017 22:42
I'm trying to make the colored boxes that act as a background for the icons less tall and I'm having trouble targeting them
korzo
@korzo
Sep 05 2017 22:43
@EricHasegawa you can taget them as .socialMedias a
Eric Hasegawa
@EricHasegawa
Sep 05 2017 22:44
@korzo But when I set a height and width to the .socialMedias a nothing changes
korzo
@korzo
Sep 05 2017 22:48
@EricHasegawa because you have padding 10vh
@EricHasegawa You made it very complicated
@EricHasegawa using <i> as an icon you can remove 90% of your css
Eric Hasegawa
@EricHasegawa
Sep 05 2017 22:52
@korzo I'm importing most of the code from my old personal portfolio which was made when I was very new to coding
So it's kind of tough
korzo
@korzo
Sep 05 2017 22:52
@EricHasegawa Isn't easier start over?
Eric Hasegawa
@EricHasegawa
Sep 05 2017 22:52
But if you have time for one last question, how can I move the text in the boxes lower down so it's not so close to the top? https://codepen.io/erichasegawa/pen/YxMJOa
korzo
@korzo
Sep 05 2017 22:55
@EricHasegawa Add bottom: 0; to .socialMedias a:before
Eric Hasegawa
@EricHasegawa
Sep 05 2017 22:55
@korzo I guess it would have been better to do that
That works better, but is there an easy way to centre it vertically?
korzo
@korzo
Sep 05 2017 22:58
@EricHasegawa Yes. The same as horizontally :)
top: 50% and change translate to translate(-50%, -50%)
Eric Hasegawa
@EricHasegawa
Sep 05 2017 23:00
@korzo Oh excellent that's perfect
Thank you so much for all the help I really appreciate it
@korzo thanks
CamperBot
@camperbot
Sep 05 2017 23:00
erichasegawa sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
api offline
korzo
@korzo
Sep 05 2017 23:01
@EricHasegawa Glad to help
Eric Hasegawa
@EricHasegawa
Sep 05 2017 23:01
I think I'm going to study css in some more detail because I'm not familiar with all the concepts on the page now
Thanks though, see you around
iso
@iso1048
Sep 05 2017 23:02
Hi. does anyone know what I could search to enable a user to download a .txt file of specific html content on the page?
Jan Shah
@JanShah
Sep 05 2017 23:04
is the script creating the text file?
@gothamknight
iso
@iso1048
Sep 05 2017 23:09
@JanShah not really. The user inputs some data, and im using js to provide an output based on that input, which is displayed on the html. So I could obtain the output from the script i guess....
aRtoo
@artoodeeto
Sep 05 2017 23:20
hey guys i was logout from my fcc account. what happend?
iso
@iso1048
Sep 05 2017 23:24
@artoodeeto i think it is not working for everyone
mstellaluna
@mstellaluna
Sep 05 2017 23:25
@artoodeeto
aRtoo
@artoodeeto
Sep 05 2017 23:25
yup. checked them on twitter