C code added
added javascript solution