These are chat archives for FreeCodeCamp/HelpFrontEnd

4th
Apr 2018
Ken Haduch
@khaduch
Apr 04 2018 02:20
@germangamboa95 - okay, those are strange questions and I like the concept of your game! Nice!
zootechdrum
@zootechdrum
Apr 04 2018 03:44
hey guys why isnt the sort being applied to the last array

function largestOfFour(arr) {
  var iteration = 0;
  var largestNum = 0;
  var ans = [];

  for(var i = 0;i <= arr.length-1;i++){
    arr[i].sort();
    ans.push(arr[i]);
  }


  return ans;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
abraham anak agung
@padunk
Apr 04 2018 03:52
@zootechdrum it does, that is the way sort() work. you have to define sort(function (a, b) { return a > b} to get it properly sort.
zootechdrum
@zootechdrum
Apr 04 2018 03:55
@padunk really! ahh god this challenge has taken me all day lol. ill continue tomorrow.
abraham anak agung
@padunk
Apr 04 2018 03:56
@zootechdrum :+1: have a good rest
German Gamboa Gonzalez
@germangamboa95
Apr 04 2018 04:00
@khaduch Thanks! Lol I know I googled weird questions
CamperBot
@camperbot
Apr 04 2018 04:00
germangamboa95 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3849 | @khaduch |http://www.freecodecamp.org/khaduch
Rahsheen Porter
@rahsheen
Apr 04 2018 04:10
@zootechdrum this should get you sorted. Check out the examples. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
Brad
@bradtaniguchi
Apr 04 2018 04:12
@rahsheen Sup rasheen, long time no see haha
Rahsheen Porter
@rahsheen
Apr 04 2018 04:14
Yo :)
Brad
@bradtaniguchi
Apr 04 2018 04:15
nice to see you still around, did you go off onto discord too?
Rahsheen Porter
@rahsheen
Apr 04 2018 04:18
Yeah, mostly :)
Brad
@bradtaniguchi
Apr 04 2018 04:21
Ah I see
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 04:54
Is this really closing down? Or just will no longer be used?
Actually, I only saw mods in the general room saying that. I think this room is fine :)
Brad
@bradtaniguchi
Apr 04 2018 05:29
@SweetCodingInc Only the general room is being closed
Gaurav Singh
@gauravsinghaec
Apr 04 2018 05:41
https://codepen.io/gauravsinghaec/full/WzdzbG
This is my random quote project link.
Any comments or feedback on AJAX call so that I will make sure the future projects are good with Ajax call.
Markus Kiili
@Masd925
Apr 04 2018 05:45
@gauravsinghaec var data = json; is redundant. You could just use json, or change the parameter name to data. No need for the extra variable.
Gaurav Singh
@gauravsinghaec
Apr 04 2018 05:50
@Masd925 hey thanks.. removed the redundant variable :smile:
CamperBot
@camperbot
Apr 04 2018 05:50
gauravsinghaec sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4754 | @masd925 |http://www.freecodecamp.org/masd925
dinesh
@1532j0004kg
Apr 04 2018 06:21
@gauravsinghaec tweet button ?
habibaatify
@habibatify_twitter
Apr 04 2018 07:01
what is ,sh file and how can run it ingitbash?
Ann Kaniga
@annkaniga
Apr 04 2018 07:02
./xxx.sh
Javier Pons
@JavierPons
Apr 04 2018 07:04
@annkaniga ?
Ann Kaniga
@annkaniga
Apr 04 2018 07:05
hehe, i replied to @habibatify_twitter
.sh is shell script and to run it in bash; enter ./xxxxxxxx.sh when is in same as script's folder
Javier Pons
@JavierPons
Apr 04 2018 07:08
@annkaniga
var myArray = [1,'a','b',3,5];
console.log(myArray);

var result = e => (typeof e === 'number'
);  
console.log(result);
Im trying to filter and create a new array without string without using map
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 07:09
@JavierPons you mean .map?
Javier Pons
@JavierPons
Apr 04 2018 07:09
I could try with filter() ....
yes,
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 07:10
you can't remove element with .map. You have to use .filter
var result = myArray.filter( e => typeof e === 'number');
@JavierPons
Javier Pons
@JavierPons
Apr 04 2018 07:11
yes
I typed first! :)
but @SweetCodingInc thanx
CamperBot
@camperbot
Apr 04 2018 07:12
javierpons sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 399 | @sweetcodinginc |http://www.freecodecamp.org/sweetcodinginc
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 07:16
:+1: @JavierPons
Javier Pons
@JavierPons
Apr 04 2018 07:21

Some vision

<html>
  <body>
    <div class="container">
    <ul id="list">
      <li id="element1">Item</li>
    </ul>
      <input name="searchTxt" type="text" id="searchText">
      <button onclick="list()">Press</button>
      <button onclick="deleteQ">Delete</button>
    </div>
  </body>

</html>
function list() {
  var ul = document.getElementById("list");
  var li = document.createElement("li");
  var text = document.getElementById("searchText").value;
 var crea = li.appendChild(document.createTextNode(text));
  ul.appendChild(li);
}

function deleteQ() {
  var child = document.getElementById('element1');
  var parent = document.getElementById('list');
  parent.removeChild(child);
}


window.onload = function() {


};

Im trying to delete the li created element ....

Sweet Coding :)
@SweetCodingInc
Apr 04 2018 07:32
@JavierPons In what order you want them deleted?
It will only work for the first time
once you delete the default li, it will not work as there will be no element with id="element1"
Javier Pons
@JavierPons
Apr 04 2018 07:37
@SweetCodingInc I want to delete li after I have created a new one
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 07:42
so you want to have only 1 li at any given point in time?
Sorry, I'm not able to understand this behavior properly
if you want to delete the li in the reverse sequence, you can refactor your deleteQ function like
function deleteQ() {
  var parent = document.getElementById('list');
  var children = parent.getElementsByTagName('li');
  var childToRemove = children[children.length - 1];
  if(childToRemove){
    parent.removeChild(childToRemove);
  }
}
Here is pen
Javier Pons
@JavierPons
Apr 04 2018 08:07
@SweetCodingInc thanx!
CamperBot
@camperbot
Apr 04 2018 08:07
javierpons sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
api offline
JoEezy
@JoEeeezy_twitter
Apr 04 2018 08:14
@JavierPons ive been trying to figure out how to change the first element's text and then after that add new li's for the past hour lol
i'm stuck now :eyes:
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 08:17
@JoEeeezy_twitter show your code please
Javier Pons
@JavierPons
Apr 04 2018 08:17
@JoEeeezy_twitter I will be glad to help you. But I must leave now. Later I will come back!
JoEezy
@JoEeeezy_twitter
Apr 04 2018 08:17
@JavierPons okay
@SweetCodingInc it's actually your code in the pen :smile: ... i'm trying to make it so the first element's text changes to searchText , and then after that it adds the new li's
i got it to change the text ... but it still adds the same new li too
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 08:20
lol.... this is just entirely meaningless :P
document.getElementById("element1").id = "element1"
i think you wanted to do == instead
and even in that case, it's pointless
JoEezy
@JoEeeezy_twitter
Apr 04 2018 08:21
oh god
lol your right
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 08:21

anyway..

but it still adds the same new li too

So you want, at most, only 2 li elements at any point in time?

I'm still unable to understand what you're trying to do
JoEezy
@JoEeeezy_twitter
Apr 04 2018 08:23
actually i was trying to make it so instead of adding an li under element1 to the list , it changes element1's innerHTML instead, and it only starts adding li's after element1 changed
JoEezy
@JoEeeezy_twitter
Apr 04 2018 08:33
@SweetCodingInc you there? i was able to get it to work by just copying some of your code around but i was wondering if you know of a better way to do this? I only did it this way to kind of show you what i mean: https://codepen.io/yaezah/pen/aYjXoR
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 08:34
I see... So it will update the first li on first time.. and then onward it will keep adding new lis
JoEezy
@JoEeeezy_twitter
Apr 04 2018 08:35
yes :smile:
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 08:39
@JoEeeezy_twitter
I'd do it like this
function list() {
  var text = document.getElementById("searchText").value.trim();

  if(!text) return;

  var element1 = document.getElementById("element1");

  var parent = document.getElementById("list");
  var children = parent.getElementsByTagName('li');
  var li = document.createElement("li");
  var crea = li.appendChild(document.createTextNode(text));

  if(element1){
    element1.id = "changed";
    element1.textContent = text;
  } else {
    parent.appendChild(li);
  }
}
no need to do anything if textbox is empty
jolio007
@jolio007
Apr 04 2018 08:40
Hey I need a quick help. I
Hey I've need a quick help. I made a nav bar with a dropdown. When I change the navbar position to fixed, my dropdown that's in absolute stops working well - https://codepen.io/jolio007/pen/jzpXMb
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 08:43
This is much better @JoEeeezy_twitter
function list() {
  var search = document.getElementById("searchText");
  var text = search.value.trim();

  if (text) {
    var element1 = document.getElementById("element1");

    if (element1) {
      element1.id = "changed";
      element1.textContent = text;
    } else {
      var parent = document.getElementById("list");
      var children = parent.getElementsByTagName("li");
      var li = document.createElement("li");
      var crea = li.appendChild(document.createTextNode(text));
      parent.appendChild(li);
    }
  }
  search.value = "";
}
JoEezy
@JoEeeezy_twitter
Apr 04 2018 08:46
@SweetCodingInc ty... that looks much cleaner :grin:
CamperBot
@camperbot
Apr 04 2018 08:46
joeeeezy_twitter sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 400 | @sweetcodinginc |http://www.freecodecamp.org/sweetcodinginc
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 08:50
@JoEeeezy_twitter PRO Tip : change all vars to let and you improve on space complexity ;)
because the variables in the else part, you want them created only when control goes into else section.
with var, they will be created and hoisted, regardless of their requirement.
Joshua Frias
@Juke-Magic
Apr 04 2018 09:27
guys
why isnt html appending in my container?
wait i got it
nvm
Stephen James
@sjames1958gm
Apr 04 2018 09:30
@Juke-Magic :+1: .container :)
habibaatify
@habibatify_twitter
Apr 04 2018 10:22
what is wrong?
Capture.PNG
Stephen James
@sjames1958gm
Apr 04 2018 10:24
@habibatify_twitter You should compare strokes to par not to specific numbers.
Because of how comma works
if (par == 4, strokes == 6) will only really test strokes == 6because the value of the comma operator expression is the last value in the comma list
Gaurav Singh
@gauravsinghaec
Apr 04 2018 10:35
@1532j0004kg :smile: added tweet button. Is the implementation ok?
habibaatify
@habibatify_twitter
Apr 04 2018 10:39
ok
Johny Sins
@JohnySi73551906_twitter
Apr 04 2018 10:45
@Masd925 can you tell me why this code returns "FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory"
function translatePigLatin(str) {
    var vocals = ['a','A','e','E','u','U','i','I','o','O'];
    var str_arr = str.split('');
    var found_vocal = false;
    for(var i = 0; i < str_arr.length; i++) {
        if (!vocals.includes(str_arr[i]) && !found_vocal) {
            str_arr.push(str_arr[i],'a','y');
            str_arr.splice(str_arr.indexOf(str_arr[i]),1);
            if (vocals.includes(str_arr[0])) {
                found_vocal = true;
            }
        } else if (vocals.includes(str.charAt(0))) {
            str_arr.push('w','a','y');
        }
    }
    console.log(str_arr.join(''));
}

translatePigLatin("eight");
Markus Kiili
@Masd925
Apr 04 2018 10:48
@JohnySi73551906_twitter Most likely you are making an infinite loop there.
Johny Sins
@JohnySi73551906_twitter
Apr 04 2018 10:49
HOW?! I'm looping thru the length of my array!!\
Markus Kiili
@Masd925
Apr 04 2018 10:50
@JohnySi73551906_twitter You are adding elements to that array you loop over. That can mess up the indices and the logic.
Johny Sins
@JohnySi73551906_twitter
Apr 04 2018 10:50
oh lol
is there a way to prevent that?
Markus Kiili
@Masd925
Apr 04 2018 10:51
@JohnySi73551906_twitter You could use a result array for new content and keep the original array intact.
Johny Sins
@JohnySi73551906_twitter
Apr 04 2018 10:51
good idea! thanks @Masd925
CamperBot
@camperbot
Apr 04 2018 10:51
johnysi73551906_twitter sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4756 | @masd925 |http://www.freecodecamp.org/masd925
Onome Sotu
@onomesotu
Apr 04 2018 11:19
Can someone confirm that one test case (the second from bottom) for the Exact change problem is wrong in the advanced algorithm scripting?
It shouldn't return insufficient funds because the cash in drawer is greater than the change due
Aditya
@ezioda004
Apr 04 2018 11:23
@onomesotu Seems correct to me, cash is cash customer giving to you, cid is the cash you have in drawer.
Markus Kiili
@Masd925
Apr 04 2018 11:24
@onomesotu Test cases are correct. You have one note of one pound and one penny coin. You cannot give 50 pennies back.
UnorthodoxThing
@UnorthodoxThing
Apr 04 2018 11:26
Hello, Im quiet new. I'm trying to make a double dropdown checkbox menu with submenu. Does anyone have an idea or guide on how to do this??
Shariq Shahbaz
@sh4r10
Apr 04 2018 11:49
guys I'm trying to make a new tab extension for chrome, I have an input field on the page and I would like it so that when a new tab is opened the input box is focused instead of chrome's omni bar. How can I achieve this? I have already tried $("#id").focus()
Stephen James
@sjames1958gm
Apr 04 2018 11:54
@habibatify_twitter Hard to tell - is there a return answer; at the bottom of the function
habibaatify
@habibatify_twitter
Apr 04 2018 11:57
thanks @sjames1958gm solved
CamperBot
@camperbot
Apr 04 2018 11:57
habibatify_twitter sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9164 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
habibaatify
@habibatify_twitter
Apr 04 2018 11:57
thanks guys
Shariq Shahbaz
@sh4r10
Apr 04 2018 11:58
anyone helping me?
mustimuu
@mustimuu
Apr 04 2018 12:29
Any wordpress experts in here ?
Ken Haduch
@khaduch
Apr 04 2018 13:10
@sh4r10 - not sure if we have any chrome extension experts here... I'm not one, but I search for some info - try this stackoverflow link it looks like it's not using jquery but vanilla JS. Hope it helps.
coderNewby
@coderNewby
Apr 04 2018 13:22
@DarrenfJ wanted to say thanks again for all your help
CamperBot
@camperbot
Apr 04 2018 13:22
codernewby sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2449 | @darrenfj |http://www.freecodecamp.org/darrenfj
Tony Hudson
@ngohungphuc
Apr 04 2018 13:45
Hi Guys, Is there anyway to avoid manually set state loading true and false for every ajax request in React JS
handleSubmit = e => {
    e.preventDefault();
    this.setState({ loading: true });

    const tagData = JSON.stringify(this.state.value.map(x => x.value));
    const tagOptions = JSON.stringify(this.state.value);
    const tagDataVm = {
      tagData,
      tagOptions
    };

    Post(env.tagCreate, tagDataVm)
      .then(res => {
        if (res.status === statusCode.Success) toastr.success("Create success");

        this.setState({ loading: false });
      })
      .catch(() => {
        this.setState({ loading: false });
        toastr.error("Something went wrong.Please try again");
      });
  };
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 13:49
@ngohungphuc not while you're not using redux
Johny Sins
@JohnySi73551906_twitter
Apr 04 2018 13:52
@Masd925 @sjames1958gm can I do https://www.freecodecamp.org/challenges/dna-pairing using objects? if yes what methods can I use?
var dna_arr = new Object ({
    "DNA-key": "its-pair"
});
vaibhav sharma
@vaibsharma
Apr 04 2018 13:54
@ngohungphuc in reactJS you must always first change the state and on the basis of state change the behaviour of your UI. I don't think there is anyway you can do it manually without changing states, otherwise it is simply like using Jquery.
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 13:57
@JohnySi73551906_twitter Very inspiring name you got yourself there ;)
Johny Sins
@JohnySi73551906_twitter
Apr 04 2018 13:58
@SweetCodingInc yea... I'm a fan of a certain someone xD
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 13:58
You could just provide mapping using object literal syntax
var pairMapping = {
  A:'T',
  T:'A',
  G:'C',
  C:'G'
};
Johny Sins
@JohnySi73551906_twitter
Apr 04 2018 13:59
interesting, so what syntax would be the most useful in my case?
Markus Kiili
@Masd925
Apr 04 2018 14:00
@JohnySi73551906_twitter The object posted by @SweetCodingInc leads to most simple solution.
Tony Hudson
@ngohungphuc
Apr 04 2018 14:05
@vaibsharma yes just my concern, because I just have to manually set state loading true then false for every ajax request is seem like very tedious
rk
@rajkumart08_twitter
Apr 04 2018 14:05

hi,

  • when I click the checkbox I need to show an image.
  • but right now I am getting an error Uncaught TypeError: Cannot read property 'checked' of null
  • can you tell me how to fix it.
  • providing my code below.

Uncaught TypeError: Cannot read property 'checked' of null
at (index):185
at dispatch (VM576 jquery.min.js:3)
at i (VM576 jquery.min.js:3)

http://jsfiddle.net/xda0kL6w/1/


    if (document.getElementById('checkIDGrid').checked) {
      alert("I am checked for the grid");

      var img = $('<img />', {
        id: 'Myid',
        src: 'https://thumbs.dreamstime.com/z/pixel-perfect-web-development-flat-icons-set-website-programming-process-webpage-coding-user-interface-creating-45297890.jpg',
        alt: 'MyAlt'
      });
      img.appendTo($('<tr>'));

    } else {
      alert("I am not checked for the grid");
    }
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 14:05
@ngohungphuc You could abstract that part away, but that would require you to move the state out side of component...
@rajkumart08_twitter it looks like there is no checkbox/radio button with id="checkIDGrid"
Tony Hudson
@ngohungphuc
Apr 04 2018 14:06
@SweetCodingInc how can I do that (move the state out of component since im not using redux). I have a spinner component
rk
@rajkumart08_twitter
Apr 04 2018 14:12
@SweetCodingInc hey its there in the code ---> template: "# if ('new' =='new') { # <input id = 'checkIDGrid' type='checkbox' checked=true class=''> # }else{# <span class='oldEventArrow'></span> #} #"
Johny Sins
@JohnySi73551906_twitter
Apr 04 2018 14:30
@SweetCodingInc @Masd925 I keep getting undefined in my result... what am I missing?
function pairElement(str) {
    str_arr = str.split('');
    final_arr = [];
    var pairMapping = {
      A:'T',
      T:'A',
      G:'C',
      C:'G'
    };
    for(var i = 0; i < str_arr.length; i++) {
        if (str_arr[i] === 'A') {
            final_arr[i] += [str_arr[i], pairMapping.A];
        } else if (str_arr[i] === 'T') {
            final_arr[i] += [str_arr[i], pairMapping.T];
        } else if (str_arr[i] === 'G') {
            final_arr[i] += [str_arr[i], pairMapping.G];
        } else {
            final_arr[i] += [str_arr[i], pairMapping.C];
        }
    }
    console.log(final_arr);
}
[ 'undefinedG,C', 'undefinedC,G', 'undefinedG,C' ]
[Finished in 0.2s]
Markus Kiili
@Masd925
Apr 04 2018 14:32
@JohnySi73551906_twitter final_arr[i] = ...
or even better final_arr.push(...)
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 14:33

@JohnySi73551906_twitter

final_arr[i] += [str_arr[i], pairMapping.A];

should be

final_arr[i] = [str_arr[i], pairMapping.A];
at all occurances
Markus Kiili
@Masd925
Apr 04 2018 14:34
@JohnySi73551906_twitter It is also possible to avoid the if else structure there.
Johny Sins
@JohnySi73551906_twitter
Apr 04 2018 14:34
how?
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 14:34
Yeah.. you can avoid that if/else hell
for (var i = 0; i < str_arr.length; i++) {
  final_arr[i] = [str_arr[i], pairMapping[str_arr[i]]];
}
or
for (var i = 0; i < str_arr.length; i++) {
  final_arr.push([str_arr[i], pairMapping[str_arr[i]]]);
}
Johny Sins
@JohnySi73551906_twitter
Apr 04 2018 14:35
I see now! thanks @SweetCodingInc & @Masd925
CamperBot
@camperbot
Apr 04 2018 14:35
johnysi73551906_twitter sends brownie points to @sweetcodinginc and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 401 | @sweetcodinginc |http://www.freecodecamp.org/sweetcodinginc
:star2: 4757 | @masd925 |http://www.freecodecamp.org/masd925
Markus Kiili
@Masd925
Apr 04 2018 14:35
@JohnySi73551906_twitter Pushing new elements is a bit safer than arr[i] = ... so you don't generate arrays with holes by accident. Both work if you are careful.
:+1:
Sweet Coding :)
@SweetCodingInc
Apr 04 2018 14:38

I'd do it like this

function pairElement(str) {
    var pairMapping = {
        A: 'T',
        T: 'A',
        G: 'C',
        C: 'G',
    };

    return str.split('').map( p => [p, pairMapping[p]]);
}

but yours is anytime more performant

Daniel Simeonov
@dbsimeonov
Apr 04 2018 14:44
hey all, so thats the group we all moved? :D
May Kittens Devour Your Soul
@diomed
Apr 04 2018 14:55

This is SPARTA!!!

Sweet Coding :)
@SweetCodingInc
Apr 04 2018 14:55
here we go...
shit talk has started dripping in here now
zootechdrum
@zootechdrum
Apr 04 2018 15:18
Good morning yall

can anyone give me a good hint? lol


function largestOfFour(arr) {
  var checkNumber = 0;
  var biggestNum = [];

  for(var i = 0; i < arr.length;i++) {
  for(var j = 0; j < arr.length;j++) {
    if(j === 3 ){
      biggestNum.push(checkNumber);  
    }else if(arr[i][j] > checkNumber) {
      checkNumber = arr[i][j];
    }
    console.log(checkNumber);
    }
   }
  return biggestNum; 
}

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

I can't seem to hit 39 in the third sub array.

Nate Mallison
@NJM8
Apr 04 2018 15:25
@zootechdrum with if (j === 3) you will always push the number to biggest num before it checks the last number
do the number check first then push it
Aditya
@ezioda004
Apr 04 2018 15:34
@zootechdrum You can perhaps do a check in j === 3 between arr[i][j] and checkNumber and push the bigger one in the array also in for(var j = 0; j < arr.length;j++) the condition should be arr[i].length
Duyali
@Duyali
Apr 04 2018 15:53
Please help me to look at this code. To implement the rotation diagram, there is a bug but I do not know how to change it.
let flag=true;
$(".pagerbox li").click(function () {
let index = $(".pagerbox li").index(".pagerbox li")
$(".pagerbox li").removeClass("active").eq(index).addClass("active");
$(".imgbox img").removeClass("active").eq(index).addClass("active");
n = index;
})
function move() {
n++;
if (n === $(".imgbox img").length) {
n = 0;
}
if (n < 0) {
n = $(".imgbox img").length - 1;
}
$(".pagerbox li").removeClass("active").eq(n).addClass("active");
$(".imgbox img").removeClass("active").eq(n).addClass("active");
}
    $(".next").click(function () {
        if(flag){
            flag=false;
            move();
        }
    })
    $(".prev").click(function () {
        if(flag){
            flag=false;
            n -= 2;
            move();
        }
    })
    let t = setInterval(move, 3000);
    $("#banner").mouseleave(function () {
       t=setInterval(move, 3000);
    })
    $("#banner").mouseenter(function () {
        clearInterval(t);
    })
    $(".imgbox img").on("transitionend",function(){
        flag=true;
    })
Duyali
@Duyali
Apr 04 2018 15:59
this is html
<div id="banner">
<div class="imgbox">
<img src="images/lun1.jpg" alt="" class="active">
<img src="images/lun2.jpg" alt="">
<img src="images/lun3.jpg" alt="">
<img src="images/lun4.jpg" alt="">
<img src="images/lun5.jpg" alt="">
</div>
<!--<ul class="imgbox">-->
<!--<li class="active"><img src="images/lun1.jpg" alt=""></li>-->
<!--<li><img src="images/lun2.jpg" alt=""></li>-->
<!--<li><img src="images/lun3.jpg" alt=""></li>-->
<!--<li><img src="images/lun4.jpg" alt=""></li>-->
<!--<li><img src="images/lun5.jpg" alt=""></li>-->
<!--</ul>-->
<ul class="pagerbox">
<li class="active"></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<div class="prev"><span class="span1"><</span></div>
<div class="next"><span class="span2">></span></div>
</div>
<div class="demo"></div>
</body>
rk
@rajkumart08_twitter
Apr 04 2018 16:05

hi

  • I am trying to learn jquery.
  • in jquery I am using change method.
  • but its not displaying this alert ---> alert("I am inside change");
  • can you tell me how to fix it.
  • providing my code below.

http://jsfiddle.net/b8yx6f16/


     $('#checkIDGrid').change(function() {
          alert("I am inside change");
        if(this.checked) {
            var returnVal = confirm("Are you sure?");
            $(this).prop("checked", returnVal);
        }
       // $('#textbox1').val(this.checked);        
    });
Andrew Pope
@andrew1601
Apr 04 2018 16:16
@rajkumart08_twitter I have taken a look at your code and have found the reason
@rajkumart08_twitter there are a few issues also, there is more than one element with the id 'checkIDGrid' - you should only use an id once on your page, the same id shouldn't be given to multiple elements.
Now, the reason why your code isn't working is because the element with id checkIDGrid is dynamically added to the page, you can't attach event handlers like that to dynamically added elements.
@rajkumart08_twitter here is something you might find useful https://stackoverflow.com/questions/15090942/event-handler-not-working-on-dynamic-content
@rajkumart08_twitter you have to add the event handler to a parent element, so it can be caught when it propagates down the DOM
Ehsan Shadmehri
@ehsansh
Apr 04 2018 16:52
hi, How should I serve generated dist folder in vue-cli project of the tutorials of this film for deploy https://www.youtube.com/watch?v=Fa4cRMaTDUI
Norvin Burrus
@ndburrus
Apr 04 2018 17:39
@Duyali this may help: :sparkles:
<span class="span1">< remove last < in this line
<span class="span2">></span> remove extra >, before closing span tag
rk
@rajkumart08_twitter
Apr 04 2018 18:20
@andrew1601 can you update in the fiddle...its confusing :(
Brandon Travis
@brandon-tr
Apr 04 2018 18:35
Hey guys I'm working on my side-project and I was wondering what design changes or new features I should add
Aga
@aga87
Apr 04 2018 19:23
Hi everyone, Q- is it a good practice to always use the CSS text-transform property when I want my text on the website to be in capital letters or are their instances where i should just capitalize with capslock directly in the html document? I want my name capitalized in the main header of my website (above the nav block) - should i use CSS? Thanks!
Aga
@aga87
Apr 04 2018 19:37
im guessing the css.
Brad
@bradtaniguchi
Apr 04 2018 19:41
@aga87 I would use CSS if the data is dynamic, otherwise whats wrong with just capitalizing the text?
Abdullah Saqer
@abdullah-saqer
Apr 04 2018 21:02
Hello
Please read this story and let me know your feed back https://hackernoon.com/website-performance-checklist-bfeeb2cd362d
Miguel
@mbarra1990_twitter
Apr 04 2018 21:12
Hi guys I just finished the portfolio webpage https://codepen.io/mbarra1945/full/yKxMvV/ pls check out
Abdullah Saqer
@abdullah-saqer
Apr 04 2018 21:17
@mbarra1990_twitter 👍
Donnie
@Donnie-D
Apr 04 2018 22:04
where is fcc room gone? i cant find it
Stephen James
@sjames1958gm
Apr 04 2018 22:20
@Donnie-D I think the main room is gone
@Donnie-D Not sure why, but maybe because there was not enough "help" going on
Donnie
@Donnie-D
Apr 04 2018 22:38
@sjames1958gm interesting! is there a ninja lurking among us watching it all happen and then put the foot down?
in simple words, is it a one man decision?
guess we'll never know :shipit:
Smootimus
@Smootimus
Apr 04 2018 22:45
The main room and a few others have been deleted, yes
Stephen James
@sjames1958gm
Apr 04 2018 22:56
@Donnie-D Maybe Quincy swooped in and made some changes.
include*engine
@newtothat
Apr 04 2018 23:19
what happened to fcc room
Donnie
@Donnie-D
Apr 04 2018 23:22
its active and buzzing as usual. why?
Brad
@bradtaniguchi
Apr 04 2018 23:23
Just the main room was removed
Unless that changed since yesterday
include*engine
@newtothat
Apr 04 2018 23:24
then why i get something like its not chat room youre loking for?
i knew before typing and thats why i actually typed to get to this chat room
Gulsvi
@gulsvi
Apr 04 2018 23:25
@newtothat These are the currently available rooms: https://gitter.im/FreeCodeCamp/home
There is no general chat anymore unfortunately.
It's all business here in gitter now :)
include*engine
@newtothat
Apr 04 2018 23:26
well all we can't build our own gitter ? if no why are we going even to learn all of thesestuf
Brad
@bradtaniguchi
Apr 04 2018 23:27
What?
include*engine
@newtothat
Apr 04 2018 23:27
it's good to see you brad
i recognized you from that room
Gulsvi
@gulsvi
Apr 04 2018 23:28
@newtothat Do you have a question about a front-end project?
Brad
@bradtaniguchi
Apr 04 2018 23:28
Yes, I'm in most of the FCC rooms
include*engine
@newtothat
Apr 04 2018 23:29
what i meant was @gulsvi said something about buseness and gitter
not front end but back-end
Gulsvi
@gulsvi
Apr 04 2018 23:29
It's a saying "It's all business here now" - means, no general chat about random stuff, just ask questions about coding and get answers, help others.
include*engine
@newtothat
Apr 04 2018 23:30
when you learn php most of conseptsdont make sense at all like u dont know why are yiou even learning them
Gulsvi
@gulsvi
Apr 04 2018 23:31
@newtothat Back End Questions: https://gitter.im/FreeCodeCamp/HelpBackEnd
include*engine
@newtothat
Apr 04 2018 23:33
well talking sometimes solve or gives an idea to solve
we arehuman beings
Gulsvi
@gulsvi
Apr 04 2018 23:34
What are you trying to solve?
include*engine
@newtothat
Apr 04 2018 23:35
by talking i mean you can ask if someone had the same problems during their learning proces
whatever but talking is our nature can you watch a movie without any sound ? or music or a book without letters?
German Gamboa Gonzalez
@germangamboa95
Apr 04 2018 23:48
Good afternoon guys, what is everyone up to tonight?
Daniel Simeonov
@dbsimeonov
Apr 04 2018 23:53
Hey guys, can anyone from you recommend me a tutorial or article for regular expressions? Literally have no idea how I can use them but multiple times used them for challenges from FCC or Codewars.
Brad
@bradtaniguchi
Apr 04 2018 23:54
@germangamboa95 Working and trying not to die from allergies
Daniel Simeonov
@dbsimeonov
Apr 04 2018 23:54
@bradtaniguchi I saw ur message late from last night, thanks for the idea. I'm currently working on this project soon will give you heads up where I got.
CamperBot
@camperbot
Apr 04 2018 23:54
dbsimeonov sends brownie points to @bradtaniguchi :sparkles: :thumbsup: :sparkles:
:cookie: 447 | @bradtaniguchi |http://www.freecodecamp.org/bradtaniguchi
German Gamboa Gonzalez
@germangamboa95
Apr 04 2018 23:56
@bradtaniguchi Nice, how bad is the allergy season in your location?
Brad
@bradtaniguchi
Apr 04 2018 23:56
@dbsimeonov Np, :D
@germangamboa95 For me its pretty bad, if you watch TV and see the allergy commercials with people looking miserable thats me.
German Gamboa Gonzalez
@germangamboa95
Apr 04 2018 23:57
@dbsimeonov https://eloquentjavascript.net/09_regexp.html I think this one is pretty good. The video that helped me understand them is by brad traversy on his modern js udemy course.
@bradtaniguchi Lol I get it. I cannot go out during this season at all without dying. :P
Daniel Simeonov
@dbsimeonov
Apr 04 2018 23:58
@germangamboa95 ok i will check this book now, and I know Brad's courses so will check it as well. tnx
CamperBot
@camperbot
Apr 04 2018 23:58
dbsimeonov sends brownie points to @germangamboa95 :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @germangamboa95 |http://www.freecodecamp.org/germangamboa95
Brad
@bradtaniguchi
Apr 04 2018 23:58
I must be really sensitive, cuse I'm basically in lockdown and still its getting tome :/