ShamsTIIDELAB

Write a program that uses console.log to print all the numbers from 1 to 200, with two exceptions. For numbers divisible by 6, print "Shams" instead of the number, and for numbers divisible by 8 (and not 6), print "TIIDELAB" instead. When you have that working, modify your program to print "ShamsTIIDELAB" for numbers that are divisible by both 6 and 8 (and still print "Shams" or "TIIDELAB" for numbers divisible by only one of those).

(This is actually an interview question that has been claimed to weed out a significant percentage of programmer candidates. So if you solved it, your labour market value just went up.)

RESULT

1

2

3

4

5

Shams

7

TTIDELAB

9

10

11

Shams

13

14

15

TTIDELAB

17

Shams

19

20

21

22

23

ShamsTIIDELAB

25

26

27

28

29

Shams

31

TTIDELAB

33

34

35

Shams

37

38

39

TTIDELAB

41

Shams

43

44

45

46

47

ShamsTIIDELAB

49

50

51

52

53

Shams

55

TTIDELAB

57

58

59

Shams

61

62

63

TTIDELAB

65

Shams

67

68

69

70

71

ShamsTIIDELAB

73

74

75

76

77

Shams

79

TTIDELAB

81

82

83

Shams

85

86

87

TTIDELAB

89

Shams

91

92

93

94

95

ShamsTIIDELAB

97

98

99

100

101

Shams

103

TTIDELAB

105

106

107

Shams

109

110

111

TTIDELAB

113

Shams

115

116

117

118

119

ShamsTIIDELAB

121

122

123

124

125

Shams

127

TTIDELAB

129

130

131

Shams

133

134

135

TTIDELAB

137

Shams

139

140

141

142

143

ShamsTIIDELAB

145

146

147

148

149

Shams

151

TTIDELAB

153

154

155

Shams

157

158

159

TTIDELAB

161

Shams

163

164

165

166

167

ShamsTIIDELAB

169

170

171

172

173

Shams

175

TTIDELAB

177

178

179

Shams

181

182

183

TTIDELAB

185

Shams

187

188

189

190

191

ShamsTIIDELAB

193

194

195

196

197

Shams

199

TTIDELAB