<!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>
No comments:
Post a Comment