patorjk / JavaScript-Snake

The game of Snake written in JavaScript.
MIT License
536 stars 631 forks source link

Request to Refactor var to let and const #116

Closed dmcote-1991 closed 1 month ago

dmcote-1991 commented 1 month ago

Proposal: Refactor var Declarations to let and const

I would like to propose a refactor of the code to replace var declarations with let and const where appropriate. This change aims to improve code readability and adhere to modern JavaScript best practices.

Proposed Changes

Benefits

Example

Here’s a snippet of the code I am referring to:

Current Code:

var SNAKE = SNAKE || {};
var instanceNumber = 0;
var blockPool = [];

Proposed Changes

I propose changing the code to:

const SNAKE = SNAKE || {};
let instanceNumber = 0;
const blockPool = [];

Questions

  1. Are there any concerns about making these changes?
  2. Is there any additional context or consideration I should be aware of before proceeding?

Thank you for considering this refactor. I believe it will contribute to a cleaner and more maintainable codebase.

patorjk commented 1 month ago

Yep, it’s been a while since I’ve used var, this code is just very old (written before those were apart of the language). I’d be fine with such a refactor.

dmcote-1991 commented 1 month ago

Great! I'll start getting to work on it. Thank you for the opportunity :)

dmcote-1991 commented 1 month ago

Hi patorjk,

I've created a Pull Request to address issue #116, where I refactored var to let and const. Please take a look when you have a chance!

Thanks!

patorjk commented 1 month ago

Looks good, thank you!

patorjk commented 1 month ago

@all-contributors please add @dmcote-1991 for code.