Skip to content
Advertisement

how to print company_name starting with letter a if the company_name function is getcompanyname()

JavaScript

the last function starta() should print the company_name starting with a.I have given com[i].getcompanynamefunction as a string to a variable comp.

Its should print the output as the companyname. this is the error shown

Exception in thread “main” java.lang.Error: Unresolved compilation problem: Can only iterate over an array or an instance of java.lang.Iterable

JavaScript

Advertisement

Answer

This is happening because you are trying to run a for loop on a String, comp, where as a for loop is meant only for an array or an iterable.. Try with below code, it should work

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement