Get the sum of two arraysβ¦actually the sum of all their elements. P.S. Each array includes only integer numbers. Output is a number too.
let arr_1 = [3, 5, 22, 5, 7, 2, 45, 75, 89, 21, 2]; // --> 276
let arr_2 = [9, 2, 42, 55, 71, 22, 4, 5, 90, 25, 26]; // --> 351
// Example output:
// 276 + 351 = 627
Using a for loop print all even numbers up to and including n. Donβt include 0.
let n1 = 22;
// Example output:
// 2 4 6 8 10 12 14 16 18 20 22 OR each item on a new line
Using a for loop output the elements in reverse order
let arr = [43, "what", 9, true, "cannot", false, "be", 3, true];
// Example output:
// true 3.5 be false cannot true 9 what 43 OR each item on a new line
Given two arrays of integers. Add up each element in the same position and create a new array containing the sum of each pair. Assume both arrays are of the same length.
let arr_3 = [4, 6, 7];
let arr_4 = [8, 1, 9];
// Example output:
// [12, 7, 16]
Check if a string contains the letter βyβ. Print βyesβ if it does and βnoβ if it does not.
let str2 = "donβt know why";
// Example output:
// βyesβ
Given a number n Calculate the factorial of the number
let n2 = 4; // 4 * 3 * 2 * 1 = 24
// Example output:
// 24
Write a program that will check if two strings are palindromes. A palindrome is a word that spells the same forward and backward. Palindrome: a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run.
let str3 = "racecar";
let str4 = "Java";
// Example output:
// string1 palindrome?:
// Yes
// string2 palindrome?:
// No
Iterate through all numbers from 1 to 45. Print the following:
- For multiples of 3 print βFizzβ
- For multiples of 5 print βBuzzβ
- For multiples of 3 and 5 print βFizzBuzzβ
Print all the elements of the following array(with for loop)
const thisIsAnArray = ["element1", "element2", "element3", "element4"];
Print the EVEN numbers from 10 to -20
input: 10 and -20;
output: 10,8,6,4,2,0,-2,-4,-6,-8..