From 2de649388da5504279074d075bd6cbdcd29d719d Mon Sep 17 00:00:00 2001
From: Maria Mendonca <71168380+mendoncamaria@users.noreply.github.com>
Date: Sat, 27 Jan 2024 11:20:15 +0530
Subject: [PATCH] Create mentoring.md
---
.../exercises/resistor-color/mentoring.md | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 tracks/typescript/exercises/resistor-color/mentoring.md
diff --git a/tracks/typescript/exercises/resistor-color/mentoring.md b/tracks/typescript/exercises/resistor-color/mentoring.md
new file mode 100644
index 000000000..3733e2826
--- /dev/null
+++ b/tracks/typescript/exercises/resistor-color/mentoring.md
@@ -0,0 +1,27 @@
+### Topics Covered:
+1. Array in Typescript
+2. Get index using inbuilt function
+
+In the problem statement, the colors and their code are already mentioned. So first let us define an array of colors.
+```
+export const COLORS = [
+ 'black',
+ 'brown',
+ 'red',
+ 'orange',
+ 'yellow',
+ 'green',
+ 'blue',
+ 'violet',
+ 'grey',
+ 'white',
+]
+```
+
+Now we have an array, we can directly get code by fetching the index of the parameter color in the array and using the Array.indexOf() to achieve our results.
+
+```
+export const colorCode = (color: string) => {
+ return COLORS.indexOf(color);
+}
+```