Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

convert c to 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);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #javascript
ADD COMMENT
Topic
Name
6+6 =