2.8. ExercisesΒΆ

  1. Translate the following into Javascript:

    def sumlist(l):
        total = 0
        for num in l:
            total = total + num
    
        return total
    
  1. Write a function that accepts an array of numbers and returns the largest number in the array.

  1. Write a function that constructs an Array containing the first 10 prime numbers

  1. Write a function that removes all occurrences of a given letter from a string. The first parameter should be the letter and the second parameter the string.

  1. Write a function that takes a string as a parameter and returns the reversed string

  1. Write a function that takes an integer as an argument and returns the number of digits in the integer.

  1. Write a function that recognizes palindromes. The function takes a string as a parameter and returns true if the string is a palindrome and false if it is not

    Before you keep reading...

    Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.