Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 07 03:10
    @bjorno43 banned @doctor-sam
  • Aug 17 2019 09:33
    User @bjorno43 unbanned @linkin-park
  • Jun 20 2019 21:19
    @bjorno43 banned @shenerd140
  • May 10 2019 09:13
    @bjorno43 banned @zhaokunhaoa
  • Apr 25 2019 17:12
    @mstellaluna banned @cmal
  • Apr 01 2019 18:11
    thecodingaviator labeled #31179
  • Apr 01 2019 18:11
    thecodingaviator labeled #31179
  • Apr 01 2019 18:09
    thecodingaviator commented #31179
  • Apr 01 2019 18:09
    thecodingaviator labeled #31182
  • Apr 01 2019 18:09
    thecodingaviator labeled #31182
  • Apr 01 2019 18:07
    thecodingaviator commented #31182
  • Apr 01 2019 18:07
    thecodingaviator labeled #31190
  • Apr 01 2019 18:07
    thecodingaviator labeled #31190
  • Apr 01 2019 18:07
    thecodingaviator commented #31190
  • Apr 01 2019 18:05
    thecodingaviator commented #31157
  • Apr 01 2019 18:04

    thecodingaviator on master

    remove A (#31157) (compare)

  • Apr 01 2019 18:04
    thecodingaviator closed #31157
  • Apr 01 2019 18:04
    thecodingaviator closed #33788
  • Apr 01 2019 18:04
    thecodingaviator commented #33788
  • Apr 01 2019 18:02
    thecodingaviator closed #31059
Alexander Køpke
@alexanderkopke
a
Tom
@moT01
@FlashHero yes, its free - pretty sure they site themselves
https://s.codepen.io/moT01/pen/vgOaoJ - did it on my portfolio
aRtoo
@artoodeeto

hello guys how do you get the values of a cell in a table in vanilla javascript?

<table id="myTable">
  <tr>
    <td id="uno">HELLO</td>
    <td>HI</td>
  </tr>
</table>

this doesnt work. document.getElementById('uno').value

Claudio Restifo
@Marmiz
use innerText or innerHtml instead of value
aRtoo
@artoodeeto

hello guys im doin my tictactoe but on this part of the code is not working

function checkGame() {

    //loops thru the winCombo array of arrays
    for (var i=0; i<winCombo.length; i++) {
        for (var j=0; j<winCombo[i].length; j++) {
            //takes the values or text of the cells 
            var uno = document.getElementById(winCombo[i][0]).textContent;
            var dos = document.getElementById(winCombo[i][1]).textContent;
            var tres = document.getElementById(winCombo[i][2]).textContent;

            //if theres no text on each cells
            if (uno === '' && dos === '' && tres === '') {
                break;
            } 
            //checks if the variables have the same text value
            else if (uno === dos && uno === tres) {
                  //if true remove the eventlistener then alart a winner
                  console.log('this will show if the condtion is true but loop is not working');  
                  for(var c=0; c<cells.length; c++) 
                    {  
                        cells[c].removeEventListener('click', function(){
                            alert('shit!!!!')
                        });
                    }
            }
        }
    }
}

but the console.log is show and the for loop to remove the event is not working.
heres the pen https://codepen.io/artoo/pen/Zvomxr

aRtoo
@artoodeeto
nevermind i got it now thanks
mitchell369
@mitchell369
Hello, I would like to know more about the Boolean value in the solution for the falsy bouncer. What is implied when you just simply state "boolean"? Most docs I come across haven't really explained it adequately from what i've learned
Dan Couper
@DanCouper
boolean refers to a logical boolean value, it's either true or false (maths/logic, not JS).
mitchell369
@mitchell369
but why does it's use with filter only return true values?
Dan Couper
@DanCouper
Also Boolean() is a JS function that converts whatever you pass to it to true or false
I think you're referring to that rather than the concept in general
mitchell369
@mitchell369
@DanCouper I am more interested in it's properties as a value
Dan Couper
@DanCouper
Not quite sure what you mean
boolean is not a value
mitchell369
@mitchell369
return arr.filter(Boolean);
Dan Couper
@DanCouper
That's the function
It's not a value
mitchell369
@mitchell369
why will it return only truthy values in a given array
Dan Couper
@DanCouper
It's the same as writing
arr.filter(value => Boolean(value))
It is running the Boolean function for each value in the array
mitchell369
@mitchell369
hmmm interesting that it is assumed rather than requiring definition
Dan Couper
@DanCouper
Not assumed, it's called beta or zeta reduction, I forget which
Can be a bit confusing
mitchell369
@mitchell369
but why don't you need to specify that filter should only retain truthy values?
what operator returns only falsy values?
Dan Couper
@DanCouper
The filter function takes an array, and runs a given function on every element in the array. It returns a new array for every element the given function returns true
So like
[1,2,3].filter(value => value > 1) - this returns [2,3] because those are the values greater than one - the function given says return true if the value is greater than 1
And re Boolean
mitchell369
@mitchell369
but merely passing Boolean through the function is sufficient to produce this interpretation... no comparison operators necessary...
Dan Couper
@DanCouper
Boolean(0) returns false, Boolean(1) returns true, Boolean(null) returns false, Boolean("hello") returns true
The Boolean function coerces anything you give it to true or false according to the rules of JS
mitchell369
@mitchell369
Yah I tihnk I get it, it already has a defined set of rules to produce true and false, filter only produces values that are assigned as true
true is already pre-defined in the function
thank you @DanCouper
CamperBot
@camperbot
mitchell369 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 863 | @dancouper |http://www.freecodecamp.org/dancouper
Dan Couper
@DanCouper
There is another aspect to this - the Boolean function is used by JS under the hood for filter anyway - anything you give to filter, JS will try to convert to true or false to make sure that it doesn't blow up, that it always returns something. So you can do
`arr.fipt
So
arr.filter(value => value)
i.e. a function that just returns the value you give it
Because
Filter already takes that value and converts it to true or false
mitchell369
@mitchell369
are you saying arr.fipt == arr.filter (value => value) ?
Markus Kiili
@Masd925
@mitchell369 arr.filter (value => value) filters in truthy array elements, the same as arr.filter (Boolean).
Dan Couper
@DanCouper
arr.fipt is me mistyping @mitchell369