Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

基本的な型の利用 #45

Closed
MofuMofu2 opened this issue Sep 20, 2023 · 3 comments · Fixed by #46
Closed

基本的な型の利用 #45

MofuMofu2 opened this issue Sep 20, 2023 · 3 comments · Fixed by #46

Comments

@MofuMofu2
Copy link
Owner

リハビリのためGPT-4にお題を出してもらい、解いてみる。

基本的な型の利用:

変数に文字列、数値、真偽値を持つオブジェクトを定義して、それらの変数をコンソールに出力する関数を作成してください。

@MofuMofu2
Copy link
Owner Author

変数に文字列・数値・真偽値を持つオブジェクトを定義する。内容は自由なので、次のような型を作る。

type User = {
  name: string;
  id: number;
  active: boolean;
}

で、これを変数で定義し、console.logに出力すればいい。

@MofuMofu2
Copy link
Owner Author

実行してみた。要件を満たせていそうなのでGPTに採点してもらう。

mofumofu at mofunoMacBook-Air in ~/git/typescript-sandbox (45-type●●)
$ npx tsc src/practice-types/practice-type.ts

mofumofu at mofunoMacBook-Air in ~/git/typescript-sandbox (45-type●●)
$ node src/practice-types/practice-type.js
{ name: 'mofu', id: 1, active: true }

@MofuMofu2
Copy link
Owner Author

採点してもらった。この勉強法いいかもしれないな

提出いただいたコードを確認しました。以下に詳細を記載します。

  1. 型の定義:

    • User という型を適切に定義しています。ここでの要件(文字列、数値、真偽値の変数を持つオブジェクト)をしっかりと満たしています。
  2. 変数の定義:

    • user という変数を正しく定義し、前述の型 User を適用しています。
  3. コンソール出力:

    • 作成したオブジェクトを正しくコンソールに出力しています。

採点結果: 100点

コードはシンプルかつ要件を正確に満たしています。素晴らしいです!次のお題にも挑戦してみてください。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant