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

CPU vs GPU Architecture

  CPU vs GPU Architecture CPU (Central Processing Unit) and GPU (Graphics Processing Unit) have distinct architectural differences, optimize...

Best for you