AllisonC
AllisonC

Reputation: 3099

Why am I getting 'Unexpected 1' in JSHint?

var canvas = document.createElement('canvas'),
    ctx = canvas.getContext("2d"); //Create the context

//more code (width, height defined elsewhere)
ctx.beginPath();
ctx.moveTo(0.35 * width, 0);
ctx.lineTo(0.35 * width, 0.65 * height);
ctx.lineTo(1 * width, 0.65 * height); //JSHint is complaining about the 1 here
ctx.stroke();

Why am I getting an error here?

Upvotes: 2

Views: 244

Answers (3)

Sjoerd de Wit
Sjoerd de Wit

Reputation: 2413

Why don't you just use :

ctx.lineTo(width, 0.65 * height);

as far as i can tell 1 * anything will most likely give the same result

Upvotes: 0

Vladimirs
Vladimirs

Reputation: 8599

That happens because multiplication by 1 is redundant.

Upvotes: 2

Scottux
Scottux

Reputation: 1577

It is a meaningless operation, multiplying by 1 doesn't do anything. Just use width.

Upvotes: 5

Related Questions