I have the requirement that i need to add a GeoTagged Image into the map and save that image in KML format. Give the approach to do this task.
Check out this online tool at https://geoprocessing.online/tool/photos-to-kmz/. It's not using the ArcGIS Java Script API, but it does exactly what you need. Just upload your geotagged images and once processed you'll have them in a KML or KMZ file.