I have the following function, which should return different values based on the head's text:
function getPage(){
  var page;
  var headText = $.trim($('h1').text());
if(headText=="Page 1"){
    page= 'a';
}else if(headText=="Page 2"){
    page= 'b';
}else if(headText=="Page 3"){
    page ='c';
}else if(headText=="Page 4"){
    page= 'd';
}else{
    page= 'ERROR';
}
return page;
}
Unfortunately, the function only returns "ERROR". I've tried it without the trim method. I've tried it by writing Page 1 - Page 4 into variables of their own and comparing 2 variables in the if() section. Nothing works. Where is my error? (I am certain that the text of the < h1>- Element is "Page 1", "Page 2", "Page 3" or "Page 4")
 
     
     
    