Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Bjorn van de Peut
@bjorno43
@ICodedGod I would also advise you to use empty() instead of isset(). Simply because isset only verifies if a variable exists. It doesn't care if the value is empty or null. Empty will verify if a variable exists and if there's data in it
Of course you'll have to use if(!empty() (if NOT empty). Otherwise it'll return false while it should return true, ghehe
supercalifragilisticthisbesuchacodekid
@ICodedGod
Oh that's a good one
Christopher Barclay
@Clesoud
Hey all, I'm having tons of trouble with the Seek and Destroy problem under Basic Algorithm Scripting. I don't understand how to use the arguments after the initial array, when you don't know how many arguments will be there. And I'm having a lot of frustrating trouble removing specific items from an array that are not either at the very end or at the very beginning. My code is a jumbled mess that I have rewritten 4 or 5 times and I know this problem can't be this long to solve.
Kaz Baig
@kbaig
@Clesoud linking the problem and your code would help us help you :)
Christopher Barclay
@Clesoud
@kbaig Hey Kaz! Thanks for the reply. Can you remind me how to link both of those?
CamperBot
@camperbot
clesoud sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 552 | @kbaig |http://www.freecodecamp.org/kbaig
Christopher Barclay
@Clesoud
Copy/paste or was there a button combo to do it better?
Kaz Baig
@kbaig
@Clesoud the url of the problem, and copy-paste your code with three backticks (`) in the lines before and after your code
Christopher Barclay
@Clesoud
// Remove all the values

function destroyer(arr) {
  // create filter list filterMe and fill it with all elements in arr except arr[0]
  var filterMe = [];

  for (var z = 1; z<arr.length; z++) {
    filterMe.push(arr[z]);
  }


  // create a list of numbers which represent the indexes of arr elements to filter
  var filterIndex = [];

  // for loop through arr[0]
  for (var y = 0; y<arr[0].length; y++) {
    // for loop through filterMe 
    for (var x = 0; x<filterMe.length; x++) {
      // if arr[0][y] === filterMe[x]
      if (arr[0][y]===filterMe[x]) {
        // push the index 'x' to filterIndex
        filterIndex.push(x);   // will contain list of all indexes to splice.
      }
    }
  }


  // new array to hold elements not cut from old arr[0]
  var newArray = [];
  // keep track of how many indexes have been cut with 'count'
  var count = 0;

  // iterate through filterIndex 
  for (var q=0; q<filterIndex.length; q++) {
    // for loop through arr[0] again to find values not to cut
    for (var r=0; r<arr[0].length; r++) {
      // if filterIndex[q]===r then skip that number
      if (filterIndex[q]===r) {  // keep track of which filterIndex we're at with 'q'
        // skip and add 1 to 'count'
        count++;
      } else {
        newArray.push(arr[0][r-count]);  // will only pick up the arr[0] elements not skipped
      }
    }
  }

  return newArray;
}


//test:
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
OK lol wow that's huge
@kbaig Kaz?
Ian
@Naiguy1
@krisb1220 I looked through all of them and nothing I try works.
Kevin Galang
@kgalang
To those familiar with react, could you please help me figure out if I am doing anything wrong in this react challenge on the beta site?
Here is the link to the challenge: https://beta.freecodecamp.org/en/challenges/react/use-arraymap-to-dynamically-render-elements
Here is my current code:
const textAreaStyles = {
  width: 235,
  margin: 5
};

class MyToDoList extends React.Component {
  constructor(props) {
    super(props);
    // change code below this line
    this.state = {
      userInput: '',
      toDoList: []
    };
    // change code above this line
    this.handleSubmit = this.handleSubmit.bind(this);
    this.handleChange = this.handleChange.bind(this);
  }
  handleSubmit() {
    const itemsArray = this.state.userInput.split(',');
    this.setState({
      toDoList: itemsArray
    });
  }
  handleChange(e) {
    this.setState({
      userInput: e.target.value
    });
  }
  render() {
    const items = this.state.toDoList.map((x) => {
      return <li> {x} </li>;
    });
    return (
      <div>
        <textarea
          onChange={this.handleChange}
          value={this.state.userInput}
          style={textAreaStyles}
          placeholder="Separate Items With Commas" /><br />
        <button onClick={this.handleSubmit}>Create List</button>
        <h1>My "To Do" List:</h1>
        <ul>
          {items}
        </ul>
      </div>
    );
  }
};

The test that I am failing says:

"When the Create List button is clicked, the MyToDoList component should dynamically return an unordered list that contains a list item element for every item of a comma-separated list entered into the textarea element. };"

Ian
@Naiguy1
Guys I have been working on this code and It won't work. could you help me. (Im a noob)
function factorialize(num) {
return num;
}
var factorialize = 1 2 3 4 5 == num;
var factorialize(5);
Kevin Galang
@kgalang
@Naiguy1 I can try to help. Are you working on a challenge? Send the link if you are
Kaz Baig
@kbaig
@kgalang he wants to return num!
Kevin Galang
@kgalang
I need more context to help you out
@kgalang Im working on a challenge
Kaz Baig
@kbaig
@Naiguy1 You have to only change code inside the function
Try using a for loop
Ian
@Naiguy1
@Naiguy1 You have to only change code inside the function
what does that mean
oh, for loop
Kaz Baig
@kbaig
function factorialize(num) {
  // in here
}

// not here
Ian
@Naiguy1
ok oll try that
Kevin Galang
@kgalang
Only leave the default code outside of the function
Ian
@Naiguy1
this is what i did and it is still being weird function factorialize(num) {
var factorialize = 1 2 3 4 5 == num;
var factorialize(5);
return num;
}
Kaz Baig
@kbaig
@Naiguy1 can you explain the logic you're trying to follow
var factorialize(5) is invalid code
you use the var keyword to define variables with the name that comes right after them
Ian
@Naiguy1
it said it wasn't defined so I put "var"
function factorialize(num) {
var factorialize = 1 2 3 4 5 == num;
return num;
}
factorialize(5);
but it still is wrong
Kaz Baig
@kbaig
var factorialize = 1 * 2 * 3 * 4 * 5 == num;
what are you trying to do here
the above code means "does 120 equal num"?
Ian
@Naiguy1
Multiply it by every positive integer less than or equal to it
Kaz Baig
@kbaig
You need to go through the logic of how to calculate a factorial for any number, and try to implement that
Ian
@Naiguy1
ok, how do I make sure it it is positive
Kaz Baig
@kbaig
Well, what logical steps do you have in mind right now?
Ian
@Naiguy1
Using < ,>,and <= to make it a less than or equal to it but positive.
Kaz Baig
@kbaig
No I mean in plain english, what steps do you take to go from a number to the factorial of that number
Ian
@Naiguy1
I have to multiply it by every positive integer that is less than or equal to it. So I will use <= to find all integers less than or equal to it then, I will use > to narrow it down to all that are above 0.
Then some how i will multiply it by them in order.