function trim(s)
{
    // Remove whitespace from the start of the string
    while (s.substring(0, 1) == " ")
    {
        s = s.substring(1, s.length);
    }

    // Remove whitespace from the end of the string
    while (s.substring(s.length - 1, s.length) == " ")
    {
        s = s.substring(0, s.length - 1);
    }

    return s;
}