Arrays
Arrays
Arrays
arr.push(element);
return arr;
function removeLastElement(arr) {
return arr.pop();
function sumArray(arr) {
Reverse Array:
function reverseArray(arr) {
return arr.reverse();
return mergedArray;
function capitalizeStrings(arr) {
function findLongestString(arr) {
return arr.reduce((longest, current) => (current.length > longest.length ? current : longest), '');
}
Strings
Reverse a String:
function reverseString(str) {
return str.split('').reverse().join('');
function isPalindrome(str) {
function titleCase(str) {
function longestWord(str) {
return str.split(' ').reduce((longest, current) => (current.length > longest.length ? current : longest),
'');
function countVowels(str) {
return mainString.includes(substring);
Objects
Add a New Key-Value Pair to an Object:
obj[key] = value;
return obj;
}
Delete a Property from an Object:
delete obj[key];
return obj;
function getAllKeys(obj) {
return Object.keys(obj);
function getAllValues(obj) {
return Object.values(obj);
function objectLength(obj) {
return Object.keys(obj).length;
}
function deepCopy(obj) {
return JSON.parse(JSON.stringify(obj));
DOM
document.getElementById('myElement').style.display = 'none';
document.getElementById('myHiddenElement').style.display = 'block';
document.body.appendChild(newParagraph);
elementToRemove.parentNode.removeChild(elementToRemove);
document.getElementById('myImage').setAttribute('src', 'image.jpg');
console.log(inputValue);
document.getElementById('myElement').style.backgroundColor = 'blue';
Functions
function squareNumber(num) {
return num ** 2;
}
Write a Function to Check if a Number is Even or Odd:
function checkEvenOdd(num) {
return arr1.concat(arr2);
function hoursToSeconds(hours) {
function factorial(num) {
return 1;
} else {
}
Write a Function that Returns the N-th Fibonacci Number:
function fibonacci(n) {
if (n <= 1) {
return n;
} else {
return str.endsWith(suffix);
function findGreatestNumber(arr) {
return Math.max(...arr);