These are chat archives for FreeCodeCamp/HelpFrontEnd

23rd
Apr 2018
pal-crystal
@pal-crystal
Apr 23 2018 00:08
good night all
anthonygallina1
@anthonygallina1
Apr 23 2018 00:10
~Rest well
zootechdrum
@zootechdrum
Apr 23 2018 04:04
hey guys I know its something stupid but why the hell is my first if statement not passing

function translatePigLatin(str) {

  var newStr = str.toLowerCase(); 
  var holdLetter = [];

  var vowels = ["a","e","i","o","u"];

  holdLetter.push(newStr.substr(0,1));

  for(var i = 0; i< vowels.length; i++){
    if(holdLetter.indexOf(vowels[i]) < 1){
      var sliced = newStr.slice(1,newStr.length);
        holdLetter.unshift(sliced);
        holdLetter.push("ay");
     return holdLetter.join("");
    }else{
     return newStr + "way";
    }
  }
}

translatePigLatin("ailifornia");
i should say why i s my first if statement passing everything lol
Brad
@bradtaniguchi
Apr 23 2018 04:09
@zootechdrum I'm not sure what this code does, but the line newStr.substr(0,1)returns the first letter of the string. So later when you perform holdLetter.indexOf(vowels[i]) < 1 its true, since holdLetter's index is always 0 (since its 1 letter at index 0) or -1 (if the value isn't "matched")
zootechdrum
@zootechdrum
Apr 23 2018 04:09
@bradtaniguchi i just caught that
thanks brad
Brad
@bradtaniguchi
Apr 23 2018 04:09
np :D
ijhar
@ijhar8
Apr 23 2018 06:16
https://codepen.io/ijhar8/pen/YaMbOx . why breakTimer is not working ..?
clearInterval is also not works.. plz help
mustimuu
@mustimuu
Apr 23 2018 06:53
Hello can someone help me?
I have this div with a picture in it. i want it to take 100% of the width, of the site
Dhaval Vira
@dhavalveera
Apr 23 2018 06:54
It is for background
ijhar
@ijhar8
Apr 23 2018 06:54
@mustimuu link of your "this" ...?
@ijhar8
mustimuu
@mustimuu
Apr 23 2018 07:10
Can someone help me ?
Dhaval Vira
@dhavalveera
Apr 23 2018 07:11
for what
mustimuu
@mustimuu
Apr 23 2018 07:12
@mustimuu
Hello can someone help me?
I have this div with a picture in it. i want it to take 100% of the width, of the site
coderNewby
@coderNewby
Apr 23 2018 07:12
@darrenfj another Q in pm thanks in advance
CamperBot
@camperbot
Apr 23 2018 07:12
codernewby sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2471 | @darrenfj |http://www.freecodecamp.org/darrenfj
Dhaval Vira
@dhavalveera
Apr 23 2018 07:13
@mustimuu it is for Back-Ground Image ?
mustimuu
@mustimuu
Apr 23 2018 07:13
The whole div i want to take 100% of the body
The part under "Forside"
gerome0123
@gerome0123
Apr 23 2018 07:56
any suggestion if i have more than 10 entries in one page??
Dhaval Vira
@dhavalveera
Apr 23 2018 07:56
what do you mean for that ?
gerome0123
@gerome0123
Apr 23 2018 07:57
i mean any suggestion to make pleasant in the eye
even thou so many entries
Roshith R
@Roshith93
Apr 23 2018 08:54
Help Needed!!
Dhaval Vira
@dhavalveera
Apr 23 2018 08:55
Say
Roshith R
@Roshith93
Apr 23 2018 08:57
I have 4 select options in my pages. So if I choose any of the select options, i need go get the id of which select option is selected.
using jquery
Markus Kiili
@Masd925
Apr 23 2018 09:02
@Roshith93 One way is to use options and selectedIndex properties of the selectElement. https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement
mustimuu
@mustimuu
Apr 23 2018 09:02
Hello guys
I can't see my widget in my backend wordpress
Any suggestions?
Mohit Garg
@mohitgarg
Apr 23 2018 10:52
Hey guys
Can anyone help me with the CSS?
Dhaval Vira
@dhavalveera
Apr 23 2018 11:16
Yes say @mohitgarg
Kingsley
@Kingwindie
Apr 23 2018 11:21
for (i = 0; i < 6; i++) {
    var tableFooter = document.createElement("tfoot");
    tableFooter.style.backgroundColor = "gray";
    tableFooter.style.height = "35px";
    tableFooter.style.textAlign = "center";
    tableFooter.textContent = "footer";
    table.appendChild(tableFooter);
}
how can i make the footer go across the screen horizontally instead of vertically
Stephen James
@sjames1958gm
Apr 23 2018 11:45
@Kingwindie You will probably need to make the elements inline or inline-block to get horizontal behavior
Kingsley
@Kingwindie
Apr 23 2018 11:46
@sjames1958gm i tried that it just moves it to the top next to the table head and everything is squished together
there's probably a flaw in the rest of my code i haven't figured out
var table = document.createElement("table");
// table.style.backgroundColor = "darkblue";
var columns = 6;




const images = ["/images/dog.jpg", "/images/dragon.jpg", "/images/horse.jpg", "/images/monkey.jpg", "/images/ox.jpg", "/images/pig.jpg", "/images/rabbit.jpg", "/images/ram.jpg", "/images/rat.jpg", "/images/rooster.jpg", "/images/snake.jpg", "/images/tiger.jpg"];








for (var i = 0; i < columns; i++) {
    /**table header */
    var tableHeader = document.createElement("th");
    tableHeader.style.width = "250px";
    tableHeader.style.height = "35px";
    tableHeader.style.lineHeight = "35px";
    tableHeader.style.borderStyle = "solid";
    tableHeader.style.borderColor = "black";
    tableHeader.style.backgroundColor = "red";
    tableHeader.style.borderWidth = "2px";
    tableHeader.style.color = "white ";
    tableHeader.style.textAlign = "center";
    tableHeader.textContent = "names";
    table.appendChild(tableHeader);


}




/**table body */
var tableBody = document.createElement("tbody");
table.appendChild(tableBody);

for (i = 0; i < 6; i++) {


    /**table data,inserts into table body */
    var tableData = document.createElement("td");
    var thisImg = document.createElement("img");
    thisImg.src = images[i];
    tableData.style.height = "250px";
    // tableData.style.width = "auto";
    tableData.style.lineHeight = "35px";
    tableData.style.borderStyle = "solid";
    tableData.style.backgroundColor = "purple";
    tableData.style.borderWidth = "2px";
    tableData.style.color = "white ";
    tableData.style.textAlign = "center";
    tableData.innerHTML = "<p>Paragro</p>";
    tableData.appendChild(thisImg);
    table.appendChild(tableData);
    // tableBody.appendChild(tableData);
}




for (i = 0; i < 6; i++) {


    /**table data,inserts into table body */
    var tableData = document.createElement("td");
    var thisImg = document.createElement("img");
    thisImg.src = images[i];
    tableData.style.height = "250px";

    tableData.style.lineHeight = "35px";
    tableData.style.borderStyle = "solid";
    tableData.style.backgroundColor = "purple";
    tableData.style.borderWidth = "2px";
    tableData.style.color = "white ";
    tableData.style.textAlign = "center";
    tableData.innerHTML = "<p>Paragro</p>";
    /*** */
    var tableFooter = document.createElement("tfoot");
    tableFooter.style.backgroundColor = "gray";
    tableFooter.style.height = "35px";
    tableFooter.style.textAlign = "center";
    tableFooter.textContent = "footer";
    table.appendChild(tableFooter);
    tableData.appendChild(thisImg);
    tableBody.appendChild(tableData);

}



// document.body.appendChild(rowOne);
document.body.append(table);
Stephen James
@sjames1958gm
Apr 23 2018 11:50
@Kingwindie Should you have table rows before table data?
If not shouldn't you append your tableData to your table body not your table directly?
Kingsley
@Kingwindie
Apr 23 2018 11:52
wait,i'm confused
the table data is appended to the table body
Stephen James
@sjames1958gm
Apr 23 2018 12:06
table.appendChild(tableData);
Kingsley
@Kingwindie
Apr 23 2018 12:10
?? is that the wrong way or the right way to do it?
mustimuu
@mustimuu
Apr 23 2018 12:10
Can someone help me?
I can see my fidget field is registrered in the wordpress backend
But i cannot see the widget
Stephen James
@sjames1958gm
Apr 23 2018 12:12
@Kingwindie Shouldn't you append them to the tableBody element to get them inside that
Hierarchy
table
   tableBody
      tableData
mustimuu
@mustimuu
Apr 23 2018 12:13
Can someone help me with a small knowledge in PHP?
Kingsley
@Kingwindie
Apr 23 2018 12:15
@sjames1958gm hang on let me look at my code again
Kingsley
@Kingwindie
Apr 23 2018 12:29

if i do that for both table bodies it places all the images in a single block,which is not what i want,i have 12 images and i want to display 6 at the top and six below it,now each image should have a name at the top and a year below it,so if i do

table
     tableBody
           tableData

it will mess up the structure of six images at the top and six below @sjames1958gm

this is frustrating
mustimuu
@mustimuu
Apr 23 2018 12:34
my god i need some help
Stephen James
@sjames1958gm
Apr 23 2018 12:38
@Kingwindie Do you need table rows?
table
     tableBody
            tableRow
               tableData
            tableRow
               tableData
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tbody
This page indicates that table rows go inside table body
zootechdrum
@zootechdrum
Apr 23 2018 15:37
hey good morning
trying to use regex but it dosent seem to activate
function translatePigLatin(str) {

  var vowels = ["a","e","i","o","u"];
  var matched = /^[cbdfghjklmnpqrstvwxyz]{1,}]/i;

  var matched_Arr  = str.match(matched);

  return matched_Arr;
}

translatePigLatin("consonant");
right now its in all white text or in this case all purple
I am sure i am missing a slashh somewhere lol
zootechdrum
@zootechdrum
Apr 23 2018 15:46
more clearly i am returning null so its not matching anything maybe something else is wrog
Elia
@elia-russad
Apr 23 2018 15:46
what are u trying to match?
zootechdrum
@zootechdrum
Apr 23 2018 15:47
@elia-russad non vowels
so consonants
matches on the website but dosent on freecodecamp
using this website
Elia
@elia-russad
Apr 23 2018 15:49
well this ^[cbdfghjklmnpqrstvwxyz]{1,}] selects nothing
so u get null
zootechdrum
@zootechdrum
Apr 23 2018 15:56
@elia-russad it dosent select c in consonant
??
Elia
@elia-russad
Apr 23 2018 15:57
nope
use this tester https://regex101.com/
select js on the left bar
zootechdrum
@zootechdrum
Apr 23 2018 15:58
did what you said found one match
found the letter c
i pasted this
^[cbdfghjklmnpqrstvwxyz]{1,}
matthewlee07
@matthewlee07
Apr 23 2018 15:59
hi, I'm looking for help if anyone is available. I think it's just event binding, but I'm not sure if it's more
Elia
@elia-russad
Apr 23 2018 16:00
@zootechdrum yeah it's different from what's in your code
/^[cbdfghjklmnpqrstvwxyz]{1,}]/i there's one extra bracket
zootechdrum
@zootechdrum
Apr 23 2018 16:01
@elia-russad damn i t
just tried it
it worked lol
@elia-russad thanks man!!!
CamperBot
@camperbot
Apr 23 2018 16:01
zootechdrum sends brownie points to @elia-russad :sparkles: :thumbsup: :sparkles:
api offline
matthewlee07
@matthewlee07
Apr 23 2018 16:03
@elia-russad would you be able to take a look at my question too please?
shameem fairooz
@sfshameem5
Apr 23 2018 16:06
Guys, I'm currently in the JavaScript Calculator Project.
I've completed the UI, but not so sure on how to implement the code.
Any suggestions ?
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 16:22
Use a string maybe to store the, numbera and signals and then use eval maybe was my approach
Cliff Galas
@Sn0wm8n
Apr 23 2018 16:28
What’s up people
shameem fairooz
@sfshameem5
Apr 23 2018 16:30
@tiagocorreiaalmeida You saved me a lot of time. I was look for something like `eval() Thank You !!!
CamperBot
@camperbot
Apr 23 2018 16:30
sfshameem5 sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 524 | @tiagocorreiaalmeida |http://www.freecodecamp.org/tiagocorreiaalmeida
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 16:32
there's one or two issues with eval one of them is that it runsscrips
either way I dont see you using it any other project
shameem fairooz
@sfshameem5
Apr 23 2018 16:32
@tiagocorreiaalmeida Can you explain it more further ?
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 16:33
eval(alert("hi"));
if you run this
it will work like you called alert alone, so it means it can run scripts passed by other users if you eval for example an input field
shameem fairooz
@sfshameem5
Apr 23 2018 16:36
@tiagocorreiaalmeida I'll get the input, as a string, and evaluate using eval(). If I get I stuck, I'll ping you. Is that alright ?
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 16:36
if im around sure
shameem fairooz
@sfshameem5
Apr 23 2018 16:37
@tiagocorreiaalmeida Okay :)
Tiago Correia
@tiagocorreiaalmeida
Apr 23 2018 16:37
the only thing that im trying to say is to avoid using eval, in this situation tis ok, but look at what I sent you im using eval on the user input and as you can see it runs the script
other kind of scripts could cause some damage
shameem fairooz
@sfshameem5
Apr 23 2018 16:38
@tiagocorreiaalmeida On this situation, It would okay on math calculations right ?
@tiagocorreiaalmeida I didn't get what you said earlier. Not enough experience using `eval() to understand that.
Lallo Vigil
@lalov1
Apr 23 2018 16:45
I'm trying to include the Materialize with my React project, but I can't get the JS to work for Materialize. Would someone let me know if I'm doing it correctly? https://codepen.io/lalov1/pen/97756811476267a589a730dc15f881a1
Eric Weiss
@eweiss17
Apr 23 2018 16:47
I believe the older versions of materialize are dependent on jquery
Kaz Baig
@kbaig
Apr 23 2018 16:47
@lalov1 also, Uncaught ReferenceError: options is not defined
on line 14
Lallo Vigil
@lalov1
Apr 23 2018 16:50
@kbaig I do see that, but I don't see why it isn't working
@eweiss17 I tried including jQuery and it still doesn't work.
Kaz Baig
@kbaig
Apr 23 2018 16:50
@lalov1 You never defined a variable called options
Lallo Vigil
@lalov1
Apr 23 2018 16:51
@eweiss17 Nevermind I had the scripts out of order. Thank you!
CamperBot
@camperbot
Apr 23 2018 16:51
lalov1 sends brownie points to @eweiss17 :sparkles: :thumbsup: :sparkles:
:cookie: 616 | @eweiss17 |http://www.freecodecamp.org/eweiss17
shameem fairooz
@sfshameem5
Apr 23 2018 17:28
@NJM8 I'm using it for math calculation.
Nate Mallison
@NJM8
Apr 23 2018 17:33
Sure, plus you have link to a bank account or user accounts or anything like that, but I just wanted to share why it can be dangerous.
Max Kazionov
@MaximKazionov
Apr 23 2018 17:33
Hey guys, can you hell me with such question :
Where it's better to start (at Freecodecamp or at a beta freecodecamp?)
Nate Mallison
@NJM8
Apr 23 2018 17:34
IMHO it also makes the calculator much easier. once you have it done and are happy with your results it's a good challenge to build your own parser to process the input. You will learn a lot and if a potential employer looks at your code won't ask why are using eval but will be wowed that you built your own parser
@MaximKazionov I think with the beta you get the advantage of so many years of experience and refinement, I also hear it is much shorter and more to the skills you need. But there are no certifications yet, at least last I looked
Max Kazionov
@MaximKazionov
Apr 23 2018 17:36
@NJM8 Thank you so much!
CamperBot
@camperbot
Apr 23 2018 17:36
maximkazionov sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 425 | @njm8 |http://www.freecodecamp.org/njm8
Max Kazionov
@MaximKazionov
Apr 23 2018 17:37
I think that we need not to use bootstrap in our projects, because we use such mad classes as col-md
Or it's make our code more heavily
shameem fairooz
@sfshameem5
Apr 23 2018 17:38
@MaximKazionov It becomes familiar after some time. It also has cross browser support
Max Kazionov
@MaximKazionov
Apr 23 2018 17:40
But I'm prefer using flexbox or even Css grid, but the last one has a low browser support
Lallo Vigil
@lalov1
Apr 23 2018 17:42
@MaximKazionov Beta has a lot better lessons, but I don't think the lessons marked and points will carry over once it goes live. The projects will since they are on CodePen.
Max Kazionov
@MaximKazionov
Apr 23 2018 17:45
@lalov1 I think I will start at fcc, and when the beta will has already been released, I will learn some new info hear
Lallo Vigil
@lalov1
Apr 23 2018 17:46
@MaximKazionov That sounds like a good plan
Max Kazionov
@MaximKazionov
Apr 23 2018 17:46
@lalov1 Yeah)
I think fcc is one of the best learning resources now!
Lallo Vigil
@lalov1
Apr 23 2018 18:00
Should I put all my initial recipes in an object? https://codepen.io/lalov1/pen/97756811476267a589a730dc15f881a1
Max Kazionov
@MaximKazionov
Apr 23 2018 18:01
@lalov1 You have used css in js?
ExpressyCode
@ExpressyCode
Apr 23 2018 18:36
Hey guys, am doing the wikipedia viewer project. Can anyone check if there is something wrong with my fetch? I get error all the time :/
Ken Haduch
@khaduch
Apr 23 2018 18:36
@ExpressyCode - post a URL.... there. taking a look
Thomas Tylek
@zippkidd
Apr 23 2018 18:36
@ExpressyCode You can't use fetch for that project
ExpressyCode
@ExpressyCode
Apr 23 2018 18:36
@zippkidd why?
Thomas Tylek
@zippkidd
Apr 23 2018 18:37
@ExpressyCode fetch can't process JSONP which is what you need to use for their API, otherwise you will get CORS error
Not exactly sure why it's set up that way
ExpressyCode
@ExpressyCode
Apr 23 2018 18:37
@zippkidd Oh ok so I have to use XMLHttpRequest?
Thomas Tylek
@zippkidd
Apr 23 2018 18:37
Yea, that or jQuery's $.ajax() method
ExpressyCode
@ExpressyCode
Apr 23 2018 18:38
@zippkidd Oh ok didn't know that. Thanks for your help :+1:
CamperBot
@camperbot
Apr 23 2018 18:38
expressycode sends brownie points to @zippkidd :sparkles: :thumbsup: :sparkles:
api offline
Thomas Tylek
@zippkidd
Apr 23 2018 18:38
Good luck, np
Ken Haduch
@khaduch
Apr 23 2018 18:39
@ExpressyCode - wikipedia does have an option to allow cross-origin - add a parameter to the URL &origin=* to allow cross-origin access.
ExpressyCode
@ExpressyCode
Apr 23 2018 18:40
@khaduch cross-origin is that fetch?
Ken Haduch
@khaduch
Apr 23 2018 18:41
@ExpressyCode - I mean that if you are getting cross origin errors, you can direct wikipedia to allow it by adding that parameter. I haven't looked at your code because of some multi-tasking...
ExpressyCode
@ExpressyCode
Apr 23 2018 18:42
@khaduch Oh ok :smile:
Ken Haduch
@khaduch
Apr 23 2018 18:43
@ExpressyCode - I just added it to your URL, and it starts working with that &origin=* tacked onto the end - at least starts echoing objects to the console
Nate Mallison
@NJM8
Apr 23 2018 18:43
@ExpressyCode Also I'm not sure you have the functions laid out correctly, I don't think you need async/await here, and if you do I think you need to await a function that performs the fetch with defined success and error call backs
ExpressyCode
@ExpressyCode
Apr 23 2018 18:44
@khaduch Ye it did work, thanks :+1:
CamperBot
@camperbot
Apr 23 2018 18:44
expressycode sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3897 | @khaduch |http://www.freecodecamp.org/khaduch
Ken Haduch
@khaduch
Apr 23 2018 18:45
@ExpressyCode - I don't see where you are adding in the search term, though?
Thomas Tylek
@zippkidd
Apr 23 2018 18:46
@khaduch Thanks for pointing that out, I didn't know. @ExpressyCode sorry about the wrong info
CamperBot
@camperbot
Apr 23 2018 18:46
zippkidd sends brownie points to @khaduch and @expressycode :sparkles: :thumbsup: :sparkles:
:star2: 3898 | @khaduch |http://www.freecodecamp.org/khaduch
:cookie: 266 | @expressycode |http://www.freecodecamp.org/expressycode
Nate Mallison
@NJM8
Apr 23 2018 18:46
@ExpressyCode Also you might want to add a search button, right now you are performing a search everytime the users types a key
ExpressyCode
@ExpressyCode
Apr 23 2018 18:46
@khaduch haven't done that yet. Just trying to get a return first:) But now it works. So I can working on it now.
@zippkidd np!
@NJM8 Ok I will read a little about that. But as I understand your have to use async await etc when your using a function. I don't need to if I do it directly in the addEventListener function. I can be wrong! Thanks for pointing it out.
CamperBot
@camperbot
Apr 23 2018 18:50
expressycode sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
:cookie: 426 | @njm8 |http://www.freecodecamp.org/njm8
Nate Mallison
@NJM8
Apr 23 2018 18:50
Sure thing, hope it helps, I'm sure there are many ways to do it
ExpressyCode
@ExpressyCode
Apr 23 2018 18:55
@NJM8 How would you write the function? If you have time to show :)
Nate Mallison
@NJM8
Apr 23 2018 18:57
in my link above to my github
your async function calls the await, which calls the api with a new Promise
although I haven't done it with fetch, I think it would be the same
personally in my project I just used new Request(url), fetch (url) .then(success).catch(error)
function getQuery(query) {
    const request = new Request(url goes here);

    fetch(request).then(function(response){
      return response.json().then(function(data){
      // do work
        }
      })
    }).catch(error => {
      console.log(error);
    })
}
ExpressyCode
@ExpressyCode
Apr 23 2018 19:04
@NJM8 Oh ok so you mean I should do the .then and .catch directly in the function instead of returning it?
@NJM8 XMLHttpRequest and fetch is pretty new to me.
Nate Mallison
@NJM8
Apr 23 2018 19:07
correct
ExpressyCode
@ExpressyCode
Apr 23 2018 19:09
@NJM8 Ok I see, I will try some different approaches to see what I like the most. But in a time matter, using .then .catch directly in the function is best?
Nate Mallison
@NJM8
Apr 23 2018 19:11
if not using async await
very clean
ExpressyCode
@ExpressyCode
Apr 23 2018 19:13
@NJM8 Thanks :)
CamperBot
@camperbot
Apr 23 2018 19:13
expressycode sends brownie points to @njm8 :sparkles: :thumbsup: :sparkles:
api offline
matthewlee07
@matthewlee07
Apr 23 2018 20:12
can anyone help me with deleting something from a list? it's not as straight forward as the hero app
Thomas Tylek
@zippkidd
Apr 23 2018 20:15
@matthewlee07 Are you trying to delete an entire <li>?
matthewlee07
@matthewlee07
Apr 23 2018 20:15
yes
Thomas Tylek
@zippkidd
Apr 23 2018 20:15
Does it matter which one? The first one? The last one?
matthewlee07
@matthewlee07
Apr 23 2018 20:15
but it's a child and not exactly in an array
on event
could I show you my repo?
Thomas Tylek
@zippkidd
Apr 23 2018 20:16
Sure
var p = document.getElementById('listID');
p.removeChild(p.getElementsByTagName('li')[0]);
^that would remove your first <li> of the <ol id="listID">
I need the delete to work, and the way I have it currently reloading the page doesn't seem like a good fix
Thomas Tylek
@zippkidd
Apr 23 2018 20:21
Hmm I'm not experienced in angular but I'll take a look
br3ntor
@br3ntor
Apr 23 2018 20:25
What happened to the main fcc gitter chat room? /freecodecamp
just me? or did it go away?
Thomas Tylek
@zippkidd
Apr 23 2018 20:25
@matthewlee07 where is your deleteGame() function located?
Hmm actually I found it..
@matthewlee07 , I'm sorry I don't know if I'll be able to help. I've never used angular before
bilaal-s
@bilaal-s
Apr 23 2018 20:32
who is good with grid
css grid that is
Thomas Tylek
@zippkidd
Apr 23 2018 20:41
@bilaal-s what do you need help with?
Try http://cssgridgarden.com/ for a nice interactive grid tutorial
From the same great author, http://flexboxfroggy.com/ is a cool flex tutorial
Tom
@moT01
Apr 23 2018 21:04
@br3ntor it got removed
can anyone tell me what I am doing wronge?
Abhilash Kumar
@apravink
Apr 23 2018 21:40
@g4m3rm1k3 What are you trying to do?
Michael
@g4m3rm1k3
Apr 23 2018 21:41
its supposed to alert when you clik in the area and when you click out
its like its looping
Boo Far
@vapidlyrapid
Apr 23 2018 21:47
hello. I was wondering how to size an element based on its background image's native size/resolution
Tom
@moT01
Apr 23 2018 21:48
@vapidlyrapid you want your element to be the same size as an image?
Boo Far
@vapidlyrapid
Apr 23 2018 21:49
@moT01 yes
Abhilash Kumar
@apravink
Apr 23 2018 21:49
@g4m3rm1k3 It loops because the DOM refreshes when you exit out of the alert box
Tom
@moT01
Apr 23 2018 21:49
could you set the size with css width and height
Abhilash Kumar
@apravink
Apr 23 2018 21:49
Try console.log instead
Tom
@moT01
Apr 23 2018 21:49
to the size of the picture
Michael
@g4m3rm1k3
Apr 23 2018 21:50
the video I am following doesn't have that problem
Boo Far
@vapidlyrapid
Apr 23 2018 21:50
@moT01 yeah. I thought there would be more of an 'automatic' process like using background-size available
but it looks like I'm going to have to hardcode it using widht and height
but i dont think those would set the size of the element
just the size of the background image
so some would get cut off if the element isnt big enough
Thomas Tylek
@zippkidd
Apr 23 2018 21:58
@g4m3rm1k3 scripts go in between the <body></body> tags of your html
also, don't call a function during the on focus event, especially an alert, you create an infinite loop because the element stays focused and alert pauses any functionality
everytime the alert is closed it is just opened again because the on focus event fires the function with alert again
Tom
@moT01
Apr 23 2018 21:59
scripts dont have to go in the body tags
Michael
@g4m3rm1k3
Apr 23 2018 22:01
@zippkidd Thanks I think he got it in the video he just stopped the page from sending messages so thats a little frustrating but I am learning so whatever
CamperBot
@camperbot
Apr 23 2018 22:01
g4m3rm1k3 sends brownie points to @zippkidd :sparkles: :thumbsup: :sparkles:
api offline
Thomas Tylek
@zippkidd
Apr 23 2018 22:02
@moT01 but they probably should. from stack overflow: "The problem with writing scripts at the head of a page is blocking. The browser must stop processing the page until the script is download, parsed and executed. The reason for this is pretty clear, these scripts might insert more into the page changing the result of the rendering, they also may remove things that dont need to be rendered, etc. "
@g4m3rm1k3 you're doing fine. The important thing is you're learning! Good for you!
Tom
@moT01
Apr 23 2018 22:11
what happens if you want a script loaded before the rest of the stuff
Michael
@g4m3rm1k3
Apr 23 2018 22:19
is there like an onload function?
Tom
@moT01
Apr 23 2018 22:32
@g4m3rm1k3 yes
Thomas Tylek
@zippkidd
Apr 23 2018 22:49
@moT01 in that case you load in the script at that specific point, and no sooner. Obviously this is a flexible rule and if there is a case where you need to load the script before the </body> then you would do that
It's just generally considered good practice to load mostly all scripts right before </body>
TonyRednil
@TonyRednil
Apr 23 2018 22:53
Can the .replace function be called on a number in an array?
Moisés Man
@moigithub
Apr 23 2018 22:58
replace works for strings... soo u need to convert it to string if u wanna use
TonyRednil
@TonyRednil
Apr 23 2018 23:00
@moigithub Yeah, I don't think there are enough values in the array to do that. I've been trying to use the .filter function and it keeps telling me "false is not a funciton" or "2 is not a function".

function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);
args = args.slice(1);
for (var i = 0; i < args.length; i++) {
for (var j = 0; j < arr.length; j++) {
Array.prototype.filter(arr[j] < args[i]);
}
}
return arr;
}

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

Thomas Tylek
@zippkidd
Apr 23 2018 23:02
@moigithub I don't think you should be using array.prototype...
shouldn't you be using arr there, the parameter of the function?
TonyRednil
@TonyRednil
Apr 23 2018 23:04
I've just been attempting to follow what the guide is instructing me to use. The parameter of the function is to remove the arguments from the array. So the code I posted should return [1, 1]
I tried just simply doing return arr.filter(arguments); but that returned "2 is not a function"
Moisés Man
@moigithub
Apr 23 2018 23:08
Thomas Tylek
@zippkidd
Apr 23 2018 23:12
Try to use Array.from your arguments object, then slice it
TonyRednil
@TonyRednil
Apr 23 2018 23:12
@moigithub Yeah, I have been reading that over and over and can't seem to get a function where it will return the values that pass it. I've tried: arr.filter(arr[i] === args[j]); arr.filter(arr[i] == args[j]); arr.filter(arr[i] >= args[j]); arr.filter(arr[i] <= args[j]); etc and they all return something like "true is not a function" "false is not a function" "2 is not a function" "array is not a function". Do I need to do something like arr.filter(arr = arr[i] < args[j]);?
Thomas Tylek
@zippkidd
Apr 23 2018 23:12
so, var args = Array.from(arguments).slice(1)
Moisés Man
@moigithub
Apr 23 2018 23:13
arr[i] <= args[j] is not a function/callback
u need to pass a function to filter
TonyRednil
@TonyRednil
Apr 23 2018 23:13
@zippkidd Is that even necessary if arr calls the array that is in the arguments?
@TonyRednil Then I'm totally lost as to what an function would be to pass through that.
@moigithub Then I'm totally lost as to what a function would be to pass through that.
Moisés Man
@moigithub
Apr 23 2018 23:14

example...

function even(num){ return num % 2 === 0; }
[1,2,3,4].filter(even)

as u can see.. even is a function.. which accepts some parameters
filter callback function.. have some parameters predefined.. but most of time only first one is used
filter will take each values from the array.. one by one.. and call the function with that value...
and return only the values which evaluates as true

TonyRednil
@TonyRednil
Apr 23 2018 23:15
So that function would filter values that have an odd remainder when divided by 2?
Thomas Tylek
@zippkidd
Apr 23 2018 23:20
@TonyRednil no it's not necessary, what you're doing works. I would at least remove Array.prototype and replace it with just arr, but maybe that's just my personal preference
@TonyRednil in regards to @moigithub 's example, think about what's going on with the return value
when 1 is passed in as num, is 1 % 2 === 0?
no, so false is being returned.
and as stated by in the MDN filter link: "Return true to keep the element, false otherwise..."
Thomas Tylek
@zippkidd
Apr 23 2018 23:26
@TonyRednil so yes, that function removes values that have any remainder after the remainder 2 operation is done. Reminder, % is not division, it is the remainder operator
Your filter method may be more complicated though because the test cases have arguments that are strings too
TonyRednil
@TonyRednil
Apr 23 2018 23:30
And I was hoping to keep this code simple....
Thomas Tylek
@zippkidd
Apr 23 2018 23:31
I would recommend something like return arr.filter(function(element) { return !args.includes(element)}
so ultimately between that and separating the arguments into an array to alter and the arguments to check the array against, it's only a few lines of code
TonyRednil
@TonyRednil
Apr 23 2018 23:33
So that is going to ultimately return arr with only values that aren't equal to either argument? What is element? Is that just a way to call each individual value in the array?
Thomas Tylek
@zippkidd
Apr 23 2018 23:33
filter runs through each element of the array you called it on
TonyRednil
@TonyRednil
Apr 23 2018 23:33
So then what is element?
Thomas Tylek
@zippkidd
Apr 23 2018 23:34
element can be renamed to anything, but essentially element is first arr[0], then arr[1], and so on...
TonyRednil
@TonyRednil
Apr 23 2018 23:35
Ah gotcha. So that code you posted is going to check each value in arr and if it's equal to either value in args it will remove it and return everything else? Am I understanding that right?
I'm still new to the while includes method
Whole*
Thomas Tylek
@zippkidd
Apr 23 2018 23:37
Yup. Because it goes, "Oh lets filter. We're filtering arr, so let's start with arr[0]. arr[0] is 1. Okay, so let's run value one into the callback function (what's inside filter(...))
"okay, the callback runs. 1 is used as the value in that function (element)."
"the callback wants to know if !args.includes(element), so does the args array NOT include this element (1)?"
TonyRednil
@TonyRednil
Apr 23 2018 23:39
Do I need to declare anything I set in place of where you put "element"?
Thomas Tylek
@zippkidd
Apr 23 2018 23:39
no, it's implicitly being declared.
just as function foo(a) {return a;} doesn't need a to be declared
TonyRednil
@TonyRednil
Apr 23 2018 23:41
I clearly have much to learn.
Thomas Tylek
@zippkidd
Apr 23 2018 23:41
You'll get it man. I was just as confused as you at the start, if not more
Just keep practicing and asking questions
Devansh-Anhal
@Devansh-Anhal
Apr 23 2018 23:43
package addchain;

import java.util.*;

public class reeer {

    public static void main(String[] args) {

        int chainLength = Integer.parseInt(args[0]) + 1;
        int chainTarget = Integer.parseInt(args[1]);
        Random rng = new Random();
        List<Integer> chain = new ArrayList<>();
        chain.add(1);

        while (true) {
            while (chain.size() != chainLength)
                chain.add(chain.get(rng.nextInt(chain.size())) + chain.get(chain.size() - 1));
            if (chain.get(chain.size() - 1) == chainTarget) {
                System.out.println(chain);
                break;
            }
            chain.clear();
            chain.add(1);
        }
    }
}
i am getting this error
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at addchain.reeer.main(reeer.java:9)
can anyone help plase
please
*URGENT
Thomas Tylek
@zippkidd
Apr 23 2018 23:44
@TonyRednil Anyway, args.includes(1) evaluates to false. But that's the value you want to keep, so !args.includes(1) evaluates to true
@TonyRednil practice running through those steps and talking through each arr[0] and then arr[1] kinda like i started to show you
Ooh, @Devansh-Anhal , I don't really know Java at all but I'll try to help
@Devansh-Anhal , you do realize this is a front-end help chat room? (HTML, CSS, JS)
Devansh-Anhal
@Devansh-Anhal
Apr 23 2018 23:46
oh sorry :P
i am really sorry
Thomas Tylek
@zippkidd
Apr 23 2018 23:46
no need to be sorry! I just don't know how much I can help you buddy!