smovidya / linenotify

0 stars 0 forks source link

Best practices to write Javascript #1

Open bunnybunbun37204 opened 5 months ago

bunnybunbun37204 commented 5 months ago

Best practices rules

  1. Use let instead of var for the variables that need to be changed.
  2. Use const instead of var for the variables that won't be changed.
  3. Chage
      try {
        var response = UrlFetchApp.fetch(lineNotifyEndPoint, options);
      }
      catch (error)  {
         Logger.log(error.name + ":" + error.message);
         return;
      }
     if (response.getResponseCode() === 200) {
         Logger.log("Sending message completed.");
      }

    To

    
      try {
        const response = UrlFetchApp.fetch(lineNotifyEndPoint, options);
        if (response.getResponseCode() === 200) {
              Logger.log("Sending message completed.");
           }
      }
      catch (error)  {
         Logger.log(error.name + ":" + error.message);
         return;
      }

4. Maintain consistent indentation, spacing, and naming conventions. Use tools like **ESLint** to enforce coding standards.
bunnybunbun37204 commented 5 months ago

Geng mak mak kub Good Job