質問編集履歴
1
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,40 +52,52 @@
|
|
52
52
|
|
53
53
|
$('#search').click(function() {
|
54
54
|
|
55
|
-
|
55
|
+
let money = $('.main-top__content--money').val();
|
56
56
|
|
57
|
-
|
57
|
+
let style = $('.main-top__content--style').val();
|
58
58
|
|
59
59
|
|
60
60
|
|
61
|
-
if(money==1 && style==1) {
|
62
|
-
|
63
|
-
const nonce = Math.floor(Math.random()*tops.length);
|
64
|
-
|
65
|
-
|
61
|
+
let totalprice = 0;
|
66
|
-
|
67
|
-
const price = tops[nonce].price;
|
68
62
|
|
69
63
|
|
70
64
|
|
71
|
-
|
65
|
+
|
72
66
|
|
73
|
-
|
67
|
+
console.log(money);
|
74
68
|
|
75
|
-
|
69
|
+
$('#result').empty();
|
76
70
|
|
77
|
-
}
|
78
71
|
|
79
|
-
|
80
72
|
|
81
|
-
|
73
|
+
do {
|
74
|
+
|
75
|
+
let nonce = Math.floor(Math.random()*tops.length);
|
76
|
+
|
77
|
+
let name = tops[nonce].name;
|
78
|
+
|
79
|
+
let price = tops[nonce].price;
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
totalprice += price;
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
$('#result').append("商品名"+ " "+ name + " " +price + "円" + "<br>");
|
88
|
+
|
89
|
+
$('#totalPrice').append("合計金額"+ totalprice + "円");
|
90
|
+
|
91
|
+
// append(); 要素の追加
|
92
|
+
|
93
|
+
} while (totalprice <= money );
|
94
|
+
|
95
|
+
|
82
96
|
|
83
97
|
|
84
98
|
|
85
99
|
});
|
86
100
|
|
87
|
-
|
88
|
-
|
89
101
|
});
|
90
102
|
|
91
103
|
```
|