समस्या
हमें एक जावास्क्रिप्ट फ़ंक्शन लिखना है जो एक संख्या लेता है। हमारा फ़ंक्शन संख्या का दशमलव बिंदु (.) के बाद का भाग चुनकर लौटाएगा।
उदाहरण
निम्न कोड देखें:
const num = 435.43436; const retrieveDecimalPart = (num = 1) => { const str = String(num); let [_, decimal] = str.split('.'); const divisor = Math.pow(10, decimal.length) decimal = +decimal; return decimal / divisor; }; console.log(retrieveDecimalPart(num));आउटपुट
निम्न कंसोल आउटपुट है:
0.43436