function help

Hey guys

Iam a newbie.Previously u guyz helped me.Thanks alot.Iam writing a small and easy script to call a function.but it is showing me error.

Here is the example iam writing

demo()
{
echo -n "hello this is a demo"
}
echo -n " do u want to see a demo or not (y/n):"
read ans
if [["$ans" = "$y"]]
demo
fi
if [["$ans" = "$n"]]
exit
fi

For this script iam getting error.And also if i want to run it for ksh.Is it going to same or the script gonna change.Please help me guyz.

Thanks
CoolKid

use code tags next time.

demo()
{
  echo  "hello this is a demo"
}
echo " do u want to see a demo or not (y/n):\c"
read ans
if [[ "$ans" = "y" ]]; then
    demo
fi
if [[  "$ans" = "n" ]] ; then 
      exit
fi

I made few changes like adding spaces before ]] and after [[ and "then" keywords
Try to read and see the differences.

Thanks dud..it works..ur awesome!!!