30 Questions for JavaScript for If statement practical (for programming) only

🟢 Beginner Programs (1–10)

  1. Write a program to check if a number is positive, negative, or zero.
  2. Write a program to check if a number is even or odd.
  3. Write a program to check if a person is eligible to vote (age ≥ 18).
  4. Write a program to check if a number is greater than 100.
  5. Write a program to check if a year is a leap year.
  6. Write a program to check if a character is a vowel or consonant.
  7. Write a program to check if a number is divisible by 5.
  8. Write a program to find the maximum of two numbers.
  9. Write a program to find the minimum of three numbers.
  10. Write a program to check whether a number is a multiple of both 3 and 7.

🟡 Intermediate Programs (11–20)

  1. Write a program to calculate grade based on marks.
  2. Write a program to check whether a character is uppercase or lowercase.
  3. Write a program to check if a number is a 3-digit number.
  4. Write a program to check whether a triangle is valid.
  5. Write a program to check the type of triangle (equilateral, isosceles, scalene).
  6. Write a program to check whether a number is a palindrome.
  7. Write a program to check whether a number is an Armstrong number.
  8. Write a program to calculate electricity bill using slab rates.
  9. Write a program to check if a user can login (username & password match).
  10. Write a program to check whether a number is divisible by 2, 3, or both.

🔴 Advanced Programs (21–30)

  1. Write a program to check if a number is prime.
  2. Write a program to calculate bonus based on salary and experience.
  3. Write a program to check whether a date is valid.
  4. Write a program to check whether a number is positive even, positive odd, or negative.
  5. Write a program to calculate income tax based on salary slabs.
  6. Write a program to check whether a character is a digit, alphabet, or special character.
  7. Write a program to check whether a number is divisible by 4 but not by 6.
  8. Write a program to check password strength using conditions.
  9. Write a program to determine the day of the week using number (1–7).
  10. Write a program to check whether a number is perfect or not.

datatable default show 100

$(document).ready(function() {
$('#example').DataTable( {
"lengthMenu": [[100, "All", 50, 25], [100, "All", 50, 25]],
"pageLength": 50

} );
} );

javascript code for make slugs

replace all non-alphanumerical characters with dashes

<script>
  $("#inputSlug").keyup(function() {
  var Text = $(this).val();
  Text = Text.toLowerCase();
  Text = Text.replace(/[^a-zA-Z0-9]+/g,'-');
  $("#inputSlug").val(Text);        
});
</script>

drag and drop folder upload JavaScript with php

<!-- Drag Drop Upload Code -->

<p>Drag files and/or directories to the box below!</p>

<div id="dropzone">
  <div id="boxtitle">
    Drop Files Here
  </div>
</div>

<h2>Directory tree:</h2>

<ul id="listing"></ul>

<script>
var dropzone = document.getElementById("dropzone");
var listing = document.getElementById("listing");

function scanAndLogFiles(item, container) {
  var elem = document.createElement("li");
  elem.innerHTML = item.name;
  container.appendChild(elem);
  if (item.isDirectory) {
    console.log('DIR '+item.webkitRelativePath);
  }
  if (item.isFile) {
    console.log('FILE '+item.webkitRelativePath);
  }
  if (item.isDirectory) {
    var directoryReader = item.createReader();
    var directoryContainer = document.createElement("ul");
    container.appendChild(directoryContainer);

    directoryReader.readEntries(function(entries) {
      entries.forEach(function(entry) {
        scanAndLogFiles(entry, directoryContainer);
      });
    });
  }
}

dropzone.addEventListener(
  "dragover",
  function(event) {
    event.preventDefault();
  },
  false
);

dropzone.addEventListener(
  "drop",
  function(event) {
    var items = event.dataTransfer.items;

    event.preventDefault();
    listing.innerHTML = "";

    for (var i = 0; i < items.length; i++) {
      var item = items[i].webkitGetAsEntry();

      if (item) {
        scanAndLogFiles(item, listing);
      }
    }
  },
  false
);
</script>
<style>
#dropzone {
  text-align: center;
  width: 300px;
  height: 100px;
  margin: 10px;
  padding: 10px;
  border: 4px dashed red;
  border-radius: 10px;
}

#boxtitle {
  display: table-cell;
  vertical-align: middle;
  text-align: center;
  color: black;
  font: bold 2em "Arial", sans-serif;
  width: 300px;
  height: 100px;
}
</style>

Put the record count at the top of the table instead of the bottom

    <script>
         $(document).ready(function() {

$('#example').DataTable( {
/*  "aoColumnDefs": [
      { 'bSortable': false, 'aTargets': [ 0 ] }
   ]*/
   "columnDefs": [
    {"orderable": true, "targets": [1] },
    {'searchable' : true, 'targets' : [1] 
},
],
"dom": '<"wrapper"flipt>', //total on top of datatable jquery
});

});
$(document).ready(function(){
 //Date range picker
  $('#reservation').daterangepicker()
});
    </script>

DataTables Tricks

Example 1


 $(document).ready(function() {

  $( "#selectType" ).change(function() {
  $('#example_filter input[type="search"]').val($(this).val()).keyup();
});

$('#example').DataTable( {
/*  "aoColumnDefs": [
      { 'bSortable': false, 'aTargets': [ 0 ] }
   ]*/
   "columnDefs": [
    { "orderable": false, "targets": [1] },
    { 'searchable'  : false, 'targets' : [9] 
},
    
],
"order": [[ 1, "desc" ]],
//"dom": 'Plfrtip',
"dom": '<"wrapper"flipt>', //total on top of datatable jquery
//"dom": 'lrtip',
//"dom": '<lf<t>ip>',
//"dom": '<"top"i>rt<"bottom"flp><"clear">',
searchPanes: {
            viewTotal: true
        },
        "orderCellsTop": true,
        "fixedHeader": true,
});

});

Example 2

$(document).ready(function() {
    // Setup - add a text input to each footer cell
    $('#example tfoot th').each( function () {
        var title = $(this).text();
        if(title == 'Status'){
        $(this).html( '<input type="text" size="5px" placeholder="'+title+'" />' );
        }
    });
 
    // DataTable
    var table = $('#example').DataTable({
        initComplete: function () {
            // Apply the search
            this.api().columns().every( function () {
                var that = this;
 
                $( 'input', this.footer() ).on( 'keyup change clear', function () {
                    if ( that.search() !== this.value ) {
                        that
                            .search( this.value )
                            .draw();
                    }
                } );
            } );
        },
        "columnDefs": [
        { "orderable": false, "targets": [1] },
        { 'searchable'  : false, 'targets' : [10] 
    },
        
    ],
    //"order": [[ 5, "asc" ]]
    });
 
} );

how to check reactjs version

Open package.json file check react version under dependencies

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.1.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}