2
2

More than 5 years have passed since last update.

三項演算子の吐き出し方がわからなかったけど解決した

Posted at

正直まだよくわかってないかもしれませんが……。つっこみどころとか、ここはこうしたほうがいいよとか、もっと外交に力を入れろとか、なんでも言ってください。

var bust = 76;
var happy = (bust >78) ? touch : photoshop;

これだとエラーになる。なんで何にも吐き出されないの? と疑問に思っていたのですが、
コンソール・ログをつけていませんでした。テストに名前書き忘れて落第した気分です。

var bust = 76;
var happy = (bust > 78) ? console.log("touch") : console.log("photoshop");

でも調べてみると、三項演算子は一行で済むとかいてある。bustに値を代入しなければならないので、複数行になるのでは……?

2
2
4

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
2
2