Simple Way Reverse Javascript Array

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Simple Way Reverse Javascript Array</title>
</head>
<body>
<button onclick="checkFunc()">Click</button>
<script type="text/javascript">
function checkFunc() {
const newArray = [1,2,3,4,5,6,7,8];
const copyArray = []
for(let i=7;newArray.length-1; i--){
let tp =  newArray[i];
if(tp>0 && newArray.length>=0)
{
copyArray.push(tp)
console.log(copyArray)
}
}
}
</script>
</body>
</html>




Simple Way Reverse Javascript Array

No comments:

Post a Comment

SQL Commands - essentials

  SELECT # Retrieve data from the database FROM # Specify the table to select data from WHERE # Filter rows based on a condition AS # Rename...

Best for you