преобразовать C в JavaScript

/*
C               | JS
-----------------|------------------
 int x;          | var x;
-----------------|------------------
 int xs[n];      | var xs = [];
-----------------|------------------
 printf(...)     | console.log(...)
-----------------|------------------
 int f (int x) { | function f (x) {
   ...           |   ...
   return y;     |   return y;
 }               | }
The remaining syntax from your post is almost identical in C and JS.

Press F12 in your browser (Chrome or Firefox) and have some fun with JavaScript ​in the "Console" tab, it's a good starting point :-) For example, copy paste the below code into the browser console and press ENTER.
*/

function add (a, b) {
  return a + b;
}
console.log("1 + 1 =", add(1, 1));
add(1, 2);
Akshay Vs