'html' is never reassigned. Use 'const' instead
131 $("#download").on("click", function () {
132 // Add download markdown as a file
133 var element = document.createElement("a");
134 let html = generateHTML(team);135 // Download generated html as a file
136 // Open window to download file to local machine
137 var file = new Blob([html], { type: 'text/html' });
'html' is never reassigned. Use 'const' instead
120 $("#generate").on("click", function () {
121 // Add download markdown as a file
122 var element = document.createElement("a");
123 let html = generateHTML(team);124 // Open a new window with the generated HTML
125 var win = window.open();
126 win.document.write(html);
'team' is never reassigned. Use 'const' instead
7import Intern from "../../lib/Intern.js"
8
9
10let team = []; 11// Function to create manager card using jquery
12const creteListItem = (employee) => {
13 // Create a div with class card
'takenIDs' is never reassigned. Use 'const' instead
10
11// helper code
12const generateHTML = require('./src/generateHTML');
13let takenIDs = []; 14
15const introQuestion = [
16 {
'teamArray' is never reassigned. Use 'const' instead
300];
301
302// variables to hold created objects and document name
303let teamArray = [];304let documentName = '';
305
306const writeToFile = (documentName, documentBody) => {
'fileName' is never reassigned. Use 'const' instead
304let documentName = '';
305
306const writeToFile = (documentName, documentBody) => {
307 let fileName = "./dist/" + documentName;308 fs.writeFile(fileName, documentBody, (err) =>
309 err ? console.error(err) : console.log("HTML document successfully created at " + fileName));
310
Description
Variables that are never re-assigned a new value after their initial declaration should be declared with the const
keyword.
This prevents the programmer from erroneously re-assigning to a read-only variable, and informs those reading the code that a variable is a constant value.
Bad Practice
let pi = Math.PI
for (let x of xs) {
use(x);
}
let { a, b } = object;
use(a, b);
Recommended
const pi = Math.PI
for (const x of xs) {
use(x);
}
const { a, b } = object;
use(a, b);