1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[書籍] JavaScript フレームワーク入門 86ページ誤植

Last updated at Posted at 2016-10-08

JavaScript フレームワーク入門の86ページでタイプエラーになったので、以下のように修正してみました。
querySelectorが、HTMLInputElement型を返さないところと、valueの戻り値がstring型でエラーとなっていました。

function calc(price:number, tax:number):number {
    return Math.floor(price * (1.0 + tax));
}

function doClick():void {
    let text1:HTMLInputElement = <HTMLInputElement>document.querySelector('#text1');
    let msg:Element = document.querySelector('#msg');
    msg.innerHTML = calc(Number(text1.value), 0.08) + '';
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?