let currentYear = (new Date()).getFullYear(); // year const options = []; for (let i = 1950; i <= currentYear; i++) { options.push(i); } jsx // <select className='border p-2 border-l-pink-700 mr-2' defaultValue={currentYear} onChange={handleYear} name="year" id="year"> { options.map(option => { return <option key={option} value={option}>{option}</option> }) } </select>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter