ApexSensei

Drills Apex basics

Quick win: double a number

A method takes input and gives back a value with return.

Your task

Fill in the body of twice so it returns the input doubled.

Integer twice(Integer n) {
    return null;
}

Requirements

  1. twice(4) should be 8
  2. twice(0) should be 0
  3. twice(-3) should be -6
  4. twice(<hidden>) should be double its input

Sign in to open this drill