Help us understand the problem. What is going on with this article?

ブックマークレット作成でハマったこと一覧

if文の指定方法 = ではなく、==で動く

動かない
let a=window.prompt('好きな野菜を選択してください\rきゅうりなら【1】 / トマトなら【2】','');
if(a = 1){a='きゅうり'}else{a='トマト'};
動く
let a=window.prompt('好きな野菜\rきゅうりなら【1】 / トマトなら【2】','');
if(a == 1){a='きゅうり'}else{a='トマト'};
kenny-000
サーバーエンジニア1年生。 細かな作業を自動化するため思考錯誤。 先輩ハッカーの皆様、コメントいただけると幸いです。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした