回答編集履歴

1

コードの修正

2018/10/04 13:32

投稿

spookybird
spookybird

スコア1803

test CHANGED
@@ -32,13 +32,13 @@
32
32
 
33
33
  // backgroundColorの初期値がrgba(0, 0, 0, 0)であることを利用して
34
34
 
35
- // 存在しない色名だったらnullを返す
35
+ // 存在しない色名だったら「未登録」を返す
36
36
 
37
- if (color.includes('rgba')) return null;
37
+ if (color.includes('rgba')) return '未登録';
38
38
 
39
39
 
40
40
 
41
- const colorCode = '#' + color.replace(/rgb((.*))/, '$1').split(', ').map(num => ('0' + (num - 0).toString(16)).slice(-2)).join('');
41
+ const colorCode = '#' + color.replace(/rgb((.*))/, '$1').split(', ').map(num => ('0' + (num - 0).toString(16)).slice(-2).toUpperCase()).join('');
42
42
 
43
43
 
44
44
 
@@ -52,6 +52,12 @@
52
52
 
53
53
  }
54
54
 
55
+ ```
55
56
 
56
57
 
58
+
59
+ ※ ちょっと足りてなかった仕様を盛り込みました。
60
+
57
- ```
61
+ 1. ない色は「未登録」と返す
62
+
63
+ 2. 色コードのアルファベットは大文字に