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.

    Before you keep reading...

    Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.

  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