Today I have learned For case in javascript

  For case in javascript:

this.state = {
      user1:[],
      user:5,
      name:[],
      name1:['Ari', 'Bob', 'Charlie', 'David', 'Eswar'],
render() {
  const numberOfItems = 5;
    const items = [];

    for (let i = 1; i <=this.state.user; i++) {
      this.state.user1.push(<li key={i}>Item {i}</li>);
    }
    const users = ['Ari', 'Bob', 'Charlie', 'David', 'Eswar'];

    const userListItems = [];
    for (let i = 0; i < this.state.name1.length; i++) {
    this.state.name.push(<li key={i}>{users[i]}</li>);
    }
    return (
      <div>
        <h2>list</h2>
        <ul>{this.state.user1}</ul>
        <h2>User List:</h2>
        <ul>{this.state.name}</ul>
Output:


Comments

Popular posts from this blog

Building a Full-Stack Student Management System with React.js and NestJS

Today I have solved the problem in javascript

Today I have solved problem in javascript