function undefined - but works in console

javascript, jquery

Solution

The function doesn't have a `return` statement, so it returns `undefined`.

Add one.

function currentImageKey() {
  return $('#akslide ul li.active').index();
}

Problem

I have simple code like this: ``` function currentImageKey() { $('#akslide ul li.active').index(); } ``` If I simply call the function in console, I get "undefined". Else, if I run the content of the function directly, like this ``` $('#akslide ul li.active').index(); ``` It works and I get the index. Why is it not working? Many thanks for your help.

Original source