How do I include one JavaScript file inside another?

Hey @sakshikuchroo, if you’re working in a Node.js environment or using bundlers like Webpack or Rollup, you can use CommonJS require() syntax to include files:

// utils.js
function greet(name) {
  return `Hello, ${name}!`;
}
module.exports = greet;

// main.js
const greet = require('./utils.js');
console.log(greet('sakshikuchroo'));

This won’t work natively in browsers but is very common in backend Node.js code or frontend projects that use build tools to bundle modules before deployment.

So if you’re planning to scale or use tooling, this is a solid approach.