JS
challenger
JS
challenger
  • Getting Started
  • Overview
  • Random Challenge
  • Javascript Basics
    • - Sum two numbers
    • - Comparison operators, strict equality
    • - Get type of value
    • - Get nth character of string
    • - Remove first n characters of string
    • - Get last n characters of string
    • - Get first n characters of string
    • - Extract first half of string
    • - Remove last n characters of string
    • - Return the percentage of a number
    • - Basic JavaScript math operators
    • - Check if a number is even
    • - How many times does a character occur?
    • - Check if a number is a whole number
    • - Multiplication, division, and comparison operators
    • - Check whether a string contains another string and concatenate
    • - Round a number to 2 decimal places
    • - Split a number into its digits
    • - Clear up the chaos behind these strings
    • - Return the next higher prime number
    • - Find next higher natural number that is divisble by y
    • - Insert character after every n characters (backwards)
    • - Find the correct word by incrementing letters in alphabet
  • Javascript Arrays
  • Javascript Objects
  • Javascript Dates
  • Javascript Sets
  • Javascript DOM
    NEW
  • Challenge Rush
Imprint Privacy Policy

Extract first half of string

// Write a function that takes a string (a) as argument
// Extract the first half a
// Return the result
function
myFunction
(
a
)
{

return
}
Test Cases:
myFunction('abcdefgh')
Expected
'abcd'
myFunction('1234')
Expected
'12'
myFunction('gedcba')
Expected
'ged'
Twitter_Logo_White-on-Blue
Follow