Using date.js to get last Sunday
Date.today().moveToDayOfWeek(0, -1); // -1 indicates to go back
Best to use a library to manipulate dates. It will make your life a lot easier.
Having said that have a long-term aim to understand dates in JavaScript. It will help you with things like debugging.