Firebase get child_added in loop


this is my firebase structure

i want to get the child of java and math in this firebase photo their child are 0,1 to each one.

i did something like that

public getCourse(departmentId:any):any{
var semesterRef = firebase.database().ref(‘Courses/’+departmentId+’/SemA’)
semesterRef.on(‘child_added’, function(courseSnapshot) {

but it gives me just the java and math names and not their child. how can i run in loop and get it and also return as array.