Questions
<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <h2>Sort in Reverse</h2> <p>The reverse() method reverses the elements in an array.</p> <p>By combining sort() and reverse() you can sort an array in descending...
View Question<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <h2>The sort() Method</h2> <p>The sort() method sorts an array alphabetically:</p> <p id="workingcode1"></p> <p id="workingcode2"></p> <script> const hero = ["Antman","Spiderman","superman","Wonderwoman"]; document.getElementById("workingcode1").innerHTML = hero; hero.sort(); document.getElementById("workingcode2").innerHTML...
View Question<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <h2>The splice() Method</h2> <p>The splice() methods can be used to remove array elements:</p> <p id="workingdemo1"></p> <p id="workingdemo2"></p> <script> const hero = ["Antman","Spiderman","superman","Wonderwoman"]; document.getElementById("workingdemo1").innerHTML =...
View Question<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <h2>The toString() Method</h2> <p>The toString() method returns an array as a comma separated string:</p> <p id="workingdemo"></p> <script> const hero = ["Antman","Spiderman","superman","Wonderwoman"]; document.getElementById("workingdemo").innerHTML = hero.toString();...
View Question<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <h2>The length Property</h2> <p>The length property returns the length of an array:</p> <p id="workingdemo"></p> <script> const hero = ["Antman","Batman","Spiderman","Wonderwoman","ironman"]; let size = hero.length; document.getElementById("workingdemo").innerHTML...
View Question<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <h2>The unshift() Method</h2> <p>The unshift() method adds new elements to the beginning of an array:</p> <p id="workingcode1"></p> <p id="workingcode2"></p> <script> const hero = ["Antman","Spiderman","Superman","Wonderwoman"];...
View Question<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <h2>The shift() Method</h2> <p>The shift() method removes the first element of an array (and "shifts" the other elements to the left):</p> <p id="workingcode1"></p> <p...
View Question<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <h2>The push() Method</h2> <p>The push() method appends a new element to an array:</p> <p id="workingcode1"></p> <p id="workingcode2"></p> <script> const hero = ["Antman","Spiderman","superman","Wonderwoman"]; document.getElementById("Workingcode1").innerHTML =...
View Question<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <h2>The pop() Method</h2> <p>The pop() method removes the last element from an array.</p> <p id="workingcode1"></p> <p id="workingcode2"></p> <script> const hero = ["Antman","Spiderman","Superman","wonderwoman"]; document.getElementById("workingcode1").innerHTML =...
View Question