Offer Ends Today | 80% + 10% Off & 30-days Extra Lab | Use Coupon Code MSD on Checkout |

  Enroll Now


20 / 52

Scala - Assessment - Write function to remove vowels

Let's now write a program which will remove all vowels from a given string.

Here, we will write a scala program whose main class name is Purge having a function named purgeVowels which would take a string as input and return another string with all vowels removed from the input string.

Usage Example:

Purge.purgeVowels("New York") should return "Nw Yrk".

  • Switch to Jupyter tab.

  • Write the code in Jupyter.

The program skeleton will look like this. Complete the code of the function in this to remove the vowels from the input string.

object Purge {
   def purgeVowels( str:String ) : String = {
      return .....

  • Press Shift+Enter.

  • Test the function with various inputs to make sure that it is returning the outputs as per requirements.

  • Click on "Submit Answer".